コード例 #1
0
        public static object ModifyTaskEntity(this TaskOptions taskOptions, ISchedulerFactory schedulerFactory,
                                              JobAction action)
        {
            TaskOptions options = null;
            object      result  = null;

            switch (action)
            {
            case JobAction.除:
                for (var i = 0; i < _taskList.Count; i++)
                {
                    options = _taskList[i];
                    if (options.TaskName == taskOptions.TaskName && options.GroupName == taskOptions.GroupName)
                    {
                        _taskList.RemoveAt(i);
                    }
                }

                break;

            case JobAction.修改:
                options = _taskList
                          .FirstOrDefault(x => x.TaskName == taskOptions.TaskName && x.GroupName == taskOptions.GroupName);
                //移除以前的配置
                if (options != null)
                {
                    _taskList.Remove(options);
                }

                //生成任务并添加新配置
                result = taskOptions.AddJob(schedulerFactory).GetAwaiter().GetResult();
                break;

            case JobAction.暂停:
            case JobAction.开启:
            case JobAction.停止:
            case JobAction.立即执行:
                options = _taskList
                          .FirstOrDefault(x => x.TaskName == taskOptions.TaskName && x.GroupName == taskOptions.GroupName);
                if (action == JobAction.暂停)
                {
                    options.Status = (int)TriggerState.Paused;
                }
                else if (action == JobAction.停止)
                {
                    options.Status = (int)action;
                }
                else
                {
                    options.Status = (int)TriggerState.Normal;
                }
                break;
            }

            //生成配置文件
            FileQuartz.WriteJobConfig(_taskList);
            FileQuartz.WriteJobAction(action, taskOptions.TaskName, taskOptions.GroupName,
                                      "操作对象:" + JsonConvert.SerializeObject(taskOptions));
            return(result);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 public IndexModel(
     ILogger <IndexModel> logger,
     ISchedulerFactory schedulerFactory)
 {
     _logger = logger;
     this.schedulerFactory = schedulerFactory;
 }
コード例 #4
0
ファイル: Service.cs プロジェクト: Jacobeom/git-first
        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();

            }
        }
        protected override void OnStart(string[] args)
        {
            string logPath = ConfigurationManager.AppSettings["LoggerPath"].ToString(); //establish con. string to fetch log path//

            Logger.ConfigureLogger(logPath);
            Logger.Info("........ On start ........");
            string scheduleTime = ConfigurationManager.AppSettings["Time"].ToString(); //schedules time how often the service to run//

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

            Logger.Info("........ Instantiate Schedular ........");
            IJobDetail transactionJob = JobBuilder.Create <PtacDealerExcelDataDBDump>()
                                        .WithIdentity("TransactionProcessing", "PtacDealer")
                                        .Build();

            Logger.Info("........ Instantiate Job ........");
            var trigger = TriggerBuilder.Create()
                          .WithIdentity("transactionTrigger", "PtacDealer")
                          .WithCronSchedule(scheduleTime.ToString())
                          .Build();

            Logger.Info("........ Instantiate trigger ........");
            sched.ScheduleJob(transactionJob, trigger);


            sched.Start();
            Logger.Info("........ Scheduled job ........");
        }
コード例 #6
0
        protected override void OnStart(string[] args)
        {
            // TODO:  在此处添加代码以启动服务。
            try {
                SetupErrorHandle();

                log.Info("WeatherService Starting...");
                NameValueCollection properties = new NameValueCollection();
                properties["quartz.scheduler.instanceName"] = "WeatherService";

                // set thread pool info
                properties["quartz.threadPool.type"]           = "Quartz.Simpl.SimpleThreadPool, Quartz";
                properties["quartz.threadPool.threadCount"]    = "5";
                properties["quartz.threadPool.threadPriority"] = "Normal";

                schedFact = new StdSchedulerFactory(properties);
                sched     = schedFact.GetScheduler();
                sched.Start();
                ConfigJobs();
                //ApplePushService.Start();
            } catch (Exception e) {
                log.Fatal("TSICService Fatal...", e);
                //Jobs.WatchDog.StatusWatchDogJob.SendWarningMsg(new List<string>() { "TSIC后台服务启动失败" });
                throw;
            }
        }
コード例 #7
0
        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();
        }
コード例 #8
0
ファイル: Billpay.cs プロジェクト: Josh-Yu/MVC4-Assignment
 public Billpay(ISchedulerFactory schedulerFactory)
 {
     this.schedulerFactory = schedulerFactory;
     //this fetches the schduler from the passed in schedulerFactory from global.asax.cs
     this.sched = schedulerFactory.GetScheduler();
     // Debug.WriteLine("Inside BillPay 1st construtor - passed in factory" + DateTime.Now.ToString());
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: kamranayub/tech.pro
        static Program() {

            // Create a regular old Quartz scheduler
            SchedulerFactory = new StdSchedulerFactory();
            Scheduler = SchedulerFactory.GetScheduler();

        }
コード例 #10
0
        public void RunStartActions()
        {
            Log4netLogger.Info(MethodBase.GetCurrentMethod().DeclaringType, "Windows service OnStart");
            try
            {
                FeederHandler.Instance.Connector = new RedisConnector(ConfigurationManager.AppSettings["redisserver"]);
                using (RedisStressContext ctx = new RedisStressContext())
                {
                    FeederHandler.Instance.ImeiList = ctx.Products.Select(p => p.Imei).ToList();
                }
                Log4netLogger.Info(MethodBase.GetCurrentMethod().DeclaringType, $"Loaded {FeederHandler.Instance.ImeiList.Count} IMEIs from SQL Server database into memory.");

                #region Quartz

                _schedulerFactory = new StdSchedulerFactory();
                _scheduler        = _schedulerFactory.GetScheduler();
                IJobDetail job     = JobBuilder.Create <HeartbeatFeeder>().WithIdentity("StatusFeederJob", "StatusFeederGroup").Build();
                ITrigger   trigger = TriggerBuilder.Create().WithIdentity("StatusFeederTrigger", "StatusFeederGroup").WithCronSchedule(ConfigurationManager.AppSettings["StatusFeederCron"], x => x.InTimeZone(TimeZoneInfo.FindSystemTimeZoneById("UTC"))).Build();
                _scheduler.ScheduleJob(job, trigger);
                _scheduler.Start();

                #endregion
            }
            catch (Exception ex)
            {
                Log4netLogger.Error(MethodBase.GetCurrentMethod().DeclaringType, ex);
            }
        }
コード例 #11
0
 public JobHostedService(IServiceProvider appApplicationServices)
 {
     _logger           = appApplicationServices.GetService <ILogger <JobHostedService> >();
     _schedulerFactory = appApplicationServices.GetService <ISchedulerFactory>();
     _jobFactory       = appApplicationServices.GetService <IJobFactory>();
     _jobMetadata      = appApplicationServices.GetService <JobMetadata>();
 }
コード例 #12
0
 static Program()
 {
     XmlConfigurator.Configure();
     // Create a regular old Quartz scheduler
     SchedulerFactory = new StdSchedulerFactory();
     Scheduler = SchedulerFactory.GetScheduler();
 }
コード例 #13
0
 public QuartzHostedService(
     ISchedulerFactory schedulerFactory,
     IOptions <QuartzHostedServiceOptions> options)
 {
     this.schedulerFactory = schedulerFactory;
     this.options          = options;
 }
コード例 #14
0
ファイル: JobsManager.cs プロジェクト: JolyneStone/Rye
 public JobsManager()
 {
     schedulerFactory = new StdSchedulerFactory();
     System.Threading.Tasks.Task <IScheduler> _scheduler = schedulerFactory.GetScheduler();
     _scheduler.Wait();
     scheduler = _scheduler.Result;
 }
コード例 #15
0
        protected async override void OnStart(string[] args)
        {
            try
            {
                //Configure Container
                IContainer container = Helpers.IocConfig.ConfigureContainer();

                //Configure LogProvider
                //Quartz.Logging.LogProvider.SetCurrentLogProvider(new Logging.NLogProvider());
                Quartz.Logging.LogProvider.SetCurrentLogProvider(new Logging.ConsoleLogProvider());

                //StdSchedulerFactory factory = new StdSchedulerFactory();
                ISchedulerFactory factory = container.Resolve <ISchedulerFactory>();
                scheduler = await factory.GetScheduler();

                //Start scheduler
                await scheduler.Start();

                //Get All Jobs
                var lstJobs = JobFactory.GetAllJobs();

                foreach (var jobItem in lstJobs)
                {
                    //Define the job
                    IJobDetail job = JobBuilder.Create(jobItem.JobType)
                                     .WithIdentity(jobItem.Name, "groupTools")
                                     .Build();

                    //Trigger the job to run now, and then repeat by Interval
                    ITrigger trigger = null;
                    if (jobItem.Interval != 0)
                    {
                        trigger = TriggerBuilder.Create()
                                  .WithIdentity("trigger" + jobItem.Number, "groupTools")
                                  .StartNow()
                                  .WithSimpleSchedule(x => x
                                                      .WithIntervalInSeconds(jobItem.Interval)
                                                      .RepeatForever())
                                  .Build();
                    }
                    else
                    {
                        trigger = TriggerBuilder.Create()
                                  .WithIdentity("trigger" + jobItem.Number, "groupTools")
                                  .StartNow()
                                  .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(jobItem.DailyAtHour, jobItem.DailyAtMinute))
                                  .Build();
                    }

                    //Tell quartz to schedule the job using our trigger
                    await scheduler.ScheduleJob(job, trigger);
                }
            }
            catch (SchedulerException se)
            {
                Console.WriteLine(se);
            }

            Logger.Info("Service Started");
        }
コード例 #16
0
ファイル: JobsProgress.aspx.cs プロジェクト: syurov/rt.srz
        private void LoadControlsData()
        {
            ISchedulerFactory schedulerFactory = ObjectFactory.GetInstance<ISchedulerFactory>();
              var scheduler = schedulerFactory.GetScheduler();
              var jobs = scheduler.GetCurrentlyExecutingJobs();

              List<JobData> jobList = new List<JobData>();
              jobList.AddRange(jobs.Select(x => new JobData()
              {
            GroupName = x.Trigger.Key.Name,
            Name = x.JobDetail.Key.ToString(),
            Datails = (x.JobDetail.JobDataMap["datails"] ?? string.Empty).ToString(),
            Position = x.JobDetail.JobDataMap["progress"] != null ?
              (int)x.JobDetail.JobDataMap["progress"] : 0
              }));

              if (jobList.Count == 0)
              {
            lbNoDataText.Visible = true;
            griddiv.Visible = false;
              }
              else
              {
            lbNoDataText.Visible = false;
            griddiv.Visible = true;
              }

              GridGroupHelper<JobData> helper = new GridGroupHelper<JobData>(x => x.GroupName);
              grid.DataSource = helper.GetDataList(grid, x => x.RecordNumber, jobList);
              grid.DataBind();
        }
コード例 #17
0
        //获取类名

        public OpenJobsService(IDbContext context, ISchedulerFactory schedulerFactory, IJobFactory iocJobfactory)
        {
            repository            = new RepositoryBase <OpenJobEntity>(context);
            uniwork               = new RepositoryBase(context);
            _scheduler            = schedulerFactory.GetScheduler().Result;
            _scheduler.JobFactory = iocJobfactory;
        }
コード例 #18
0
 protected BaseSchedulersFactory(
     IServiceProvider container,
     ISchedulerFactory schedulerFactory)
 {
     _container        = container;
     _schedulerFactory = schedulerFactory ?? throw new ArgumentNullException(nameof(schedulerFactory));
 }
コード例 #19
0
 public QuartzHostedService(
     ISchedulerFactory schedulerFactory,
     IJobFactory jobFactory)
 {
     _schedulerFactory = schedulerFactory;
     _jobFactory       = jobFactory;
 }
コード例 #20
0
 public QuartzHostedService(ISchedulerFactory schedulerFactory,
                            IJobFactory jobFactory, IEnumerable <JobSchedule> jobSchedules)
 {
     _jobFactory       = jobFactory;
     _jobSchedules     = jobSchedules;
     _schedulerFactory = schedulerFactory;
 }
コード例 #21
0
ファイル: QuartzServer.cs プロジェクト: redrhino/autoMT4
 public void Initialize()
 {
     _logger.DebugFormat("Start to Initialize instance of Quartz server");
     _schedulerFactory = new StdSchedulerFactory();
     _scheduler = _schedulerFactory.GetScheduler();
     _scheduler.Start();
 }
コード例 #22
0
ファイル: SchedulerPool.cs プロジェクト: bczang2/JobScheduler
 static SchedulerPool()
 {
     if (schedulerFactory == null)
     {
         schedulerFactory = new StdSchedulerFactory(NameValueCollectionPool.NameValue);
     }
 }
コード例 #23
0
 public QuartzStartup(IJobFactory iocJobfactory, ILogger <QuartzStartup> logger, ISchedulerFactory schedulerFactory)
 {
     this._logger = logger;
     //1、声明一个调度工厂
     this._schedulerFactory = schedulerFactory;
     this._iocJobfactory    = iocJobfactory;
 }
コード例 #24
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="QuartzServer" /> class. The given internal jobs will be executed once
 ///     and
 ///     then scheduled as normal jobs
 /// </summary>
 public QuartzServer(IJobFactory jobFactory, IJobListener jobListener, ISchedulerFactory factory, IInternalJob[] internalJobs)
 {
     _jobFactory       = jobFactory;
     _jobListener      = jobListener;
     _internalJobs     = internalJobs;
     _schedulerFactory = factory;
 }
コード例 #25
0
        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);
            }
        }
コード例 #26
0
ファイル: Billpay.cs プロジェクト: Josh-Yu/MVC4-Assignment
 public Billpay(ISchedulerFactory schedulerFactory)
 {
     this.schedulerFactory = schedulerFactory;
     //this fetches the schduler from the passed in schedulerFactory from global.asax.cs
     this.sched = schedulerFactory.GetScheduler();
        // Debug.WriteLine("Inside BillPay 1st construtor - passed in factory" + DateTime.Now.ToString());
 }
コード例 #27
0
ファイル: Service1.cs プロジェクト: pyfxl/fxlweb
        public Service1()
        {
            InitializeComponent();

            schedulerFactory = new StdSchedulerFactory();
            scheduler = schedulerFactory.GetScheduler();
        }
コード例 #28
0
        public static async void Init()
        {
            sf    = new StdSchedulerFactory();
            sched = await sf.GetScheduler();

            await sched.Start();
        }
コード例 #29
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="question"></param>
 /// <param name="answer"></param>
 /// <param name="schedulerFactory"></param>
 public StandardTriviaQuestion(string question, string answer, ISchedulerFactory schedulerFactory)
 {
     _scheduler    = schedulerFactory.GenerateScheduler();
     Question      = question;
     Answer        = answer;
     _parsedAnswer = answer.ToLower().Trim(); //TODO strip non ascii characters from this
 }
コード例 #30
0
 static QuartzHelper()
 {
     NameValueCollection props = new NameValueCollection();
     props.Add("quartz.scheduler.instanceName", QuartzHelperScheulerName);
     sf = new StdSchedulerFactory(props);
     sched = sf.GetScheduler();
 }
コード例 #31
0
ファイル: Class1.cs プロジェクト: gw850402/ISL
        public void Star()
        {
            //创建一个调度器
            factory   = new StdSchedulerFactory();
            scheduler = factory.GetScheduler();
            scheduler.Start();

            //2、创建一个任务
            IJobDetail job = JobBuilder.Create <TimeJob>().WithIdentity("job1", "group1").Build();;


            //3、创建一个触发器
            //DateTimeOffset runTime = DateBuilder.EvenMinuteDate(DateTimeOffset.UtcNow);
            ITrigger trigger = TriggerBuilder.Create()
                               .WithIdentity("trigger1", "group1")
                               .WithCronSchedule("0/5 * * * * ?") //5秒执行一次
                                                                  //.StartAt(runTime)
                               .Build();


            // 设置初始参数
            //job.JobDataMap.Put("", "SELECT * FROM [ACT_ID_USER]");



            //4、将任务与触发器添加到调度器中
            scheduler.ScheduleJob(job, trigger);

            //5、开始执行
            scheduler.Start();
        }
コード例 #32
0
        public void Run()
        {
            if (sf == null)
            {
                NameValueCollection properties = new NameValueCollection();
                properties["quartz.scheduler.instanceName"] = "XmlConfiguredInstance";

                // set thread pool info
                properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
                properties["quartz.threadPool.threadCount"] = "5";
                properties["quartz.threadPool.threadPriority"] = "Normal";

                // job initialization plugin handles our xml reading, without it defaults are used
                properties["quartz.plugin.xml.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz";
                properties["quartz.plugin.xml.fileNames"] = "~/quartz_jobs.xml";
                sf = new StdSchedulerFactory(properties);
                log.Info("------- Initialization Complete -----------");
                log.Info("------- Not Scheduling any Jobs - relying on XML definitions --");
                log.Info("------- Starting Scheduler ----------------");
            }
            sched = sf.GetScheduler();
            // start the schedule
            sched.Start();
            log.Info("------- Started Scheduler -----------------");
        }
コード例 #33
0
 public void Initialize()
 {
     _logger.DebugFormat("Start to Initialize instance of Quartz server");
     _schedulerFactory = new StdSchedulerFactory();
     _scheduler        = _schedulerFactory.GetScheduler();
     _scheduler.Start();
 }
コード例 #34
0
ファイル: NetCellHost.cs プロジェクト: gcvalderrama/netcell
        public void Start()
        {
            //Configure Container
            this.Container =  new NetCellDependencies().Configure();
            this.Container.RegisterInstance<IConnectionFactory>(new NMSConnectionFactory(MESSAGING_HOST));

            //Configure Mapper
            var engine = new App_Start.NetCellMapping().Configure();
            Container.RegisterInstance<AutoMapper.IMappingEngine>(engine);

            // Configure API
            this.ApiHost = WebApp.Start(BASE_HOST, (appBuilder) => {
                HttpConfiguration apiConfig = new HttpConfiguration();
                apiConfig.DependencyResolver = new UnityResolver(this.Container);
                apiConfig.Services.Replace(typeof(IAssembliesResolver), new CustomAssemblyResolver());
                apiConfig.MapHttpAttributeRoutes();
                apiConfig.EnsureInitialized();
                var desc = apiConfig.Services.GetApiExplorer().ApiDescriptions;
                appBuilder.UseWebApi(apiConfig);
            });

            //Configure Quartz
            NameValueCollection config = (NameValueCollection)ConfigurationManager.GetSection("quartz");
            this.SchedulerFactory = new StdSchedulerFactory(config);
            this.Scheduler = this.SchedulerFactory.GetScheduler();
            this.Scheduler.JobFactory = new NetCellJobFactory(Container);
            this.Scheduler.Start();
        }
コード例 #35
0
        /// <summary>
        /// 添加作业
        /// </summary>
        /// <param name="taskOptions"></param>
        /// <param name="schedulerFactory"></param>
        /// <param name="init">是否初始化,否=需要重新生成配置文件,是=不重新生成配置文件</param>
        /// <returns></returns>
        public static async Task <object> AddJob(this TaskOptions taskOptions, ISchedulerFactory schedulerFactory, bool init = false)
        {
            try
            {
                //元组用于验证CRON表达式是否正确
                (bool, string)validExpression = taskOptions.Interval.IsValidExpression();
                if (!validExpression.Item1)
                {
                    return new { status = false, msg = validExpression.Item2 }
                }
                ;

                //元组用于验证作业是否已经存在
                (bool, object)result = taskOptions.Exists(init);
                if (!result.Item1)
                {
                    return(result.Item2);
                }
                if (!init)
                {
                    _taskList.Add(taskOptions);
                    FileQuartz.WriteJobConfig(_taskList);
                }

                IJobDetail job = JobBuilder.Create <HttpResultful>()
                                 .WithIdentity(taskOptions.TaskName, taskOptions.GroupName)
                                 .Build();
                ITrigger trigger = TriggerBuilder.Create()
                                   .WithIdentity(taskOptions.TaskName, taskOptions.GroupName)
                                   .StartNow().WithDescription(taskOptions.Describe)
                                   .WithCronSchedule(taskOptions.Interval)
                                   .Build();
                IScheduler scheduler = await schedulerFactory.GetScheduler();

                await scheduler.ScheduleJob(job, trigger);

                if (taskOptions.Status == (int)TriggerState.Normal)
                {
                    await scheduler.Start();
                }
                else
                {
                    await schedulerFactory.Pause(taskOptions);

                    //TODO:更新日志
                    FileQuartz.WriteStartLog($"作业:{taskOptions.TaskName},分组:{taskOptions.GroupName},新建时未启动原因,状态为:{taskOptions.Status}");
                }
                //TODO:更新动作日志
                if (!init)
                {
                    FileQuartz.WriteJobAction(JobAction.新增, taskOptions.TaskName, taskOptions.GroupName);
                }
            }
            catch (Exception ex)
            {
                return(new { status = false, msg = ex.Message });
            }
            return(new { status = true });
        }
コード例 #36
0
ファイル: Startup.cs プロジェクト: hmsfeng/IoTSharp
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISchedulerFactory factory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();
            app.UseCors(option => option
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseDefaultFiles();
            app.UseStaticFiles();
            app.UseSilkierQuartz(new  SilkierQuartzOptions()
            {
                Scheduler         = factory.GetScheduler().Result,
                VirtualPathRoot   = "/quartzmin",
                ProductName       = "IoTSharp",
                DefaultDateFormat = "yyyy-MM-dd",
                DefaultTimeFormat = "HH:mm:ss",
                UseLocalTime      = true
            });
            app.UseIotSharpMqttServer();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                //   endpoints.MapMqtt("/mqtt");
            });
            app.UseSwaggerUi3();
            app.UseOpenApi();



            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });
            app.UseResponseCompression(); // No need if you use IIS, but really something good for Kestrel!


            app.UseHealthChecks("/healthz", new HealthCheckOptions
            {
                Predicate      = _ => true,
                ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
            });
            app.UseHealthChecksUI();
        }
コード例 #37
0
ファイル: Service.cs プロジェクト: davelondon/dontstayin
		public Service()
		{
			InitializeComponent();
			schedulerFactory = new StdSchedulerFactory(Common.Properties.QuartzSchedulerProperties);
			scheduler = schedulerFactory.GetScheduler();
			scheduler.AddGlobalJobListener(new MemcachedLogJobListener());
			AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
		}
コード例 #38
0
ファイル: StationService.cs プロジェクト: xu0830/MVCCoreDemo
 public StationService(IRepository <TicketTask> _ticketTaskRepository,
                       ISchedulerFactory _schedulerFactory,
                       IMapper _mapper)
 {
     ticketTaskRepository = _ticketTaskRepository;
     schedulerFactory     = _schedulerFactory;
     mapper = _mapper;
 }
コード例 #39
0
 public BackgroundJobService(IServiceProvider serviceProvider)
 {
     _serviceProvider      = serviceProvider;
     _stdSchedulerFactory  = new StdSchedulerFactory();
     _scheduler            = _stdSchedulerFactory.GetScheduler().Result;
     _scheduler.JobFactory = new JobFactory(_serviceProvider);
     _scheduler.Start().Wait();
 }
コード例 #40
0
 public UpdateTriggersJob(ISchedulerFactory schedulerFactory,
                          IJobSchedulesProvider jobSchedulesProvider,
                          ILogger <UpdateTriggersJob> logger)
 {
     _schedulerFactory     = schedulerFactory;
     _jobSchedulesProvider = jobSchedulesProvider;
     _logger = logger;
 }
コード例 #41
0
ファイル: Program.cs プロジェクト: beginor/quartz-demo
        private static async Task Run()
        {
            schedulerFactory = new StdSchedulerFactory();

            scheduler = await schedulerFactory.GetScheduler().ConfigureAwait(false);

            await scheduler.Start().ConfigureAwait(false);
        }
コード例 #42
0
 protected override void Initialize()
 {            
     Container.RegisterType<IJobFactory, UnityJobFactory>();
     Container.RegisterInstance<ISchedulerFactory>(new StdSchedulerFactory());
     _schedulerfactory = Container.Resolve<ISchedulerFactory>();
     _scheduler = _schedulerfactory.GetScheduler();
     _scheduler.JobFactory = Container.Resolve<IJobFactory>();
     _scheduler.Start();
 }
コード例 #43
0
ファイル: MdnMonitorWinSrv.cs プロジェクト: DM-TOR/nhin-d
 /// <summary>
 /// method to initialize fields utilized by the service
 /// </summary>
 private void InitializeService()
 {
     m_diagnostics.ServiceInitializing();
    
     m_schedulerfactory = new StdSchedulerFactory();
     m_scheduler = m_schedulerfactory.GetScheduler();
     
     m_diagnostics.ServiceInitializingComplete();
 }
コード例 #44
0
ファイル: QMServer.cs プロジェクト: bushadam/QM
 public QMServer() {
     try {
         this.Factory = new StdSchedulerFactory();
         this.Scheduler = this.Factory.GetScheduler();
         this.Scheduler.JobFactory = new IsolatedJobFactory();
         this.CanStart = true;
     } catch {
         this.CanStart = false;
     }
 }
コード例 #45
0
ファイル: Service.cs プロジェクト: k-best/BackgroundJobHost
 public Service(Logger logger, ISchedulerFactory schedulerFactory, IJobFactory jobFactory, IJobActivator jobActivator, IEnumerable<IJobConfiguration> jobsConfig, WcfServiceHostFactory serviceHostFactory)
 {
     _logger = logger;
     _schedulerFactory = schedulerFactory;
     _jobFactory = jobFactory;
     _jobActivator = jobActivator;
     _jobsConfig = jobsConfig;
     _serviceHostFactory = serviceHostFactory;
     ServiceName = Program.ServiceName;
 }
コード例 #46
0
 internal static NancyHost Start(ISchedulerFactory factory, Uri hostUrl, ISet<string> ignoredScheduleSet)
 {
     Factory = factory;
     IgnoredScheduleSet = ignoredScheduleSet;
     var defaultNancyBootstrapper = new QuartzConsoleBootstrapper();
     var nancyHost = new NancyHost(hostUrl, defaultNancyBootstrapper);
     nancyHost.Start();
     Log.InfoFormat("QuartzNet Console succesfully started on {0}", new Uri(hostUrl, "quartzconsole"));
     return nancyHost;
 }
コード例 #47
0
ファイル: QuartzServer.cs プロジェクト: aries544/eXpand
 /// <summary>
 /// Initializes the instance of the <see cref="QuartzServer"/> class.
 /// </summary>
 public virtual void Initialize(XafApplication application) {
     try {
         _schedulerFactory = CreateSchedulerFactory(application);
         _scheduler = GetScheduler();
         _scheduler.ListenerManager.AddJobListener(new XpandJobListener(), EverythingMatcher<JobKey>.AllJobs());
         _scheduler.ListenerManager.AddTriggerListener(new XpandTriggerListener(), EverythingMatcher<JobKey>.AllTriggers());
     } catch (Exception e) {
         _logger.Error("Server initialization failed:" + e.Message, e);
         throw;
     }
 }
コード例 #48
0
        public Scheduler(int repeatInterval, ParsingService service)
        {
            this.service = service;
            RepeatInterval = TimeSpan.FromSeconds(repeatInterval);
            // construct a scheduler factory
            schedFact = new StdSchedulerFactory();

            // get a scheduler
            sched = schedFact.GetScheduler();
            sched.Start();
            State = RunningState.Waiting;
        }
コード例 #49
0
ファイル: QuartzServer.cs プロジェクト: BredStik/quartznet
 /// <summary>
 /// Initializes the instance of the <see cref="QuartzServer"/> class.
 /// </summary>
 public virtual void Initialize()
 {
     try
     {
         schedulerFactory = CreateSchedulerFactory();
         scheduler = GetScheduler();
     }
     catch (Exception e)
     {
         logger.Error("Server initialization failed:" + e.Message, e);
         throw;
     }
 }
コード例 #50
0
ファイル: JobScheduler.cs プロジェクト: teamaton/speak-lib
        /// <summary>
        /// Creates a new JobScheduler which provides an in-process scheduler.
        /// </summary>
        /// <param name="groupName">Name for a group of jobs and triggers.</param>
        public JobScheduler(string groupName)
        {
            GroupName = groupName;
            _properties = new NameValueCollection();
            _properties["quartz.scheduler.instanceName"] = "RemoteServer";

            // set thread pool info
            _properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
            _properties["quartz.threadPool.threadCount"] = "5";
            _properties["quartz.threadPool.threadPriority"] = "Normal";

            _schedulerFactory = new StdSchedulerFactory(_properties);
        }
コード例 #51
0
        public QuartzScheduler(string server, int port, string scheduler)
        {
            Address = string.Format("tcp://{0}:{1}/{2}", server, port, scheduler);
            _schedulerFactory = new StdSchedulerFactory(getProperties(Address));

            try
            {
                _scheduler = _schedulerFactory.GetScheduler();
            }
            catch (SchedulerException)
            {
                MessageBox.Show("Unable to connect to the specified server", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #52
0
 /// <summary>
 /// 调度工厂
 /// </summary>
 /// <returns></returns>
 public static ISchedulerFactory GetSchedulerFactory()
 {
     if (sf == null)
     {
         lock (lockObj1)
         {
             if (sf == null)
             {
                 sf = new StdSchedulerFactory();
             }
         }
     }
     return sf;
 }
コード例 #53
0
ファイル: Program.cs プロジェクト: trulstveoy/Sandbox
        private static void NewTrigger(ISchedulerFactory schedulerFactory)
        {
            Console.WriteLine("New trigger...");

            var scheduler = schedulerFactory.GetScheduler();
            var trigger = TriggerBuilder
                    .Create()
                    .WithIdentity(TriggerName)
                    .ForJob(new JobKey(JobName))
                    .WithCronSchedule(Every2Seconds)
                    .Build();

            scheduler.ScheduleJob(trigger);
        }
コード例 #54
0
ファイル: Global.asax.cs プロジェクト: nsillvan/SNMPDemo
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Construct a scheduler factory
            SchedulerFactory = new StdSchedulerFactory();
            // Get a scheduler
            Scheduler = SchedulerFactory.GetScheduler();
            // Start the scheduler
            Scheduler.Start();
        }
コード例 #55
0
        public SelfUpdaterManager()
        {
            //instancio el schedule
            if (_sf == null) {
                var properties = new NameValueCollection();

                properties["quartz.scheduler.instanceName"] = "SelfUpdaterScheduler";
                properties["quartz.scheduler.instanceId"] = "SelfUpdaterinstance_one";
                properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
                properties["quartz.threadPool.threadCount"] = "1";
                properties["quartz.threadPool.threadPriority"] = "Normal";

                _sf = new StdSchedulerFactory(properties);

            }
        }
コード例 #56
0
ファイル: Scheduler.cs プロジェクト: feik/crystal-quartz
            public Scheduler(string server, int port, string scheduler)
            {
                Address = string.Format("tcp://{0}:{1}/{2}", server, port, scheduler);
                _schedulerFactory = new StdSchedulerFactory(GetProperties(Address));

                try
                {
                    Instance = _schedulerFactory.GetScheduler();

                    if (!Instance.IsStarted)
                        Instance.Start();
                }
                catch (SchedulerException ex)
                {
                    throw new Exception(string.Format("Failed: {0}", ex.Message));
                }
            }
コード例 #57
0
ファイル: ScheduledTasks.cs プロジェクト: garysharp/Disco
        public static void InitalizeScheduledTasks(DiscoDataContext database, ISchedulerFactory SchedulerFactory, bool InitiallySchedule)
        {
            ScheduledTasksLog.LogInitializingScheduledTasks();

            try
            {
                _TaskScheduler = SchedulerFactory.GetScheduler();
                _TaskScheduler.Start();

                // Scheduled Cleanup
                ScheduledTaskCleanup.Schedule(_TaskScheduler);

                if (InitiallySchedule)
                {
                    // Discover DiscoScheduledTask
                    var appDomain = AppDomain.CurrentDomain;
                    var servicesAssemblyName = typeof(ScheduledTask).Assembly.GetName().Name;

                    var scheduledTaskTypes = (from a in appDomain.GetAssemblies()
                                              where !a.GlobalAssemblyCache &&
                                                !a.IsDynamic &&
                                                (a.GetName().Name == servicesAssemblyName || a.GetReferencedAssemblies().Any(ra => ra.Name == servicesAssemblyName))
                                              from type in a.GetTypes()
                                              where typeof(ScheduledTask).IsAssignableFrom(type) && !type.IsAbstract
                                              select type);
                    foreach (Type scheduledTaskType in scheduledTaskTypes)
                    {
                        ScheduledTask instance = (ScheduledTask)Activator.CreateInstance(scheduledTaskType);
                        try
                        {
                            instance.InitalizeScheduledTask(database);
                        }
                        catch (Exception ex)
                        {
                            ScheduledTasksLog.LogInitializeException(ex, scheduledTaskType);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ScheduledTasksLog.LogInitializeException(ex);
            }

        }
コード例 #58
0
ファイル: Program.cs プロジェクト: evercam/snapmail
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main()
 {
     AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
     SchedulerFactory = new StdSchedulerFactory();
     Scheduler = SchedulerFactory.GetScheduler();
     Scheduler.Start();
     //#if(!DEBUG)
     ServiceBase[] ServicesToRun;
     ServicesToRun = new ServiceBase[]
     {
         new Service1()
     };
     ServiceBase.Run(ServicesToRun);
     //#else
     //Service1 myServ = new Service1();
     //myServ.Start();
     //#endif
 }
コード例 #59
0
ファイル: WorkerRole.cs プロジェクト: stemarie/Quartz.Azure
        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.

            // construct a scheduler factory
            schedFact = new StdSchedulerFactory();

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

            // Start the Scheduler
            sched.Start();

            return base.OnStart();
        }
コード例 #60
0
        public static IScheduler GetCurrentSchedular()
        {
            if (_scheduler == null)
            {
                //start quartz schedular
                var properties = new NameValueCollection();
                properties["quartz.scheduler.instanceName"] = "RemoteServer";
                // set thread pool info
                properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
                properties["quartz.threadPool.threadCount"] = "5";
                properties["quartz.threadPool.threadPriority"] = "Normal";

                _schedulerFactory = new StdSchedulerFactory(properties);
                _scheduler = _schedulerFactory.GetScheduler();
                _scheduler.Start();
            }
            return _scheduler;

        }