public NotifyMessageManager(INotifyMessageStore notifyMessageStore, INotifySettingStore notifySettingStore,
                             NotifyQueue queue)
 {
     _notifyMessageStore = notifyMessageStore;
     _notifySettingStore = notifySettingStore;
     _queue = queue;
 }
Ejemplo n.º 2
0
 public void Dispose()
 {
     if (!DatabaseQuery.InTransaction)
     {
         NotifyInfo ni;
         while (NotifyQueue.TryDequeue(out ni))
         {
             Notifications.Notify(ni);
         }
     }
 }
Ejemplo n.º 3
0
        public int SaveMessage(NotifyMessage m)
        {
            using var scope     = ServiceProvider.CreateScope();
            using var dbContext = scope.ServiceProvider.GetService <DbContextManager <NotifyDbContext> >().Get(dbid);
            using var tx        = dbContext.Database.BeginTransaction(IsolationLevel.ReadCommitted);

            var notifyQueue = new NotifyQueue
            {
                NotifyId      = 0,
                TenantId      = m.Tenant,
                Sender        = m.From,
                Reciever      = m.To,
                Subject       = m.Subject,
                ContentType   = m.ContentType,
                Content       = m.Content,
                SenderType    = m.Sender,
                CreationDate  = new DateTime(m.CreationDate),
                ReplyTo       = m.ReplyTo,
                Attachments   = m.EmbeddedAttachments.ToString(),
                AutoSubmitted = m.AutoSubmitted
            };

            notifyQueue = dbContext.NotifyQueue.Add(notifyQueue).Entity;
            dbContext.SaveChanges();

            var id = notifyQueue.NotifyId;

            var info = new NotifyInfo
            {
                NotifyId   = id,
                State      = 0,
                Attempts   = 0,
                ModifyDate = DateTime.UtcNow,
                Priority   = m.Priority
            };

            dbContext.NotifyInfo.Add(info);
            dbContext.SaveChanges();

            tx.Commit();

            return(1);
        }