Пример #1
0
        private void UpdateMessageRetries(Message replayedMessage)
        {
            using (var transaction = auditContext.BeginTransaction())
            {
                var messageToUpdate = auditContext.MessageLog.First(a => a.BrokerId == replayedMessage.BrokerId);

                messageToUpdate.Retries++;
                auditContext.SaveChanges();
                transaction.Commit();
            }
        }
        public void CompleteCorrelatedMessages(Guid correlationId)
        {
            using (var transaction = auditContext.BeginTransaction())
            {
                var correlatedMessages = auditContext.MessageLog.Where(m => m.CorrelationId == correlationId);

                foreach (var correlatedMessage in correlatedMessages)
                {
                    correlatedMessage.CompletionDate = DateTime.Now;
                }

                auditContext.SaveChanges();
                transaction.Commit();
            }
        }
        private void AcknowledgeCorrelatedMessages(Message remoteDocumentSuccessfullyInsertedEvent)
        {
            using (var transaction = auditContext.BeginTransaction())
            {
                var correlatedMessages =
                    auditContext.MessageLog.Where(
                        m => m.CorrelationId == remoteDocumentSuccessfullyInsertedEvent.CorrelationId);

                foreach (var correlatedMessage in correlatedMessages)
                {
                    correlatedMessage.CompletionDate = DateTime.Now;
                }

                auditContext.SaveChanges();
                transaction.Commit();
            }
        }
        public void Handle(HubConnectionEvent hubConnectionEvent)
        {
            using (var transaction = auditContext.BeginTransaction())
            {
                auditContext.HubConnectionLog.Add(
                    new HubConnectionLog()
                {
                    BrokerId            = hubConnectionEvent.BrokerId,
                    ConnectionEventType = hubConnectionEvent.ConnectionEventType,
                    ConnectionId        = hubConnectionEvent.ConnectionId,
                    CreateDate          = hubConnectionEvent.CreateDate
                });

                auditContext.SaveChanges();

                transaction.Commit();
            }
        }