コード例 #1
0
ファイル: MvcBaseApplicationStart.cs プロジェクト: Zedfa/Core
        public static void End()
        {
            System.Web.ApplicationShutdownReason shutdownReason = System.Web.Hosting.HostingEnvironment.ShutdownReason;
            string shutdownDetail = "";

            //Evaluate which option caused the error
            switch (shutdownReason)
            {
            case ApplicationShutdownReason.BinDirChangeOrDirectoryRename:
                shutdownDetail = "A change was made to the bin directory or the directory was renamed";
                break;

            case ApplicationShutdownReason.BrowsersDirChangeOrDirectoryRename:
                shutdownDetail = "A change was made to the App_browsers folder or the files contained in it";
                break;

            case ApplicationShutdownReason.ChangeInGlobalAsax:
                shutdownDetail = "A change was made in the global.asax file";
                break;

            case ApplicationShutdownReason.ChangeInSecurityPolicyFile:
                shutdownDetail = "A change was made in the code access security policy file";
                break;

            case ApplicationShutdownReason.CodeDirChangeOrDirectoryRename:
                shutdownDetail = "A change was made in the App_Code folder or the files contained in it";
                break;

            case ApplicationShutdownReason.ConfigurationChange:
                shutdownDetail = "A change was made to the application level configuration";
                break;

            case ApplicationShutdownReason.HostingEnvironment:
                shutdownDetail = "The hosting environment shut down the application";
                break;

            case ApplicationShutdownReason.HttpRuntimeClose:
                shutdownDetail = "A call to Close() was requested";
                break;

            case ApplicationShutdownReason.IdleTimeout:
                shutdownDetail = "The idle time limit was reached";
                break;

            case ApplicationShutdownReason.InitializationError:
                shutdownDetail = "An error in the initialization of the AppDomain";
                break;

            case ApplicationShutdownReason.MaxRecompilationsReached:
                shutdownDetail = "The maximum number of dynamic recompiles of a resource limit was reached";
                break;

            case ApplicationShutdownReason.PhysicalApplicationPathChanged:
                shutdownDetail = "A change was made to the physical path to the application";
                break;

            case ApplicationShutdownReason.ResourcesDirChangeOrDirectoryRename:
                shutdownDetail = "A change was made to the App_GlobalResources foldr or the files contained within it";
                break;

            case ApplicationShutdownReason.UnloadAppDomainCalled:
                shutdownDetail = "A call to UnloadAppDomain() was completed";
                break;

            default:
                shutdownDetail = "Unknown shutdown reason";
                break;
            }

            //var eLog = Core.Cmn.AppBase.LogService.GetEventLogObj();
            //eLog.OccuredException = null;
            //eLog.UserId = "Core";
            //eLog.CustomMessage = "Application_End => Cause: " + shutdownDetail;
            //Core.Cmn.AppBase.LogService.Handle(eLog);
            Core.Cmn.AppBase.LogService.Write("Core=> Application_End => Cause: " + shutdownDetail);
        }
コード例 #2
0
        protected void Application_End(Object sender, EventArgs e)
        {
            System.Web.ApplicationShutdownReason shutdownReason = System.Web.Hosting.HostingEnvironment.ShutdownReason;
            string shutdownDetail = "";

            switch (shutdownReason)
            {
            case ApplicationShutdownReason.BinDirChangeOrDirectoryRename:
                shutdownDetail = "A change was made to the bin directory or the directory was renamed";
                break;

            case ApplicationShutdownReason.BrowsersDirChangeOrDirectoryRename:
                shutdownDetail = "A change was made to the App_browsers folder or the files contained in it";
                break;

            case ApplicationShutdownReason.ChangeInGlobalAsax:
                shutdownDetail = "A change was made in the global.asax file";
                break;

            case ApplicationShutdownReason.ChangeInSecurityPolicyFile:
                shutdownDetail = "A change was made in the code access security policy file";
                break;

            case ApplicationShutdownReason.CodeDirChangeOrDirectoryRename:
                shutdownDetail = "A change was made in the App_Code folder or the files contained in it";
                break;

            case ApplicationShutdownReason.ConfigurationChange:
                shutdownDetail = "A change was made to the application level configuration";
                break;

            case ApplicationShutdownReason.HostingEnvironment:
                shutdownDetail = "The hosting environment shut down the application";
                break;

            case ApplicationShutdownReason.HttpRuntimeClose:
                shutdownDetail = "A call to Close() was requested";
                break;

            case ApplicationShutdownReason.IdleTimeout:
                shutdownDetail = "The idle time limit was reached";
                break;

            case ApplicationShutdownReason.InitializationError:
                shutdownDetail = "An error in the initialization of the AppDomain";
                break;

            case ApplicationShutdownReason.MaxRecompilationsReached:
                shutdownDetail = "The maximum number of dynamic recompiles of a resource limit was reached";
                break;

            case ApplicationShutdownReason.PhysicalApplicationPathChanged:
                shutdownDetail = "A change was made to the physical path to the application";
                break;

            case ApplicationShutdownReason.ResourcesDirChangeOrDirectoryRename:
                shutdownDetail = "A change was made to the App_GlobalResources foldr or the files contained within it";
                break;

            case ApplicationShutdownReason.UnloadAppDomainCalled:
                shutdownDetail = "A call to UnloadAppDomain() was completed";
                break;

            default:
                shutdownDetail = "Unknown shutdown reason";
                break;
            }

            System.IO.StreamWriter Writer = System.IO.File.AppendText(Server.MapPath("~/App.log"));

            Writer.WriteLine("App End: " + DateTime.Now.ToString() + "Reason: " + shutdownDetail);
            Writer.Close();
        }
コード例 #3
0
        public static void LogEnd()
        {
            try
            {
                System.Web.ApplicationShutdownReason shutdownReason = System.Web.Hosting.HostingEnvironment.ShutdownReason;
                string shutdownDetail = "";
                switch (shutdownReason)
                {
                case ApplicationShutdownReason.BinDirChangeOrDirectoryRename:
                    shutdownDetail = "The AppDomain shut down because of a change to the Bin folder or files contained in it.";
                    break;

                case ApplicationShutdownReason.BrowsersDirChangeOrDirectoryRename:
                    shutdownDetail = "The AppDomain shut down because of a change to the App_Browsers folder or files contained in it.";
                    break;

                case ApplicationShutdownReason.ChangeInGlobalAsax:
                    shutdownDetail = "The AppDomain shut down because of a change to Global.asax.";
                    break;

                case ApplicationShutdownReason.ChangeInSecurityPolicyFile:
                    shutdownDetail = "The AppDomain shut down because of a change in the code access security policy file.";
                    break;

                case ApplicationShutdownReason.CodeDirChangeOrDirectoryRename:
                    shutdownDetail = "The AppDomain shut down because of a change to the App_Code folder or files contained in it.";
                    break;

                case ApplicationShutdownReason.ConfigurationChange:
                    shutdownDetail = "The AppDomain shut down because of a change to the application level configuration.";
                    break;

                case ApplicationShutdownReason.HostingEnvironment:
                    shutdownDetail = "The AppDomain shut down because of the hosting environment.";
                    break;

                case ApplicationShutdownReason.HttpRuntimeClose:
                    shutdownDetail = "The AppDomain shut down because of a call to Close.";
                    break;

                case ApplicationShutdownReason.IdleTimeout:
                    shutdownDetail = "The AppDomain shut down because of the maximum allowed idle time limit.";
                    break;

                case ApplicationShutdownReason.InitializationError:
                    shutdownDetail = "The AppDomain shut down because of an AppDomain initialization error.";
                    break;

                case ApplicationShutdownReason.MaxRecompilationsReached:
                    shutdownDetail = "The AppDomain shut down because of the maximum number of dynamic recompiles of resources limit.";
                    break;

                case ApplicationShutdownReason.PhysicalApplicationPathChanged:
                    shutdownDetail = "The AppDomain shut down because of a change to the physical path for the application.";
                    break;

                case ApplicationShutdownReason.ResourcesDirChangeOrDirectoryRename:
                    shutdownDetail = "The AppDomain shut down because of a change to the App_GlobalResources folder or files contained in it.";
                    break;

                case ApplicationShutdownReason.UnloadAppDomainCalled:
                    shutdownDetail = "The AppDomain shut down because of a call to UnloadAppDomain.";
                    break;

                default:
                    shutdownDetail = "No shutdown reason provided.";
                    break;
                }
                EventLogController objEv           = new EventLogController();
                LogInfo            objEventLogInfo = new LogInfo();
                objEventLogInfo.BypassBuffering = true;
                objEventLogInfo.LogTypeKey      = Services.Log.EventLog.EventLogController.EventLogType.APPLICATION_SHUTTING_DOWN.ToString();
                objEventLogInfo.AddProperty("Shutdown Details", shutdownDetail);
                objEv.AddLog(objEventLogInfo);
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            //if (Globals.Status != Globals.UpgradeStatus.Install)
            //{
            //    LoggingProvider.Instance().PurgeLogBuffer();
            //}
        }