Пример #1
0
        public static void SendAll()
        {
            lock (_locker)
                try
                {
                    HS.GetOrCreateSericeStatus(nameof(MailSender));
                    using (var unitOfWork = new UnitOfWork(XpoDefault.DataLayer))
                    {
                        var allMessage2Send = unitOfWork.Query <DoSoEmail>().Where(x => x.Status == BusinessObjects.Base.DoSoMessageBase.MessageStatusEnum.Active && x.ExpiredOn == null && x.SendingDate < DateTime.Now && (x.DoSoReportSchedule == null || x.DoSoReportSchedule.IsActive));

                        foreach (var message2Send in allMessage2Send)
                        {
                            if (!HS.EnableMailSender)
                            {
                                return;
                            }
                            Send(message2Send, unitOfWork);
                            unitOfWork.CommitChanges();
                        }
                    }
                }
                catch (Exception ex)
                {
                    HS.GetOrCreateSericeStatus(nameof(MailSender), true);
                    HS.CreateExceptionLog(ex.Message, ex.ToString(), 6);
                }
        }
Пример #2
0
 public static void GenerateAll()
 {
     lock (_locker)
         try
         {
             HS.GetOrCreateSericeStatus(nameof(SmsGenerator));
             using (var unitOfWork = new UnitOfWork(XpoDefault.DataLayer))
             {
                 var allSchedule = unitOfWork.Query <DoSoSmsSchedule>().Where(x => x.IsActive && x.NextExecutionDate < DateTime.Now && x.ExpiredOn == null);
                 foreach (var item in allSchedule)
                 {
                     if (!HS.EnableSmsGenerator)
                     {
                         return;
                     }
                     item.GenerateMessages(unitOfWork);
                     item.GetNextExecutionDate();
                     unitOfWork.CommitChanges();
                 }
             }
         }
         catch (Exception ex)
         {
             HS.GetOrCreateSericeStatus(nameof(SmsGenerator), true);
             HS.CreateExceptionLog(ex.Message, ex.ToString(), 6);
         }
 }
Пример #3
0
        public static void SendAll()
        {
            lock (_locker)
                try
                {
                    HS.GetOrCreateSericeStatus(nameof(SmsSender));
                    using (var unitOfWork = new UnitOfWork(XpoDefault.DataLayer))
                    {
                        var allSmsToSend = unitOfWork.Query <DoSoSms>().Where(x => x.Status == MessageStatusEnum.Active && x.ExpiredOn == null && x.SendingDate < DateTime.Now && (x.DoSoSmsSchedule == null || x.DoSoSmsSchedule.IsActive));

                        foreach (var smsToSend in allSmsToSend)
                        {
                            Send(smsToSend, unitOfWork);
                        }
                    }
                }
                catch (Exception ex)
                {
                    HS.GetOrCreateSericeStatus(nameof(SmsSender), true);
                    HS.CreateExceptionLog(ex.Message, ex.ToString(), 6);
                }
        }