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


C# IScheduler.ScheduleJobs方法代码示例

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


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

示例1: Test


//.........这里部分代码省略.........

                   scheduler.UnscheduleJob(nt2.Key);
                   scheduler.ScheduleJob(nt2);

                   var triggerFromDb = (IDailyTimeIntervalTrigger) scheduler.GetTrigger(nt2.Key);
                   Assert.That(triggerFromDb.StartTimeOfDay.Hour, Is.EqualTo(1));
                   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));
开发者ID:ndepoel,项目名称:quartznet,代码行数:67,代码来源:SmokeTestPerformer.cs

示例2: ScheduleWithJob

        /// <summary>
        /// Schedules the with the provided <see cref="IJobDetail"/>.
        /// </summary>
        /// <param name="sched">The sched.</param>
        /// <param name="jobDetail">The job detail.</param>
        public void ScheduleWithJob(IScheduler sched, IJobDetail jobDetail)
        {
            RegisterCalendars(sched);

            if (RegisterGroups.Count > 1) // use the bulk add method if using more than 1
            {
                List<ITrigger> triggers = new List<ITrigger>();
                RegisterGroups.ForEach(x => triggers.Add(x.TriggerBuilder.Build()));

                var dic = new Dictionary<Quartz.IJobDetail, Quartz.Collection.ISet<ITrigger>>();
                Quartz.Collection.ISet<ITrigger> set = new Collection.HashSet<ITrigger>(triggers);
                dic.Add(jobDetail, set);
               
                sched.ScheduleJobs(dic, true);
            }
            else if (RegisterGroups.Count == 1)
            {
                ITrigger trigger = RegisterGroups[0].TriggerBuilder.Build();
                sched.ScheduleJob(jobDetail, trigger);
            }
        }
开发者ID:amazing-andrew,项目名称:Quartz.TextToSchedule,代码行数:26,代码来源:TextToScheduleResults.cs


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