Beispiel #1
0
 private void ProcessNextWorkDate()
 {
     while (true)
     {
         try
         {
             WorkRule workRule = new WorkRule();
             bool     flag     = false;
             foreach (Work_Plan current in workRule.GetCreateNextPlanDate(this._Work_Host))
             {
                 try
                 {
                     DateTime dateTime = PlanHelper.CreateNextPlanDate(current.PlanConfig, current.LastRunDate);
                     if (dateTime != DateTime.MaxValue)
                     {
                         Work_PlanRun work_PlanRun = new Work_PlanRun();
                         work_PlanRun.WorkInfoID = current.WorkInfoID;
                         work_PlanRun.PlanID     = current.PlanID;
                         work_PlanRun.RunDate    = dateTime;
                         work_PlanRun.IsRun      = false;
                         flag = true;
                         workRule.CurrentEntities.AddTowork_planrun(work_PlanRun);
                     }
                 }
                 catch (Exception ex)
                 {
                     ("循环检查创建" + current.PlanName + "下次执行时间出现异常:" + ex.Message).WriteLineRed("");
                     LogHelper.Write("WorkLog", "循环检创建" + current.PlanName + "下次执行时间出现异常", ex, "");
                 }
             }
             if (flag)
             {
                 "提交下一次计划更新".WriteLineYellow("");
                 workRule.CurrentEntities.SaveChanges();
             }
         }
         catch (Exception ex)
         {
             ("循环检查创建各作业下次执行时间出现异常:" + ex.Message).WriteLineRed("");
             try
             {
                 LogHelper.Write("WorkLog", "循环检查创建各作业下次执行时间出现异常", ex, "");
             }
             catch (Exception exception)
             {
                 EventLogWriter.WriterLog(exception);
             }
         }
         Thread.Sleep(this._NextWorkDateSleep);
     }
 }