Пример #1
0
        /// <summary>
        /// Creates a new <see cref="Error"/> model from an <see cref="ErrorResult"/> instance.
        /// </summary>
        /// <param name="messageId">The ebMS message identifier of this message unit.</param>
        /// <param name="refToMessageId">The reference to an ebMS message identifier of an <see cref="Core.UserMessage"/>.</param>
        /// <param name="result">The occured error to create an ebMS error message from.</param>
        public static Error FromErrorResult(string messageId, string refToMessageId, ErrorResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            return(new Error(messageId, refToMessageId, ErrorLine.FromErrorResult(result)));
        }
Пример #2
0
        /// <summary>
        /// Creates an AS4 error referencing a given <paramref name="userMessage"/>.
        /// </summary>
        /// <param name="errorMessageId">The ebMS message identifier of this message unit.</param>
        /// <param name="userMessage">The AS4 user message to reference in the to be created error.</param>
        /// <param name="occurredError">The error that has happened during the step execution.</param>
        /// <param name="userMessageSendViaMultiHop">
        ///     Whether or not the user message was send in a multi-hop fashion or not.
        ///     Setting this on <c>true</c> will result in an error with the referencing user message included in a RoutingInput element.
        /// </param>
        public static Error CreateFor(
            string errorMessageId,
            UserMessage userMessage,
            ErrorResult occurredError,
            bool userMessageSendViaMultiHop = false)
        {
            if (userMessageSendViaMultiHop)
            {
                var routedUserMessage = UserMessageMap.ConvertToRouting(userMessage);
                return(occurredError == null
                    ? new Error(errorMessageId, userMessage?.MessageId, DateTimeOffset.Now, new ErrorLine[0], routedUserMessage)
                    : new Error(errorMessageId, userMessage?.MessageId, DateTimeOffset.Now, new [] { ErrorLine.FromErrorResult(occurredError) }, routedUserMessage));
            }

            return(occurredError == null
                ? new Error(errorMessageId, userMessage?.MessageId)
                : new Error(errorMessageId, userMessage?.MessageId, ErrorLine.FromErrorResult(occurredError)));
        }