Esempio n. 1
0
        public static void Schedule(IContainer container, ServiceConfigurator <JobService> svc)
        {
            try
            {
                svc.UsingQuartzJobFactory(() => container.Resolve <IJobFactory>());
            }
            catch (Exception)
            {
                throw;
            }

            foreach (var job in JobList)
            {
                svc.ScheduleQuartzJob(q =>
                {
                    q.WithJob(JobBuilder.Create(Type.GetType(JobNamespceFormat.Fmt(job.Name)))
                              .WithIdentity(job.Name, ServiceName)
                              .Build);

                    q.AddTrigger(() => TriggerBuilder.Create()
                                 .WithCronSchedule(job.Cron)
                                 .Build());

                    log.InfoFormat("任务 {0} 已完成调度设置", JobNamespceFormat.Fmt(job.Name));
                });
            }
        }
Esempio n. 2
0
        public static void InitSchedule(ServiceConfigurator <ServiceRunner> svc)
        {
            svc.UsingQuartzJobFactory(Container.Resolve <IJobFactory>);
            InitQuartzJob();

            foreach (var job in JobList)
            {
                svc.ScheduleQuartzJob(q =>
                {
                    q.WithJob(JobBuilder.Create <ReportAutoGenerateJob>()
                              .WithIdentity(job.Name, AppSettings.JobGroupName)
                              .UsingJobData("JobEntity", JsonConvert.SerializeObject(job))
                              .Build);

                    q.AddTrigger(() => TriggerBuilder.Create()
                                 .WithIdentity($"{job.Name}_trigger", AppSettings.JobGroupName)
                                 .WithCronSchedule(job.CornLike)
                                 .Build());

                    CommHelper.AppLogger.InfoFormat("任务 {0} 已完成调度设置", job.Name);
                });
            }

            CommHelper.AppLogger.Info("调度任务 初始化完毕");
        }
Esempio n. 3
0
        private static void ConfigureBackgroundJobs(ServiceConfigurator<ServiceCore> svc)
        {
            svc.UsingQuartzJobFactory(() => _container.Resolve<IJobFactory>());

            svc.ScheduleQuartzJob(q =>
            {
                q.WithJob(JobBuilder.Create<HeartbeatJob>()
                    .WithIdentity("Heartbeat", "Maintenance")
                    .Build);
                q.AddTrigger(() => TriggerBuilder.Create()
                    .WithSchedule(SimpleScheduleBuilder.RepeatSecondlyForever(2)).Build());
            });
        }
        private static void ConfigureBackgroundJobs(ServiceConfigurator <ServiceCore> svc)
        {
            svc.UsingQuartzJobFactory(() => _container.Resolve <IJobFactory>());

            svc.ScheduleQuartzJob(q =>
            {
                q.WithJob(JobBuilder.Create <HeartbeatJob>()
                          .WithIdentity("Heartbeat", "Maintenance")
                          .Build);
                q.AddTrigger(() => TriggerBuilder.Create()
                             .WithSchedule(SimpleScheduleBuilder.RepeatSecondlyForever(2)).Build());
            });
        }
Esempio n. 5
0
        private static void ConfigureBackgroundJobs(ServiceConfigurator<ServiceCore> svc)
        {
            svc.UsingQuartzJobFactory(() => _container.Resolve<IJobFactory>());

            var cron = ConfigurationManager.AppSettings.Get("CRON");

            svc.ScheduleQuartzJob(q =>
            {
                q.WithJob(JobBuilder.Create<VapoJob>()
                    .WithIdentity("Vaporize", "Maintenance")
                    .Build);
                q.AddTrigger(() => TriggerBuilder.Create()
                    .WithCronSchedule(cron).Build());
            });
        }
Esempio n. 6
0
        public void ConfigureBackgroundJobs(ServiceConfigurator <JobsManager> svc)
        {
            svc.UsingQuartzJobFactory(() => _container.Resolve <PollerAutofacJobFactory>());

            foreach (var taskAdapter in _concreteTask)
            {
                string      name            = taskAdapter.Key;
                TaskAdapter adapter         = taskAdapter.Value;
                string      taskDescription = adapter.TaskDescription;
                if (adapter.IntervalInSeconds > 0)
                {
                    svc.ScheduleQuartzJob(
                        q =>
                    {
                        q.WithJob(
                            JobBuilder.Create <Job>().WithIdentity(name).WithDescription(taskDescription).Build);
                        q.AddTrigger(
                            () =>
                            TriggerBuilder.Create()
                            .WithSchedule(
                                SimpleScheduleBuilder.RepeatSecondlyForever(adapter.IntervalInSeconds))
                            .Build());
                    });
                }
                else
                {
                    svc.ScheduleQuartzJob(
                        q =>
                    {
                        q.WithJob(
                            JobBuilder.Create <Job>().WithIdentity(name).WithDescription(taskDescription).Build);
                        q.AddTrigger(
                            () =>
                            TriggerBuilder.Create()
                            .WithSimpleSchedule(s =>
                                                s.RepeatForever()
                                                .WithInterval(TimeSpan.FromMilliseconds(1)))
                            .StartNow()
                            .Build());
                    });
                }
            }
        }
Esempio n. 7
0
        public static void UseAutofac(this ServiceConfigurator <MainService> svc)
        {
            var builder = new ContainerBuilder();

            builder.RegisterModule(new QuartzAutofacFactoryModule());
            builder.RegisterModule(new QuartzAutofacJobsModule(typeof(MainService).Assembly));

            builder.Register(r => Configuration).As <IConfiguration>().SingleInstance();

            builder.Register(a => new MongoRepository(Configuration["Infrastructure:Mongodb"])).SingleInstance();

            builder.RegisterAssemblyTypes(Assembly.Load("Sikiro.SMSService"))
            .Where(t => t.GetInterfaces().Any(a => a == typeof(IService)))
            .InstancePerLifetimeScope();

            builder.RegisterEasyNetQ(Configuration["Infrastructure:RabbitMQ"]);

            var container = builder.Build();

            svc.UsingQuartzJobFactory(container.Resolve <IJobFactory>);
        }
Esempio n. 8
0
        /// <summary>
        /// 初始化调度任务
        /// </summary>
        /// <param name="svc"></param>
        public static void InitSchedule(ServiceConfigurator <JobService> svc)
        {
            svc.UsingQuartzJobFactory(Container.Resolve <IJobFactory>);

            foreach (var job in JobList)
            {
                svc.ScheduleQuartzJob(q =>
                {
                    q.WithJob(JobBuilder.Create(Type.GetType(string.Format(JobNamespceFormat, job.JobName)))
                              .WithIdentity(job.JobName, ServiceName)
                              .Build);

                    q.AddTrigger(() => TriggerBuilder.Create()
                                 .WithCronSchedule(job.Cron)
                                 .Build());

                    Log.InfoFormat("任务 {0} 已完成调度设置", string.Format(JobNamespceFormat, job.JobName));
                });
            }

            Log.Info("调度任务 初始化完毕");
        }
Esempio n. 9
0
        public void ConfigureBackgroundJobs(ServiceConfigurator<JobsManager> svc)
        {
            svc.UsingQuartzJobFactory(() => _container.Resolve<PollerAutofacJobFactory>());

            foreach (var taskAdapter in _concreteTask)
            {
                string name = taskAdapter.Key;
                TaskAdapter adapter = taskAdapter.Value;
                string taskDescription = adapter.TaskDescription;
                if (adapter.IntervalInSeconds > 0)
                {
                    svc.ScheduleQuartzJob(
                    q =>
                    {
                        q.WithJob(
                            JobBuilder.Create<Job>().WithIdentity(name).WithDescription(taskDescription).Build);
                        q.AddTrigger(
                            () =>
                            TriggerBuilder.Create()
                                            .WithSchedule(
                                                  SimpleScheduleBuilder.RepeatSecondlyForever(adapter.IntervalInSeconds))
                                          .Build());
                    });
                }
                else
                {
                    svc.ScheduleQuartzJob(
                    q =>
                    {
                        q.WithJob(
                            JobBuilder.Create<Job>().WithIdentity(name).WithDescription(taskDescription).Build);
                        q.AddTrigger(
                            () =>
                            TriggerBuilder.Create()
                                          .WithSimpleSchedule(s =>
                                                s.RepeatForever()
                                                .WithInterval(TimeSpan.FromMilliseconds(1)))
                                          .StartNow()
                                          .Build());
                    });
                }
                
            }
        }
Esempio n. 10
0
 public static ServiceConfigurator <T> UseNinjectQuartzJobFactory <T>(this ServiceConfigurator <T> configurator)
     where T : class
 {
     return(configurator.UsingQuartzJobFactory(() => NinjectBuilderConfigurator.Kernel.Get <NinjectJobFactory>()));
 }