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


C# IScheduler.DeleteJob方法代码示例

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


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

示例1: SetupCleanupJob

        void SetupCleanupJob(IScheduler scheduler)
        {
            JobKey jobKey = JobKey.Create(_tenant.Id, "sys.cleanup");
            scheduler.DeleteJob(jobKey);

            var job = JobBuilder
                .Create<CleanupJob>()
                .UsingJobData(JobKeys.TenantId, _tenant.Id)
                .WithIdentity(jobKey)
                .Build();

            var trigger = TriggerBuilder.Create()
#if DEBUG
                .StartAt(DateTimeOffset.Now.AddSeconds(30))
                .WithSimpleSchedule(b => b.RepeatForever().WithIntervalInSeconds(15))
#else
                .StartAt(DateTimeOffset.Now.AddMinutes(30))
                .WithSimpleSchedule(b=>b.RepeatForever().WithIntervalInMinutes(5))
#endif
.WithPriority(1)
                .Build();

            scheduler.ScheduleJob(job, trigger);
        }
开发者ID:ProximoSrl,项目名称:Jarvis.DocumentStore,代码行数:24,代码来源:TenantJobsInstaller.cs

示例2: SetupTimeoutJob

        void SetupTimeoutJob(IScheduler scheduler)
        {
            JobKey jobKey = JobKey.Create("queuedMonitorForTimeout", "sys.cleanup");
            scheduler.DeleteJob(jobKey);

            var job = JobBuilder
                .Create<QueuedJobQuartzMonitor>()
                .WithIdentity(jobKey)
                .Build();

            var trigger = TriggerBuilder.Create()
#if DEBUG
.StartAt(DateTimeOffset.Now.AddSeconds(5))
                .WithSimpleSchedule(b => b.RepeatForever().WithIntervalInMinutes(2))
#else
                .StartAt(DateTimeOffset.Now.AddMinutes(2))
                .WithSimpleSchedule(b=>b.RepeatForever().WithIntervalInMinutes(2))
#endif
.WithPriority(1)
                .Build();

            var nextExcution = scheduler.ScheduleJob(job, trigger);
            _logger.InfoFormat("Scheduled QueuedJobQuartzMonitor: first execution at {0}.", nextExcution);
        }
开发者ID:ProximoSrl,项目名称:Jarvis.DocumentStore,代码行数:24,代码来源:QueueInfrasctructureInstaller.cs

示例3: AddJob

        private void AddJob(IScheduler scheduler, SystemJob jobItem, Func<Type, IJobActivity> getJob)
        {
            var jobKey = new JobKey(jobItem.SystemJobId, jobItem.JobClassType);
            var type = Type.GetType(jobItem.JobClassType, true);

            // Define the Job to be scheduled
            var quartzJobDetail = JobBuilder.Create(typeof(QuartzJob))
                .WithIdentity(jobKey)
                .RequestRecovery()
                .Build();

            Func<IJobActivity> jobActivityConstructor = () => getJob(type);

            Func<DateTime, Action<string>> getAudit = startDateTime =>
                message => _schedulerDbTools.CreateSystemJobLogEntry(
                jobItem.SystemJobId, startDateTime, DateTime.Now, message,
                Thread.CurrentThread.Name, null, jobItem.AllowMultipleInstances);

            var section = ConfigurationManager.GetSection("traceContextConfiguration") ?? new TraceContextConfigurationSection();
            ITraceContextConfigurator config = (TraceContextConfigurationSection)section;
            var contextName = new ContextName(type.FullName, "");
            var configuration = config.GetDefault(contextName.Service, contextName.Method);
            var traceSource = new TraceSource("VirtoCommerce.ScheduleService.Trace");
            var traceContext = new TraceContext(configuration, contextName, Guid.NewGuid(), traceSource);

            quartzJobDetail.JobDataMap.Add("realization", jobActivityConstructor);
            quartzJobDetail.JobDataMap.Add("getAudit", getAudit);
            quartzJobDetail.JobDataMap.Add("context", traceContext);
            quartzJobDetail.JobDataMap.Add("parameters", jobItem.JobParameters.ToDictionary(pk => pk.Name.ToLowerInvariant(), pv => pv.Value));

            // Associate a trigger with the Job
            var trigger = TriggerBuilder.Create()
                .WithIdentity(jobItem.SystemJobId, jobItem.JobClassType)
                .WithSimpleSchedule(x =>
                {
                    x.WithInterval(TimeSpan.FromSeconds(jobItem.Period));
                    x.RepeatForever();
                })
                .StartAt(DateTime.UtcNow)
                .WithPriority(jobItem.Priority)
                .Build();

            // Validate that the job doesn't already exists
            if (scheduler.CheckExists(jobKey))
            {
                scheduler.DeleteJob(jobKey);
            }
            scheduler.ScheduleJob(quartzJobDetail, trigger);
        }
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:49,代码来源:JobScheduler.cs

示例4: 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

示例5: CleanUp

        private static void CleanUp(IScheduler inScheduler)
        {
            // unschedule jobs
            IList<string> groups = inScheduler.GetTriggerGroupNames();
            foreach (string group in groups)
            {
                Collection.ISet<TriggerKey> keys = inScheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals(group));
                foreach (TriggerKey key in keys)
                {
                    inScheduler.UnscheduleJob(key);
                }
            }

            // delete jobs
            groups = inScheduler.GetJobGroupNames();
            foreach (string group in groups)
            {
                Collection.ISet<JobKey> jobNames = inScheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(group));
                foreach (JobKey jobKey in jobNames)
                {
                    inScheduler.DeleteJob(jobKey);
                }
            }

            inScheduler.DeleteCalendar("annualCalendar");
            inScheduler.DeleteCalendar("baseCalendar");
            inScheduler.DeleteCalendar("cronCalendar");
            inScheduler.DeleteCalendar("dailyCalendar");
            inScheduler.DeleteCalendar("holidayCalendar");
            inScheduler.DeleteCalendar("monthlyCalendar");
            inScheduler.DeleteCalendar("weeklyCalendar");
        }
开发者ID:Leftyx,项目名称:quartznet,代码行数:32,代码来源:AdoJobStoreSmokeTest.cs


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