Example #1
0
        /// <summary>
        /// 立即执行
        /// </summary>
        /// <returns></returns>
        public bool StartJob(int id)
        {
            var jobInfo = _jobDetailRepository.FirstOrDefault(x => x.Id == id);

            CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.CronSchedule(jobInfo.Cron);
            var      triggerKey = CreateTriggerKey(jobInfo.TriggerName, jobInfo.TriggerGroupName);
            ITrigger trigger    = TriggerBuilder.Create().StartNow()
                                  .WithIdentity(jobInfo.TriggerName, jobInfo.TriggerGroupName)
                                  .WithSchedule(scheduleBuilder.WithMisfireHandlingInstructionFireAndProceed())
                                  .Build();

            _scheduler.RescheduleJob(triggerKey, trigger);
            return(true);
        }
Example #2
0
        public override IScheduleBuilder GetScheduleBuilder()
        {
            CronScheduleBuilder cb = CronScheduleBuilder.CronSchedule(CronExpressionString).InTimeZone(TimeZone);

            switch (MisfireInstruction)
            {
            case Quartz.MisfireInstruction.CronTrigger.DoNothing: cb.WithMisfireHandlingInstructionDoNothing();
                break;

            case Quartz.MisfireInstruction.CronTrigger.FireOnceNow: cb.WithMisfireHandlingInstructionFireAndProceed();
                break;
            }

            return(cb);
        }
Example #3
0
        public override IScheduleBuilder GetScheduleBuilder()
        {
            CronScheduleBuilder cb = null;

            try
            {
                cb = CronScheduleBuilder.CronSchedule(CronExpressionString).InTimeZone(TimeZone);
            }
            catch (FormatException)
            {
                // can't happen (because the expression was validated to get here in the first place)
            }

            switch (MisfireInstruction)
            {
            case Quartz.MisfireInstruction.CronTrigger.DoNothing: cb.WithMisfireHandlingInstructionDoNothing();
                break;

            case Quartz.MisfireInstruction.CronTrigger.FireOnceNow: cb.WithMisfireHandlingInstructionFireAndProceed();
                break;
            }

            return(cb);
        }