| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <%@ Application Language="C#" %>
- <%@ Import Namespace="Curtain.DataAccess" %>
- <%@ Import Namespace="Curtain.Log" %>
- <%@ Import Namespace="DK.XuWei.WebMes" %>
- <script RunAt="server">
- // 定时器
- System.Timers.Timer tr = null;
- void Application_Start(object sender, EventArgs e)
- {
- // 在应用程序启动时运行的代码
- string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
- DataAccess.DefaultParameterType = SQLParameterType.CDA;
- DataAccess.DefaultDataBaseType = Curtain.DataAccess.DataBaseType.Oracle;
- DataAccess.DefaultConnectionString = connStr;
- // 设置定时器
- tr_Load();
- }
- /// <summary>
- /// 设置定时器
- /// </summary>
- void tr_Load()
- {
- Logger.Debug("$$$定时器已启动$$$");
- //设置timer
- tr = new System.Timers.Timer(180000);
- tr.Elapsed += new System.Timers.ElapsedEventHandler(tr_Timer);
- tr.Enabled = true;
- tr.AutoReset = true;
- }
- /// <summary>
- /// 定时器要执行的任务
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void tr_Timer(object sender, EventArgs e)
- {
- // 发送数据到LED
- Led.SendData();
- }
- void Application_End(object sender, EventArgs e)
- {
- // 在应用程序关闭时运行的代码
- Logger.Debug("$$$定时器被关闭$$$");
- if (tr != null)
- {
- tr.Dispose();
- }
- // 重新唤醒当前应用
- ReworkHttp.Rework();
- }
- void Application_Error(object sender, EventArgs e)
- {
- // 在出现未处理的错误时运行的代码
- Exception error = Server.GetLastError().GetBaseException();
- if (error != null)
- {
- //记录日志
- Logger.Error(error);
- //输出错误信息
- //2022-11-15 冯林勇 出现错误不弹出日志
- //HttpContext.Current.Response.Write(new JsonResult(JsonStatus.otherError).ToJson());
- //2022-11-15 冯林勇 出现错误不弹出日志
- }
- Server.ClearError();
- }
- void Session_Start(object sender, EventArgs e)
- {
- // 在新会话启动时运行的代码
- }
- void Session_End(object sender, EventArgs e)
- {
- // 在会话结束时运行的代码。
- // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
- // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
- // 或 SQLServer,则不引发该事件。
- }
- </script>
|