/// <summary> /// Confirms a condition. /// </summary> /// <param name="condition">an AcknowledgeableCondition.</param> /// <param name="comment">a comment.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task <StatusCode> ConfirmAsync(AcknowledgeableCondition condition, LocalizedText comment = null) { if (condition == null) { throw new ArgumentNullException(nameof(condition)); } if (this.State != CommunicationState.Opened) { return(StatusCodes.BadServerNotConnected); } return(await this.InnerChannel.ConfirmAsync(condition, comment)); }
/// <summary> /// Acknowledges a condition. /// </summary> /// <param name="channel">The channel.</param> /// <param name="condition">an AcknowledgeableCondition.</param> /// <param name="comment">a comment.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public static async Task <StatusCode> AcknowledgeAsync(this IRequestChannel channel, AcknowledgeableCondition condition, LocalizedText comment = null) { if (condition == null) { throw new ArgumentNullException(nameof(condition)); } var response = await channel.CallAsync(new CallRequest { MethodsToCall = new[] { new CallMethodRequest { ObjectId = condition.ConditionId, MethodId = NodeId.Parse(MethodIds.AcknowledgeableConditionType_Acknowledge), InputArguments = new Variant[] { condition.EventId, comment } // ?? new LocalizedText(string.Empty) } } } }); return(response.Results[0].StatusCode); }
/// <summary> /// Confirms a condition. /// </summary> /// <param name="channel">The channel.</param> /// <param name="condition">an AcknowledgeableCondition.</param> /// <param name="comment">a comment.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public static async Task <StatusCode> ConfirmAsync(this IRequestChannel channel, AcknowledgeableCondition condition, LocalizedText?comment = null) { if (condition == null) { throw new ArgumentNullException(nameof(condition)); } var response = await channel.CallAsync(new CallRequest { MethodsToCall = new[] { new CallMethodRequest { ObjectId = condition.ConditionId, MethodId = NodeId.Parse(MethodIds.AcknowledgeableConditionType_Confirm), InputArguments = new Variant[] { condition.EventId, comment } // ?? new LocalizedText(string.Empty) } } } }); var result = response.Results?[0]; if (result == null) { throw new ServiceResultException(StatusCodes.BadDataEncodingInvalid, "The CallMethodeResult is null!"); } return(result.StatusCode); }