通过字符串作业名称获取JobDetail

时间:2013-06-21 20:11:10

标签: c# .net quartz.net

如果我只有字符串作业名称而不是JobKey,如何获取IJobDetail?

string jobName

我可以访问

public IScheduler Scheduler { get; set; }

对象。

2 个答案:

答案 0 :(得分:1)

您可以尝试:

Quartz.Collection.ISet<JobKey> jobKeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(SchedulerConstants.DefaultGroup));
jobKeys.Where(key => key.Name == "Your job name")

答案 1 :(得分:0)

总结,以下作品:

using Quartz;
using Quartz.Impl.Matchers;
using Quartz.Collection;
using System.Linq;


ISet<JobKey> jobKeys = _scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(SchedulerConstants.DefaultGroup));
JobKey key = jobKeys.Where(x => x.Name == jobName).First();
IJobDetail jobData = _scheduler.GetJobDetail(key);