Example #1
0
        /// <summary>
        /// Insert an <see cref="OutException"/> based on an exception that occured during the outgoing processing of an <see cref="AS4Message"/>.
        /// </summary>
        /// <param name="exception">The exception which message will be inserted.</param>
        /// <param name="ebmsMessageId">The primary message id of the <see cref="AS4Message"/> that caused the exception</param>
        /// <param name="entityId">The primary key of the stored record to which the mesage is refering to.</param>
        /// <param name="pmode">The PMode that was used during the processing of the message.</param>
        public async Task <OutException> InsertOutgoingAS4MessageExceptionAsync(
            Exception exception,
            string ebmsMessageId,
            long?entityId,
            SendingProcessingMode pmode)
        {
            OutException entity =
                OutException
                .ForEbmsMessageId(ebmsMessageId, exception)
                .SetOperationFor(pmode?.ExceptionHandling);

            await entity.SetPModeInformationAsync(pmode);

            _repository.InsertOutException(entity);

            if (entityId.HasValue)
            {
                _repository.UpdateOutMessage(entityId.Value, m => m.SetStatus(OutStatus.Exception));
            }

            return(entity);
        }
Example #2
0
        /// <summary>
        /// Insert an <see cref="OutException"/> based on an exception that occured during the outgoing Submit operation.
        /// </summary>
        /// <param name="exception">The exception which message will be inserted.</param>
        /// <param name="submit">The message that caused the exception.</param>
        /// <param name="pmode">The PMode that was being used during the Submit operation.</param>
        public async Task <OutException> InsertOutgoingSubmitExceptionAsync(
            Exception exception,
            SubmitMessage submit,
            SendingProcessingMode pmode)
        {
            Stream stream = await AS4XmlSerializer.ToStreamAsync(submit);

            string location = await _bodyStore.SaveAS4MessageStreamAsync(
                _config.OutExceptionStoreLocation,
                stream);

            OutException entity =
                OutException
                .ForMessageBody(location, exception)
                .SetOperationFor(pmode?.ExceptionHandling);

            await entity.SetPModeInformationAsync(pmode);

            _repository.InsertOutException(entity);

            return(entity);
        }