Exemple #1
0
        //<summary>
        //创建任务
        //</summary>
        //<param name="myjob">任务对象</param>
        public string Build(IQJob qjob)
        {
            IMyJob myjob = new MyJob(qjob);

            if (JobVariables.jobs.Exists(j => j.JobId == myjob.JobId && j.SysCode == myjob.SysCode))
            {
                return("任务与存在!!!");
            }
            JobAdd(myjob);
            IJobDetail     jobdetail = Create_Jobdetail(myjob);
            ISimpleTrigger trigger   = Create_Trigger(myjob);

            _scheduler.ScheduleJob(jobdetail, trigger);
            if (_scheduler.IsShutdown || _scheduler.InStandbyMode)
            {
                _scheduler.Start();
            }
            StandSave(qjob);
            return(qjob.Key());
        }
Exemple #2
0
 /// <summary>
 /// 初始化任务
 /// </summary>
 public void Initialize()
 {
     string[] array = XMLProcess.GetFiles();
     if (array == null)
     {
         return;
     }
     foreach (var path in array)
     {
         IQJob  myjob = XMLProcess.Deserialize(typeof(QJob), XMLProcess.ReadXml(path)) as QJob;
         IMyJob qjob  = new MyJob(myjob);
         JobFactory.Instance.Build(myjob);
         DateTime nowtime = Convert.ToDateTime(string.Format("{0}:{1}", DateTime.Now.Hour, DateTime.Now.Minute));
         DateTime jobtime = Convert.ToDateTime(string.Format("{0}:{1}", myjob.StartTime.Hour, qjob.StartTime.Minute));
         if (DateTime.Compare(nowtime, Convert.ToDateTime(jobtime)) > 0)
         {
             DoJob(qjob);
         }
     }
 }