Exemple #1
0
        /// <summary>
        /// Batch method to send notification
        /// </summary>
        ///

        //VC20140819
        private void BatchNotifications()
        {
            try
            {
                DateTime    CurrentDateTime       = DateTime.Now;
                List <long> NotificationServiceID = new List <long>();//To update context after notification

                var Registration_IDsJSON = "";
                var groupedData          = SystemRepository.GetNotificationService(CurrentDateTime).GroupBy(x => new { x.PushNotificationMessage, x.NotificationID }).ToList();
                // LogTraceEngine.WriteLogWithCategory("Notification service Called and count : " + groupedData.Count + "curent date time =" + CurrentDateTime.ToLongDateString(), AppVariables.AppLogTraceCategoryName.NotificationListener);
                AndroiddNotificationManager pushNotifier = new AndroiddNotificationManager();

                foreach (var notification in groupedData) //Iterate Grouped data on Notification ID
                {
                    NotificationServiceID.AddRange(notification.Select(x => x.NotificationServiceID));
                    Registration_IDsJSON = String.Join(",", notification.Select(x => "\"" + x.AndroidID + "\"").ToArray());
                    string response = pushNotifier.SendNotification(Registration_IDsJSON, notification.Key.PushNotificationMessage, 1);                          //Send for Notification
                    systemRepository.UpdateNotificationServiceResponse(NotificationServiceID, response, notification.Key.NotificationID.Value, CurrentDateTime); //Update Context
                }
            }
            catch (Exception ex)
            {
                LogTraceEngine.WriteLogWithCategory("Batch Notification service Called and exception occured : Database string  : " + dataAccess.ConnectionString + " " + ex.Message, AppVariables.AppLogTraceCategoryName.NotificationListener);
            }
        }
Exemple #2
0
        public void CoverageNotifications()
        {
            try
            {
                //if (systemRepository == null)
                //{
                systemRepository = new SystemDataImpl();
                //}
                LogTraceEngine.WriteLogWithCategory("Coverage Notification service Called Step 1 ", AppVariables.AppLogTraceCategoryName.NotificationListener);
                if (systemRepository.CoverageNotificationTimeSetting() != null) //Get Time Slot settings
                {
                    LogTraceEngine.WriteLogWithCategory("Coverage Notification service Called Time Matched with TimeSettings ", AppVariables.AppLogTraceCategoryName.NotificationListener);
                    //If time slot gets in current time
                    var notifications = SystemRepository.GetCoverageNotificationService(); //Execute Procedure to generate Notification Data
                    AndroiddNotificationManager        pushNotifier         = new AndroiddNotificationManager();
                    List <CoverageNotificationService> CoverageNotification = new List <CoverageNotificationService>();

                    if (notifications != null && notifications.Count > 0)
                    {
                        LogTraceEngine.WriteLogWithCategory("Coverage Notification started pushing notification to users ", AppVariables.AppLogTraceCategoryName.NotificationListener);
                        foreach (var notification in notifications)
                        {
                            if (!String.IsNullOrEmpty(notification.AndroidID))
                            {
                                string response = pushNotifier.SendNotification("\"" + notification.AndroidID + "\"", "Coverage Notification~" + notification.PushNotificationMessage, 1); //Send for Notification
                                if (!String.IsNullOrEmpty(response) && response.Contains("id"))
                                {
                                    response = String.Format("Success Coverage Notification Status For UserID: {0} of Notification Date {1},{2}", notification.UserID, DateTime.Now.ToString(), response);
                                    CoverageNotification.Add(GenerateCoverageNotificationResponse(true, false, notification.CoverageNotificationServiceID, "Success: " + response));
                                }
                                else
                                {
                                    if (response != null)
                                    {
                                        response = String.Format("Failure Coverage Notification Status For UserID: {0} of Notification Date {1},{2}", notification.UserID, DateTime.Now.ToString(), response);
                                    }
                                    CoverageNotification.Add(GenerateCoverageNotificationResponse(true, false, notification.CoverageNotificationServiceID, "Success: " + response));
                                }
                            }
                        }
                        LogTraceEngine.WriteLogWithCategory("Coverage Notification End pushing notification to users ", AppVariables.AppLogTraceCategoryName.NotificationListener);


                        SystemRepository.UpdateCoverageNotificationServiceResponse(CoverageNotification);
                    }
                }
            }
            catch (Exception ex)
            {
                LogTraceEngine.WriteLogWithCategory("Coverage Notification service Called and exception occured : Database string  : " + dataAccess.ConnectionString + " " + ex.Message, AppVariables.AppLogTraceCategoryName.NotificationListener);
            }
        }