128 lines
4.1 KiB
Plaintext
128 lines
4.1 KiB
Plaintext
|
<%@ Application Language="C#" %>
|
|||
|
<%@ Import Namespace="view.App_Code"%>
|
|||
|
<%@ Import Namespace="DeiNiu.Utils"%>
|
|||
|
|
|||
|
<script runat="server">
|
|||
|
|
|||
|
void Application_Start(object sender, EventArgs e)
|
|||
|
{
|
|||
|
// Code that runs on application startup
|
|||
|
Application["usercnt"] = 0;
|
|||
|
Application["userlst"] = new ArrayList();
|
|||
|
|
|||
|
|
|||
|
SessionEndModule.SessionObjectKey = "CurrentUserId";
|
|||
|
SessionEndModule.SessionEnd += SessionTimoutModule_SessionEnd;
|
|||
|
}
|
|||
|
|
|||
|
void Application_End(object sender, EventArgs e)
|
|||
|
{
|
|||
|
// Code that runs on application shutdown
|
|||
|
Application.Clear();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void Application_Error(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
|
|||
|
Exception objErr = Server.GetLastError().GetBaseException();
|
|||
|
string error = "<22><><EFBFBD><EFBFBD><EFBFBD>쳣ҳ: " + Request.Url.ToString() + "<br/>";
|
|||
|
if (Request.Url.ToString().IndexOf("ShowError.aspx") > 0) //<2F><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
Server.ClearError();
|
|||
|
return;
|
|||
|
}
|
|||
|
error += "<22>쳣<EFBFBD><ECB3A3>Ϣ: " + objErr.Message + "<br/>";
|
|||
|
error += objErr.StackTrace + "<br/>";
|
|||
|
error += Request.Url.ToString() + "<br/>";
|
|||
|
Server.ClearError();
|
|||
|
Application["error"] = error;
|
|||
|
Response.Redirect("~/ShowError.aspx");
|
|||
|
|
|||
|
|
|||
|
/*
|
|||
|
Exception ev = Server.GetLastError();
|
|||
|
Server.ClearError();
|
|||
|
StringBuilder strResponse = new StringBuilder();
|
|||
|
myLog.RequestLog logobj = new myLog.RequestLog();
|
|||
|
logobj.RecordExceptionLog(ev);
|
|||
|
|
|||
|
strResponse.Append(ev);
|
|||
|
|
|||
|
if (ev is MyException) strResponse.Append(((MyException)ev).ExtrMsg);
|
|||
|
if (Session["currentSql"] != null)
|
|||
|
strResponse.Append("<br/>referenced sql is:<br/>" + HttpContext.Current.Session["currentSql"]);
|
|||
|
Session["ERROINFO"] = strResponse;
|
|||
|
Response.Redirect("~/ShowError.aspx");
|
|||
|
|
|||
|
if (ev.InnerException != null)
|
|||
|
{
|
|||
|
|
|||
|
strResponse.Append(ev.InnerException.ToString().Trim());
|
|||
|
|
|||
|
if (ev is MyException) strResponse.Append(((MyException) ev).ExtrMsg);
|
|||
|
if (Session["currentSql"] != null)
|
|||
|
strResponse.Append("<br/>referenced sql is:<br/>" + HttpContext.Current.Session["currentSql"]);
|
|||
|
Session["ERROINFO"] = strResponse;
|
|||
|
Response.Redirect("~/ShowError.aspx");
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
else if (ev is HttpException)
|
|||
|
{
|
|||
|
/// return;
|
|||
|
}
|
|||
|
|
|||
|
else
|
|||
|
{
|
|||
|
Response.Redirect("~/fileNotFound.aspx");
|
|||
|
}
|
|||
|
|
|||
|
*/
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void Session_Start(object sender, EventArgs e)
|
|||
|
{
|
|||
|
// Code that runs when a new session is started
|
|||
|
Session["CurrentUserId"] = "0";
|
|||
|
}
|
|||
|
|
|||
|
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.
|
|||
|
int cuid = Session["CurrentUserId"] == null ? 0 :Convert.ToInt32( Session["CurrentUserId"].ToString());
|
|||
|
//if (Session["CurrentUserId"] != null && (string)Session["CurrentUserId"] != "0")
|
|||
|
if(cuid >0)
|
|||
|
{
|
|||
|
((ArrayList)Application["userlst"]).Remove(Session["CurrentUserAccount"].ToString());
|
|||
|
|
|||
|
DeiNiu.RequestLog logobj = new DeiNiu.RequestLog();
|
|||
|
logobj.LogoutLog(Convert.ToInt32( Session["CurrentUserId"].ToString()));
|
|||
|
if (HttpContext.Current != null)
|
|||
|
{
|
|||
|
HttpContext.Current.Response.Redirect("~/index.aspx");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
private static void SessionTimoutModule_SessionEnd(object sender,SessionEndedEventArgs e)
|
|||
|
{
|
|||
|
<20><>
|
|||
|
|
|||
|
// This will be the value in the session for the key specified in Application_Start
|
|||
|
object sessionObject = e.SessionObject;
|
|||
|
string val = (sessionObject == null) ? "[null]" : sessionObject.ToString();
|
|||
|
if (val ==null || val == "0") return;
|
|||
|
|
|||
|
DeiNiu.RequestLog logobj = new DeiNiu.RequestLog();
|
|||
|
logobj.LogoutLog(val);
|
|||
|
|
|||
|
}
|
|||
|
</script>
|