
using System;
using System.Text;
using System.Globalization;
using System.Reflection;

using Legalsoft.Workflow.Application;

public partial class Settings : System.Web.HttpApplication
{
    public static System.Threading.Timer stateTimer = null;

    //程序启动时激发
    protected void Application_Start(Object sender, EventArgs e)
    {
        #region 以下代码使得DateTime.Now的默认时间格式为yyyy-MM-dd HH:mm:ss
        if (DateTimeFormatInfo.CurrentInfo != null)
        {
            var type = DateTimeFormatInfo.CurrentInfo.GetType();
            var field = type.GetField("generalLongTimePattern", BindingFlags.NonPublic | BindingFlags.Instance);
            if (field != null)
            {
                field.SetValue(DateTimeFormatInfo.CurrentInfo, "yyyy-MM-dd HH:mm:ss");
            }
        }
        #endregion

        System.Threading.AutoResetEvent autoEvent = new System.Threading.AutoResetEvent(false);
        System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(timerCall);
        stateTimer = new System.Threading.Timer(timerDelegate, autoEvent, 0, 1949);

        Baby.RemoteUrl = "http://127.0.0.1:82/api/v1/";
    }

    private void timerCall(object arts)
    {
        Commands.Sending();
    }

    //每个请求开始时
    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
    }
    //每个请求结束时
    protected void Application_EndRequest(Object sender, EventArgs e)
    {
    }
    //用来对调用者进行验证
    protected void Application_AuthenticateRequest(Object sender, EventArgs e)
    {
    }
    //引发未处理的异常时激发
    protected void Application_Error(Object sender, EventArgs e)
    {
    }
    //程序结束时激发(或应用程序已经有20分钟没有请求)
    protected void Application_End(Object sender, EventArgs e)
    {
    }
    //会话开始时激发
    protected void Session_Start(Object sender, EventArgs e)
    {
    }
    //会话结束时激发
    protected void Session_End(Object sender, EventArgs e)
    {
    }
}
