using Epost.BLL; using Epost.Common; using Epost.Model; using Epost.TestToolsWeb.App_Start; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Net; using System.Threading; using System.Timers; using System.Web; using System.Web.Http; using System.Web.Mvc; using System.Web.Optimization; using System.Web.Routing; using System.Web.WebSockets; namespace Epost.TestToolsWeb { public class MvcApplication : System.Web.HttpApplication { InboundOrdersBLL inboundBLL = new InboundOrdersBLL(); protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Time_TaskHelper.Instance().ExecuteTask += new System.Timers.ElapsedEventHandler(Global_ExecuteTask); Time_TaskHelper.Instance().Interval = 1000 * 10;//表示间隔 Time_TaskHelper.Instance().Start(); } void Global_ExecuteTask(object sender, System.Timers.ElapsedEventArgs e) { //在这里编写需要定时执行的逻辑代码 LogHelper.WriteLogInfo("任务执行中"); DataTable dt = inboundBLL.GetInOrderList(" and state =0"); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { AgvHelper agv = new AgvHelper(); AgvSchedulingTaskModel reqmodel = new AgvSchedulingTaskModel(); reqmodel.reqCode =DateTime.Now.Month+DateTime.Now.Day+ row["id"].ToString();; List positionList = new List(); Positioncodepath pathModel = new Positioncodepath(); pathModel.positionCode = row["spositionCode"].ToString(); pathModel.type = "05";//agv提供 positionList.Add(pathModel); Positioncodepath pathModel2 = new Positioncodepath(); pathModel2.positionCode = row["dpositionCode"].ToString(); pathModel2.type = "05"; positionList.Add(pathModel2); reqmodel.positionCodePath = positionList; reqmodel.taskTyp = "ZY01";//agv提供 reqmodel.ctnrTyp = "1"; AgvResultModel res= agv.genAgvSchedulingTask(reqmodel); if (res.code == "0") { //调用agv成功 更新订单状态 inboundBLL.UpInOrderList(row["id"].ToString(),"1",res.data); } } } } protected void Session_Start(object sender, EventArgs e) { // 在新会话启动时运行的代码 } } }