本文整理汇总了C#中Quartz.Impl.StdSchedulerFactory.GetTrigger方法的典型用法代码示例。如果您正苦于以下问题:C# StdSchedulerFactory.GetTrigger方法的具体用法?C# StdSchedulerFactory.GetTrigger怎么用?C# StdSchedulerFactory.GetTrigger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quartz.Impl.StdSchedulerFactory
的用法示例。
在下文中一共展示了StdSchedulerFactory.GetTrigger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStart
public override bool OnStart()
{
Trace.WriteLine("WorkerRole1 Run", "Information");
var properties = new NameValueCollection();
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.clustered"] = "true";
properties["quartz.jobStore.selectWithLockSQL"] = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM {0}{1} WHERE {2} = {3} AND {4} = @lockName", new object[] { "{0}", "LOCKS", "SCHED_NAME", "{1}", "LOCK_NAME" });
properties["quartz.jobStore.acquireTriggersWithinLock"] = "true";
properties["quartz.scheduler.instanceId"] = "AUTO";
properties["quartz.threadPool.threadCount"] = "1";
properties["quartz.jobStore.tablePrefix"] = "Scheduling.";
properties["quartz.dataSource.default.connectionString"] = @"Server = (local)\sqlexpress; Database = DB; Integrated Security = True";
properties["quartz.dataSource.default.provider"] = "SqlServer-20";
var scheduler = new StdSchedulerFactory(properties).GetScheduler();
scheduler.Clear();
var triggerKey = new TriggerKey("t1");
var trigger = scheduler.GetTrigger(triggerKey);
var jobBuilder = JobBuilder.Create<Job>();
var job = jobBuilder.Build();
var t = scheduler.GetTrigger(new TriggerKey("t1"));
trigger = new SimpleTriggerImpl("t1", 100000, TimeSpan.FromSeconds(5));
scheduler.ScheduleJob(job, trigger);
scheduler.Start();
return base.OnStart();
}
示例2: TestBasicStorageFunctions
public void TestBasicStorageFunctions()
{
NameValueCollection config = new NameValueCollection();
config["quartz.scheduler.instanceName"] = "SchedulerTest_Scheduler";
config["quartz.scheduler.instanceId"] = "AUTO";
config["quartz.threadPool.threadCount"] = "2";
config["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
IScheduler sched = new StdSchedulerFactory(config).GetScheduler();
// test basic storage functions of scheduler...
IJobDetail job = JobBuilder.Create()
.OfType<TestJob>()
.WithIdentity("j1")
.StoreDurably()
.Build();
Assert.IsFalse(sched.CheckExists(new JobKey("j1")), "Unexpected existence of job named 'j1'.");
sched.AddJob(job, false);
Assert.IsTrue(sched.CheckExists(new JobKey("j1")), "Expected existence of job named 'j1' but checkExists return false.");
job = sched.GetJobDetail(new JobKey("j1"));
Assert.IsNotNull(job, "Stored job not found!");
sched.DeleteJob(new JobKey("j1"));
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("t1")
.ForJob(job)
.StartNow()
.WithSimpleSchedule(x => x.RepeatForever().WithIntervalInSeconds(5))
.Build();
Assert.IsFalse(sched.CheckExists(new TriggerKey("t1")), "Unexpected existence of trigger named '11'.");
sched.ScheduleJob(job, trigger);
Assert.IsTrue(sched.CheckExists(new TriggerKey("t1")), "Expected existence of trigger named 't1' but checkExists return false.");
job = sched.GetJobDetail(new JobKey("j1"));
Assert.IsNotNull(job, "Stored job not found!");
trigger = sched.GetTrigger(new TriggerKey("t1"));
Assert.IsNotNull(trigger, "Stored trigger not found!");
job = JobBuilder.Create()
.OfType<TestJob>()
.WithIdentity("j2", "g1")
.Build();
trigger = TriggerBuilder.Create()
.WithIdentity("t2", "g1")
.ForJob(job)
.StartNow()
.WithSimpleSchedule(x => x.RepeatForever().WithIntervalInSeconds(5))
.Build();
sched.ScheduleJob(job, trigger);
job = JobBuilder.Create()
.OfType<TestJob>()
.WithIdentity("j3", "g1")
.Build();
trigger = TriggerBuilder.Create()
.WithIdentity("t3", "g1")
.ForJob(job)
.StartNow()
.WithSimpleSchedule(x => x.RepeatForever().WithIntervalInSeconds(5))
.Build();
sched.ScheduleJob(job, trigger);
IList<string> jobGroups = sched.GetJobGroupNames();
IList<string> triggerGroups = sched.GetTriggerGroupNames();
Assert.AreEqual(2, jobGroups.Count, "Job group list size expected to be = 2 ");
Assert.AreEqual(2, triggerGroups.Count, "Trigger group list size expected to be = 2 ");
Collection.ISet<JobKey> jobKeys = sched.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(JobKey.DefaultGroup));
Collection.ISet<TriggerKey> triggerKeys = sched.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals(TriggerKey.DefaultGroup));
Assert.AreEqual(1, jobKeys.Count, "Number of jobs expected in default group was 1 ");
Assert.AreEqual(1, triggerKeys.Count, "Number of triggers expected in default group was 1 ");
jobKeys = sched.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("g1"));
triggerKeys = sched.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("g1"));
Assert.AreEqual(2, jobKeys.Count, "Number of jobs expected in 'g1' group was 2 ");
Assert.AreEqual(2, triggerKeys.Count, "Number of triggers expected in 'g1' group was 2 ");
TriggerState s = sched.GetTriggerState(new TriggerKey("t2", "g1"));
Assert.AreEqual(TriggerState.Normal, s, "State of trigger t2 expected to be NORMAL ");
//.........这里部分代码省略.........