コード例 #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);
     }
 }
コード例 #2
0
 private void ProcessNextWorkRun()
 {
     while (true)
     {
         try
         {
             WorkRule workRule = new WorkRule();
             List <Work_RunProcessInfo> createRunProcess = workRule.GetCreateRunProcess(this._Work_Host);
             if (createRunProcess.Count > 0)
             {
                 List <int> PlanIDList = (from s in createRunProcess
                                          select s.PlanID).Distinct <int>().ToList <int>();
                 List <Work_PlanStepInfo> source = (from s in workRule.Work_PlanStepInfo
                                                    where PlanIDList.Contains(s.PlanID)
                                                    select s).ToList <Work_PlanStepInfo>();
                 using (List <Work_RunProcessInfo> .Enumerator enumerator = createRunProcess.GetEnumerator())
                 {
                     while (enumerator.MoveNext())
                     {
                         Work_RunProcessInfo objWork_RunProcessInfo = enumerator.Current;
                         PlanInfo            planInfo = new PlanInfo
                         {
                             PlanRunID      = objWork_RunProcessInfo.PlanRunID,
                             PlanID         = objWork_RunProcessInfo.PlanID,
                             RunDateTime    = objWork_RunProcessInfo.RunDate,
                             WorkInfoID     = objWork_RunProcessInfo.WorkInfoID,
                             WorkInfoName   = objWork_RunProcessInfo.WorkInfoName,
                             PlanName       = objWork_RunProcessInfo.PlanName,
                             PlanConfigInfo = objWork_RunProcessInfo.ConfigInfo
                         };
                         planInfo.ProcessInfoList = new List <PlanStepInfo>();
                         foreach (Work_PlanStepInfo current in from s in
                                  (from s in source
                                   where s.PlanID == objWork_RunProcessInfo.PlanID
                                   select s).Distinct <Work_PlanStepInfo>()
                                  orderby s.SortIndex
                                  select s)
                         {
                             PlanStepInfo item = new PlanStepInfo
                             {
                                 WorkInfoName      = planInfo.WorkInfoName,
                                 RunDateTime       = objWork_RunProcessInfo.RunDate,
                                 WorkLogID         = planInfo.WorkLogID,
                                 ProcessConfig     = current.ProcessConfig,
                                 PlanConfigInfo    = planInfo.PlanConfigInfo,
                                 PlanID            = objWork_RunProcessInfo.PlanID,
                                 ProcessID         = current.ProcessID,
                                 ProcessName       = current.ProcessName,
                                 AssemblyName      = current.AssemblyName,
                                 SortIndex         = current.SortIndex,
                                 TypeName          = current.TypeName,
                                 FailProcessType   = current.FailProcessType,
                                 SucessProcessType = current.SucessProcessType,
                                 PlanStepID        = current.PlanStepID,
                                 RunCount          = current.RunCount,
                                 RunInterval       = current.RunInterval,
                                 StepName          = current.StepName,
                                 PlanName          = objWork_RunProcessInfo.PlanName
                             };
                             planInfo.ProcessInfoList.Add(item);
                         }
                         ThreadPool.QueueUserWorkItem(new WaitCallback(this.ProcessWorkRun), planInfo);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             ("循环检查各作业的计划处理出现异常:" + ex.Message).WriteLineRed("");
             try
             {
                 LogHelper.Write("WorkLog", "循环检查各作业的计划处理出现异常", ex, "");
             }
             catch (Exception exception)
             {
                 EventLogWriter.WriterLog(exception);
             }
         }
         Thread.Sleep(this._NextWorkRunSleep);
     }
 }