コード例 #1
0
 private void SendSmsMessages(Project project, string update)
 {
     if (null != project.TextMessageRecipients && project.TextMessageRecipients.Count > 0)
     {
         foreach (var r in project.TextMessageRecipients)
         {
             try
             {
                 OutboundNotification n = new OutboundNotification()
                 {
                     DateCreated = DateTime.Now,
                     Message = update,
                     NotificationType = "SMS",
                     Recipient = r.PhoneNumber,
                     SentSuccessfully = false,
                     DateSent = DateTime.MaxValue
                 };
                 project.OutboundNotifications.Add(n);
                 database.SaveChanges();
                 try
                 {
                     textMessageService.SendText(r.PhoneNumber, update);
                     n.SentSuccessfully = true;
                     n.DateSent = DateTime.Now;
                 }
                 catch (Exception sx)
                 {
                     n.SentSuccessfully = false;
                 }
                 database.SaveChanges();
             }
             catch (Exception e)
             {
                 //TODO: Log this
                 throw e;
             }
         }
     }
 }
コード例 #2
0
 private void SendDirectMessages(Project project, string update)
 {
     foreach (var r in project.MessageRecipients)
     {
         try
         {
             OutboundNotification n = new OutboundNotification()
             {
                 DateCreated = DateTime.Now,
                 Message = update,
                 NotificationType = "Twitter",
                 Recipient = r.ScreenName,
                 SentSuccessfully = false,
                 DateSent = DateTime.MaxValue
             };
             project.OutboundNotifications.Add(n);
             database.SaveChanges();
             try
             {
                 twitter.SendDirectMessage(r.ScreenName, update);
                 n.SentSuccessfully = true;
                 n.DateSent = DateTime.Now;
             }
             catch (Exception sx)
             {
                 n.SentSuccessfully = false;
             }
             database.SaveChanges();
         }
         catch (Exception e)
         {
             //TODO: Log this
         }
     }
 }