コード例 #1
0
ファイル: MessagingService.cs プロジェクト: pbailey3/Rooster
 public static void OpenShiftsBroadcast(List <Guid> businessLocations)
 {
     if (MessagingService.IsNotificationsEnabled)
     {
         foreach (var busLocId in businessLocations)
         {
             //Todo: get list of staff who work in each business locations and their preferences.
             using (UserPreferencesAPIController userPrefsController = new UserPreferencesAPIController())
             {
                 var userPrefs = userPrefsController.GetUserPrefsForBusLocation(busLocId);
                 foreach (var userPref in userPrefs)
                 {
                     if (userPref.InternalAvailableShifts)
                     {
                         if (userPref.NotifyByEmail)
                         {
                             MailHelper.SendOpenShiftBroadcastMail(userPref.UserProfileEmail, userPref.UserProfileFirstName);
                         }
                         if (userPref.NotifyByApp)
                         {
                             using (NotificationsAPIController notificationController = new NotificationsAPIController())
                             {
                                 //Send push notification
                                 notificationController.Post(String.Format(ConfigurationManager.AppSettings.Get("mailShiftBroadcastBody"), userPref.UserProfileFirstName), userPref.UserProfileEmail)
                                 .ContinueWith(t => Trace.TraceError("ERROR:" + t.Exception.ToString()), TaskContinuationOptions.OnlyOnFaulted);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: MessagingService.cs プロジェクト: pbailey3/Rooster
        public static void BusinessRegisteredEmployee(string firstName, string busName, bool isExistingUser, string toAddress = null, string mobileNumber = null)
        {
            if (MessagingService.IsNotificationsEnabled)
            {
                if (isExistingUser)
                {
                    UserPreferencesDTO userPrefs = null;
                    if (!String.IsNullOrEmpty(toAddress))
                    {
                        userPrefs = MessagingService.GetUserPreferences(toAddress);
                    }

                    if (userPrefs.NotifyByEmail)
                    {
                        MailHelper.SendBusRegEmplMail(toAddress, firstName, busName, isExistingUser);
                    }
                    if (userPrefs.NotifyBySMS && !String.IsNullOrEmpty(mobileNumber))
                    {
                        SmsHelper.SendBusRegEmplSms(mobileNumber);
                    }
                    if (userPrefs.NotifyByApp)
                    {
                        using (NotificationsAPIController notificationController = new NotificationsAPIController())
                        {
                            //Send push notification
                            notificationController.Post(String.Format(ConfigurationManager.AppSettings.Get("mailBusRegExistingBody"), firstName, busName, ConfigurationManager.AppSettings.Get("ApiBaseURL")), toAddress)
                            .ContinueWith(t => Trace.TraceError("ERROR:" + t.Exception.ToString()), TaskContinuationOptions.OnlyOnFaulted);
                        }
                    }
                }
                else //New user, does not already exist in Rooster
                {
                    if (!String.IsNullOrEmpty(toAddress))
                    {
                        MailHelper.SendBusRegEmplMail(toAddress, firstName, busName, isExistingUser);
                    }

                    if (!String.IsNullOrEmpty(mobileNumber))
                    {
                        SmsHelper.SendBusRegEmplSms(mobileNumber);
                    }
                }
            }
        }
コード例 #3
0
ファイル: MessagingService.cs プロジェクト: pbailey3/Rooster
        public static void ShiftBroadcast(string toAddress, string firstName)
        {
            if (MessagingService.IsNotificationsEnabled)
            {
                var userPrefs = MessagingService.GetUserPreferences(toAddress);

                if (userPrefs.NotifyByEmail)
                {
                    MailHelper.SendShiftBroadcastMailAsync(toAddress, firstName);
                }
                if (userPrefs.NotifyByApp)
                {
                    using (NotificationsAPIController notificationController = new NotificationsAPIController())
                    {
                        //Send push notification
                        notificationController.Post(String.Format(ConfigurationManager.AppSettings.Get("mailShiftBroadcastBody"), firstName), toAddress)
                        .ContinueWith(t => Trace.TraceError("ERROR:" + t.Exception.ToString()), TaskContinuationOptions.OnlyOnFaulted);
                    }
                }
            }
        }
コード例 #4
0
ファイル: MessagingService.cs プロジェクト: pbailey3/Rooster
        public static void ShiftCancelled(string toAddress, string firstName, string busLocation, DateTime shiftStart, DateTime shiftFinish)
        {
            if (MessagingService.IsNotificationsEnabled)
            {
                var userPrefs = MessagingService.GetUserPreferences(toAddress);

                if (userPrefs.NotifyByEmail)
                {
                    MailHelper.SendShiftCancelledMail(toAddress, firstName, busLocation, shiftStart, shiftFinish);
                }
                if (userPrefs.NotifyByApp)
                {
                    using (NotificationsAPIController notificationController = new NotificationsAPIController())
                    {
                        //Send push notification
                        notificationController.Post(String.Format(ConfigurationManager.AppSettings.Get("mailShiftCancelledBody"), firstName, busLocation, shiftStart.ToString(), shiftFinish.ToString()), toAddress)
                        .ContinueWith(t => Trace.TraceError("ERROR:" + t.Exception.ToString()), TaskContinuationOptions.OnlyOnFaulted);
                    }
                }
            }
        }