private void Init(NameValueCollection props) { if (props == null) { props = new NameValueCollection(); } if (String.IsNullOrWhiteSpace(props.Get(StdSchedulerFactory.PropertySchedulerInstanceName))) { props.Set(StdSchedulerFactory.PropertySchedulerInstanceName, Guid.NewGuid().ToString()); } ActorTaskScheduler.RunTask(async() => { if (props == null) { Scheduler = await new StdSchedulerFactory().GetScheduler(); } else { Scheduler = await new StdSchedulerFactory(props).GetScheduler(); } await Scheduler.Start(); OnSchedulerCreated(Scheduler); }); }
public void Initialize(string pluginName, Quartz.IScheduler sched) { logger.Info("SmartNodePlugin 开始初始化"); mName = pluginName; mSched = sched; logger.Info("SmartNodePlugin 初始化结束"); }
public void ExecuteScheduler() { try { StdSchedulerFactory factory = new StdSchedulerFactory(); Quartz.IScheduler scheduler = factory.GetScheduler(); // and start it off scheduler.Start(); // define the job and tie it to our HelloJob class IJobDetail job = JobBuilder.Create <ParseJob>() .WithIdentity("job1", "group1") .Build(); // Trigger the job to run now, and then repeat every 10 seconds ITrigger trigger = TriggerBuilder.Create() .WithIdentity("trigger1", "group1") .StartNow() .WithSimpleSchedule(x => x .WithInterval(new TimeSpan(10, 0, 0, 0)) .RepeatForever()) .Build(); // Tell quartz to schedule the job using our trigger scheduler.ScheduleJob(job, trigger); } catch (SchedulerException se) { Console.WriteLine(se); } }
public SchedulingActor(IScheduler scheduler) { _logger.Debug("Scheduling actor started at path {Path}", Self.Path); _scheduler = scheduler; Receive <ScheduleCommand>(message => Schedule(message)); Receive <ScheduleMessage>(message => Schedule(message)); Receive <Unschedule>(message => Unschedule(message)); }
public SchedulingActor() { _publisher = Context.System.GetTransport(); _logger.Debug("Scheduling actor started at path {Path}", Self.Path); _scheduler = Context.System.GetExtension <SchedulingExtension>().Scheduler; ReceiveAsync <ScheduleCommandExecution>(Schedule); Receive <Unschedule>(message => Unschedule(message)); }
public ScheduleContainer() { var ssf = new StdSchedulerFactory(); Scheduler = ssf.GetScheduler(); Scheduler.Start(); Scheduler.Context.Add("Container", this); }
public QuartzCronSchedulerViaCommandLine(Options options, IJobFactory jobFactory, ILoggerFactoryAdapter loggerFactory) { _options = options; _scheduler = StdSchedulerFactory.GetDefaultScheduler(); _scheduler.JobFactory = jobFactory; LogManager.Adapter = loggerFactory; _logger = LogManager.GetLogger("Quartz.Net"); }
public SpiderController(PortalDbContext dbContext, PortalOptions options, Quartz.IScheduler sched, ILogger <SpiderController> logger) { _logger = logger; _dbContext = dbContext; _sched = sched; _options = options; }
public QuartzCronSchedulerViaInternalSchedule(Options options, List <Schedule> schedule, IJobFactory jobFactory, ILoggerFactoryAdapter loggerFactory) { _options = options; _schedule = schedule; _scheduler = StdSchedulerFactory.GetDefaultScheduler(); _scheduler.JobFactory = jobFactory; LogManager.Adapter = loggerFactory; _logger = LogManager.GetLogger("Quartz.Net"); }
public QuartzCronSchedulerViaCommandLine(Options options, IJobFactory jobFactory, ILoggerFactory loggerFactory) { _options = options; _scheduler = StdSchedulerFactory.GetDefaultScheduler().Result; _scheduler.JobFactory = jobFactory; Quartz.LogContext.SetCurrentLogProvider(loggerFactory); _logger = loggerFactory.CreateLogger("Quartz.Net"); }
/// <summary> /// 启动 /// </summary> public async Task StartAsync() { _scheduler = await GetScheduler(); if (_scheduler.IsStarted) { return; } await _scheduler.Start(); }
public Scheduler(ILog log) { _scheduler = StdSchedulerFactory .GetDefaultScheduler() .ConfigureAwait(true) .GetAwaiter() .GetResult(); _log = log; }
public override void Update(Quartz.IScheduler scheduler) { this.Scheduler = scheduler; this.Calendars = scheduler.GetCalendarNames().Select(n => new { Name = n, Calendar = scheduler.GetCalendar(n) }).ToDictionary(n => n.Name, n => n.Calendar); this.NotifyOfPropertyChange(() => this.Calendars); }
// Helpers private async Task <bool> InitialiseScheduler(CancellationToken cancellationToken = default) { // First time initialization of Scheduler quartzScheduler = await schedulerFactory.GetScheduler(cancellationToken); quartzScheduler.JobFactory = jobFactory; quartzScheduler.ListenerManager.AddJobListener(new JobListener(this)); // Load configuration return(await LoadConfiguration(cancellationToken)); }
public override void Update(Quartz.IScheduler scheduler) { this.Scheduler = scheduler; //NOT SUPPORT this.TriggerListeners = scheduler.ListenerManager.GetTriggerListeners().ToList(); this.SchedulerListeners = scheduler.ListenerManager.GetSchedulerListeners().ToList(); this.JobListeners = scheduler.ListenerManager.GetJobListeners().ToList(); this.NotifyOfPropertyChange(() => this.TriggerListeners); this.NotifyOfPropertyChange(() => this.SchedulerListeners); this.NotifyOfPropertyChange(() => this.JobListeners); }
/// <summary> /// 删除 /// </summary> /// <param name="scheduler"></param> /// <param name="dellist"></param> public static void deleteJob(Quartz.IScheduler scheduler, List <Config> dellist) { IList <JobKey> jlist = new List <Quartz.JobKey>(); foreach (var it in dellist) { JobKey key = new JobKey(it.jobname, it.groupname); jlist.Add(key); } scheduler.DeleteJobs(jlist); }
public async Task <bool> TryInitWithSchedule(IBot owner, string cronExpression) { Owner = owner; LogProvider.SetCurrentLogProvider(new ConsoleLogProvider()); var factory = new StdSchedulerFactory(); scheduler = await factory.GetScheduler(); bool ok = await TrySetSchedule(cronExpression, scheduler); return(ok); }
public IJob NewJob(TriggerFiredBundle bundle, Quartz.IScheduler scheduler) { try { var x = NinjectBootstrapper.Get(bundle.JobDetail.JobType); return((IJob)x); } catch (Exception err) { this.EventReporter.ExceptionForObject(err, bundle.JobDetail); throw; } }
public virtual void Initialize() { try { schedulerFactory = CreateSchedulerFactory(); scheduler = GetScheduler(); } catch (Exception e) { logger.Error("Server initialization failed:" + e.Message, e); throw; } }
public ExportDataService() { Thread.Sleep(5000); try { InitializeComponent(); Quartz.ISchedulerFactory schedulerFactory = new StdSchedulerFactory(); scheduler = schedulerFactory.GetScheduler(); } catch (Exception ex) { LogHelper.LogWriter("异常啦:" + ex); } }
public IJob NewJob(TriggerFiredBundle bundle, Quartz.IScheduler scheduler) { var scope = scopeFactory.CreateScope(); var job = scope.ServiceProvider.GetService(bundle.JobDetail.JobType) as IJob; if (job == null) { logger.LogError($"Could not create job of type: {bundle.JobDetail.JobType}, job will be paused!"); scheduler.PauseJob(bundle.JobDetail.Key); throw new ArgumentException($"Could not create job of type: {bundle.JobDetail.JobType}"); } this.scopes.Add(job.GetHashCode(), scope); return(job); }
/// <summary> ///添加一箱 /// </summary> /// <param name="scheduler"></param> /// <param name="item"></param> private static void addjob(Quartz.IScheduler scheduler, Core.Config item) { Assembly assembly = Assembly.Load(item.assemblyname); Type type = assembly.GetType(item.@namespace); IJobDetail job = JobBuilder.Create(type) .WithIdentity(item.jobname, item.groupname).Build(); // name "myJob", group "group1" var trigger = addTriger(item); scheduler.ScheduleJob(job, trigger.Build()); }
public void Stop() { if (_scheduler == null) { return; } if (_scheduler.Shutdown(waitForJobsToComplete: true).Wait(30000)) { _scheduler = null; } else { } _logger.LogCritical("Schedule job upload as application stopped"); }
/// <summary> /// 修改 /// </summary> /// <param name="scheduler"></param> /// <param name="modilist"></param> public static void modiJob(Quartz.IScheduler scheduler, List <Config> modilist) { // scheduler.GetTrigger(new TriggerKey( foreach (var item in modilist) { //var old = scheduler.GetTrigger(new TriggerKey(item.jobname + "trigger", "触发器组")); //if (old == null) // return; //var newtrigger = addTriger(item).Build(); //scheduler.RescheduleJob(old.Key, newtrigger); JobKey key = new JobKey(item.jobname, item.groupname); scheduler.DeleteJob(key); addjob(scheduler, item); } }
public Scheduler() { this.tirggers = new Dictionary <IScheduledJob, TriggerKey>(); //configuring logger LogProvider.SetCurrentLogProvider(new SchedulerLogProvider()); // Grab the Scheduler instance from the Factory NameValueCollection props = new NameValueCollection { { "quartz.serializer.type", "binary" } }; StdSchedulerFactory factory = new StdSchedulerFactory(props); this.scheduler = factory.GetScheduler().Result; // and start it off scheduler.Start().Wait(); }
public IJob NewJob(TriggerFiredBundle bundle, Quartz.IScheduler scheduler) { try { var genericType = typeof(AutofacJobWrapper <>); Type[] typeArgs = { bundle.JobDetail.JobType }; var actualType = genericType.MakeGenericType(typeArgs); var x = this.Context.Resolve(actualType); return((IJob)x); } catch (Exception err) { //using(var scope = this.Context.BeginLifetimeScope()) //{ // var reporter = scope.Resolve<IEventReporter>(); // reporter.ExceptionForObject(err, bundle.JobDetail); //} throw; } }
public void Start() { Log.Debug("Starting LIM Scheduler"); var properties = new NameValueCollection(); properties["quartz.scheduler.instanceName"] = "RemoteServer"; properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz"; properties["quartz.threadPool.threadCount"] = "5"; properties["quartz.threadPool.threadPriority"] = "Normal"; properties["quartz.plugin.xml.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz"; properties["quartz.plugin.xml.fileNames"] = "jobs.xml"; ISchedulerFactory schedulerFactory = new StdSchedulerFactory(properties); _scheduler = schedulerFactory.GetScheduler(); _scheduler.JobFactory = new JobFactory(_container); var bus = _container.Resolve<IAdvancedBus>(); var senderQueue = bus.QueueDeclare("DataPlatform.Integration.Sender"); var senderExchange = bus.ExchangeDeclare("DataPlatform.Integration.Sender", ExchangeType.Fanout); bus.Bind(senderExchange, senderQueue, string.Empty); var receiverQueue = bus.QueueDeclare("DataPlatform.Integration.Receiver"); var receiverExchange = bus.ExchangeDeclare("DataPlatform.Integration.Receiver", ExchangeType.Fanout); bus.Bind(receiverExchange, receiverQueue, string.Empty); bus.Consume(senderQueue, q => q.Add<PackageResponseMessage>( (message, info) => new SenderConsumers<PackageResponseMessage>(message, _container))); bus.Consume(receiverQueue, q => q.Add<PackageConfigurationMessage>( (message, info) => new ReceiverConsumers<PackageConfigurationMessage>(message, _container))); _scheduler.Start(); Log.Debug("LIM Scheduler has started"); }
protected override void OnStart(string[] args) { Tools.Logger.LogToFile(new Models.LogEntry(0, "OnStart", "Service Started Successfully")); // First, initialize Quartz.NET as usual. In this sample app I'll configure Quartz.NET by code. var schedulerFactory = new StdSchedulerFactory(); scheduler = schedulerFactory.GetScheduler(); scheduler.Start(); scheduler.ListenerManager.AddJobListener(new Listeners.GlobalJobListener()); scheduler.ListenerManager.AddTriggerListener(new Listeners.GlobalTriggerListener()); // A sample trigger and job var SoapTrigger = TriggerBuilder.Create() .WithIdentity("CheckTrigger").WithSchedule(Quartz.SimpleScheduleBuilder.RepeatMinutelyForever(2)) .StartNow() .Build(); var SoapJob = new JobDetailImpl("SoapJob", "Soap", typeof(Jobs.SoapJob)); scheduler.ScheduleJob(SoapJob, SoapTrigger); scheduler.AddCalendar("myCalendar", new Calendars.RiskCalendar { Description = "Risk Calendar" }, false, false); }
public async Task <string> Start() { //2、通过调度工厂获得调度器 _scheduler = await _schedulerFactory.GetScheduler(); _scheduler.JobFactory = this._iocJobfactory;// 替换默认工厂 //3、开启调度器 await _scheduler.Start(); //4、创建一个触发器 var trigger = TriggerBuilder.Create() .WithSimpleSchedule(x => x.WithIntervalInSeconds(2).RepeatForever())//每两秒执行一次 .Build(); //5、创建任务 var jobDetail = JobBuilder.Create <OpcServerSyncjob>() .WithIdentity("job", "group") .Build(); //6、将触发器和任务器绑定到调度器中 await _scheduler.ScheduleJob(jobDetail, trigger); return(await Task.FromResult("将触发器和任务器绑定到调度器中完成")); }
public void Start() { var cronExpression = ConfigurationManager.AppSettings["CronSchedule"]; if (!CronExpression.IsValidExpression(cronExpression)) { _log.Warn("Couldn't start the scheduler. Cron expression is invalid."); return; } if (string.IsNullOrEmpty(cronExpression)) { _log.Warn("No schedule set."); return; } _log.Info("Starting the scheduler..."); _quartzScheduler = _schedulerFactory.GetScheduler(); _quartzScheduler.JobFactory = new NinjectJobFactory(_resolutionRoot); _quartzScheduler.Start(); var job = JobBuilder.Create <PushNotificationJob>() .WithIdentity("job1", "group1") .Build(); var trigger = TriggerBuilder.Create() .WithIdentity("trigger1", "group1") .StartNow() .WithSchedule(CronScheduleBuilder.CronSchedule(cronExpression)) //.WithSimpleSchedule(x => x // .WithIntervalInSeconds(120) // .RepeatForever()) // .ForJob(job) .Build(); _quartzScheduler.ScheduleJob(job, trigger); }
private async Task <bool> TrySetSchedule(string cronExpression, Quartz.IScheduler scheduler) { if (!CronExpression.IsValidExpression(cronExpression)) { return(false); } IJobDetail job = JobBuilder.Create <PostWeeklySeedJob>() .WithIdentity("WeeklySeedJob", "Group1") .Build(); ITrigger trigger = TriggerBuilder.Create() .WithIdentity("schedule", "Group1") .StartNow() .WithCronSchedule(cronExpression) .Build(); await scheduler.Clear(); await scheduler.ScheduleJob(job, trigger); return(true); }
public void Start() { Log.Debug("Starting Cache Worker"); var properties = new NameValueCollection(); properties["quartz.scheduler.instanceName"] = "RemoteServer"; properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz"; properties["quartz.threadPool.threadCount"] = "5"; properties["quartz.threadPool.threadPriority"] = "Normal"; properties["quartz.plugin.xml.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz"; properties["quartz.plugin.xml.fileNames"] = "jobs.xml"; ISchedulerFactory schedulerFactory = new StdSchedulerFactory(properties); _scheduler = schedulerFactory.GetScheduler(); _scheduler.JobFactory = new JobFactory(_container); _scheduler.Start(); _bus = _container.Resolve<IAdvancedBus>(); var receiverQueue = _bus.QueueDeclare("DataPlatform.DataProvider.Cache.Receiver"); var receiverExchange = _bus.ExchangeDeclare("DataPlatform.DataProvider.Cache.Receiver", ExchangeType.Fanout); _bus.Bind(receiverExchange, receiverQueue, string.Empty); _bus.Consume(receiverQueue, q => q .Add<ClearCacheCommand>( (message, info) => new ReceiverConsumers<ClearCacheCommand>(message, _container)) .Add<RefreshCacheCommand>( (message, info) => new ReceiverConsumers<RefreshCacheCommand>(message, _container)) .Add<RestartCacheDataStoreCommand>( (message, info) => new ReceiverConsumers<RestartCacheDataStoreCommand>(message, _container))); Log.Debug("Cache Worker has started"); }
} // End Constructor public async System.Threading.Tasks.Task StartJobs(System.Threading.CancellationToken stoppingToken) { this._stopppingToken = stoppingToken; this._schedulerFactory = new Quartz.Impl.StdSchedulerFactory(); this._scheduler = await this._schedulerFactory.GetScheduler(); await this._scheduler.Start(); Quartz.IJobDetail job1 = Quartz.JobBuilder.Create <Job1>() .WithIdentity("job1", "gtoup") .Build(); Quartz.ITrigger trigger1 = Quartz.TriggerBuilder.Create() .WithIdentity("trigger_10_sec", "group") .StartNow() .WithSimpleSchedule(x => x .WithIntervalInSeconds(10) .RepeatForever()) .Build(); Quartz.IJobDetail job2 = Quartz.JobBuilder.Create <Job2>() .WithIdentity("job2", "group") .Build(); Quartz.ITrigger trigger2 = Quartz.TriggerBuilder.Create() .WithIdentity("trigger_20_sec", "group") .StartNow() .WithSimpleSchedule(x => x .WithIntervalInSeconds(20) .RepeatForever()) .Build(); await this._scheduler.ScheduleJob(job1, trigger1, this._stopppingToken); await this._scheduler.ScheduleJob(job2, trigger2, this._stopppingToken); } // End Task StartJobs
private QuartzWrapper() { var schedulerFact = new Quartz.Impl.StdSchedulerFactory(); _scheduler = schedulerFact.GetScheduler(); _scheduler.Start(); }