/// <summary> /// Asynchronously calls the CreateMonitoredItems service. /// </summary> public virtual IAsyncResult BeginCreateMonitoredItems(CreateMonitoredItemsMessage message, AsyncCallback callback, object callbackData) { try { // check for bad data. if (message == null) throw new ArgumentNullException("message"); // set the request context. SetRequestContext(RequestEncoding.Xml); // create handler. ProcessRequestAsyncResult result = new ProcessRequestAsyncResult(this, callback, callbackData, 0); return result.BeginProcessRequest(SecureChannelContext.Current, message.CreateMonitoredItemsRequest); } catch (Exception e) { throw CreateSoapFault(message.CreateMonitoredItemsRequest, e); } }
/// <summary> /// The operation contract for the CreateMonitoredItems service. /// </summary> public virtual CreateMonitoredItemsResponseMessage CreateMonitoredItems(CreateMonitoredItemsMessage request) { CreateMonitoredItemsResponse response = null; try { // OnRequestReceived(message.CreateMonitoredItemsRequest); SetRequestContext(RequestEncoding.Xml); response = (CreateMonitoredItemsResponse)CreateMonitoredItems(request.CreateMonitoredItemsRequest); // OnResponseSent(response); return new CreateMonitoredItemsResponseMessage(response); } catch (Exception e) { Exception fault = CreateSoapFault(request.CreateMonitoredItemsRequest, e); // OnResponseFaultSent(fault); throw fault; } }
/// <summary> /// The operation contract for the CreateMonitoredItems service. /// </summary> public virtual CreateMonitoredItemsResponseMessage CreateMonitoredItems(CreateMonitoredItemsMessage request) { try { SetRequestContext(RequestEncoding.Xml); CreateMonitoredItemsResponse response = (CreateMonitoredItemsResponse)CreateMonitoredItems(request.CreateMonitoredItemsRequest); return new CreateMonitoredItemsResponseMessage(response); } catch (Exception e) { throw CreateSoapFault(request.CreateMonitoredItemsRequest, e); } }
/// <summary> /// Specifies one or more nodes to monitor for data changes or events. /// </summary> public CreateMonitoredItemsResponseMessage CreateMonitoredItems(CreateMonitoredItemsMessage request) { try { lock (m_lock) { // verify session. VerifySession(request.RequestHeader, false); // look up subscription. Subscription subscription = null; if (!m_subscriptions.TryGetValue(request.SubscriptionId, out subscription)) { throw new StatusCodeException(StatusCodes.BadSubscriptionIdInvalid, "Could not find subscription"); } // process each item. ListOfMonitoredItemCreateResult results = new ListOfMonitoredItemCreateResult(); ListOfDiagnosticInfo diagnosticInfos = new ListOfDiagnosticInfo(); for (int ii = 0; ii < request.ItemsToCreate.Count; ii++) { MonitoredItemCreateResult result = new MonitoredItemCreateResult(); DiagnosticInfo diagnosticInfo = new DiagnosticInfo(); subscription.CreateMonitoredItem( request.TimestampsToReturn, request.ItemsToCreate[ii], result, diagnosticInfo); results.Add(result); diagnosticInfos.Add(diagnosticInfo); } // return the response. CreateMonitoredItemsResponseMessage response = new CreateMonitoredItemsResponseMessage(); response.ResponseHeader = CreateResponseHeader(request.RequestHeader); response.Results = results; response.DiagnosticInfos = diagnosticInfos; return response; } } catch (Exception e) { throw CreateSoapFault(request.RequestHeader, e); } }