示例#1
0
        public void Start()
        {
            log.Info("Start requested");

            try
            {
                repositoryContext = new MongoContext(ConfigurationManager.AppSettings["ConnectionString"], "Encore");
                repositoryContext.TryConnect();

                poolPartyClient = new PoolPartyClient(
                    ConfigurationManager.AppSettings["PoolParty.EncoreUrl"],
                    ConfigurationManager.AppSettings["PoolParty.UserName"],
                    ConfigurationManager.AppSettings["PoolParty.Password"]);

                var container = new TinyIoCContainer();
                ConfigureContainer(container);

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

                scheduler.JobFactory = new ServiceJobFactory(container);
                scheduler.ListenerManager.AddJobListener(new LoggingJobListener(), GroupMatcher<JobKey>.AnyGroup());

                scheduler.BuildJob<ProcessReportsJob>().
                    WithRepeatingTrigger(int.Parse(ConfigurationManager.AppSettings["Report.PollIntervalMs"]));

                scheduler.BuildJob<SyncSummaryDataJob>().
                    WithDailyTrigger(TimeOfDay.HourAndMinuteOfDay(0, 0));

                scheduler.BuildJob<CleanUpResultsJob>().
                    UsingJobData("DeleteAfterDays", int.Parse(ConfigurationManager.AppSettings["Report.DeleteAfterDays"])).
                    WithDailyTrigger(TimeOfDay.HourAndMinuteOfDay(1, 0));

                scheduler.BuildJob<SyncSiteAndFieldData>().
                    WithDailyTrigger(TimeOfDay.HourAndMinuteOfDay(2, 0));

                scheduler.Start();
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }