Global程序定时执行

void Application_Start(object sender, EventArgs e)
    {
        // 在应用程序启动时运行的代码
        System.Timers.Timer time = new System.Timers.Timer(5000);//5秒执行一次
        time.AutoReset = true;
        time.Enabled = true;
        time.Elapsed += new System.Timers.ElapsedEventHandler(this.PaiDuiTimer);    
    }

    void PaiDuiTimer(Object sender,System.Timers.ElapsedEventArgs e)
    {

        //GetLoginMsg ei = new GetLoginMsg();
       
        int StationID =0; //ei.findWorkStationNo(); Int32.Parse(dt.Rows[0]["WorkStationID"].ToString());
        int FactoryNo = 0; //ei.findFactoryNo(); Int32.Parse(dt.Rows[0]["FactoryNo"].ToString());
       
        if (Application["WorkStationNo"].ToString() != "")
        {
            StationID = Int32.Parse(Application["WorkStationNo"].ToString());
        }

        if (Application["FactoryNo"].ToString() != "")
        {
            FactoryNo = Int32.Parse(Application["FactoryNo"].ToString());
        }
       
        Car.PaiDuiService pd = new Car.PaiDuiService();
        pd.GetBestEmp(StationID,FactoryNo);
    }

posted @ 2009-06-10 09:43  戒子  阅读(472)  评论(2编辑  收藏  举报