/// <summary> /// Handles PropertyChanged event. If the property is associated with a MonitoredItem, writes the property value to the node of the server. /// </summary> /// <param name="sender">the sender.</param> /// <param name="e">the event.</param> private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (this.isPublishing || string.IsNullOrEmpty(e.PropertyName)) { return; } if (e.PropertyName == nameof(ISubscription.PublishingEnabled)) { var request = new SetPublishingModeRequest { SubscriptionIds = new[] { this.subscriptionId }, PublishingEnabled = this.subscription.PublishingEnabled }; Task.Run(async() => { try { await this.session.SetPublishingModeAsync(request).ConfigureAwait(false); } catch (Exception ex) { Trace.TraceWarning($"Subscription error setting publishing mode for subscription. {ex.Message}"); } }); return; } MonitoredItemBase item; if (this.subscription.MonitoredItems.TryGetValueByName(e.PropertyName, out item)) { item.OnPropertyChanged(); } }
public static LogEntry For(SetPublishingModeRequest request) { LogEntry entry = new LogEntry("SetPublishingModeRequest"); entry.Add("RequestHeader", For(request.RequestHeader)); entry.Add("PublishingEnabled", For(request.PublishingEnabled)); entry.Add("SubscriptionIds", For(request.SubscriptionIds)); return(entry); }
public async Task SetPublishingModeAsync() { var response = new SetPublishingModeResponse(); var request = new SetPublishingModeRequest(); var channel = new TestRequestChannel(response); var ret = await channel.SetPublishingModeAsync(request); ret .Should().BeSameAs(response); channel.Request .Should().BeSameAs(request); }
/// <summary> /// Enables sending of Notifications on one or more Subscriptions. /// </summary> /// <param name="channel">A instance of <see cref="IRequestChannel"/>.</param> /// <param name="request">A <see cref="SetPublishingModeRequest"/>.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation that returns a <see cref="SetPublishingModeResponse"/>.</returns> public static async Task <SetPublishingModeResponse> SetPublishingModeAsync(this IRequestChannel channel, SetPublishingModeRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } return((SetPublishingModeResponse)await channel.RequestAsync(request).ConfigureAwait(false)); }
/// <summary> /// Begins an asynchronous invocation of the SetPublishingMode service. /// </summary> public IAsyncResult BeginSetPublishingMode( RequestHeader requestHeader, bool publishingEnabled, UInt32Collection subscriptionIds, AsyncCallback callback, object asyncState) { SetPublishingModeRequest request = new SetPublishingModeRequest(); request.RequestHeader = requestHeader; request.PublishingEnabled = publishingEnabled; request.SubscriptionIds = subscriptionIds; UpdateRequestHeader(request, requestHeader == null, "SetPublishingMode"); if (UseTransportChannel) { return TransportChannel.BeginSendRequest(request, callback, asyncState); } return InnerChannel.BeginSetPublishingMode(new SetPublishingModeMessage(request), callback, asyncState); }
/// <summary> /// Invokes the SetPublishingMode service. /// </summary> public virtual ResponseHeader SetPublishingMode( RequestHeader requestHeader, bool publishingEnabled, UInt32Collection subscriptionIds, out StatusCodeCollection results, out DiagnosticInfoCollection diagnosticInfos) { SetPublishingModeRequest request = new SetPublishingModeRequest(); SetPublishingModeResponse response = null; request.RequestHeader = requestHeader; request.PublishingEnabled = publishingEnabled; request.SubscriptionIds = subscriptionIds; UpdateRequestHeader(request, requestHeader == null, "SetPublishingMode"); try { if (UseTransportChannel) { IServiceResponse genericResponse = TransportChannel.SendRequest(request); if (genericResponse == null) { throw new ServiceResultException(StatusCodes.BadUnknownResponse); } ValidateResponse(genericResponse.ResponseHeader); response = (SetPublishingModeResponse)genericResponse; } else { SetPublishingModeResponseMessage responseMessage = InnerChannel.SetPublishingMode(new SetPublishingModeMessage(request)); if (responseMessage == null || responseMessage.SetPublishingModeResponse == null) { throw new ServiceResultException(StatusCodes.BadUnknownResponse); } response = responseMessage.SetPublishingModeResponse; ValidateResponse(response.ResponseHeader); } results = response.Results; diagnosticInfos = response.DiagnosticInfos; } finally { RequestCompleted(request, response, "SetPublishingMode"); } return response.ResponseHeader; }
/// <summary> /// Initializes the message with the body. /// </summary> public SetPublishingModeMessage(SetPublishingModeRequest SetPublishingModeRequest) { this.SetPublishingModeRequest = SetPublishingModeRequest; }