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


C# IScheduler.ScheduleJob方法代码示例

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


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

示例1: Service1

        public Service1()
        {
            InitializeComponent();

            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

            ISchedulerFactory schedFact = new StdSchedulerFactory();

            _scheduler = schedFact.GetScheduler();

            var parseJob = new JobDetailImpl("ParseJob", "ParserStuff", typeof(ParseJob));

            var parseTrigger = new CronTriggerImpl("ParseTime", "ParserStuff", "0 0/10 * * * ?") // Exactly every ten minutes
            {
                StartTimeUtc = DateTime.UtcNow
            };
            _scheduler.ScheduleJob(parseJob, parseTrigger);

            var summaryJob = new JobDetailImpl("SummaryJob", "SummaryStuff", typeof(SummaryJob));

            var summaryTrigger = new CronTriggerImpl("SummaryTime", "SummaryStuff", "0 0 4 1/1 * ? *") // At 04:00 AM every night
            {
                StartTimeUtc = DateTime.UtcNow
            };
            _scheduler.ScheduleJob(summaryJob, summaryTrigger);
        }
开发者ID:karl-sjogren,项目名称:vkminus,代码行数:26,代码来源:Service1.cs

示例2: Start

        public void Start()
        {
            sf = new StdSchedulerFactory();
            sched = sf.GetScheduler();
            sched.JobFactory = _jobFactory;

            IJobDetail job1 = JobBuilder.Create<Job1>()
                .WithIdentity("job1", "group1")
                .Build();
            IJobDetail job2 = JobBuilder.Create<Job2>()
                .WithIdentity("job2", "group1")
                .Build();
            IJobDetail job3 = JobBuilder.Create<Job3>()
                .WithIdentity("job3", "group1")
                .Build();

            var trigger1 = (ICronTrigger) TriggerBuilder.Create()
                                              .WithIdentity("trigger1", "group1").StartNow()
                                              .WithCronSchedule("0/2 * * * * ?")
                                              .Build();
            var trigger2 = (ICronTrigger) TriggerBuilder.Create()
                                              .WithIdentity("trigger2", "group1").StartNow()
                                              .WithCronSchedule("0/5 * * * * ?")
                                              .Build();
            var trigger3 = (ICronTrigger) TriggerBuilder.Create()
                                              .WithIdentity("trigger3", "group1").StartNow()
                                              .WithCronSchedule("0/10 * * * * ?")
                                              .Build();

            sched.ScheduleJob(job1, trigger1);
            sched.ScheduleJob(job2, trigger2);
            sched.ScheduleJob(job3, trigger3);

            sched.Start();
        }
开发者ID:onurogurtani,项目名称:QuartzCastleWindsor,代码行数:35,代码来源:QuartzInitializer.cs

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

示例4: Start

        public void Start()
        {
            try
            {
                _scheduler = StdSchedulerFactory.GetDefaultScheduler();
                _scheduler.Start();

                var inboxCheckJob = JobBuilder.Create<CheckSupportMailboxJob>()
                    .WithIdentity("inboxChecker", "inboxChecking")
                    .Build();

                var tasklogsCheckJob = JobBuilder.Create<CheckForNewTasklogsJob>()
                    .WithIdentity("tasklogChecker", "tasklogChecking")
                    .Build();

                var sendQueueCheckJob = JobBuilder.Create<SendEmailJob>()
                    .WithIdentity("emailQueueChecker", "queueChecking")
                    .Build();

                var inboxCheckTrigger = TriggerBuilder.Create()
                    .WithIdentity("trigger1", "inboxChecking")
                    .StartNow()
                    .WithSimpleSchedule(x => x
                        .WithIntervalInSeconds((int)TimeSpan.FromSeconds(15).TotalSeconds)
                        .RepeatForever())
                    .Build();

                var tasklogCheckTrigger = TriggerBuilder.Create()
                    .WithIdentity("trigger1", "tasklogChecking")
                    .StartNow()
                    .WithSimpleSchedule(x => x
                        .WithIntervalInSeconds((int)TimeSpan.FromSeconds(30).TotalSeconds)
                        .RepeatForever())
                    .Build();

                var emailQeueueCheckTrigger = TriggerBuilder.Create()
                    .WithIdentity("trigger2", "queueChecking")
                    .StartNow()
                    .WithSimpleSchedule(x => x
                        .WithIntervalInSeconds((int)TimeSpan.FromSeconds(15).TotalSeconds)
                        .RepeatForever())
                    .Build();

                _scheduler.ScheduleJob(inboxCheckJob, inboxCheckTrigger);
                _scheduler.ScheduleJob(sendQueueCheckJob, emailQeueueCheckTrigger);
                _scheduler.ScheduleJob(tasklogsCheckJob, tasklogCheckTrigger);
            }
            catch (SchedulerException se)
            {
                log.Error(se);
            }
        }
开发者ID:NephelimDK,项目名称:IOfficeConnect,代码行数:52,代码来源:QuartzScheduler.cs

示例5: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Starting scheduler...");

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

            // set thread pool infoD:\Projects\QuartzMaster\QuartzMaster.TestServerHost\Program.cs
            properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
            properties["quartz.threadPool.threadCount"] = "5";
            properties["quartz.threadPool.threadPriority"] = "Normal";

            // set remoting expoter
            properties["quartz.scheduler.exporter.type"] = "Quartz.Simpl.RemotingSchedulerExporter, Quartz";
            properties["quartz.scheduler.exporter.port"] = "500";
            properties["quartz.scheduler.exporter.bindName"] = "QuartzScheduler";
            properties["quartz.scheduler.exporter.channelType"] = "tcp";

            var schedulerFactory = new StdSchedulerFactory(properties);
            scheduler = schedulerFactory.GetScheduler();

            // define the job and ask it to run
            var map = new JobDataMap();
            map.Put("msg", "Some message!");
            map.Put("msg 2", "Some message 2!");
            map.Put("msg 3", "Some message 3!");

            var job = new JobDetail("localJob", "default", typeof(NoOpJob))
            {
                JobDataMap = map
            };

            var job2 = new JobDetail("localJob 2", "default", typeof(NoOpJob))
            {
                JobDataMap = map
            };

            var trigger2 = new SimpleTrigger("Simple Trigger", "default", "localJob 2", "default", DateTime.Now, DateTime.Now.AddMinutes(10), SimpleTrigger.RepeatIndefinitely, new TimeSpan(0, 0, 45));

            var trigger = new CronTrigger("remotelyAddedTrigger", "default", "localJob", "default", DateTime.UtcNow, null, "/5 * * ? * *");

            var trigger3 = new SimpleTrigger("remotelyAddedTriggerB", "default", "localJob", "default", DateTime.Now, DateTime.Now.AddMinutes(10), SimpleTrigger.RepeatIndefinitely, new TimeSpan(0, 0, 45));

            // schedule the job
            scheduler.ScheduleJob(job, trigger3);
            scheduler.ScheduleJob(job2, trigger2);

            scheduler.Start();

            Console.WriteLine("Scheduler has been started.");
            Console.WriteLine("Press any key to stop scheduler");
            Console.ReadKey();
            scheduler.Shutdown();
        }
开发者ID:AndrejMikhalev,项目名称:quartz-master,代码行数:54,代码来源:Program.cs

示例6: Service

        public Service()
        {
            InitializeComponent();

            try
            {
                XmlConfigurator.Configure();

                log.Info("--------------------- Initializing Service ----------------------");

                schedulerFactory = new StdSchedulerFactory();
                scheduler = schedulerFactory.GetScheduler();

                IJobDetail job = JobBuilder.Create<TwitterServiceWrapper>()
                    .WithIdentity("TwitterServiceJobr")
                    .Build();

                ITrigger trigger = TriggerBuilder.Create()
                    .WithIdentity("TwitterTrigger")
                    .WithCronSchedule(CronExpression)
                    .Build();

                scheduler.ScheduleJob(job, trigger);

            }
            catch (Exception ex)
            {
                log.Error("Fatall error Initializing Windows Service", ex);
                if (scheduler != null && scheduler.IsStarted)
                    scheduler.Shutdown();

            }
        }
开发者ID:Jacobeom,项目名称:git-first,代码行数:33,代码来源:Service.cs

示例7: ScheduleDataUploadingJob

 //private static void ScheduleRatioRankingJob(IScheduler scheduler) {
 //    const int INTERVAL_IN_MINUTES = 15;
 //    scheduler.ScheduleJob(
 //        JobBuilder.Create<RatioRankingJob>().WithIdentity("RatioRankingJob").Build(),
 //        TriggerBuilder.Create().WithIdentity("RatioRankingTrigger").StartNow().WithSimpleSchedule(x => x.RepeatForever().WithIntervalInMinutes(INTERVAL_IN_MINUTES)).Build());
 //}
 private static void ScheduleDataUploadingJob(IScheduler scheduler)
 {
     const int INTERVAL_IN_MINUTES = 15;
     scheduler.ScheduleJob(
         JobBuilder.Create<DataUploadingJob>().WithIdentity("DataUploadingJob").Build(),
         TriggerBuilder.Create().WithIdentity("DataUploadingTrigger").StartNow().WithSimpleSchedule(x => x.RepeatForever().WithIntervalInMinutes(INTERVAL_IN_MINUTES)).Build());
 }
开发者ID:keily,项目名称:LightOne,代码行数:13,代码来源:Program.cs

示例8: InitializeScheduler

        private void InitializeScheduler()
        {
            try
            {
                if (scheduler != null) { return; }

                Logger.Log.Debug("Initializing Collector scheduler...");
                schedulerFactory = new StdSchedulerFactory();
                scheduler = schedulerFactory.GetScheduler();

                // BatDongSanJob
                jobDetail = new JobDetail("BatDongSanJob", null, typeof(BatDongSanJob));
                string cronEx = CollectorConfiguration.BatDongSan.BatDongSanCronTriggerExpression;
                cronTrigger = new CronTrigger(
                    "BatDongSanTrigger",
                    null,
                    cronEx
                    );
                cronTrigger.StartTimeUtc = DateTime.UtcNow;
                scheduler.ScheduleJob(jobDetail, cronTrigger);

                Logger.Log.Debug("Initialize Collector scheduler completely.");
            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex);
            }
        }
开发者ID:netthanhhung,项目名称:RoomSearch,代码行数:28,代码来源:CollectorService.cs

示例9: ScheduleTasks

 static async void ScheduleTasks(IScheduler scheduler)
 {
     using (var repo = new Repository())
     {
         var forms = (await repo.GetForms())
             .Where(t => t.TimeRemaining(repo) > TimeSpan.Zero)
             .ToList();
         foreach (var form in forms)
         {
             var job = JobBuilder.Create<FormBlockingJob>()
                 .WithIdentity($"Form{form.form_id}Job")
                 .UsingJobData("FormId", form.form_id)
                 .Build();
             var schedTime = new DateTimeOffset(form.DateExpired(repo));
             var trigger = TriggerBuilder.Create()
                 .WithIdentity($"Form{form.form_id}JobTrigger")
                 .StartAt(schedTime)
                 .ForJob($"Form{form.form_id}Job")
                 .Build();
             if (!scheduler.CheckExists(job.Key))
             {
                 scheduler.ScheduleJob(job, trigger);
                 _log.Info($"Scheduled block {form.name} at {trigger.StartTimeUtc}");
             }
             else
             {
                 scheduler.RescheduleJob(trigger.Key, trigger);
                 _log.Info($"Re-scheduled block {form.name} at {trigger.StartTimeUtc}");
             }
         }
     }
 }
开发者ID:superbatonchik,项目名称:EduFormManager,代码行数:32,代码来源:Program.cs

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

示例11: OnStart

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            bool result = base.OnStart();

            Bootstrap();
            scheduler = container.GetInstance<IScheduler>();


            // Below this line should be whatever code you are using today to schedule jobs, triggers, etc. and start the scheduler. This is just here for context

            // add jobs and start scheduler
            scheduler.ScheduleJob(
                JobBuilder.Create<JobNotification>().Build(),
                TriggerBuilder.Create().WithSimpleSchedule(
                    
                    s => s.WithIntervalInSeconds(60)).Build());

            // start scheduler
            scheduler.Start();


            Trace.TraceInformation("WorkerRoleTestDI_Entity has been started");

            return result;
        }
开发者ID:fjvela,项目名称:dotnet-ef-ioc-mvc-webapi-worker-nlayers,代码行数:31,代码来源:WorkerRole.cs

示例12: ScheduleJob

 private static void ScheduleJob(IScheduler scheduler)
 {
     const int INTERVAL_IN_SECONDS = 5;
     scheduler.ScheduleJob(
         JobBuilder.Create<YhdArchiveJob>().WithIdentity("YhdArchiveJob").Build(),
         TriggerBuilder.Create().WithIdentity("YhdArchiveTrigger").StartNow().WithSimpleSchedule(x => x.RepeatForever().WithIntervalInSeconds(INTERVAL_IN_SECONDS)).Build());
 }
开发者ID:keily,项目名称:LightOne,代码行数:7,代码来源:Program.cs

示例13: StartTrigger

        public void StartTrigger()
        {
            // construct a scheduler factory
            ISchedulerFactory schedFact = new StdSchedulerFactory();

            // get a scheduler
            _sched = schedFact.GetScheduler();

            // define the job and tie it to our HelloJob class
            IJobDetail job = JobBuilder.Create<QuartzJob>()
                .WithIdentity("job_" + datasetConfig.Name, "group1")
                .Build();


            DateTimeOffset runTime = DateBuilder.EvenMinuteDate(DateTimeOffset.UtcNow);

            // Trigger the job to run on the next round minute
            ITrigger trigger = TriggerBuilder.Create()
                .WithIdentity("trigger_" + datasetConfig.Name, "group1")
                .WithCronSchedule(datasetConfig.CronTab)
                //.StartAt(runTime)
                .Build();

            job.JobDataMap["CallbackMethod"] = new Action(TriggerCallback);

            _sched.ScheduleJob(job, trigger);
            _sched.Start();
        }
开发者ID:WaDeSo,项目名称:DotNetSiemensPLCToolBoxLibrary,代码行数:28,代码来源:QuartzTriggerThread.cs

示例14: Register

 private static void Register(IScheduler scheduler)
 {
     var jobDetail = new JobDetail("GamificationCheckStatusJob", null, typeof(TrackerController));
     Trigger trigger = TriggerUtils.MakeMinutelyTrigger(30);
     trigger.Name = "GamificationCheckStatus";
     scheduler.ScheduleJob(jobDetail, trigger);
 }
开发者ID:Letractively,项目名称:dc-gamification,代码行数:7,代码来源:TrackerController.cs

示例15: ConfigureScheduledEvents

 //public void Echo(string message)
 //{
 //    Console.WriteLine(message);
 //    hubProxy.Invoke("commandSent", string.Empty, message);
 //}
 private static void ConfigureScheduledEvents(IScheduler sched)
 {
     foreach (var trigger in GetTriggers())
     {
         sched.ScheduleJob(JobBuilder.Create<PublishEvent>().Build(), trigger);
     }
 }
开发者ID:erichexter,项目名称:HomeAutomation,代码行数:12,代码来源:X10AgentService.cs


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