fleet-contractor/Site/Global.asax
2024-03-26 15:56:31 +08:00

90 lines
3.0 KiB
Plaintext

<%@ Application Language="C#" %>
<script RunAt="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
IronIntel.Contractor.SystemParams.CreateDbObjects();
IronIntel.Contractor.IronIntelHost.Init();
// FI.FIC.DataProviders.Alert.Alertmanager.Instance.Start();
//FI.FIC.Models.ScheduleService.Instance.Start();
// FI.FIC.Email.ChartProvider.StartSend();
//IronIntel.Contractor.Maintenance.IATCAlertsSyncService.Start();
}
void Application_End(object sender, EventArgs e)
{
//FI.FIC.Models.ScheduleService.Instance.Stop();
//FI.FIC.DataProviders.Alert.Alertmanager.Instance.Stop();
// FI.FIC.Email.ChartProvider.EndSend();
//IronIntel.Contractor.Maintenance.IATCAlertsSyncService.Stop();
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
var exception = Server.GetLastError();
if (exception is HttpUnhandledException)
{
exception = exception.InnerException;
// build error strings
var sb = new StringBuilder();
while (exception != null)
{
sb.AppendLine(exception.Message);
sb.AppendLine();
sb.AppendLine(exception.StackTrace);
sb.AppendLine(new string('-', 20));
sb.AppendLine("\n\n");
exception = exception.InnerException;
}
var bs = Encoding.UTF8.GetBytes(sb.ToString());
// emulate the errorpage
string result = null;
var url = Request.Url;
var addr = string.Format("{0}://{1}:{2}{3}/ErrorPage.aspx", url.Scheme, url.Host, url.Port, Request.ApplicationPath);
var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(addr);
request.Method = "POST";
using (var req = request.GetRequestStream())
{
req.Write(bs, 0, bs.Length);
}
using (var response = request.GetResponse())
{
using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
{
result = reader.ReadToEnd();
}
}
if (result != null)
{
Response.Write(result);
}
Response.StatusCode = 200;
Server.ClearError();
}
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>