Beispiel #1
0
        /// <summary>
        /// Insert an <see cref="OutException"/> based on an exception that occured during an outgoing operation for which we do not have a valid/complete message.
        /// Example: transformation.
        /// </summary>
        /// <param name="exception">The exception which message will be inserted.</param>
        /// <param name="messageStream">The stream that represents the message which caused the exception.</param>
        public async Task InsertOutgoingExceptionAsync(Exception exception, Stream messageStream)
        {
            string location = await _bodyStore.SaveAS4MessageStreamAsync(
                _config.OutExceptionStoreLocation,
                messageStream);

            OutException entity = OutException.ForMessageBody(location, exception);

            _repository.InsertOutException(entity);
        }
Beispiel #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);
        }
        protected virtual void SetupDataStore()
        {
            using (datastoreContext = new DatastoreContext(options, StubConfig.Default))
            {
                string pmodeString = AS4XmlSerializer.ToString(pmode);
                string pmodeId     = pmode.Id;

                {
                    var message = new InMessage(ebmsMessageId: InEbmsMessageId1)
                    {
                        EbmsRefToMessageId = InEbmsRefToMessageId1,
                        InsertionTime      = DateTime.UtcNow.AddMinutes(-1),
                    };
                    message.SetStatus(InStatus.Created);
                    message.SetPModeInformation(pmodeId, pmodeString);
                    datastoreContext.InMessages.Add(message);
                }

                {
                    var message = new InMessage(ebmsMessageId: InEbmsMessageId2)
                    {
                        EbmsRefToMessageId = InEbmsRefToMessageId2,
                        InsertionTime      = DateTime.UtcNow.AddMinutes(-1)
                    };
                    message.SetStatus(InStatus.Received);
                    datastoreContext.InMessages.Add(message);
                }

                {
                    var message = new OutMessage(OutEbmsMessageId1)
                    {
                        EbmsRefToMessageId = OutEbmsRefToMessageId1,
                        InsertionTime      = DateTime.UtcNow.AddMinutes(-1)
                    };
                    message.SetStatus(OutStatus.Created);

                    datastoreContext.OutMessages.Add(message);
                }

                {
                    var message = new OutMessage(OutEbmsMessageId2)
                    {
                        EbmsRefToMessageId = OutEbmsRefToMessageId2,

                        InsertionTime = DateTime.UtcNow.AddMinutes(-1)
                    };
                    message.SetStatus(OutStatus.Created);
                    datastoreContext.OutMessages.Add(message);
                }

                InException inEx1 = Entities.InException.ForEbmsMessageId(InEbmsMessageId1, InException);
                inEx1.InsertionTime = DateTime.UtcNow.AddMinutes(-1);
                datastoreContext.InExceptions.Add(inEx1);

                InException inEx2 = Entities.InException.ForEbmsMessageId(InEbmsMessageId1, InException);
                inEx2.InsertionTime = DateTime.UtcNow.AddMinutes(-1);
                datastoreContext.InExceptions.Add(inEx2);

                InException inEx3 = Entities.InException.ForMessageBody(MessageLocation, InException);
                inEx3.InsertionTime = DateTime.UtcNow.AddMinutes(-1);
                datastoreContext.InExceptions.Add(inEx3);

                OutException outEx1 = Entities.OutException.ForEbmsMessageId(OutEbmsRefToMessageId1, InException);
                outEx1.InsertionTime = DateTime.UtcNow.AddMinutes(-1);
                datastoreContext.OutExceptions.Add(outEx1);

                OutException outEx2 = OutException.ForEbmsMessageId(InEbmsRefToMessageId1, Exception);
                outEx2.InsertionTime = DateTime.UtcNow.AddMinutes(-1);
                datastoreContext.OutExceptions.Add(outEx2);

                OutException outEx3 = OutException.ForMessageBody(MessageLocation, Exception);
                outEx3.InsertionTime = DateTime.UtcNow.AddMinutes(-1);
                datastoreContext.OutExceptions.Add(outEx3);

                datastoreContext.SaveChanges();

                foreach (var inMessage in datastoreContext.InMessages)
                {
                    inMessage.SetPModeInformation(pmodeId, pmodeString);
                }

                foreach (var outMessage in datastoreContext.OutMessages)
                {
                    outMessage.SetPModeInformation(pmodeId, pmodeString);
                }

                foreach (var inException in datastoreContext.InExceptions)
                {
                    inException.SetPModeInformation(pmodeId, pmodeString);
                }

                foreach (var outException in datastoreContext.OutExceptions)
                {
                    outException.SetPModeInformation(pmodeId, pmodeString);
                }

                datastoreContext.SaveChanges();
            }
        }