Пример #1
0
        private static Trigger BuildTrigger(JobItem jobItem)
        {
            Trigger trigger = TriggerBuilder.Build(jobItem.Trigger);

            trigger.Name = string.Format("{0}Trigger", jobItem.Name);
            return(trigger);
        }
Пример #2
0
        private JobDetail BuildJobDetail(JobItem job)
        {
            JobDetail jobDetail = new JobDetail(job.Name, SchedulerConstants.DefaultGroup, Type.GetType(job.Type));

            jobDetail.JobDataMap.PutAll(job.GetParams());
            jobDetail.JobDataMap.Put("JobName", job.Name);
            return(jobDetail);
        }
Пример #3
0
        public void Unschedule(string name)
        {
            JobItem job = jobLoader.LoadJob(name);

            if (job != null && job.Enabled)
            {
                logger.Debug("Unschedule Job: " + name);
                Trigger trigger = TriggerBuilder.Build(job.Trigger);
                scheduler.UnscheduleJob(trigger.Name, SchedulerConstants.DefaultGroup);
                job.Enabled = false;
            }
        }
Пример #4
0
        public void Schedule(string name)
        {
            JobItem job = jobLoader.LoadJob(name);

            if (job != null && !job.Enabled)
            {
                logger.Debug("Schedule Job: " + name);
                JobDetail jobDetail = BuildJobDetail(job);
                Trigger   trigger   = TriggerBuilder.Build(job.Trigger);
                scheduler.ScheduleJob(jobDetail, trigger);
                job.Enabled = true;
            }
        }
Пример #5
0
        public void Reschedule(string name, Trigger trigger)
        {
            JobItem job = jobLoader.LoadJob(name);

            if (job != null)
            {
                logger.Debug("Reschedule Job: " + name);
                Unschedule(name);
                JobDetail jobDetail = BuildJobDetail(job);
                scheduler.ScheduleJob(jobDetail, trigger);
                job.Enabled = true;
            }
        }
Пример #6
0
        public DateTime?GetPreviousFireTime(string name)
        {
            JobItem job = jobLoader.LoadJob(name);

            if (job != null)
            {
                Trigger trigger     = TriggerBuilder.Build(job.Trigger);
                Trigger currTrigger = scheduler.GetTrigger(trigger.Name, SchedulerConstants.DefaultGroup);
                if (currTrigger != null)
                {
                    return(trigger.GetPreviousFireTimeUtc());
                }
            }
            return(null);
        }
Пример #7
0
        public void RunNowJob(string name)
        {
            JobItem job = jobLoader.LoadJob(name);

            if (job != null)
            {
                logger.Debug("Schedule Run Now Job: " + name);

                Trigger trigger = TriggerBuilder.Build(job.Trigger);
                trigger.StartTimeUtc = DateTime.UtcNow;
                if (trigger is SimpleTrigger)
                {
                    ((SimpleTrigger)trigger).SetPreviousFireTime(DateTime.UtcNow);
                }

                Reschedule(name, trigger);
            }
        }