Global.asax.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using SysBaseLibs;
  2. using SysSecLibs;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Http;
  8. using System.Web.Mvc;
  9. using System.Web.Routing;
  10. using System.Web.Security;
  11. using System.Web.SessionState;
  12. using DataTransfersLibs;
  13. namespace GSMarketSys
  14. {
  15. public class Global : HttpApplication
  16. {
  17. void Application_Start(object sender, EventArgs e)
  18. {
  19. // 在应用程序启动时运行的代码
  20. AreaRegistration.RegisterAllAreas();
  21. GlobalConfiguration.Configure(WebApiConfig.Register);
  22. RouteConfig.RegisterRoutes(RouteTable.Routes);
  23. AutoMapConfiguration.Configure();
  24. string lcVpath = AppDomain.CurrentDomain.BaseDirectory;
  25. SysSecLibs.FileFuns.AddSeachingFolder(lcVpath + "Bin");
  26. SysBaseLibs.ThreadLog.LogBlank(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  27. SysBaseLibs.ThreadLog.LogInfo("Application_Start -- System Begin Start!");
  28. // 重要商品来源数据抓取
  29. //MajorGoodsSourcePuller.Instance.Start();
  30. }
  31. void global_asax_EndRequest(object sender, EventArgs e)
  32. {
  33. SysBaseLibs.ThreadLog.LogInfo(this.ToString() + " global_asax_EndRequest sender:" + sender.ToString() + " e: " + e.ToString());
  34. }
  35. void global_asax_Error(object sender, EventArgs e)
  36. {
  37. SysBaseLibs.ThreadLog.LogInfo(this.ToString() + " global_asax_Error sender:" + sender.ToString() + " e: " + e.ToString());
  38. }
  39. void global_asax_Disposed(object sender, EventArgs e)
  40. {
  41. SysBaseLibs.ThreadLog.LogInfo(this.ToString() + " global_asax_Disposed sender:" + sender.ToString() + " e: " + e.ToString());
  42. }
  43. void Application_End(object sender, EventArgs e)
  44. {
  45. // 在应用程序关闭时运行的代码
  46. SysBaseLibs.ThreadLog.LogInfo(" Application_End -- System End!");
  47. // 重要商品来源数据抓取
  48. //MajorGoodsSourcePuller.Instance.Stop();
  49. }
  50. void Application_Error(object sender, EventArgs e)
  51. {
  52. // 在出现未处理的错误时运行的代码
  53. Exception ex = Server.GetLastError();
  54. //实际发生的异常
  55. Exception innerException = ex.InnerException;
  56. if (innerException != null) ex = innerException;
  57. SysBaseLibs.ThreadLog.LogErr("Application_Error: " + ex);
  58. SysBaseLibs.ThreadLog.LogErr("Application_Error: "+this.Session.Contents.SessionID);
  59. }
  60. void Session_Start(object sender, EventArgs e)
  61. {
  62. // 在新会话启动时运行的代码;
  63. SysBaseLibs.ThreadLog.LogInfo("Session_Start");
  64. }
  65. void Session_End(object sender, EventArgs e)
  66. {
  67. // 在会话结束时运行的代码。
  68. // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
  69. // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
  70. // 或 SQLServer,则不会引发该事件。
  71. SysDataLibs.UserSession loSession = SysDataLibs.WebLibs.GetUserSession();
  72. if (loSession != null)
  73. {
  74. SysBaseLibs.ThreadLog.LogInfo(loSession.UserInfo.UserID + "logout");
  75. SysDataLibs.TableClass.Sys_Log_info.LogMsg(SysDataLibs.TableClass.LogType.System, "LoginOut", loSession.UserInfo.UserID, "");
  76. loSession.Destroy();
  77. loSession = null;
  78. }
  79. SysBaseLibs.ThreadLog.LogInfo("Session_End");
  80. }
  81. }
  82. }