本文整理汇总了C#中IScheduler.GetJobKeys方法的典型用法代码示例。如果您正苦于以下问题:C# IScheduler.GetJobKeys方法的具体用法?C# IScheduler.GetJobKeys怎么用?C# IScheduler.GetJobKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScheduler
的用法示例。
在下文中一共展示了IScheduler.GetJobKeys方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllJobs
public static List<JobKey> GetAllJobs(IScheduler scheduler)
{
var jobs = new List<JobKey>();
foreach (var group in scheduler.GetJobGroupNames())
{
var groupMatcher = GroupMatcher<JobKey>.GroupContains(@group);
foreach (var jobKey in scheduler.GetJobKeys(groupMatcher))
{
jobs.Add(jobKey);
}
}
return jobs;
}
示例2: UnscheduleAll
/// <summary>
/// This method unschedules all jobs in a specified scheduler.
/// </summary>
/// <param name="qScheduler"></param>
/// <returns>bool</returns>
public bool UnscheduleAll(IScheduler qScheduler)
{
foreach (var group in qScheduler.GetTriggerGroupNames())
{
var groupMatcher = GroupMatcher<JobKey>.GroupContains(group);
var jobKeys = qScheduler.GetJobKeys(groupMatcher);
foreach (var triggers in jobKeys.Select(jobKey => qScheduler.GetTriggersOfJob(jobKey)))
{
return qScheduler.UnscheduleJobs(triggers.Select(t => t.Key).ToList());
}
}
return false;
}
示例3: SchedulerModel
public SchedulerModel(IScheduler scheduler)
{
//get triggers
//get job groups and jobs
foreach (string groupName in scheduler.GetJobGroupNames())
{
var jobs = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupStartsWith(groupName));
List<JobModel> jobModels = new List<JobModel>();
foreach (JobKey jobKey in jobs)
{
jobModels.Add(new JobModel(scheduler, jobKey));
}
_jobGroups.Add(new JobGroup(groupName, jobModels));
}
}
示例4: GetAllJobs
private static void GetAllJobs(IScheduler scheduler)
{
IList<string> jobGroups = scheduler.GetJobGroupNames();
IList<string> triggerGroups = scheduler.GetTriggerGroupNames();
foreach (string group in jobGroups)
{
var groupMatcher = GroupMatcher<JobKey>.GroupContains(group);
var jobKeys = scheduler.GetJobKeys(groupMatcher);
foreach (var jobKey in jobKeys)
{
var detail = scheduler.GetJobDetail(jobKey);
var triggers = scheduler.GetTriggersOfJob(jobKey);
foreach (ITrigger trigger in triggers)
{
Console.WriteLine(group);
Console.WriteLine(jobKey.Name);
Console.WriteLine(detail.Description);
Console.WriteLine(trigger.Key.Name);
Console.WriteLine(trigger.Key.Group);
Console.WriteLine(trigger.GetType().Name);
Console.WriteLine(scheduler.GetTriggerState(trigger.Key));
DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
if (nextFireTime.HasValue)
{
Console.WriteLine(nextFireTime.Value.LocalDateTime.ToString());
}
DateTimeOffset? previousFireTime = trigger.GetPreviousFireTimeUtc();
if (previousFireTime.HasValue)
{
Console.WriteLine(previousFireTime.Value.LocalDateTime.ToString());
}
}
}
}
}
示例5: GetAllJobs
private JobGroups GetAllJobs(IScheduler scheduler)
{
int countJobs = 0;
IList<string> jobGroups = scheduler.GetJobGroupNames();
IList<string> triggerGroups = scheduler.GetTriggerGroupNames();
List<JobGroup> entidadeJobGroup = new List<JobGroup>();
foreach (string group in jobGroups)
{
var groupMatcher = GroupMatcher<JobKey>.GroupContains(group);
JobGroup grupoItem = new JobGroup();
grupoItem.Name = group;
grupoItem.Jobs = new List<JobDetails>();
var jobKeys = scheduler.GetJobKeys(groupMatcher);
foreach (var jobKey in jobKeys)
{
countJobs++;
var detail = scheduler.GetJobDetail(jobKey);
var triggers = scheduler.GetTriggersOfJob(jobKey);
foreach (ITrigger trigger in triggers)
{
DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
DateTimeOffset? previousFireTime = trigger.GetPreviousFireTimeUtc();
DateTimeOffset? startFireTime = trigger.StartTimeUtc;
DateTimeOffset? lastFireTime = trigger.FinalFireTimeUtc;
//
grupoItem.Jobs.Add(new JobDetails()
{
Grupo = group,
FirstFire = (startFireTime.HasValue) ? startFireTime.Value.LocalDateTime.ToString() : "",
LastFire = (lastFireTime.HasValue) ? lastFireTime.Value.LocalDateTime.ToString() : "",
Type = trigger.GetType().Name,
NomeLegivel = service.GetWorkflowSistemaName(jobKey.Name),
Name = jobKey.Name,
Description = detail.Description,
NextFire = (nextFireTime.HasValue) ? nextFireTime.Value.LocalDateTime.ToString() : "",
PreviousFire = (previousFireTime.HasValue) ? previousFireTime.Value.LocalDateTime.ToString() : "",
State = scheduler.GetTriggerState(trigger.Key).ToString(),
TriggerId = trigger.Key.Name
});
}
}
entidadeJobGroup.Add(grupoItem);
}
JobGroups entidadeRetorno = new JobGroups();
entidadeRetorno.Grupos = new List<JobGroup>();
entidadeRetorno.Grupos = entidadeJobGroup;
entidadeRetorno.TotalJobs = countJobs;
return entidadeRetorno;
}
示例6: GetJobs
private static IList<JobData> GetJobs(IScheduler scheduler, string groupName)
{
var result = new List<JobData>();
foreach (var jobKey in scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(groupName)))
{
result.Add(GetJobData(scheduler, jobKey.Name, groupName));
}
return result;
}
示例7: Test
//.........这里部分代码省略.........
Assert.That(triggerFromDb.StartTimeOfDay.Minute, Is.EqualTo(2));
Assert.That(triggerFromDb.StartTimeOfDay.Second, Is.EqualTo(3));
Assert.That(triggerFromDb.EndTimeOfDay.Hour, Is.EqualTo(2));
Assert.That(triggerFromDb.EndTimeOfDay.Minute, Is.EqualTo(3));
Assert.That(triggerFromDb.EndTimeOfDay.Second, Is.EqualTo(4));
job.RequestsRecovery = (true);
CalendarIntervalTriggerImpl intervalTrigger = new CalendarIntervalTriggerImpl(
"calint_trig_" + count,
schedId,
DateTime.UtcNow.AddMilliseconds(300),
DateTime.UtcNow.AddMinutes(1),
IntervalUnit.Second,
8);
intervalTrigger.JobKey = job.Key;
scheduler.ScheduleJob(intervalTrigger);
// bulk operations
var info = new Dictionary<IJobDetail, Collection.ISet<ITrigger>>();
IJobDetail detail = new JobDetailImpl("job_" + count, schedId, typeof(SimpleRecoveryJob));
ITrigger simple = new SimpleTriggerImpl("trig_" + count, schedId, 20, TimeSpan.FromMilliseconds(4500));
var triggers = new Collection.HashSet<ITrigger>();
triggers.Add(simple);
info[detail] = triggers;
scheduler.ScheduleJobs(info, true);
Assert.IsTrue(scheduler.CheckExists(detail.Key));
Assert.IsTrue(scheduler.CheckExists(simple.Key));
// QRTZNET-243
scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupContains("a").DeepClone());
scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEndsWith("a").DeepClone());
scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupStartsWith("a").DeepClone());
scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("a").DeepClone());
scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupContains("a").DeepClone());
scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEndsWith("a").DeepClone());
scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupStartsWith("a").DeepClone());
scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("a").DeepClone());
scheduler.Start();
Thread.Sleep(TimeSpan.FromSeconds(3));
scheduler.PauseAll();
scheduler.ResumeAll();
scheduler.PauseJob(new JobKey("job_1", schedId));
scheduler.ResumeJob(new JobKey("job_1", schedId));
scheduler.PauseJobs(GroupMatcher<JobKey>.GroupEquals(schedId));
Thread.Sleep(TimeSpan.FromSeconds(1));
scheduler.ResumeJobs(GroupMatcher<JobKey>.GroupEquals(schedId));
scheduler.PauseTrigger(new TriggerKey("trig_2", schedId));
scheduler.ResumeTrigger(new TriggerKey("trig_2", schedId));
scheduler.PauseTriggers(GroupMatcher<TriggerKey>.GroupEquals(schedId));
示例8: CleanUp
private static void CleanUp(IScheduler inScheduler)
{
// unschedule jobs
IList<string> groups = inScheduler.GetTriggerGroupNames();
foreach (string group in groups)
{
Collection.ISet<TriggerKey> keys = inScheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals(group));
foreach (TriggerKey key in keys)
{
inScheduler.UnscheduleJob(key);
}
}
// delete jobs
groups = inScheduler.GetJobGroupNames();
foreach (string group in groups)
{
Collection.ISet<JobKey> jobNames = inScheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(group));
foreach (JobKey jobKey in jobNames)
{
inScheduler.DeleteJob(jobKey);
}
}
inScheduler.DeleteCalendar("annualCalendar");
inScheduler.DeleteCalendar("baseCalendar");
inScheduler.DeleteCalendar("cronCalendar");
inScheduler.DeleteCalendar("dailyCalendar");
inScheduler.DeleteCalendar("holidayCalendar");
inScheduler.DeleteCalendar("monthlyCalendar");
inScheduler.DeleteCalendar("weeklyCalendar");
}
示例9: GetJobs
private static IList<JobData> GetJobs(IScheduler scheduler, string groupName)
{
return scheduler
.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(groupName))
.Select(jobName => GetJobData(scheduler, jobName))
.ToList();
}
示例10: TestMatchers
private void TestMatchers(IScheduler scheduler)
{
scheduler.Clear();
IJobDetail job = JobBuilder.Create<NoOpJob>().WithIdentity("job1", "aaabbbccc").StoreDurably().Build();
scheduler.AddJob(job, true);
SimpleScheduleBuilder schedule = SimpleScheduleBuilder.Create();
ITrigger trigger = TriggerBuilder.Create().WithIdentity("trig1", "aaabbbccc").WithSchedule(schedule).ForJob(job).Build();
scheduler.ScheduleJob(trigger);
job = JobBuilder.Create<NoOpJob>().WithIdentity("job1", "xxxyyyzzz").StoreDurably().Build();
scheduler.AddJob(job, true);
schedule = SimpleScheduleBuilder.Create();
trigger = TriggerBuilder.Create().WithIdentity("trig1", "xxxyyyzzz").WithSchedule(schedule).ForJob(job).Build();
scheduler.ScheduleJob(trigger);
job = JobBuilder.Create<NoOpJob>().WithIdentity("job2", "xxxyyyzzz").StoreDurably().Build();
scheduler.AddJob(job, true);
schedule = SimpleScheduleBuilder.Create();
trigger = TriggerBuilder.Create().WithIdentity("trig2", "xxxyyyzzz").WithSchedule(schedule).ForJob(job).Build();
scheduler.ScheduleJob(trigger);
Collection.ISet<JobKey> jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.AnyGroup());
Assert.That(jkeys.Count, Is.EqualTo(3), "Wrong number of jobs found by anything matcher");
jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("xxxyyyzzz"));
Assert.That(jkeys.Count, Is.EqualTo(2), "Wrong number of jobs found by equals matcher");
jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("aaabbbccc"));
Assert.That(jkeys.Count, Is.EqualTo(1), "Wrong number of jobs found by equals matcher");
jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupStartsWith("aa"));
Assert.That(jkeys.Count, Is.EqualTo(1), "Wrong number of jobs found by starts with matcher");
jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupStartsWith("xx"));
Assert.That(jkeys.Count, Is.EqualTo(2), "Wrong number of jobs found by starts with matcher");
jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEndsWith("cc"));
Assert.That(jkeys.Count, Is.EqualTo(1), "Wrong number of jobs found by ends with matcher");
jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEndsWith("zzz"));
Assert.That(jkeys.Count, Is.EqualTo(2), "Wrong number of jobs found by ends with matcher");
jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupContains("bc"));
Assert.That(jkeys.Count, Is.EqualTo(1), "Wrong number of jobs found by contains with matcher");
jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupContains("yz"));
Assert.That(jkeys.Count, Is.EqualTo(2), "Wrong number of jobs found by contains with matcher");
Collection.ISet<TriggerKey> tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.AnyGroup());
Assert.That(tkeys.Count, Is.EqualTo(3), "Wrong number of triggers found by anything matcher");
tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("xxxyyyzzz"));
Assert.That(tkeys.Count, Is.EqualTo(2), "Wrong number of triggers found by equals matcher");
tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("aaabbbccc"));
Assert.That(tkeys.Count, Is.EqualTo(1), "Wrong number of triggers found by equals matcher");
tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupStartsWith("aa"));
Assert.That(tkeys.Count, Is.EqualTo(1), "Wrong number of triggers found by starts with matcher");
tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupStartsWith("xx"));
Assert.That(tkeys.Count, Is.EqualTo(2), "Wrong number of triggers found by starts with matcher");
tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEndsWith("cc"));
Assert.That(tkeys.Count, Is.EqualTo(1), "Wrong number of triggers found by ends with matcher");
tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEndsWith("zzz"));
Assert.That(tkeys.Count, Is.EqualTo(2), "Wrong number of triggers found by ends with matcher");
tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupContains("bc"));
Assert.That(tkeys.Count, Is.EqualTo(1), "Wrong number of triggers found by contains with matcher");
tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupContains("yz"));
Assert.That(tkeys.Count, Is.EqualTo(2), "Wrong number of triggers found by contains with matcher");
}
示例11: GetSchedules
public List<JobSchedule> GetSchedules(IScheduler qScheduler, string groupName)
{
var jcs = new List<JobSchedule>();
var groupMatcher = GroupMatcher<JobKey>.GroupContains(groupName);
var jobKeys = qScheduler.GetJobKeys(groupMatcher);
foreach (var jobKey in jobKeys)
{
var triggers = qScheduler.GetTriggersOfJob(jobKey);
foreach (var trigger in triggers)
{
var js = new JobSchedule();
js.Name = jobKey.Name;
js.Description = trigger.Description;
js.Group = jobKey.Group;
js.TriggerType = trigger.GetType().Name;
js.TriggerState = qScheduler.GetTriggerState(trigger.Key).ToString();
js.Priority = trigger.Priority;
DateTimeOffset? startTime = trigger.StartTimeUtc;
js.StartTime = TimeZone.CurrentTimeZone.ToLocalTime(startTime.Value.DateTime);
DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
if (nextFireTime.HasValue)
{
js.NextFire = TimeZone.CurrentTimeZone.ToLocalTime(nextFireTime.Value.DateTime);
}
DateTimeOffset? previousFireTime = trigger.GetPreviousFireTimeUtc();
if (previousFireTime.HasValue)
{
js.LastFire = TimeZone.CurrentTimeZone.ToLocalTime(previousFireTime.Value.DateTime);
}
jcs.Add(js);
}
}
return jcs;
}
示例12: MigrateJobs
private void MigrateJobs(MyDBContext context, IScheduler scheduler)
{
//Check if there are jobs in the QDMS db and no jobs in the quartz db - in that case we migrate them
if (context.DataUpdateJobs.Any() && scheduler.GetJobKeys(GroupMatcher<JobKey>.AnyGroup()).Count == 0)
{
foreach (DataUpdateJobSettings job in context.DataUpdateJobs)
{
JobsManager.ScheduleJob(scheduler, job);
}
}
}