当前位置: 首页>>代码示例>>C#>>正文


C# IScheduler.PauseTrigger方法代码示例

本文整理汇总了C#中IScheduler.PauseTrigger方法的典型用法代码示例。如果您正苦于以下问题:C# IScheduler.PauseTrigger方法的具体用法?C# IScheduler.PauseTrigger怎么用?C# IScheduler.PauseTrigger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScheduler的用法示例。


在下文中一共展示了IScheduler.PauseTrigger方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitScheduler

        protected override void InitScheduler(IScheduler scheduler)
        {
            // construct job info
            IJobDetail jobDetail = JobBuilder.Create<HelloJob>().WithIdentity("myJob").StoreDurably(true).Build();
            // fire every minute for two occurances
            ITrigger trigger =
                TriggerBuilder.Create()
                .WithSimpleSchedule(s => s.WithIntervalInMinutes(1).WithRepeatCount(2))
                .StartNow()
                .WithIdentity("myTrigger")
                .Build();
            scheduler.ScheduleJob(jobDetail, trigger);

            // construct job info
            IJobDetail jobDetail2 = JobBuilder.Create<HelloJob>().WithIdentity("myJob2").Build();

            // fire every hour
            ITrigger trigger2 =
                TriggerBuilder.Create()
                .WithIdentity("myTrigger2")
                .WithSimpleSchedule(s => s.WithIntervalInMinutes(1).WithRepeatCount(2))
                .StartNow()
                .Build();
            scheduler.ScheduleJob(jobDetail2, trigger2);

            ITrigger trigger3 = TriggerBuilder.Create()
                .WithIdentity("myTrigger3")
                .WithSimpleSchedule(s => s.WithIntervalInMinutes(5).WithRepeatCount(5))
                .ForJob("myJob2")
                .StartNow()
                .Build();
            scheduler.ScheduleJob(trigger3);

            // construct job info
            JobDataMap jobDataMap = new JobDataMap
                {
                    {"key1", "value1"},
                    {"key2", "value2"},
                    {"key3", 1l},
                    {"key4", 1d}
                };
            IJobDetail jobDetail4 = JobBuilder.Create<HelloJob>()
                .WithIdentity("myJob4", "MyOwnGroup")
                .UsingJobData(jobDataMap)
                .Build();

            // fire every hour
            ITrigger trigger4 = TriggerBuilder.Create()
                .WithIdentity("myTrigger4", jobDetail4.Key.Group)
                .WithSimpleSchedule(s => s.WithIntervalInMinutes(1).WithRepeatCount(1))
                .StartNow()
                .Build();
            scheduler.ScheduleJob(jobDetail4, trigger4);

            scheduler.PauseJob(jobDetail4.Key);
            scheduler.PauseTrigger(trigger3.Key);

            scheduler.Start();
        }
开发者ID:stevebering,项目名称:CrystalQuartz,代码行数:59,代码来源:FakeProvider.cs

示例2: InitScheduler

        protected override void InitScheduler(IScheduler scheduler)
        {
            
            // construct job info
            JobDetail jobDetail = new JobDetail("myJob", null, typeof(HelloJob));
            // fire every hour
            jobDetail.Durable = true;
            Trigger trigger = TriggerUtils.MakeMinutelyTrigger(1, 2);
            // start on the next even hour
            trigger.StartTimeUtc = DateTime.UtcNow;
            trigger.Name = "myTrigger";
            scheduler.ScheduleJob(jobDetail, trigger);

            // construct job info
            JobDetail jobDetail2 = new JobDetail("myJob2", null, typeof(HelloJob));
            // fire every hour
            Trigger trigger2 = TriggerUtils.MakeMinutelyTrigger(1, 2);
            // start on the next even hour
            trigger2.StartTimeUtc = DateTime.UtcNow;
            trigger2.Name = "myTrigger2";
            scheduler.ScheduleJob(jobDetail2, trigger2);

            Trigger trigger3 = TriggerUtils.MakeSecondlyTrigger(5, 5);
            // start on the next even hour
            trigger3.StartTimeUtc = DateTime.UtcNow;
            trigger3.Name = "myTrigger3";
            trigger3.JobName = "myJob2";
            scheduler.ScheduleJob(trigger3);

            // construct job info
            JobDetail jobDetail4 = new JobDetail("myJob4", null, typeof(HelloJob));
            jobDetail4.Group = "MyOwnGroup";
            jobDetail4.JobDataMap.Add("key1", "value1");
            jobDetail4.JobDataMap.Add("key2", "value2");
            jobDetail4.JobDataMap.Add("key3", 1l);
            jobDetail4.JobDataMap.Add("key4", 1d);
            // fire every hour
            Trigger trigger4 = TriggerUtils.MakeMinutelyTrigger(1, 1);
            // start on the next even hour
            trigger4.StartTimeUtc = DateTime.UtcNow;
            trigger4.Name = "myTrigger4";
            trigger4.Group = jobDetail4.Group;
            scheduler.ScheduleJob(jobDetail4, trigger4);

            scheduler.PauseJob("myJob4", "MyOwnGroup");
            scheduler.PauseTrigger("myTrigger3", "DEFAULT");
        }
开发者ID:sdancer,项目名称:crystal-quartz,代码行数:47,代码来源:FakeProvider.cs

示例3: 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);
               }
        }
开发者ID:ndepoel,项目名称:quartznet,代码行数:101,代码来源:SmokeTestPerformer.cs

示例4: InitScheduler

        protected override void InitScheduler(IScheduler scheduler)
        {
            // construct job info
            var jobDetail = JobBuilder.Create<HelloJob>()
                .WithIdentity("myJob")
                .StoreDurably()
                .Build();

            // fire every minute
            var trigger = TriggerBuilder.Create()
                .WithIdentity("myTrigger")
                .StartNow()
                .WithSimpleSchedule(x => x.WithIntervalInMinutes(1).RepeatForever())
                .Build();

            scheduler.ScheduleJob(jobDetail, trigger);

            // construct job info
            var jobDetail2 = JobBuilder.Create<HelloJob>()
                .WithIdentity("myJob2")
                .Build();

            // fire every 3 minutes
            var trigger2 = TriggerBuilder.Create()
                .WithIdentity("myTrigger2")
                .StartNow()
                .WithSimpleSchedule(x => x.WithIntervalInMinutes(3))
                .Build();

            scheduler.ScheduleJob(jobDetail2, trigger2);

            var trigger3 = TriggerBuilder.Create()
                .WithIdentity("myTrigger3")
                .ForJob(jobDetail2)
                .StartNow()
                .WithSimpleSchedule(x => x.WithIntervalInSeconds(2).RepeatForever())
                //.WithSimpleSchedule(x => x.WithIntervalInMinutes(5).RepeatForever())
                .Build();

            scheduler.ScheduleJob(trigger3);

            // construct job info
            var jobDetail4 = JobBuilder.Create<HelloJob>()
                .WithIdentity("myJob4", "MyOwnGroup")
                .Build();

            jobDetail4.JobDataMap.Add("key1", "value1");
            jobDetail4.JobDataMap.Add("key2", "value2");
            jobDetail4.JobDataMap.Add("key3", 1L);
            jobDetail4.JobDataMap.Add("key4", 1d);

            // fire every hour
            ITrigger trigger4 = TriggerBuilder.Create()
                .WithIdentity("myTrigger4", jobDetail4.Key.Group)
                .StartNow()
                .WithSimpleSchedule(x => x.WithIntervalInMinutes(1))
                .Build();

            ITrigger trigger5 = TriggerBuilder.Create()
                .WithIdentity("myTrigger5", jobDetail4.Key.Group)
                .StartNow()
                .WithCronSchedule("0 0/5 * * * ?")
                .Build();

            scheduler.ScheduleJob(jobDetail4, new HashSet<ITrigger>(new[] { trigger4, trigger5}), false);
            //            scheduler.ScheduleJob(jobDetail4, trigger5);

            scheduler.PauseJob(new JobKey("myJob4", "MyOwnGroup"));
            scheduler.PauseTrigger(new TriggerKey("myTrigger3", "DEFAULT"));
        }
开发者ID:GoneFishern,项目名称:CrystalQuartz,代码行数:70,代码来源:FakeProvider.cs


注:本文中的IScheduler.PauseTrigger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。