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


C# IScheduler.Clear方法代码示例

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


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

示例1: ScheduleJobs

        public static void ScheduleJobs(IScheduler scheduler, List<DataUpdateJobDetails> jobs)
        {
            if (jobs == null || jobs.Count == 0) return;

            //start by clearing all the jobs
            scheduler.Clear();

            //then convert and add them
            foreach (DataUpdateJobDetails job in jobs)
            {
                IDictionary map = new Dictionary<string, object> { { "details", job } };

                IJobDetail quartzJob = JobBuilder
                    .Create<DataUpdateJob>()
                    .WithIdentity(job.Name)
                    .UsingJobData(new JobDataMap(map))
                    .Build();
                try
                {
                    scheduler.ScheduleJob(quartzJob, CreateTrigger(job));
                }
                catch(Exception ex)
                {
                    var logger = LogManager.GetCurrentClassLogger();
                    logger.Log(LogLevel.Error, "Quartz Error scheduling job: " + ex.Message);
                }
            }
        }
开发者ID:QANTau,项目名称:QDMS,代码行数:28,代码来源:JobsManager.cs

示例2: InitScheduler

        /// <summary>
        /// 初始化任务调度对象
        /// </summary>
        public static void InitScheduler()
        {
            try
            {
                lock (obj)
                {
                    if (scheduler == null)
                    {
                        NameValueCollection properties = new NameValueCollection();

                        properties["quartz.scheduler.instanceName"] = "ExampleDefaultQuartzScheduler";

                        properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";

                        properties["quartz.threadPool.threadCount"] = "10";

                        properties["quartz.threadPool.threadPriority"] = "Normal";

                        properties["quartz.jobStore.misfireThreshold"] = "60000";

                        properties["quartz.jobStore.type"] = "Quartz.Simpl.RAMJobStore, Quartz";

                        ISchedulerFactory factory = new StdSchedulerFactory(properties);

                        scheduler = factory.GetScheduler();
                        scheduler.Clear();
                        LogHelper.WriteLog("任务调度初始化成功!");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("任务调度初始化失败!", ex);
            }
        }
开发者ID:jiasw,项目名称:TaskManager,代码行数:38,代码来源:QuartzHelper.cs

示例3: Instance

        public static IScheduler Instance()
        {
            if (scheduler == null)
            {
                scheduler = StdSchedulerFactory.GetDefaultScheduler();
                scheduler.Start();
                scheduler.Clear();
            }

            return scheduler;
        }
开发者ID:R-Carver,项目名称:CodeBackup,代码行数:11,代码来源:Scheduler.cs

示例4: ScheduleJobs

        public static void ScheduleJobs(IScheduler scheduler, List<DataUpdateJobDetails> jobs)
        {
            if (jobs == null || jobs.Count == 0) return;

            //start by clearing all the jobs
            scheduler.Clear();

            //then convert and add them
            foreach (DataUpdateJobDetails job in jobs)
            {
                IDictionary map = new Dictionary<string, object> { { "details", job } };

                IJobDetail quartzJob = JobBuilder
                    .Create<DataUpdateJob>()
                    .WithIdentity(job.Name)
                    .UsingJobData(new JobDataMap(map))
                    .Build();
                scheduler.ScheduleJob(quartzJob, CreateTrigger(job));
            }
        }
开发者ID:KeithNel,项目名称:qdms,代码行数:20,代码来源:JobsManager.cs

示例5: Schedule

        public override void Schedule(IScheduler scheduler)
        {
            // construct jobs
            var map = new JobDataMap();
            map.Put("msg", "Some message!");

            IJobDetail startAchPayments = JobBuilder.Create<StartAchPaymentProcessingJob>()
                .WithIdentity("StartACHPayments", "Processing")
                .WithDescription("Starts processing of ACH payments")
                .StoreDurably(true)
                .UsingJobData(map)
                .Build();

            var schedule = SchedulingExtensions.DailyAt(4);

            ITrigger achPaymentsTrigger = TriggerBuilder.Create()
                .WithIdentity("StartAchPaymentsTriggerDaily", "DailyTriggers")
                .WithCronSchedule(schedule, c => c.InTimeZone(TimeZoneInfo.Local))
                .Build();

            scheduler.Clear();
            scheduler.ScheduleJob(startAchPayments, achPaymentsTrigger);
        }
开发者ID:stevebering,项目名称:MessageScheduler,代码行数:23,代码来源:AchPaymentProcessingScheduler.cs

示例6: Test

        public void Test(IScheduler scheduler, bool clearJobs, bool scheduleJobs)
        {
            try
               {
               if (clearJobs)
               {
                   scheduler.Clear();
               }

               if (scheduleJobs)
               {
                   ICalendar cronCalendar = new CronCalendar("0/5 * * * * ?");
                   ICalendar holidayCalendar = new HolidayCalendar();

                   // QRTZNET-86
                   ITrigger t = scheduler.GetTrigger(new TriggerKey("NonExistingTrigger", "NonExistingGroup"));
                   Assert.IsNull(t);

                   AnnualCalendar cal = new AnnualCalendar();
                   scheduler.AddCalendar("annualCalendar", cal, false, true);

                   IOperableTrigger calendarsTrigger = new SimpleTriggerImpl("calendarsTrigger", "test", 20, TimeSpan.FromMilliseconds(5));
                   calendarsTrigger.CalendarName = "annualCalendar";

                   JobDetailImpl jd = new JobDetailImpl("testJob", "test", typeof(NoOpJob));
                   scheduler.ScheduleJob(jd, calendarsTrigger);

                   // QRTZNET-93
                   scheduler.AddCalendar("annualCalendar", cal, true, true);

                   scheduler.AddCalendar("baseCalendar", new BaseCalendar(), false, true);
                   scheduler.AddCalendar("cronCalendar", cronCalendar, false, true);
                   scheduler.AddCalendar("dailyCalendar", new DailyCalendar(DateTime.Now.Date, DateTime.Now.AddMinutes(1)), false, true);
                   scheduler.AddCalendar("holidayCalendar", holidayCalendar, false, true);
                   scheduler.AddCalendar("monthlyCalendar", new MonthlyCalendar(), false, true);
                   scheduler.AddCalendar("weeklyCalendar", new WeeklyCalendar(), false, true);

                   scheduler.AddCalendar("cronCalendar", cronCalendar, true, true);
                   scheduler.AddCalendar("holidayCalendar", holidayCalendar, true, true);

                   Assert.IsNotNull(scheduler.GetCalendar("annualCalendar"));

                   JobDetailImpl lonelyJob = new JobDetailImpl("lonelyJob", "lonelyGroup", typeof(SimpleRecoveryJob));
                   lonelyJob.Durable = true;
                   lonelyJob.RequestsRecovery = true;
                   scheduler.AddJob(lonelyJob, false);
                   scheduler.AddJob(lonelyJob, true);

                   string schedId = scheduler.SchedulerInstanceId;

                   int count = 1;

                   JobDetailImpl job = new JobDetailImpl("job_" + count, schedId, typeof(SimpleRecoveryJob));

                   // ask scheduler to re-Execute this job if it was in progress when
                   // the scheduler went down...
                   job.RequestsRecovery = true;
                   IOperableTrigger trigger = new SimpleTriggerImpl("trig_" + count, schedId, 20, TimeSpan.FromSeconds(5));
                   trigger.JobDataMap.Add("key", "value");
                   trigger.EndTimeUtc = DateTime.UtcNow.AddYears(10);

                   trigger.StartTimeUtc = DateTime.Now.AddMilliseconds(1000L);
                   scheduler.ScheduleJob(job, trigger);

                   // check that trigger was stored
                   ITrigger persisted = scheduler.GetTrigger(new TriggerKey("trig_" + count, schedId));
                   Assert.IsNotNull(persisted);
                   Assert.IsTrue(persisted is SimpleTriggerImpl);

                   count++;
                   job = new JobDetailImpl("job_" + count, schedId, typeof(SimpleRecoveryJob));
                   // ask scheduler to re-Execute this job if it was in progress when
                   // the scheduler went down...
                   job.RequestsRecovery = (true);
                   trigger = new SimpleTriggerImpl("trig_" + count, schedId, 20, TimeSpan.FromSeconds(5));

                   trigger.StartTimeUtc = (DateTime.Now.AddMilliseconds(2000L));
                   scheduler.ScheduleJob(job, trigger);

                   count++;
                   job = new JobDetailImpl("job_" + count, schedId, typeof(SimpleRecoveryStatefulJob));
                   // ask scheduler to re-Execute this job if it was in progress when
                   // the scheduler went down...
                   job.RequestsRecovery = (true);
                   trigger = new SimpleTriggerImpl("trig_" + count, schedId, 20, TimeSpan.FromSeconds(3));

                   trigger.StartTimeUtc = (DateTime.Now.AddMilliseconds(1000L));
                   scheduler.ScheduleJob(job, trigger);

                   count++;
                   job = new JobDetailImpl("job_" + count, schedId, typeof(SimpleRecoveryJob));
                   // ask scheduler to re-Execute this job if it was in progress when
                   // the scheduler went down...
                   job.RequestsRecovery = (true);
                   trigger = new SimpleTriggerImpl("trig_" + count, schedId, 20, TimeSpan.FromSeconds(4));

                   trigger.StartTimeUtc = (DateTime.Now.AddMilliseconds(1000L));
                   scheduler.ScheduleJob(job, trigger);

                   count++;
//.........这里部分代码省略.........
开发者ID:ndepoel,项目名称:quartznet,代码行数:101,代码来源:SmokeTestPerformer.cs

示例7: TestMatchers

        private void TestMatchers(IScheduler scheduler)
        {
            scheduler.Clear();

            IJobDetail job = JobBuilder.Create<NoOpJob>().WithIdentity("job1", "aaabbbccc").StoreDurably().Build();
            scheduler.AddJob(job, true);
            SimpleScheduleBuilder schedule = SimpleScheduleBuilder.Create();
            ITrigger trigger = TriggerBuilder.Create().WithIdentity("trig1", "aaabbbccc").WithSchedule(schedule).ForJob(job).Build();
            scheduler.ScheduleJob(trigger);

            job = JobBuilder.Create<NoOpJob>().WithIdentity("job1", "xxxyyyzzz").StoreDurably().Build();
            scheduler.AddJob(job, true);
            schedule = SimpleScheduleBuilder.Create();
            trigger = TriggerBuilder.Create().WithIdentity("trig1", "xxxyyyzzz").WithSchedule(schedule).ForJob(job).Build();
            scheduler.ScheduleJob(trigger);

            job = JobBuilder.Create<NoOpJob>().WithIdentity("job2", "xxxyyyzzz").StoreDurably().Build();
            scheduler.AddJob(job, true);
            schedule = SimpleScheduleBuilder.Create();
            trigger = TriggerBuilder.Create().WithIdentity("trig2", "xxxyyyzzz").WithSchedule(schedule).ForJob(job).Build();
            scheduler.ScheduleJob(trigger);

            Collection.ISet<JobKey> jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.AnyGroup());
            Assert.That(jkeys.Count, Is.EqualTo(3), "Wrong number of jobs found by anything matcher");

            jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("xxxyyyzzz"));
            Assert.That(jkeys.Count, Is.EqualTo(2), "Wrong number of jobs found by equals matcher");

            jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("aaabbbccc"));
            Assert.That(jkeys.Count, Is.EqualTo(1), "Wrong number of jobs found by equals matcher");

            jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupStartsWith("aa"));
            Assert.That(jkeys.Count, Is.EqualTo(1), "Wrong number of jobs found by starts with matcher");

            jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupStartsWith("xx"));
            Assert.That(jkeys.Count, Is.EqualTo(2), "Wrong number of jobs found by starts with matcher");

            jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEndsWith("cc"));
            Assert.That(jkeys.Count, Is.EqualTo(1), "Wrong number of jobs found by ends with matcher");

            jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEndsWith("zzz"));
            Assert.That(jkeys.Count, Is.EqualTo(2), "Wrong number of jobs found by ends with matcher");

            jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupContains("bc"));
            Assert.That(jkeys.Count, Is.EqualTo(1), "Wrong number of jobs found by contains with matcher");

            jkeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupContains("yz"));
            Assert.That(jkeys.Count, Is.EqualTo(2), "Wrong number of jobs found by contains with matcher");

            Collection.ISet<TriggerKey> tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.AnyGroup());
            Assert.That(tkeys.Count, Is.EqualTo(3), "Wrong number of triggers found by anything matcher");

            tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("xxxyyyzzz"));
            Assert.That(tkeys.Count, Is.EqualTo(2), "Wrong number of triggers found by equals matcher");

            tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("aaabbbccc"));
            Assert.That(tkeys.Count, Is.EqualTo(1), "Wrong number of triggers found by equals matcher");

            tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupStartsWith("aa"));
            Assert.That(tkeys.Count, Is.EqualTo(1), "Wrong number of triggers found by starts with matcher");

            tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupStartsWith("xx"));
            Assert.That(tkeys.Count, Is.EqualTo(2), "Wrong number of triggers found by starts with matcher");

            tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEndsWith("cc"));
            Assert.That(tkeys.Count, Is.EqualTo(1), "Wrong number of triggers found by ends with matcher");

            tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEndsWith("zzz"));
            Assert.That(tkeys.Count, Is.EqualTo(2), "Wrong number of triggers found by ends with matcher");

            tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupContains("bc"));
            Assert.That(tkeys.Count, Is.EqualTo(1), "Wrong number of triggers found by contains with matcher");

            tkeys = scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupContains("yz"));
            Assert.That(tkeys.Count, Is.EqualTo(2), "Wrong number of triggers found by contains with matcher");
        }
开发者ID:JustAGhosT,项目名称:quartznet,代码行数:76,代码来源:SmokeTestPerformer.cs

示例8: DeleteAll

 /// <summary>
 /// This method deletes all jobs in a specified scheduler.
 /// </summary>
 /// <param name="qScheduler"></param>
 public void DeleteAll(IScheduler qScheduler)
 {
     qScheduler.Clear();
 }
开发者ID:Majestic3691,项目名称:HelloWorldQuartzDotNet,代码行数:8,代码来源:RFFCQuartzCommon.cs


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