コード例 #1
0
        /// <summary>
        /// Application reset notification.
        /// </summary>
        public static void ResetNotification()
        {
            HttpRuntime runtime = (HttpRuntime)typeof(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);

            string allLog = "Shutdown message: " + Environment.NewLine + "\t" + shutDownMessage;

            allLog += "ShutdownStack:" + Environment.NewLine + "\t" + shutDownStack;

            Logger.Log(allLog, LogLevel.Info, LogFilePrefix.Restart);
        }
コード例 #2
0
        void Application_End(object sender, EventArgs e)
        {
            try
            {
                string shutDownMessage = "";
                string shutDownStack   = "";

                HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime",
                                                                                               BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField,
                                                                                               null, null, null);
                if (runtime != null)
                {
                    shutDownMessage = shutDownMessage + "  ...  " + (string)runtime.GetType().InvokeMember("_shutDownMessage",
                                                                                                           BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField,
                                                                                                           null, runtime, null);

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

                _ObjClsCommon.AddAppLog("Admissionjankari " + shutDownMessage, shutDownStack, DateTime.Now);
            }
            catch (Exception ex)
            {
                _ObjClsCommon.AddAppLog(ex.Message, ex.InnerException.Message, DateTime.Now);
            }
        }
コード例 #3
0
ファイル: Global.asax.cs プロジェクト: onurh/AF452
        protected void Application_End()
        {
            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);

            var logger = EngineContext.Current.Resolve <ILogger>();

            logger.Information(string.Format("Application ended\n message : {0}\n stack : {1}", shutDownMessage, shutDownStack));
        }
コード例 #4
0
ファイル: WebRole.cs プロジェクト: mikesavior/elmcity
        protected void Application_End(object sender, EventArgs e)
        {
            HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime",
                                                                                           BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField,
                                                                                           null,
                                                                                           null,
                                                                                           null);

            if (runtime == null)
            {
                return;
            }

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

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

            var ts = TableStorage.MakeDefaultTableStorage();

            GenUtils.PriorityLogMsg("Application_End", shutdown_message, shutdown_stack);
        }
コード例 #5
0
        protected void Application_End(object sender, EventArgs e)
        {
            // Get all the log entries and force a write immediately.
            StringBuilder logEntries = new StringBuilder();

            logEntries.Append("LMS application module shut down/restart." + Environment.NewLine);

            HttpRuntime runtime = null;
            Type        t       = typeof(HttpRuntime);

            runtime = (HttpRuntime)t.InvokeMember("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);
            if (runtime == null)
            {
                Log.Info(logEntries.ToString());
                return;
            }

            //get reason for shutdown
            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);

            logEntries.Append("Shutdown Message=" + shutDownMessage + Environment.NewLine);
            logEntries.Append("Shutdown Stack=" + shutDownStack + Environment.NewLine);

            Log.Info(logEntries.ToString());
        }
コード例 #6
0
        protected void Application_End(object sender, EventArgs e)
        {
            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);


            org.miloss.fgsms.agent.Logger.warn(String.Format(
                                                   "\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}",
                                                   shutDownMessage, shutDownStack));
        }
コード例 #7
0
        protected virtual void Application_End()
        {
            HttpRuntime runtime = (HttpRuntime)typeof(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);

            Log.Info(String.Format("\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}",
                                   shutDownMessage,
                                   shutDownStack));
        }
コード例 #8
0
        /// <summary>
        /// Handles the End event of the Application control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void Application_End(object sender, EventArgs e)
        {
            try
            {
                // log the reason that the application end was fired
                HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);

                if (runtime != null)
                {
                    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);

                    // send debug info to debug window
                    System.Diagnostics.Debug.WriteLine(String.Format("shutDownMessage:{0}\r\n\r\n_shutDownStack:\r\n{1}", shutDownMessage, shutDownStack));
                }
            }
            catch
            {
                // intentionally ignore exception
            }

            // close out jobs infrastructure if running under IIS
            bool runJobsInContext = Convert.ToBoolean(ConfigurationManager.AppSettings["RunJobsInIISContext"]);

            if (runJobsInContext)
            {
                if (sched != null)
                {
                    sched.Shutdown();
                }
            }

            // process the transaction queue
            DrainTransactionQueue();
        }
コード例 #9
0
        protected virtual void Application_End(Object sender, EventArgs e)
        {
            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);

            if (EventLogEnabled)
            {
                EventLog.WriteEntry(String.Format("{0}\n{1}\n\n{2}",
                                                  System.Web.Hosting.HostingEnvironment.ShutdownReason,
                                                  shutDownMessage,
                                                  shutDownStack),
                                    EventLogEntryType.Warning);
            }
        }
コード例 #10
0
ファイル: OnDispose.cs プロジェクト: Zero-Xiong/UMSolution
        private void OnAppDispose(IAppBuilder app, CancellationToken cancelToken)
        {
            var log = app.CreateLogger("OnAppDispose");

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

            if (runtime != null)
            {
                var shutDownMsg = runtime.GetType().InvokeMember("_shutDownMessage",
                                                                 BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField,
                                                                 null, runtime, null);

                if (shutDownMsg != null)
                {
                    log.WriteInformation($"ShutDown Message: {shutDownMsg}");
                }

                var shutdownStack = runtime.GetType().InvokeMember("_shutDownStack",
                                                                   BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField,
                                                                   null, runtime, null);

                if (shutdownStack != null)
                {
                    log.WriteInformation($"ShutDown Stack: {shutdownStack}");
                }
            }

            log.WriteInformation("Webapi is Disposed");
        }
コード例 #11
0
        /// <summary>
        /// Retrieves shutdown information about an ongoing shutdown.
        /// </summary>
        /// <returns></returns>
        public static ShutdownInfo GetShutdownInfo()
        {
            try
            {
                HttpRuntime runtime = (HttpRuntime)typeof(HttpRuntime).InvokeMember("_theRuntime",
                                                                                    BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);

                if (runtime == null)
                {
                    return(null);
                }

                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);

                return(new ShutdownInfo
                {
                    Message = shutDownMessage,
                    StackTrace = shutDownStack
                });
            }
            catch (System.Exception)
            {
                { }
            }
            return(null);
        }
コード例 #12
0
        /// <summary>
        /// 记录系统停止日志
        /// </summary>
        public static void WriteServerStopLog()
        {
            string shutDownMessageShort = "不明原因";

            try
            {
#if NET
                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);
                var    shutDownMessageArr = shutDownMessage.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Take(3).ToArray().Select(a => a.Trim('。').Trim('.').Trim(',').Trim(':'));
                shutDownMessageShort = string.Join(",", shutDownMessageArr);
                //写到事件查看器
                new EventLog().WriteEntry(String.Format("\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}", shutDownMessage, shutDownStack), EventLogEntryType.Information);
#endif
            }
            catch
            {
            }
            //写到自定义日志中
            string      detail = string.Format("服务器停止,停止原因为[{0}],运行时长{1}", shutDownMessageShort, ClientServerInfo.ServerInfo.GetRunningTime());
            LogTraceEdm stop   = new LogTraceEdm()
            {
                Detail  = detail,
                LogType = LogType.停止,
                Remark  = "停止时间" + DateTime.Now,
            };
            WriteLog(stop);
        }
コード例 #13
0
        private static void LogShutDownReason()
        {
            HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime",
                                                                                           System.Reflection.BindingFlags.NonPublic |
                                                                                           System.Reflection.BindingFlags.Static |
                                                                                           System.Reflection.BindingFlags.GetField,
                                                                                           null, null, null);

            if (runtime == null)
            {
                Log.LogWarning("ASP.NET Shut Down", "Unable to determine cause of shut down");
                return;
            }

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

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

            shutDownMessage = (shutDownMessage ?? "null").Replace("\n", "   \n");

            Log.LogVerbose("RGB(250,50,50)ASP.NET Shut Down",
                           $"_shutDownMessage=\n{shutDownMessage}\n\n_shutDownStack=\n{shutDownStack}");
        }
コード例 #14
0
ファイル: Global.asax.cs プロジェクト: geji5239/Geji2015
        protected void RecordEndReason()
        {
            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);

            this.Log(String.Format("Application End:\r\nshutDownMessage={0}\r\nshutDownStack={1}", shutDownMessage, shutDownStack));
        }
コード例 #15
0
        protected void Application_End(Object sender, EventArgs e)
        {
            ErrorLog.ErrorRoutine(false, "APP_END");

            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);

            //if (!EventLog.SourceExists(".NET Runtime"))
            //{
            //    EventLog.CreateEventSource(".NET Runtime", "Application");
            //}

            //EventLog log = new EventLog();
            //log.Source = ".NET Runtime";

            string errStr;

            errStr = String.Format("\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}",
                                   shutDownMessage,
                                   shutDownStack);

            ErrorLog.ErrorRoutine(false, "APP_END: " + errStr);
        }
コード例 #16
0
        protected void Application_End(object sender, EventArgs e)
        {
            HttpRuntime runtime         = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);
            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);
            string      path            = ConfigurationManager.AppSettings["ErrorLogPath"];

            if (path == null || path == "")
            {
                path = Server.MapPath("");
            }
            string filename = path + "\\AppDomain_log_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";

            BitPlate.Domain.Utils.Logger.Log(filename, shutDownMessage + "\r\n\r\n" + shutDownStack + "\r\n\r\n");
            //System.Diagnostics.Debugger.Break();
        }
コード例 #17
0
        public void Application_End()
        {
            // http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx
            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);

            if (!EventLog.SourceExists(".NET Runtime"))
            {
                EventLog.CreateEventSource(".NET Runtime", "Application");
            }

            EventLog log = new EventLog();

            log.Source = ".NET Runtime";
            log.WriteEntry(String.Format("\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}",
                                         shutDownMessage,
                                         shutDownStack),
                           EventLogEntryType.Error);
        }
コード例 #18
0
        /// <summary>
        /// Handles the End event of the application
        /// </summary>
        protected virtual void Application_End()
        {
            HttpRuntime runtime = (HttpRuntime)typeof(HttpRuntime).InvokeMember(
                "_theRuntime",
                BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField,
                null,
                null,
                null);

            if (runtime.IsNull())
            {
                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);

            if (!EventLog.SourceExists(".NET Runtime"))
            {
                EventLog.CreateEventSource(".NET Runtime", "Application");
            }

            EventLog log = new EventLog();

            log.Source = ".NET Runtime";
            log.WriteEntry(
                string.Format(
                    "\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}",
                    shutDownMessage,
                    shutDownStack),
                EventLogEntryType.Error);
        }
コード例 #19
0
        //void Application_OnPostAuthenticateRequest(object sender, EventArgs e)
        //{
        //    // 获取当前User的引用
        //    IPrincipal usr = HttpContext.Current.User;

        //    // 如果当前用户通过认证, 并且是Forms认证
        //    if (usr.Identity.IsAuthenticated)
        //    {
        //        FormsIdentity fIdent = usr.Identity as FormsIdentity;

        //        // 基于当前票据创建一个XiaoneiIdentity
        //        HappyTogether.Helper.XiaoneiIdentity xi = new HappyTogether.Helper.XiaoneiIdentity(fIdent.Ticket);

        //        // 创建一个XiaoneiPrincipal
        //        HappyTogether.Helper.XiaoneiPrincipal p = new HappyTogether.Helper.XiaoneiPrincipal(xi);

        //        // 附件到 HttpContext.User 和 Thread.CurrentPrincipal
        //        HttpContext.Current.User = p;
        //        Thread.CurrentPrincipal = p;
        //    }
        //}

        public void Application_End()
        {
            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);

            NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
            logger.Trace("******************** Application_End ********************" + Environment.NewLine
                         + "ShutDownMessage: " + shutDownMessage + Environment.NewLine
                         + "ShutDownStack: " + shutDownStack + Environment.NewLine);
        }
コード例 #20
0
        void Application_End()
        {
            try
            {
                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);

                File.AppendAllText(AssemblyDirectory + "\\Logs\\ECMSLogs.txt", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss:ffff") + " : shutDownMessage--" + shutDownMessage + " : shutDownStack--" + shutDownStack);
            }
            catch (Exception ex)
            {
                File.AppendAllText(AssemblyDirectory + "\\Logs\\ECMSLogs.txt", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss:ffff") + " : Error while shutdown " + ex.ToString());
            }
        }
コード例 #21
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);
                }
            }
        }
コード例 #22
0
        protected void Application_End(Object sender, EventArgs e)
        {
            // system restart
            FI.BusinessObjects.DistributionManager.Instance.OnSystemRestart();

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

            if (runtime != null)
            {
                shutDownMessage = (string)runtime.GetType().InvokeMember("_shutDownMessage",
                                                                         BindingFlags.NonPublic
                                                                         | BindingFlags.Instance
                                                                         | BindingFlags.GetField,
                                                                         null,
                                                                         runtime,
                                                                         null);

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

            // write event
            LogWriter.Instance.WriteEventLogEntry(string.Format("Application_End:\r\nShutDownMessage={0}\r\n\r\nShutDownStack={1}",
                                                                shutDownMessage,
                                                                shutDownStack),
                                                  EventLogEntryType.Error);
        }
コード例 #23
0
        private T GetValue <T>(string name)
        {
            if (_runtime != null)
            {
                try
                {
                    return((T)_runtime.GetType().InvokeMember(name, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, _runtime, null));
                }
                catch {}
            }

            return(default(T));
        }
コード例 #24
0
        void Application_End(object sender, EventArgs e)
        {
            //  Code that runs on application shutdown
            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);

            if (!EventLog.SourceExists(".NET Runtime"))
            {
                EventLog.CreateEventSource(".NET Runtime", "Application");
            }
            EventLog log = new EventLog();

            log.Source = ".NET Runtime";
            log.WriteEntry(String.Format("\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}", shutDownMessage, shutDownStack), EventLogEntryType.Error);
        }
コード例 #25
0
        protected void Application_End()
        {
            #region 分析Application Pool 退出/重启的原因
#if !DEBUG
            try
            {
                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
                    );

                Hyt.Util.Log.LogManager.Instance.WriteLog("ASP.NET应用程序关闭。\r\n关闭消息:\r\n" + shutDownMessage + "堆栈跟踪:\r\n" +
                                                          shutDownStack);
            }
            catch
            {
                Hyt.Util.Log.LogManager.Instance.WriteLog("ASP.NET应用程序关闭。\r\n关闭原因:\r\n" +
                                                          HostingEnvironment.ShutdownReason);
            }
#endif

            #endregion
        }
コード例 #26
0
ファイル: Global.asax.cs プロジェクト: zhangbo27/bbsmax
        //[Conditional("DEBUG")]
        protected void Application_End(object sender, EventArgs e)
        {
#if !Passport
            //备份在线列表
            OnlineUserPool.Instance.Backup();
#endif

            #region 记录关机原因

            try
            {
                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
                    );

                LogHelper.CreateDebugLog("ASP.NET应用程序关闭。\r\n关闭消息:\r\n" + shutDownMessage + "堆栈跟踪:\r\n" + shutDownStack);
            }
            catch
            {
                LogHelper.CreateDebugLog("ASP.NET应用程序关闭。\r\n关闭原因:\r\n" + HostingEnvironment.ShutdownReason);
            }

            #endregion
        }
コード例 #27
0
        public void Application_End()
        {
            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);

            LogHelper.Say("\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}"
                          , shutDownMessage, shutDownStack);
        }
コード例 #28
0
        protected void Application_End(object sender, EventArgs e)
        {
            m_Logger.Debug("Application ended");

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

            if (runtime != null)
            {
                string shutDownMessage = (string)runtime.GetType().InvokeMember("_shutDownMessage", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null);
                m_Logger.WarnFormat("Application shutdown - message: {0}", shutDownMessage);
            }

            // Shutdown the log
            LogManager.Shutdown();
        }
コード例 #29
0
ファイル: Global.asax.cs プロジェクト: tytok/PlanServer
        void Application_End(object sender, EventArgs e)
        {
            // 程序池停止日志,并收集停止原因
            string      message = string.Empty;
            HttpRuntime runtime = (HttpRuntime)typeof(HttpRuntime).InvokeMember("_theRuntime",
                                                                                BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);

            if (runtime != null)
            {
                Type         type            = runtime.GetType();
                BindingFlags flags           = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField;
                string       shutDownMessage = (string)type.InvokeMember("_shutDownMessage", flags, null, runtime, null);
                string       shutDownStack   = (string)type.InvokeMember("_shutDownStack", flags, null, runtime, null);
                message = string.Format("\r\nshutDownMessage:{0}\r\nshutDownStack:\r\n:{1}", shutDownMessage, shutDownStack);
            }
            LogHelper.WriteCustom("Application_End " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + message, "AppStartEnd\\");
        }
コード例 #30
0
ファイル: Global.asax.cs プロジェクト: MicLiu1992/DemoCode
        /// <summary>
        /// 站点退出,记录日志
        /// </summary>
        protected virtual void Application_End()
        {
            // 程序池停止日志,并收集停止原因
            string      message = string.Empty;
            HttpRuntime runtime = (HttpRuntime)typeof(HttpRuntime).InvokeMember("_theRuntime",
                                                                                BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);

            if (runtime != null)
            {
                Type         type            = runtime.GetType();
                BindingFlags flags           = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField;
                string       shutDownMessage = (string)type.InvokeMember("_shutDownMessage", flags, null, runtime, null);
                string       shutDownStack   = (string)type.InvokeMember("_shutDownStack", flags, null, runtime, null);
                message = $"\r\nshutDownMessage:{shutDownMessage}\r\nshutDownStack:\r\n:{shutDownStack}";
            }
            LoggerDefault.Default.Custom("AppStartEnd\\",
                                         "Application_End " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + message);
        }