Ejemplo n.º 1
0
 public static void SendAsyncSMS(SMSMessageEntity message)
 {
     Task.Factory.StartNew(() =>
     {
         SendSMS(message);
     });
 }
Ejemplo n.º 2
0
 private static void SendOneMessage(SMSMessageEntity message)
 {
     using (OperationLogic.AllowSave <SMSMessageEntity>())
     {
         try
         {
             message.MessageID = GetProvider().SMSSendAndGetTicket(message);
             message.SendDate  = TimeZoneManager.Now.TrimToSeconds();
             message.State     = SMSMessageState.Sent;
             message.Save();
         }
         catch (Exception e)
         {
             var ex = e.LogException();
             using (Transaction tr = Transaction.ForceNew())
             {
                 message.Exception = ex.ToLite();
                 message.State     = SMSMessageState.SendFailed;
                 message.Save();
                 tr.Commit();
             }
             throw;
         }
     }
 }
Ejemplo n.º 3
0
 public static void SendSMS(SMSMessageEntity message)
 {
     if (!message.DestinationNumber.Contains(','))
     {
         SendOneMessage(message);
     }
     else
     {
         var numbers = message.DestinationNumber.Split(',').Select(n => n.Trim()).Distinct();
         message.DestinationNumber = numbers.FirstEx();
         SendOneMessage(message);
         foreach (var number in numbers.Skip(1))
         {
             SendOneMessage(new SMSMessageEntity
             {
                 DestinationNumber = number,
                 Certified         = message.Certified,
                 EditableMessage   = message.EditableMessage,
                 From                   = message.From,
                 Message                = message.Message,
                 Referred               = message.Referred,
                 State                  = SMSMessageState.Created,
                 Template               = message.Template,
                 SendPackage            = message.SendPackage,
                 UpdatePackage          = message.UpdatePackage,
                 UpdatePackageProcessed = message.UpdatePackageProcessed,
             });
         }
     }
 }
Ejemplo n.º 4
0
 private static void SendOneMessage(SMSMessageEntity message)
 {
     message.MessageID = Provider.SMSSendAndGetTicket(message);
     message.SendDate  = TimeZoneManager.Now.TrimToSeconds();
     message.State     = SMSMessageState.Sent;
     message.Save();
 }
Ejemplo n.º 5
0
        public static List <SMSMessageEntity> CreateAndSendMultipleSMSMessages(MultipleSMSModel template, List <string> phones)
        {
            var messages = new List <SMSMessageEntity>();
            var IDs      = GetProvider().SMSMultipleSendAction(template, phones);
            var sendDate = TimeZoneManager.Now.TrimToSeconds();

            for (int i = 0; i < phones.Count; i++)
            {
                var message = new SMSMessageEntity {
                    Message = template.Message, From = template.From
                };
                message.SendDate = sendDate;
                //message.SendState = SendState.Sent;
                message.DestinationNumber = phones[i];
                message.MessageID         = IDs[i];
                message.Save();
                messages.Add(message);
            }

            return(messages);
        }
Ejemplo n.º 6
0
 public async Task <ActionResult> SMSPost(SMSMessageEntity model)
 {
     return(RentoJson(await CallApiTask("Message/SendSMS", model)));
 }
Ejemplo n.º 7
0
 private void removeNonSMSChars_Click(object sender, RoutedEventArgs e)
 {
     MessageDC.Message = SMSCharacters.RemoveNoSMSCharacters(MessageDC.Message);
     MessageDC         = MessageDC;
 }