Example #1
0
        private static void SMSNotify(string msg, WebsiteNotifications mailinfo)
        {
            return; // inactive

            if (msg.Length > 70)
            {
                msg = msg.Substring(0, 70);
            }

            List <string> list = new List <string>();

            foreach (AdminDetails details in mailinfo.Recipients)
            {
                list.Add(details.Phone);
            }

            // send SMS code
        }
Example #2
0
        /// <summary>
        /// Handles Application End event.
        /// </summary>
        public static void HandleApplicationEnd()
        {
            Logger.Info("Website stopped");

            HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);

            if (runtime == null)
            {
                return;
            }

            string shutDownMessage = (string)runtime.GetType().InvokeMember("_shutDownMessage", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null);
            string shutDownStack   = (string)runtime.GetType().InvokeMember("_shutDownStack", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null);

            Logger.Info(string.Format("Website stopped (Message: {0}, Stacktrace: {1})", shutDownMessage, shutDownStack));

            WebsiteNotifications mailinfo = (WebsiteNotifications)ConfigurationManager.GetSection("Notifications/WebsiteNotifications");

            if (mailinfo != null && mailinfo.WebsiteStopped.Enabled && mailinfo.From != null && mailinfo.Recipients.Count > 0)
            {
                // memory stats
                Process process         = Process.GetCurrentProcess();
                long    memoryKB        = ToKiloBytes(process.WorkingSet64);
                long    virtualMemoryKB = ToKiloBytes(process.VirtualMemorySize64);

                string memory        = memoryKB.ToString("N0");
                string virtualMemory = virtualMemoryKB.ToString("N0");

                // build message
                string subject = string.Format("{0} - {1}", Environment.MachineName, mailinfo.WebsiteStopped.Subject);
                string body    = string.Format(mailinfo.WebsiteStopped.Body.Text, shutDownMessage.Replace("\r\n", "<BR/>"), shutDownStack, memory, virtualMemory);
                ProperServices.Common.Mail.Mailer.SendMail(mailinfo.Recipients.GetReceipients(), mailinfo.From.Email, subject, body, mailinfo.WebsiteStopped.Body.IsHtml);

                // send sms
                if (mailinfo.WebsiteStopped.SMSNotification)
                {
                    SMSNotify("Shutdown: " + shutDownMessage, mailinfo);
                }
            }
        }