Exemplo n.º 1
0
        /// <summary>
        /// Handles Application End event.
        /// </summary>
        public static void HandleApplicationStarted()
        {
            Logger.Info("Website started");

            ProperServices.Common.Mail.Data.WebsiteNotifications mailinfo = (ProperServices.Common.Mail.Data.WebsiteNotifications)ConfigurationManager.GetSection("Notifications/WebsiteNotifications");
            if (mailinfo != null && mailinfo.WebsiteStarted.Enabled && mailinfo.From != null && mailinfo.Recipients.Count > 0)
            {
                string subject = string.Format("{0} - {1}", Environment.MachineName, mailinfo.WebsiteStarted.Subject);
                ProperServices.Common.Mail.Mailer.SendMail(mailinfo.Recipients.GetReceipients(), mailinfo.From.Email, subject, mailinfo.WebsiteStarted.Body.Text, mailinfo.WebsiteStarted.Body.IsHtml);

                // send sms
                if (mailinfo.WebsiteStarted.SMSNotification)
                {
                    SMSNotify(mailinfo.WebsiteStarted.Subject, mailinfo);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles Application End event.
        /// </summary>
        public static void HandleApplicationError(HttpApplication app)
        {
            if (app != null && app.Context != null && app.Server != null && app.Server.GetLastError() != null)
            {
                Exception ex = app.Server.GetLastError().GetBaseException();
                Logger.Error(ex, "Website errors: {0}", ex.Message);

                ProperServices.Common.Mail.Data.WebsiteNotifications mailinfo = (ProperServices.Common.Mail.Data.WebsiteNotifications)ConfigurationManager.GetSection("Notifications/WebsiteNotifications");
                if (mailinfo != null && mailinfo.WebsiteErrors.Enabled && mailinfo.From != null && mailinfo.Recipients.Count > 0)
                {
                    string subject = string.Format("{0} - {1}", Environment.MachineName, mailinfo.WebsiteErrors.Subject);
                    string body    = string.Format(mailinfo.WebsiteErrors.Body.Text, ex.Message, ex.StackTrace);
                    ProperServices.Common.Mail.Mailer.SendMail(mailinfo.Recipients.GetReceipients(), mailinfo.From.Email, subject, body, mailinfo.WebsiteErrors.Body.IsHtml);
                }

                // send sms
                if (mailinfo.WebsiteErrors.SMSNotification)
                {
                    SMSNotify(mailinfo.WebsiteErrors.Subject, mailinfo);
                }
            }
        }