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


C# IScheduler.TriggerJob方法代码示例

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


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

示例1: Main

        public static void Main(string[] args)
        {
            //            XmlConfigurator.Configure();

               var properties = new NameValueCollection();
               properties["quartz.scheduler.instanceName"] = "ServerScheduler";

            // set thread pool info
            properties["quartz.threadPool.threadCount"] = "0";

            // set remoting expoter
            properties["quartz.scheduler.proxy"] = "true";
            properties["quartz.scheduler.proxy.address"] = "tcp://localhost:555/QuartzScheduler";

            var scheduleFactory = new StdSchedulerFactory(properties);

            scheduler = scheduleFactory.GetScheduler();
            var md = scheduler.GetMetaData();
            scheduler.Start();

            IJobDetail job = JobBuilder.Create<Jobs.SimpleJob>().Build();

            ITrigger jobTrigger = new SimpleTriggerImpl("TenSecondTrigger", 20, new TimeSpan(0, 0, 0, 5));

            //Periodic scheduling
            scheduler.ScheduleJob(job,jobTrigger);

            //Trigger a job from elsewhere without a trigger for one time
            var jobKey = job.Key;
            var jobDataMap = job.JobDataMap;
            scheduler.TriggerJob(jobKey,jobDataMap);
        }
开发者ID:srutis90,项目名称:QuartzAsWindowsService,代码行数:32,代码来源:Program.cs

示例2: Run

        public void Run()
        {
            // TODO Initialiaze Scheduler
            scheduler = new StdSchedulerFactory().GetScheduler();
            scheduler.Start();

            // Let's generate our email job detail now
            CreateJob();

            // And finally, schedule the job
            ScheduleJob();

            // Run immediately?
            if (this.workerConfig.RunImmediately)
            {
                scheduler.TriggerJob(this.jobKey);
            }
        }
开发者ID:modulexcite,项目名称:QuartzOnWindowsService,代码行数:18,代码来源:ScheduledJob.cs

示例3: MonitorService

        public MonitorService()
        {
            this.ServiceName = "Sharp Monitoring Service";

            // create the job to be scheduled
            Type jobType = typeof(DailyTask);
            JobDetail job = new JobDetail(jobType.Name, null, jobType);

            ISchedulerFactory schedFact = new StdSchedulerFactory();
            sched = schedFact.GetScheduler();
            sched.Start();

            // schedule daily cron job
            Trigger trigger = new CronTrigger("CronTrigger", null, jobType.Name, null, SharpMonitor.Properties.Settings.Default.CornExpression);
            sched.AddJob(job, true);

            DateTime ft = sched.ScheduleJob(trigger);

            // start job immediately if next schedule job is tomorrow
            if (ft > DateTime.UtcNow)
            {
                sched.TriggerJob(jobType.Name, null);
            }
        }
开发者ID:notsilicon,项目名称:sharpmon,代码行数:24,代码来源:MonitorService.cs

示例4: TriggerJobsCore

 Action<JobKey> TriggerJobsCore(IScheduler scheduler, JobDataMap jobDataMap) {
     return key => {
         if (scheduler.GetJobDetail(new JobKey(key.Name, key.Group)) != null)
             scheduler.TriggerJob(new JobKey(key.Name, key.Group),jobDataMap);
     };
 }
开发者ID:aries544,项目名称:eXpand,代码行数:6,代码来源:XpandJobListener.cs

示例5: AddJob6

        private void AddJob6(IScheduler scheduler, IJobDetail job, ISimpleTrigger trigger)
        {
            job = JobBuilder.Create<SimpleJob>()
                    .WithIdentity("job6", "group1")
                    .StoreDurably()
                    .Build();

            scheduler.AddJob(job, true);
            log.Info("'Manually triggering job6...");
            scheduler.TriggerJob(new JobKey("job6", "group1"));
        }
开发者ID:Ju2ender,项目名称:csharp-e,代码行数:11,代码来源:SimpleTriggerExample.cs

示例6: Test


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

                    // bulk operations
                    var info = new Dictionary<IJobDetail, 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 HashSet<ITrigger>();
                    triggers.Add(simple);
                    info[detail] = triggers;

                    await scheduler.ScheduleJobs(info, true);

                    Assert.IsTrue(await scheduler.CheckExists(detail.Key));
                    Assert.IsTrue(await scheduler.CheckExists(simple.Key));

                    // QRTZNET-243
                    await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupContains("a").DeepClone());
                    await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEndsWith("a").DeepClone());
                    await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupStartsWith("a").DeepClone());
                    await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals("a").DeepClone());

                    await scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupContains("a").DeepClone());
                    await scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEndsWith("a").DeepClone());
                    await scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupStartsWith("a").DeepClone());
                    await scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.GroupEquals("a").DeepClone());

                    await scheduler.Start();

                    await Task.Delay(TimeSpan.FromSeconds(3));

                    await scheduler.PauseAll();

                    await scheduler.ResumeAll();

                    await scheduler.PauseJob(new JobKey("job_1", schedId));

                    await scheduler.ResumeJob(new JobKey("job_1", schedId));

                    await scheduler.PauseJobs(GroupMatcher<JobKey>.GroupEquals(schedId));

                    await Task.Delay(TimeSpan.FromSeconds(1));

                    await scheduler.ResumeJobs(GroupMatcher<JobKey>.GroupEquals(schedId));

                    await scheduler.PauseTrigger(new TriggerKey("trig_2", schedId));
                    await scheduler.ResumeTrigger(new TriggerKey("trig_2", schedId));

                    await scheduler.PauseTriggers(GroupMatcher<TriggerKey>.GroupEquals(schedId));

                    var pausedTriggerGroups = await scheduler.GetPausedTriggerGroups();
                    Assert.AreEqual(1, pausedTriggerGroups.Count);

                    await Task.Delay(TimeSpan.FromSeconds(3));
                    await 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"));

                    var genericjobKey = new JobKey("genericJob", "genericGroup");
                    GenericJobType.Reset();
                    var genericJob = JobBuilder.Create<GenericJobType>()
                        .WithIdentity(genericjobKey)
                        .StoreDurably()
                        .Build();

                    await scheduler.AddJob(genericJob, false);

                    genericJob = await scheduler.GetJobDetail(genericjobKey);
                    Assert.That(genericJob, Is.Not.Null);
                    await scheduler.TriggerJob(genericjobKey);

                    GenericJobType.WaitForTrigger(TimeSpan.FromSeconds(20));

                    Assert.That(GenericJobType.TriggeredCount, Is.EqualTo(1));
                    await scheduler.Standby();

                    CollectionAssert.IsNotEmpty(await scheduler.GetCalendarNames());
                    CollectionAssert.IsNotEmpty(await scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(schedId)));

                    CollectionAssert.IsNotEmpty(await scheduler.GetTriggersOfJob(new JobKey("job_2", schedId)));
                    Assert.IsNotNull(scheduler.GetJobDetail(new JobKey("job_2", schedId)));

                    await scheduler.DeleteCalendar("cronCalendar");
                    await scheduler.DeleteCalendar("holidayCalendar");
                    await scheduler.DeleteJob(new JobKey("lonelyJob", "lonelyGroup"));
                    await scheduler.DeleteJob(job.Key);

                    await scheduler.GetJobGroupNames();
                    await scheduler.GetCalendarNames();
                    await scheduler.GetTriggerGroupNames();

                    await TestMatchers(scheduler);
                }
            }
            finally
            {
                await scheduler.Shutdown(false);
            }
        }
开发者ID:jvilalta,项目名称:quartznet,代码行数:101,代码来源:SmokeTestPerformer.cs


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