public void ScheduleDaily(IScheduledJob scheduledJob, int hour, int minutes) { // define the job and tie it to our HelloJob class IDictionary <string, object> data = new Dictionary <string, object>(); data.Add("scheduledJob", scheduledJob); IJobDetail job = JobBuilder.Create <TemplateJob>() .WithIdentity("schedule:" + scheduledJob.GetType().Name, defaultScheduleGroupName) .UsingJobData(new JobDataMap(data)) .Build(); // Trigger the job to run now, and then repeat every 10 seconds ITrigger trigger = TriggerBuilder.Create() .WithIdentity("trigger:" + scheduledJob.GetType().Name, defaultScheduleGroupName) .StartNow() .WithDailyTimeIntervalSchedule(x => x .OnEveryDay() .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(hour, minutes)) .EndingDailyAfterCount(1)) .Build(); // Tell quartz to schedule the job using our trigger this.scheduler.ScheduleJob(job, trigger).Wait(); this.tirggers.Add(scheduledJob, trigger.Key); }
public void Schedule(IScheduledJob scheduledJob, int everySeconds) { // define the job and tie it to our HelloJob class IDictionary <string, object> data = new Dictionary <string, object>(); data.Add("scheduledJob", scheduledJob); IJobDetail job = JobBuilder.Create <TemplateJob>() .WithIdentity("schedule:" + scheduledJob.GetType().Name, defaultScheduleGroupName) .UsingJobData(new JobDataMap(data)) .Build(); // Trigger the job to run now, and then repeat every 10 seconds ITrigger trigger = TriggerBuilder.Create() .WithIdentity("trigger:" + scheduledJob.GetType().Name, defaultScheduleGroupName) .StartNow() .WithSimpleSchedule(x => x .WithIntervalInSeconds(everySeconds) .RepeatForever()) .Build(); // Tell quartz to schedule the job using our trigger this.scheduler.ScheduleJob(job, trigger).Wait(); this.tirggers.Add(scheduledJob, trigger.Key); }
public bool AddOrUpdate(IScheduledJob job) { var name = job.GetType().Name; var options = _optionsMonitor.Get(name); return(AddJob(name, job, options)); }
private void ExecuteJob(IScheduledJob job, CancellationToken token) { var name = job.GetType().Name; _config?.OnJobStart?.Invoke(name); Start(); job.Execute(token); Stop(); _config?.OnJobEnd?.Invoke(name); }
public bool AddOrUpdate(IScheduledJob job, SchedulerOptions options) { var name = job.GetType().Name; return(AddJob(name, job, options)); }
public bool AddOrUpdate(IScheduledJob job) { return(AddOrUpdate(job.GetType().Name, job)); }