using Learun.Application.Scheduler; using Learun.Application.Web.Common; using Learun.Cache.Base; using Learun.Cache.Factory; using System; using System.Timers; using System.Web; using System.Web.Http; using System.Web.Mvc; using System.Web.Routing; using System.Web.SessionState; namespace Learun.Application.Web { /// /// 版 本 PIT-ADMS V7.0.3 敏捷开发框架 /// Copyright (c) 2013-2018 Hexagon PPM /// 创建人:研发部 /// 日 期:2017.03.08 /// 描 述:应用程序全局设置 /// public class MvcApplication : HttpApplication { /// /// 启动应用程序 /// protected void Application_Start() { AreaRegistration.RegisterAllAreas(); //在API启动时注册路由映射 GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); ////一天执行一次备份 Timer timer = new Timer(86400000); //timer.Elapsed += Timer_Elapsed; //timer.Start(); #region redis清理 ICache redisObj = CacheFactory.CaChe(); redisObj.RemoveAll(); #endregion } private void Timer_Elapsed(object sender, ElapsedEventArgs e) { ProjectBakupJob.Execute(); } /// /// Session配置之WebApi支持(https://www.cnblogs.com/ca47/p/4603701.html) /// public override void Init() { PostAuthenticateRequest += (s, e) => HttpContext.Current.SetSessionStateBehavior(SessionStateBehavior.Required); base.Init(); } /// /// 应用程序错误处理 /// /// sender /// EventArgs protected void Application_Error(object sender, EventArgs e) { var lastError = Server.GetLastError(); //// 在应用程序关闭时运行的代码 //if (BaseScheduler.scheduler != null) //{ // BaseScheduler.scheduler.Shutdown(true); //} } protected void Application_End(object sender, EventArgs e) { // 在应用程序关闭时运行的代码 if (BaseScheduler.scheduler != null) { BaseScheduler.scheduler.Shutdown(true); } } } }