예제 #1
0
        /// <summary>
        /// Send the notifications on application exception
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="methodCall"></param>
        public void SendApplicationExceptionNotifications(Exception ex, string methodCall)
        {
            if (applicationLog.ContainsKey(ex.GetType()))
            {
                var timeDiff = DateTime.Now - applicationLog[ex.GetType()];
                if (timeDiff > sameNotificationTime)
                {
                    applicationLog.Remove(ex.GetType());
                }
                else
                {
                    return;
                }
            }

            var emails = GetApplicationNotificationEmails();

            if (emails.Any())
            {
                string subject = "Application Exception";
                string message = string.Format("Method: {0} \n{1}", methodCall, ex.ToString());
                emailSender.SendEmails(emails, subject, message);
                applicationLog.Add(ex.GetType(), DateTime.Now);
            }
        }
예제 #2
0
        private void SendAlerts(string alertMessage)
        {
            try
            {
                string  tigerReserveName      = string.Empty;
                DataSet dsGetTigerReserveName = CheckListBAL.Instance.GetTigerReserveName(TigerReserverId);
                if (dsGetTigerReserveName != null)
                {
                    DataRow dr2 = dsGetTigerReserveName.Tables[0].Rows[0];
                    if (dr2[0] != DBNull.Value)
                    {
                        tigerReserveName = Convert.ToString(dr2["TigerReserveName"]);
                    }
                }
                int           n            = 0;
                string        EmailAddress = string.Empty;
                string        userName     = string.Empty;
                Alert         alert        = new Alert();
                DataSet       dsEmail      = UserBAL.Instance.GetAllNTCAUsersEmail();
                List <string> Emailid      = new List <string>();
                for (int i = 0; i < dsEmail.Tables[2].Rows.Count; i++)
                {
                    if (dsEmail != null)
                    {
                        DataRow dr = dsEmail.Tables[2].Rows[0];
                        if (dr[0] != DBNull.Value)
                        {
                            alert.UserId = Convert.ToInt32(dsEmail.Tables[2].Rows[i]["UserId"]);
                            alert.SentTo = Convert.ToString(dsEmail.Tables[2].Rows[i]["UserName"]);
                            EmailAddress = Convert.ToString(dsEmail.Tables[2].Rows[i]["Email"]);
                        }
                    }
                    Emailid.Add(EmailAddress);
                    alert.Subject = tigerReserveName + ", " + ConfigurationManager.AppSettings["TryingSubmitApoAfterDueDate"];
                    alert.Body    = tigerReserveName + ", " + alertMessage;
                    //Remove bellow hard coded APO title once we have APO in the database
                    alert.APOTitle     = "APO 1";
                    alert.LoggedInUser = AuthoProvider.User;
                    n = AlertBAL.Instance.SendAlerts(alert);

                    if (n != 0)
                    {
                        string           subject   = alert.Subject;
                        string           body      = alert.Body;
                        SendEmailService sendEmail = new SendEmailService();
                        sendEmail.SendEmails(Emailid, subject, body);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHandler.LogFatal((ex.InnerException != null ? ex.InnerException.Message : ex.Message), ex, this.GetType());
                Response.RedirectPermanent("~/ErrorPage.aspx", false);
            }
        }
예제 #3
0
        private void SendAlertsOnSuccess(string alertMessage)
        {
            try
            {
                int     n            = 0;
                string  EmailAddress = string.Empty;
                string  userName     = string.Empty;
                Alert   alert        = new Alert();
                DataSet dsEmail      = UserBAL.Instance.GetAllNTCAUsersEmail(TigerReserverId);
                for (int index = 0; index <= dsEmail.Tables.Count; index++)
                {
                    List <string> Emailid = new List <string>();
                    for (int i = 0; i < dsEmail.Tables[index].Rows.Count; i++)
                    {
                        if (dsEmail != null)
                        {
                            DataRow dr = dsEmail.Tables[1].Rows[0];
                            if (dr[0] != DBNull.Value)
                            {
                                alert.UserId = Convert.ToInt32(dsEmail.Tables[1].Rows[i]["UserId"]);
                                alert.SentTo = Convert.ToString(dsEmail.Tables[1].Rows[i]["UserName"]);
                                EmailAddress = Convert.ToString(dsEmail.Tables[1].Rows[i]["Email"]);
                            }
                        }
                        Emailid.Add(EmailAddress);
                        alert.Subject = ConfigurationManager.AppSettings["AlertSubject"];
                        alert.Body    = alertMessage;

                        alert.LoggedInUser = ConfigurationManager.AppSettings["AlertSentBy"];
                        n = AlertBAL.Instance.SendAlerts(alert);

                        if (n != 0)
                        {
                            string           subject   = alert.Subject;
                            string           body      = alert.Body;
                            SendEmailService sendEmail = new SendEmailService();
                            sendEmail.SendEmails(Emailid, subject, body);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return;
            }
        }
예제 #4
0
        private void SendAlerts()
        {
            try
            {
                //int userId = Convert.ToInt32(ddlName.SelectedValue);
                int           n            = 0;
                string        EmailAddress = string.Empty;
                string        userName     = string.Empty;
                Alert         alert        = new Alert();
                string        userIds      = mChkName.SelectedValueList;
                string        userNames    = mChkName.SelectedTextListForDB.Replace("'", "");
                DataSet       dsEmail      = AlertBAL.Instance.GetMultipleEmailAddress(userIds);
                List <string> Emailid      = new List <string>();
                for (int i = 0; i < dsEmail.Tables[0].Rows.Count; i++)
                {
                    string[] userId = userIds.Split(',');
                    EmailAddress = Convert.ToString(dsEmail.Tables[0].Rows[i]["Email"]);
                    Emailid.Add(EmailAddress);
                    string[] recipiantName = userNames.Split(',');
                    //userName = Convert.ToString(dsEmail.Tables[0].Rows[i]["UserName"]);

                    alert.UserId  = Convert.ToInt32(userId[i]);
                    alert.SentTo  = recipiantName[i].ToString();
                    alert.Subject = txtSubject.Text;
                    alert.Body    = txtComments.Text;
                    //Remove bellow hard coded APO title once we have APO in the database
                    alert.APOTitle     = "APO 1";
                    alert.LoggedInUser = AuthoProvider.User;
                    n = AlertBAL.Instance.SendAlerts(alert);
                }
                if (n != 0)
                {
                    //List<string> Emailid = new List<string>();
                    //Emailid.Add(EmailAddress);
                    string           subject   = alert.Subject;
                    string           body      = alert.Body;
                    SendEmailService sendEmail = new SendEmailService();
                    sendEmail.SendEmails(Emailid, subject, body);
                }
            }
            catch (Exception ex)
            {
                LogHandler.LogFatal((ex.InnerException != null ? ex.InnerException.Message : ex.Message), ex, this.GetType());
                Response.RedirectPermanent("~/ErrorPage.aspx", false);
            }
        }