本文整理汇总了C#中IScheduler.TriggerJob方法的典型用法代码示例。如果您正苦于以下问题:C# IScheduler.TriggerJob方法的具体用法?C# IScheduler.TriggerJob怎么用?C# IScheduler.TriggerJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScheduler
的用法示例。
在下文中一共展示了IScheduler.TriggerJob方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
// XmlConfigurator.Configure();
var properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "ServerScheduler";
// set thread pool info
properties["quartz.threadPool.threadCount"] = "0";
// set remoting expoter
properties["quartz.scheduler.proxy"] = "true";
properties["quartz.scheduler.proxy.address"] = "tcp://localhost:555/QuartzScheduler";
var scheduleFactory = new StdSchedulerFactory(properties);
scheduler = scheduleFactory.GetScheduler();
var md = scheduler.GetMetaData();
scheduler.Start();
IJobDetail job = JobBuilder.Create<Jobs.SimpleJob>().Build();
ITrigger jobTrigger = new SimpleTriggerImpl("TenSecondTrigger", 20, new TimeSpan(0, 0, 0, 5));
//Periodic scheduling
scheduler.ScheduleJob(job,jobTrigger);
//Trigger a job from elsewhere without a trigger for one time
var jobKey = job.Key;
var jobDataMap = job.JobDataMap;
scheduler.TriggerJob(jobKey,jobDataMap);
}
示例2: Run
public void Run()
{
// TODO Initialiaze Scheduler
scheduler = new StdSchedulerFactory().GetScheduler();
scheduler.Start();
// Let's generate our email job detail now
CreateJob();
// And finally, schedule the job
ScheduleJob();
// Run immediately?
if (this.workerConfig.RunImmediately)
{
scheduler.TriggerJob(this.jobKey);
}
}
示例3: MonitorService
public MonitorService()
{
this.ServiceName = "Sharp Monitoring Service";
// create the job to be scheduled
Type jobType = typeof(DailyTask);
JobDetail job = new JobDetail(jobType.Name, null, jobType);
ISchedulerFactory schedFact = new StdSchedulerFactory();
sched = schedFact.GetScheduler();
sched.Start();
// schedule daily cron job
Trigger trigger = new CronTrigger("CronTrigger", null, jobType.Name, null, SharpMonitor.Properties.Settings.Default.CornExpression);
sched.AddJob(job, true);
DateTime ft = sched.ScheduleJob(trigger);
// start job immediately if next schedule job is tomorrow
if (ft > DateTime.UtcNow)
{
sched.TriggerJob(jobType.Name, null);
}
}
示例4: 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);
};
}
示例5: AddJob6
private void AddJob6(IScheduler scheduler, IJobDetail job, ISimpleTrigger trigger)
{
job = JobBuilder.Create<SimpleJob>()
.WithIdentity("job6", "group1")
.StoreDurably()
.Build();
scheduler.AddJob(job, true);
log.Info("'Manually triggering job6...");
scheduler.TriggerJob(new JobKey("job6", "group1"));
}
示例6: Test
//.........这里部分代码省略.........
// bulk operations
var info = new Dictionary<IJobDetail, 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 HashSet<ITrigger>();
triggers.Add(simple);
info[detail] = triggers;
await scheduler.ScheduleJobs(info, true);
Assert.IsTrue(await scheduler.CheckExists(detail.Key));
Assert.IsTrue(await scheduler.CheckExists(simple.Key));
// QRTZNET-243
await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupContains("a").DeepClone());
await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEndsWith("a").DeepClone());
await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupStartsWith("a").DeepClone());
await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("a").DeepClone());
await scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupContains("a").DeepClone());
await scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEndsWith("a").DeepClone());
await scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupStartsWith("a").DeepClone());
await scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("a").DeepClone());
await scheduler.Start();
await Task.Delay(TimeSpan.FromSeconds(3));
await scheduler.PauseAll();
await scheduler.ResumeAll();
await scheduler.PauseJob(new JobKey("job_1", schedId));
await scheduler.ResumeJob(new JobKey("job_1", schedId));
await scheduler.PauseJobs(GroupMatcher<JobKey>.GroupEquals(schedId));
await Task.Delay(TimeSpan.FromSeconds(1));
await scheduler.ResumeJobs(GroupMatcher<JobKey>.GroupEquals(schedId));
await scheduler.PauseTrigger(new TriggerKey("trig_2", schedId));
await scheduler.ResumeTrigger(new TriggerKey("trig_2", schedId));
await scheduler.PauseTriggers(GroupMatcher<TriggerKey>.GroupEquals(schedId));
var pausedTriggerGroups = await scheduler.GetPausedTriggerGroups();
Assert.AreEqual(1, pausedTriggerGroups.Count);
await Task.Delay(TimeSpan.FromSeconds(3));
await 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"));
var genericjobKey = new JobKey("genericJob", "genericGroup");
GenericJobType.Reset();
var genericJob = JobBuilder.Create<GenericJobType>()
.WithIdentity(genericjobKey)
.StoreDurably()
.Build();
await scheduler.AddJob(genericJob, false);
genericJob = await scheduler.GetJobDetail(genericjobKey);
Assert.That(genericJob, Is.Not.Null);
await scheduler.TriggerJob(genericjobKey);
GenericJobType.WaitForTrigger(TimeSpan.FromSeconds(20));
Assert.That(GenericJobType.TriggeredCount, Is.EqualTo(1));
await scheduler.Standby();
CollectionAssert.IsNotEmpty(await scheduler.GetCalendarNames());
CollectionAssert.IsNotEmpty(await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(schedId)));
CollectionAssert.IsNotEmpty(await scheduler.GetTriggersOfJob(new JobKey("job_2", schedId)));
Assert.IsNotNull(scheduler.GetJobDetail(new JobKey("job_2", schedId)));
await scheduler.DeleteCalendar("cronCalendar");
await scheduler.DeleteCalendar("holidayCalendar");
await scheduler.DeleteJob(new JobKey("lonelyJob", "lonelyGroup"));
await scheduler.DeleteJob(job.Key);
await scheduler.GetJobGroupNames();
await scheduler.GetCalendarNames();
await scheduler.GetTriggerGroupNames();
await TestMatchers(scheduler);
}
}
finally
{
await scheduler.Shutdown(false);
}
}