Esempio n. 1
0
        public static void AddActionsToScheduler(
            ReportJobConfiguration config,
            CoreBusinessLayerService service)
        {
            if (!config.get_Enabled())
            {
                return;
            }
            ReportingActionContext reportingActionContext = new ReportingActionContext();

            reportingActionContext.set_AccountID(config.get_AccountID());
            reportingActionContext.set_UrlsGroupedByLeftPart(ReportJobInitializer.GroupUrls(config));
            reportingActionContext.set_WebsiteID(config.get_WebsiteID());
            ReportingActionContext reportingContext  = reportingActionContext;
            MacroContext           macroContext      = ((ActionContextBase)reportingContext).get_MacroContext();
            ReportingContext       reportingContext1 = new ReportingContext();

            reportingContext1.set_AccountID(config.get_AccountID());
            reportingContext1.set_ScheduleName(config.get_Name());
            reportingContext1.set_ScheduleDescription(config.get_Description());
            reportingContext1.set_LastRun(config.get_LastRun());
            reportingContext1.set_WebsiteID(config.get_WebsiteID());
            macroContext.Add((ContextBase)reportingContext1);
            ((ActionContextBase)reportingContext).get_MacroContext().Add((ContextBase) new GenericContext());
            int num = 0;

            if (config.get_Schedules() == null)
            {
                return;
            }
            using (List <ReportSchedule> .Enumerator enumerator1 = config.get_Schedules().GetEnumerator())
            {
                while (enumerator1.MoveNext())
                {
                    ReportSchedule current  = enumerator1.Current;
                    DateTime       dateTime = !current.get_EndTime().HasValue ? DateTime.MaxValue : current.get_EndTime().Value;
                    Scheduler.get_Instance().Add(new ScheduledTask(string.Format("ReportJob-{0}_{1}", (object)config.get_ReportJobID(), (object)num), (TimerCallback)(o =>
                    {
                        ReportJobInitializer.log.Info((object)"Starting action execution");
                        using (List <ActionDefinition> .Enumerator enumerator = config.get_Actions().GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                service.ExecuteAction(enumerator.Current, (ActionContextBase)reportingContext);
                            }
                        }
                        config.set_LastRun(new DateTime?(DateTime.Now.ToUniversalTime()));
                        ReportJobDAL.UpdateLastRun(config.get_ReportJobID(), config.get_LastRun());
                    }), (object)null, current.get_CronExpression(), current.get_StartTime(), dateTime, config.get_LastRun(), current.get_CronExpressionTimeZoneInfo()), true);
                    ++num;
                }
            }
        }
Esempio n. 2
0
        // Token: 0x060003A4 RID: 932 RVA: 0x00017FE4 File Offset: 0x000161E4
        public static void AddActionsToScheduler(ReportJobConfiguration config, CoreBusinessLayerService service)
        {
            if (!config.Enabled)
            {
                return;
            }
            ReportingActionContext reportingContext = new ReportingActionContext
            {
                AccountID             = config.AccountID,
                UrlsGroupedByLeftPart = ReportJobInitializer.GroupUrls(config),
                WebsiteID             = config.WebsiteID
            };

            reportingContext.MacroContext.Add(new ReportingContext
            {
                AccountID           = config.AccountID,
                ScheduleName        = config.Name,
                ScheduleDescription = config.Description,
                LastRun             = config.LastRun,
                WebsiteID           = config.WebsiteID
            });
            reportingContext.MacroContext.Add(new GenericContext());
            int num = 0;

            if (config.Schedules != null)
            {
                TimerCallback < > 9__0;
                foreach (ReportSchedule reportSchedule in config.Schedules)
                {
                    DateTime      dateTime = (reportSchedule.EndTime == null) ? DateTime.MaxValue : reportSchedule.EndTime.Value;
                    string        text     = string.Format("ReportJob-{0}_{1}", config.ReportJobID, num);
                    TimerCallback timerCallback;
                    if ((timerCallback = < > 9__0) == null)
                    {
                        timerCallback = (< > 9__0 = delegate(object o)
                        {
                            ReportJobInitializer.log.Info("Starting action execution");
                            foreach (ActionDefinition actionDefinition in config.Actions)
                            {
                                service.ExecuteAction(actionDefinition, reportingContext);
                            }
                            config.LastRun = new DateTime?(DateTime.Now.ToUniversalTime());
                            ReportJobDAL.UpdateLastRun(config.ReportJobID, config.LastRun);
                        });
                    }
                    ScheduledTask scheduledTask = new ScheduledTask(text, timerCallback, null, reportSchedule.CronExpression, reportSchedule.StartTime, dateTime, config.LastRun, reportSchedule.CronExpressionTimeZoneInfo);
                    Scheduler.Instance.Add(scheduledTask, true);
                    num++;
                }
            }
        }