87 lines
2.7 KiB
C#
87 lines
2.7 KiB
C#
using Models;
|
||
using Models.ModelItems;
|
||
using Models.View;
|
||
using Services.Cache;
|
||
using Services.Manager;
|
||
using Services.Tool;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Threading.Tasks;
|
||
using System.Web;
|
||
using System.Web.Mvc;
|
||
using System.Web.Optimization;
|
||
using System.Web.Routing;
|
||
|
||
namespace UI
|
||
{
|
||
public class MvcApplication : System.Web.HttpApplication
|
||
{
|
||
protected void Application_Start()
|
||
{
|
||
//注入定时任务
|
||
TimingService.MyRegistry.GoWork();
|
||
|
||
AreaRegistration.RegisterAllAreas();
|
||
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
|
||
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
||
BundleConfig.RegisterBundles(BundleTable.Bundles);
|
||
|
||
|
||
|
||
try
|
||
{
|
||
//初始化数据
|
||
//刷新缓存
|
||
CacheHelp.Updatesys(null);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Logs.WriteTimingUDPLog(ex.ToString());
|
||
}
|
||
}
|
||
|
||
protected void Application_End()
|
||
{
|
||
try
|
||
{
|
||
string strURL = ConfigHelper.GetConfigString("Homeurl") ?? "";
|
||
Logs.WriteTimingUDPLog("进程即将被IIS回收" + strURL);
|
||
System.Net.WebClient wc = new System.Net.WebClient();
|
||
System.IO.Stream stream = wc.OpenRead(strURL);
|
||
System.IO.StreamReader reader = new StreamReader(stream);
|
||
string html = reader.ReadToEnd();
|
||
if (!string.IsNullOrWhiteSpace(html))
|
||
{
|
||
Logs.WriteTimingUDPLog("唤醒程序成功");
|
||
}
|
||
reader.Close();
|
||
reader.Dispose();
|
||
stream.Close();
|
||
stream.Dispose();
|
||
wc.Dispose();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Logs.WriteTimingUDPLog("唤醒异常" + ex.Message );
|
||
}
|
||
}
|
||
protected void Application_Error(Object sender, EventArgs e)
|
||
{
|
||
Exception lastError = Server.GetLastError();//获取异常
|
||
if (lastError != null)
|
||
{
|
||
//异常信息
|
||
string strExceptionMessage = string.Empty;
|
||
//对HTTP 404做额外处理,其他错误全部当成500服务器错误
|
||
HttpException httpError = lastError as HttpException;
|
||
//得到错误信息,可以写到日志里
|
||
LogHelp.WriteExceptionLog(lastError);
|
||
//一定要调用Server.ClearError()否则会触发错误详情页(就是黄页)
|
||
//Server.ClearError();
|
||
}
|
||
}
|
||
}
|
||
}
|