本文整理汇总了C#中IScheduler.GetJobDetail方法的典型用法代码示例。如果您正苦于以下问题:C# IScheduler.GetJobDetail方法的具体用法?C# IScheduler.GetJobDetail怎么用?C# IScheduler.GetJobDetail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScheduler
的用法示例。
在下文中一共展示了IScheduler.GetJobDetail方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JobModel
public JobModel(IScheduler scheduler, JobKey jobKey)
{
foreach (ITrigger trigger in scheduler.GetTriggersOfJob(jobKey))
{
_triggersForJob.Add(new TriggerModel(trigger));
}
MapValuesFromJobDetail(scheduler.GetJobDetail(jobKey));
}
示例2: AdminModule
public AdminModule(IScheduler scheduler, LogsStore logsStore, CreativePackagesStore creativePackagesStore,Logger logger,OmniRecordManager omniRecordManager)
: base("/admin")
{
Get["/hello"] = x => Response.AsText("OK");
Get["/fire-task/{job}"] = x =>
{
scheduler.TriggerTaskByClassName((string)x.job);
return Response.AsText("OK");
};
Get["/postfix-logs"] = x =>
{
var logs = logsStore.GetAllLogs();
var lines = logs.Select(entry => string.Format("{0} {1}", entry.time.ToLongTimeString(), entry.msg)).ToList();
return Response.AsText(string.Join(Environment.NewLine, lines));
};
Get["/jobs"] = x =>
{
var tasks = scheduler.GetCurrentJobs();
var data = tasks.Select(jobKey => new { Data = scheduler.GetJobDetail(jobKey).JobDataMap, Job = jobKey.Name }).ToList();
return Response.AsJson(data);
};
Post["/flush-unprocessed-packages"] = _ =>
{
var packages = creativePackagesStore.GetAll();
packages.ToList().ForEach(x =>
{
x.Processed = true;
logger.Info("write false for: {0}",x.To);
creativePackagesStore.Save(x);
});
return Response.AsText("OK");
};
Get["/purge-blocking-rules"] = _ =>
{
omniRecordManager.RemoveSingle<GroupsAndIndividualDomainsSendingPolicies>();
return "OK";
};
}
示例3: 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());
}
}
}
}
}
示例4: 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;
}
示例5: ScheduleJob
/// <summary>
/// Schedules a given job and trigger (both wrapped by a <see cref="JobSchedulingBundle" />).
/// </summary>
/// <param name="job">The job.</param>
/// <param name="sched">The sched.</param>
/// <param name="localOverWriteExistingJobs">if set to <c>true</c> [local over write existing jobs].</param>
/// <exception cref="SchedulerException">
/// if the Job or Trigger cannot be added to the Scheduler, or
/// there is an internal Scheduler error.
/// </exception>
public virtual void ScheduleJob(JobSchedulingBundle job, IScheduler sched, bool localOverWriteExistingJobs)
{
if ((job != null) && job.Valid)
{
JobDetail detail = job.JobDetail;
JobDetail dupeJ = sched.GetJobDetail(detail.Name, detail.Group);
if ((dupeJ != null) && !localOverWriteExistingJobs)
{
Log.Info("Not overwriting existing job: " + dupeJ.FullName);
return;
}
if (dupeJ != null)
{
Log.Info(string.Format(CultureInfo.InvariantCulture, "Replacing job: {0}", detail.FullName));
}
else
{
Log.Info(string.Format(CultureInfo.InvariantCulture, "Adding job: {0}", detail.FullName));
}
if (job.Triggers.Count == 0 && !job.JobDetail.Durable)
{
throw new SchedulerException("A Job defined without any triggers must be durable");
}
sched.AddJob(detail, true);
foreach(Trigger trigger in job.Triggers)
{
Trigger dupeT = sched.GetTrigger(trigger.Name, trigger.Group);
trigger.JobName = detail.Name;
trigger.JobGroup = detail.Group;
if (trigger.StartTimeUtc == DateTime.MinValue)
{
trigger.StartTimeUtc = DateTime.UtcNow;
}
if (dupeT != null)
{
Log.Debug(string.Format(CultureInfo.InvariantCulture, "Rescheduling job: {0} with updated trigger: {1}", detail.FullName, trigger.FullName));
if (!dupeT.JobGroup.Equals(trigger.JobGroup) || !dupeT.JobName.Equals(trigger.JobName))
{
Log.Warn("Possibly duplicately named triggers in jobs xml file!");
}
sched.RescheduleJob(trigger.Name, trigger.Group, trigger);
}
else
{
Log.Debug(string.Format(CultureInfo.InvariantCulture, "Scheduling job: {0} with trigger: {1}", detail.FullName, trigger.FullName));
sched.ScheduleJob(trigger);
}
}
AddScheduledJob(job);
}
}
示例6: Test
//.........这里部分代码省略.........
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));
Assert.AreEqual(1, scheduler.GetPausedTriggerGroups().Count);
Thread.Sleep(TimeSpan.FromSeconds(3));
scheduler.ResumeTriggers(GroupMatcher<TriggerKey>.GroupEquals(schedId));
Assert.IsNotNull(scheduler.GetTrigger(new TriggerKey("trig_2", schedId)));
Assert.IsNotNull(scheduler.GetJobDetail(new JobKey("job_1", schedId)));
Assert.IsNotNull(scheduler.GetMetaData());
Assert.IsNotNull(scheduler.GetCalendar("weeklyCalendar"));
Thread.Sleep(TimeSpan.FromSeconds(20));
scheduler.Standby();
CollectionAssert.IsNotEmpty(scheduler.GetCalendarNames());
CollectionAssert.IsNotEmpty(scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(schedId)));
CollectionAssert.IsNotEmpty(scheduler.GetTriggersOfJob(new JobKey("job_2", schedId)));
Assert.IsNotNull(scheduler.GetJobDetail(new JobKey("job_2", schedId)));
scheduler.DeleteCalendar("cronCalendar");
scheduler.DeleteCalendar("holidayCalendar");
scheduler.DeleteJob(new JobKey("lonelyJob", "lonelyGroup"));
scheduler.DeleteJob(job.Key);
scheduler.GetJobGroupNames();
scheduler.GetCalendarNames();
scheduler.GetTriggerGroupNames();
}
}
finally
{
scheduler.Shutdown(false);
}
}
示例7: TriggerJobsCore
Action<JobKey> TriggerJobsCore(IScheduler scheduler, JobDataMap jobDataMap) {
return key => {
if (scheduler.GetJobDetail(new JobKey(key.Name, key.Group)) != null)
scheduler.TriggerJob(new JobKey(key.Name, key.Group),jobDataMap);
};
}
示例8: JobExists
private static IJobDetail JobExists(ScheduledTask task, IScheduler scheduler)
{
return scheduler.GetJobDetail(task.GetJob().Key);
}