Exemple #1
0
        private static ProcessEntity?UpdateMessages(List <SMSMessageEntity> messages)
        {
            if (!messages.Any())
            {
                return(null);
            }

            SMSUpdatePackageEntity package = new SMSUpdatePackageEntity().Save();

            var packLite = package.ToLite();

            if (messages.Any(m => m.State != SMSMessageState.Sent))
            {
                throw new ApplicationException("SMS messages must be sent prior to update the status");
            }

            messages.ForEach(ms => ms.UpdatePackage = packLite);
            messages.SaveList();

            var process = ProcessLogic.Create(SMSMessageProcess.UpdateStatus, package);

            process.Execute(ProcessOperation.Execute);

            return(process);
        }
    public void Execute(ExecutingProcess executingProcess)
    {
        SMSUpdatePackageEntity package = (SMSUpdatePackageEntity)executingProcess.Data !;

        executingProcess.ForEachLine(package.SMSMessages().Where(sms => sms.State == SMSMessageState.Sent && !sms.UpdatePackageProcessed), sms =>
        {
            sms.Execute(SMSMessageOperation.UpdateStatus);
        });
    }
Exemple #3
0
        public static ProcessEntity?UpdateAllSentSMS()
        {
            var messages = Database.Query <SMSMessageEntity>().Where(a => a.State == SMSMessageState.Sent);

            if (!messages.Any())
            {
                return(null);
            }

            SMSUpdatePackageEntity package = new SMSUpdatePackageEntity();

            package.Save();
            messages.UnsafeUpdate().Set(a => a.UpdatePackage, a => package.ToLite()).Execute();
            return(SMSMessageProcess.UpdateStatus.Create(package).Execute(ProcessOperation.Execute));
        }
Exemple #4
0
 public static IQueryable <SMSMessageEntity> SMSMessages(this SMSUpdatePackageEntity e) =>
 As.Expression(() => Database.Query <SMSMessageEntity>().Where(a => a.UpdatePackage.Is(e)));
Exemple #5
0
 public static IQueryable <SMSMessageEntity> SMSMessages(this SMSUpdatePackageEntity e)
 {
     return(SMSMessagesUpdateExpression.Evaluate(e));
 }