Beispiel #1
0
        public Scheduler()
        {
            var applicationSettings = SettingProvider.LoadApplicationSettings();

            if (applicationSettings == null)
            {
                SettingProvider.Save(new ApplicationSettings
                {
                    Accounts = new List <Account> {
                        new Account()
                    },
                    Services = new List <ReminderService> {
                        new ReminderService()
                    }
                });

                Environment.Exit(1);
            }

            scheduler = new StdSchedulerFactory().GetScheduler();
            scheduler.AddGlobalTriggerListener(new ShabbosTriggerListener());
            foreach (var service in applicationSettings.Services)
            {
                SchedulerHelper.ScheduleZmanJob(scheduler, service,
                                                applicationSettings.Accounts.Where(a => a.Id == service.AccountId).First()
                                                );
            }
        }
Beispiel #2
0
        public void TestSchedulerFactoryObjectWithListeners()
        {
            IJobFactory jobFactory = new AdaptableJobFactory();

            IScheduler scheduler = (IScheduler)mockery.CreateMock(typeof(IScheduler));

            ISchedulerListener schedulerListener     = new TestSchedulerListener();
            IJobListener       globalJobListener     = new TestJobListener();
            IJobListener       jobListener           = new TestJobListener();
            ITriggerListener   globalTriggerListener = new TestTriggerListener();
            ITriggerListener   triggerListener       = new TestTriggerListener();

            Expect.Call(scheduler.JobFactory = (jobFactory));
            scheduler.AddSchedulerListener(schedulerListener);
            scheduler.AddGlobalJobListener(globalJobListener);
            scheduler.AddJobListener(jobListener);
            scheduler.AddGlobalTriggerListener(globalTriggerListener);
            scheduler.AddTriggerListener(triggerListener);
            scheduler.Start();
            scheduler.Shutdown(false);

            mockery.ReplayAll();

            SchedulerFactoryObject schedulerFactoryObject = new TestSchedulerFactoryObject(scheduler);

            schedulerFactoryObject.JobFactory             = (jobFactory);
            schedulerFactoryObject.SchedulerListeners     = (new ISchedulerListener[] { schedulerListener });
            schedulerFactoryObject.GlobalJobListeners     = (new IJobListener[] { globalJobListener });
            schedulerFactoryObject.JobListeners           = (new IJobListener[] { jobListener });
            schedulerFactoryObject.GlobalTriggerListeners = (new ITriggerListener[] { globalTriggerListener });
            schedulerFactoryObject.TriggerListeners       = (new ITriggerListener[] { triggerListener });
            try
            {
                schedulerFactoryObject.AfterPropertiesSet();
                schedulerFactoryObject.Start();
            }
            finally
            {
                schedulerFactoryObject.Dispose();
            }

            mockery.VerifyAll();
        }
Beispiel #3
0
        public Scheduler()
        {
            var applicationSettings = SettingProvider.LoadApplicationSettings();
            if (applicationSettings == null)
            {
                SettingProvider.Save(new ApplicationSettings
                {
                    Accounts = new List<Account> { new Account() },
                    Services = new List<ReminderService> { new ReminderService() }
                });

                Environment.Exit(1);
            }

            scheduler = new StdSchedulerFactory().GetScheduler();
            scheduler.AddGlobalTriggerListener(new ShabbosTriggerListener());
            foreach (var service in applicationSettings.Services)
            {
                SchedulerHelper.ScheduleZmanJob(scheduler, service,
                              applicationSettings.Accounts.Where(a => a.Id == service.AccountId).First()
                    );
            }
        }
 /// <summary>
 /// Called during creation of the <see cref="IScheduler" /> in order to give
 /// the <see cref="ISchedulerPlugin" /> a chance to Initialize.
 /// </summary>
 public virtual void Initialize(String pluginName, IScheduler sched)
 {
     name = pluginName;
     sched.AddGlobalTriggerListener(this);
 }
 /// <summary>
 /// Called during creation of the <see cref="IScheduler" /> in order to give
 /// the <see cref="ISchedulerPlugin" /> a chance to Initialize.
 /// </summary>
 public virtual void Initialize(String pluginName, IScheduler sched)
 {
     name = pluginName;
     sched.AddGlobalTriggerListener(this);
 }