private List <IJobDetail> GetJobs(GroupMatcher <JobKey> matcher) { try { Quartz.Collection.ISet <JobKey> jobKeys = scheduler.GetJobKeys(matcher); List <IJobDetail> jobDetails = new List <IJobDetail>(); foreach (JobKey key in jobKeys) { jobDetails.Add(scheduler.GetJobDetail(key)); } return(jobDetails); } catch (SchedulerException e) { } return(null); }
private List <ITrigger> GetTriggers(GroupMatcher <TriggerKey> matcher) { try { Quartz.Collection.ISet <TriggerKey> Keys = scheduler.GetTriggerKeys(matcher); List <ITrigger> triggers = new List <ITrigger>(); foreach (TriggerKey key in Keys) { ITrigger trigger = scheduler.GetTrigger(key); triggers.Add(trigger); } return(triggers); } catch (Exception e) { } return(null); }
public object GetAllJobs() { Quartz.Collection.ISet <JobKey> jobKeys = _scheduler.GetJobKeys(GroupMatcher <JobKey> .GroupEquals(SchedulerConstants.DefaultGroup)); var jobDetail = _scheduler.GetJobDetail(jobKeys.First()); var triggerKeys = _scheduler.GetTriggerKeys(GroupMatcher <TriggerKey> .GroupEquals(SchedulerConstants.DefaultGroup)); return (new { jobs = jobKeys.Select(key => new ProductDto() { Name = key.Name, Schedule = string.Join(", ", _scheduler.GetTriggersOfJob(key).Select(trigger => trigger.StartTimeUtc.ToString())), Id = key.Name.ToString(), Group = key.Group }).ToList() } ); }
public async Task <List <IJobDetail> > GetJobList() #endif { List <IJobDetail> details = new List <IJobDetail>(); #if NET45 Quartz.Collection.ISet <JobKey> jobs = scheduler.GetJobKeys(GroupMatcher <JobKey> .AnyGroup()); #else IReadOnlyCollection <JobKey> jobs = await scheduler.GetJobKeys(GroupMatcher <JobKey> .AnyGroup()); #endif foreach (var item in jobs) { #if NET45 IJobDetail detail = scheduler.GetJobDetail(item); #else IJobDetail detail = await scheduler.GetJobDetail(item); #endif details.Add(detail); } return(details); }
/// <summary> /// delete job data from db /// </summary> /// <param name="scheduler"></param> public virtual void CleanUp(IScheduler scheduler) { _log.Warn("*************Deleting existing jobs/triggers " + DateTime.Now + "**************"); IList <string> groups = scheduler.GetTriggerGroupNames(); for (int i = 0; i < groups.Count; i++) { Quartz.Collection.ISet <TriggerKey> triggerKeys = scheduler.GetTriggerKeys(GroupMatcher <TriggerKey> .GroupEquals(groups[i])); foreach (TriggerKey key in triggerKeys) { scheduler.UnscheduleJob(key); } } groups = scheduler.GetJobGroupNames(); for (int i = 0; i < groups.Count; i++) { Quartz.Collection.ISet <JobKey> jobKeys = scheduler.GetJobKeys(GroupMatcher <JobKey> .GroupEquals(groups[i])); foreach (JobKey key in jobKeys) { scheduler.DeleteJob(key); } } }
public void ScheduleJob(IJobDetail jobDetail, Quartz.Collection.ISet <ITrigger> triggersForJob, bool replace) { _scheduler.ScheduleJob(jobDetail, triggersForJob, replace); }