private async Task UpdateRetryStatusForMessageAsync(MessagingContext ctx, SendResult result)
        {
            if (ctx.MessageEntityId.HasValue)
            {
                using (DatastoreContext db = _createDatastore())
                {
                    var repository = new DatastoreRepository(db);
                    var service    = new MarkForRetryService(repository);
                    service.UpdateAS4MessageForSendResult(
                        messageId: ctx.MessageEntityId.Value,
                        status: result);

                    await db.SaveChangesAsync()
                    .ConfigureAwait(false);
                }
            }

            if (ctx.AS4Message?.IsPullRequest == true)
            {
                using (DatastoreContext db = _createDatastore())
                {
                    var service = new PiggyBackingService(db);
                    service.ResetSignalMessagesToBePiggyBacked(ctx.AS4Message.SignalMessages, result);

                    await db.SaveChangesAsync()
                    .ConfigureAwait(false);
                }
            }
        }
        private async Task UpdateDeliverMessageAccordinglyToUploadResult(string messageId, SendResult status)
        {
            using (DatastoreContext context = _createDbContext())
            {
                var repository = new DatastoreRepository(context);
                var service    = new MarkForRetryService(repository);

                service.UpdateDeliverMessageForUploadResult(messageId, status);
                await context.SaveChangesAsync().ConfigureAwait(false);
            }
        }
Esempio n. 3
0
        private async Task UpdateDeliverMessageAsync(MessagingContext messagingContext, SendResult result)
        {
            using (DatastoreContext context = _createDbContext())
            {
                var repository   = new DatastoreRepository(context);
                var retryService = new MarkForRetryService(repository);
                retryService.UpdateDeliverMessageForDeliverResult(
                    messagingContext.DeliverMessage.Message.MessageInfo.MessageId, result);

                await context.SaveChangesAsync().ConfigureAwait(false);
            }
        }
        private async Task UpdateDatastoreAsync(
            NotifyMessageEnvelope notifyMessage,
            long?messageEntityId,
            SendResult result)
        {
            using (DatastoreContext context = _createContext())
            {
                var repository = new DatastoreRepository(context);
                var service    = new MarkForRetryService(repository);

                if (!messageEntityId.HasValue)
                {
                    throw new InvalidOperationException(
                              $"Unable to update notified entities of type {notifyMessage.EntityType?.FullName} because no entity id is present");
                }

                if (notifyMessage.EntityType == typeof(InMessage))
                {
                    service.UpdateNotifyMessageForIncomingMessage(messageEntityId.Value, result);
                }
                else if (notifyMessage.EntityType == typeof(OutMessage))
                {
                    service.UpdateNotifyMessageForOutgoingMessage(messageEntityId.Value, result);
                }
                else if (notifyMessage.EntityType == typeof(InException))
                {
                    service.UpdateNotifyExceptionForIncomingMessage(messageEntityId.Value, result);
                }
                else if (notifyMessage.EntityType == typeof(OutException))
                {
                    service.UpdateNotifyExceptionForOutgoingMessage(messageEntityId.Value, result);
                }
                else
                {
                    throw new InvalidOperationException(
                              $"Unable to update notified entities of type {notifyMessage.EntityType?.FullName}."
                              + "Please provide one of the following types in the notify message: "
                              + "InMessage, OutMessage, InException, and OutException are supported");
                }

                await context.SaveChangesAsync().ConfigureAwait(false);
            }
        }