Esempio n. 1
0
 /// <summary>
 /// 开始工作
 /// </summary>
 public void StartJob()
 {
     try
     {
         if (this.mIsRunning)
         {
             if (this.mConfigObject != null && this.mNextTime != null)
             {
                 if (this.mConfigObject.Enabled.ToLower() == "true" && Convert.ToDateTime(this.mConfigObject.startTime) <= DateTime.Now)
                 {
                     if (DateTime.Now >= this.mNextTime)
                     {
                         if (this.mConfigObject.runningType == 1)
                         {
                             fristtrun      = true;
                             this.mNextTime = DateTime.Now.AddSeconds((double)this.mConfigObject.intervalTime);
                         }
                         else if (this.mConfigObject.runningType == 0)
                         {
                             DateTime runningdaytime = DateTime.MinValue;
                             DateTime tempDatetime   = DateTime.MinValue;
                             if (this.mConfigObject.intervalType == 1)
                             {
                                 if (this.mConfigObject.runningDate == -1)
                                 {
                                     tempDatetime   = Convert.ToDateTime(DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd") + " " + this.mConfigObject.runningTime);
                                     runningdaytime = tempDatetime <= DateTime.Now ? tempDatetime.AddMonths(1) : tempDatetime;
                                 }
                                 else
                                 {
                                     tempDatetime   = Convert.ToDateTime(DateTime.Now.AddDays(1 - DateTime.Now.Day).AddDays(this.mConfigObject.runningDate - 1).ToString("yyyy-MM-dd") + " " + this.mConfigObject.runningTime);
                                     runningdaytime = tempDatetime <= DateTime.Now ? tempDatetime.AddMonths(1) : tempDatetime;
                                 }
                             }
                             else if (this.mConfigObject.intervalType == 2)
                             {
                                 tempDatetime = Convert.ToDateTime
                                                    (DateTime.Now.AddDays(this.mConfigObject.runningDate - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d")) < 0
                                     ? 7 - (this.mConfigObject.runningDate - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d")))
                                     : this.mConfigObject.runningDate - Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))).ToString("yyyy-MM-dd") + " " + this.mConfigObject.runningTime
                                                    );
                                 runningdaytime = tempDatetime <= DateTime.Now ? tempDatetime.AddDays(7) : tempDatetime;
                             }
                             else if (this.mConfigObject.intervalType == 3)
                             {
                                 tempDatetime   = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + this.mConfigObject.runningTime);
                                 runningdaytime = tempDatetime <= DateTime.Now ? tempDatetime.AddDays(1) : tempDatetime;
                             }
                             this.mNextTime = runningdaytime;
                         }
                         if (fristtrun)
                         {
                             this.Start();
                         }
                         fristtrun = true;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         CommonLog.WriteLog("运行信息", ex.ToString());
         StopJob();
     }
 }
Esempio n. 2
0
 public void WriteLogInfo(string strLog)
 {
     CommonLog.WriteLog(mConfigObject.Description, strLog);
 }