如果我只有字符串作业名称而不是 JobKey,如何获取 IJobDetail?
string jobName
我可以访问
public IScheduler Scheduler { get; set; }
目的。
如果我只有字符串作业名称而不是 JobKey,如何获取 IJobDetail?
string jobName
我可以访问
public IScheduler Scheduler { get; set; }
目的。
你可以试试:
Quartz.Collection.ISet<JobKey> jobKeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(SchedulerConstants.DefaultGroup));
jobKeys.Where(key => key.Name == "Your job name")
总结一下,以下作品:
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);