Пример #1
0
        public ScheduleRegistry()
        {
            XmlConfigurator.Configure(); //configure logging
            _logger = LogManager.GetLogger(typeof(ScheduleRegistry));


            var numSecondsBackoff = 3600;
                var numSecondsBackoffStr = ConfigurationManager.AppSettings["UNSENT_NOTIFICATION_BACKOFF_SECONDS"];
                if (!string.IsNullOrEmpty(numSecondsBackoffStr))
                    numSecondsBackoff = int.Parse(numSecondsBackoffStr);

            Initialise();

            //Run notification processor every 30 seconds
            var mailgunSender = new MailGunEmailSender();
            Schedule(() => new NotificationProcessor(
                               new EmailNotificationDispatcher(_logger, mailgunSender),
                               new ToastDispatcher(_database.MasterStore, _logger),
                               _database.GetAllOrgStores(),
                               new SmsDispatcher(_logger, new TxtLocalSmsSender()),
                               _logger,
                               numSecondsBackoff
                               )
                               .Process())
                .ToRunNow().AndEvery(30).Seconds();

            
            Schedule(() => new TrialProcessor(_database,_logger)
                               .Process())
                .ToRunNow().AndEvery(2).Minutes();

            //inference engine schedule
            var inferenceTypes= new IInferenceType[] {
                new PoorHigInferenceType(new InferenceTypeConfig{CheckForOtherInferencesPeriodDays = 10,NumberInPeriod = 3,PeriodDays = 10})
                                       {
                                           Actions = new IInferenceAction[]
                                                         {
                                                             new NotifyManagerAction()
                                                         }},

            new ManyConcernsInferenceType(new InferenceTypeConfig{CheckForOtherInferencesPeriodDays = 10,NumberInPeriod = 2,PeriodDays = 10})
                                       {
                                           Actions = new IInferenceAction[]
                                                         {
                                                             new NotifyManagerAction()
                                                         }},
             new PraiseInferenceType(new InferenceTypeConfig{CheckForOtherInferencesPeriodDays = 10,NumberInPeriod = 3,PeriodDays = 10})
                                       {
                                           Actions = new IInferenceAction[]
                                                         {
                                                             new NotifyManagerAction()
                                                         }},
            new NoPraiseInferenceType(new InferenceTypeConfig{CheckForOtherInferencesPeriodDays = 180,NumberInPeriod = 0,PeriodDays = 180})
                                       {
                                           Actions = new IInferenceAction[]
                                                         {
                                                             new NotifyManagerAction()
                                                         }},
            new RepeatedSicknessReasonInferenceType(new InferenceTypeConfig{CheckForOtherInferencesPeriodDays = 365,NumberInPeriod = 2,PeriodDays = 365})
                                       {
                                           Actions = new IInferenceAction[]
                                                         {
                                                             new NotifyManagerAction()
                                                         }},

            };
            Schedule(() => new InferenceProcessor(
                               _database.GetAllOrgStores(),
                               inferenceTypes,
                               _logger)
                               .Process())
                .ToRunNow().AndEvery(10).Minutes();

            //Run daily email task at 3am

            Schedule(() => new Tasks.EmailDailyTasks().DoWork(_database, mailgunSender)).ToRunEvery(1).Days().At(3, 0);


            //Run Open task updates at 6am?
            Schedule(() => new Tasks.ConsolidateEndDates().DoWork(_database)).ToRunEvery(1).Days().At(6, 0);

            //one off update of ALL tasks etc. 
            Schedule(() => new Tasks.ConsolidateEndDates(true).DoWork(_database)).ToRunNow();


            //Update Assignees occsionally. !. 
            Schedule(() => new Tasks.RefreshAssignees().DoWork(_database)).ToRunNow().AndEvery(1).Hours();

            //Update Users occsionally. !. 
            Schedule(() => new Tasks.RefreshUserState().DoWork(_database))
                .ToRunNow().AndEvery(4).Hours();
            
            Schedule(()=>new Tasks.UpdateGraphite().DoWork(_database))
                .ToRunNow().AndEvery(1).Minutes();

        }
Пример #2
0
        private static void TestDailyEmail()
        {
            var ds = new DocumentStore { ConnectionStringName = "MasterDB" };
            var database = IlluminateDatabase.Create(ds, true, false, false);

            var mailgunSender = new MailGunEmailSender();
            var worker = new EmailDailyTasks();
            worker.DoWork(database, mailgunSender);
        }