public NotifyMessageManager(INotifyMessageStore notifyMessageStore, INotifySettingStore notifySettingStore, NotifyQueue queue) { _notifyMessageStore = notifyMessageStore; _notifySettingStore = notifySettingStore; _queue = queue; }
public void Dispose() { if (!DatabaseQuery.InTransaction) { NotifyInfo ni; while (NotifyQueue.TryDequeue(out ni)) { Notifications.Notify(ni); } } }
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); }