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; } } }
// 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++; } } }
// Token: 0x060003A5 RID: 933 RVA: 0x000181D0 File Offset: 0x000163D0 public static Dictionary <string, List <string> > GroupUrls(ReportJobConfiguration config) { StringBuilder errors = new StringBuilder(); StringComparer strcmp = StringComparer.OrdinalIgnoreCase; Dictionary <string, List <string> > dictionary = new Dictionary <string, List <string> >(strcmp); if (config == null) { ReportJobInitializer.log.ErrorFormat("GroupUrls(ReportJobConfiguration) config is NULL {0}", Environment.StackTrace); return(dictionary); } try { List <string> list = (from report in config.Reports select string.Format("{0}/Orion/Report.aspx?ReportID={1}", WebsitesDAL.GetSiteAddress(config.WebsiteID), report.ID)).Union(config.Urls.Select(delegate(string url) { if (!url.Contains('?')) { return(url + "?"); } return(url); })).ToList <string>(); foreach (string text in list) { if (text.IndexOf("/Orion/", StringComparison.OrdinalIgnoreCase) < 0) { if (!dictionary.ContainsKey(OrionWebClient.UseDefaultWebsiteIdentifier)) { dictionary.Add(OrionWebClient.UseDefaultWebsiteIdentifier, new List <string>()); } dictionary[OrionWebClient.UseDefaultWebsiteIdentifier].Add(text); } else { string uriLeftPart; try { Uri uri; if (!Uri.TryCreate(text, UriKind.Absolute, out uri)) { errors.AppendFormat("Invalid URL {0} \r\n", text); continue; } uriLeftPart = uri.GetLeftPart(UriPartial.Authority); } catch (Exception arg) { errors.AppendFormat("Invalid URL {0}. {1}\r\n", text, arg); continue; } if (!dictionary.ContainsKey(uriLeftPart)) { dictionary.Add(uriLeftPart, list.Where(delegate(string u) { bool result; try { Uri uri2; if (!Uri.TryCreate(u, UriKind.Absolute, out uri2)) { errors.AppendFormat("Invalid URL {0} \r\n", u); result = false; } else { string leftPart = uri2.GetLeftPart(UriPartial.Authority); result = strcmp.Equals(uriLeftPart, leftPart); } } catch (Exception arg3) { errors.AppendFormat("Invalid URL {0}. {1}\r\n", u, arg3); result = false; } return(result); }).ToList <string>()); } } } } catch (Exception arg2) { errors.AppendFormat("Unexpected exception {0}", arg2); } if (errors.Length > 0) { StringBuilder stringBuilder = new StringBuilder().AppendFormat("Errors in ReportJob-{0}({1}) @ Engine {2} & Website {3} \r\n", new object[] { config.ReportJobID, config.Name, config.EngineId, config.WebsiteID }).Append(errors); ReportJobInitializer.log.Error(stringBuilder); } return(dictionary); }
public static Dictionary <string, List <string> > GroupUrls( ReportJobConfiguration config) { StringBuilder errors = new StringBuilder(); StringComparer strcmp = StringComparer.OrdinalIgnoreCase; Dictionary <string, List <string> > dictionary = new Dictionary <string, List <string> >((IEqualityComparer <string>)strcmp); if (config == null) { ReportJobInitializer.log.ErrorFormat("GroupUrls(ReportJobConfiguration) config is NULL {0}", (object)Environment.StackTrace); return(dictionary); } try { List <string> list = ((IEnumerable <ReportTuple>)config.get_Reports()).Select <ReportTuple, string>((Func <ReportTuple, string>)(report => string.Format("{0}/Orion/Report.aspx?ReportID={1}", (object)WebsitesDAL.GetSiteAddress(config.get_WebsiteID()), (object)report.get_ID()))).Union <string>(config.get_Urls().Select <string, string>((Func <string, string>)(url => !url.Contains <char>('?') ? url + "?" : url))).ToList <string>(); foreach (string uriString in list) { if (uriString.IndexOf("/Orion/", StringComparison.OrdinalIgnoreCase) < 0) { if (!dictionary.ContainsKey((string)OrionWebClient.UseDefaultWebsiteIdentifier)) { dictionary.Add((string)OrionWebClient.UseDefaultWebsiteIdentifier, new List <string>()); } dictionary[(string)OrionWebClient.UseDefaultWebsiteIdentifier].Add(uriString); } else { string uriLeftPart; try { Uri result; if (!Uri.TryCreate(uriString, UriKind.Absolute, out result)) { errors.AppendFormat("Invalid URL {0} \r\n", (object)uriString); continue; } uriLeftPart = result.GetLeftPart(UriPartial.Authority); } catch (Exception ex) { errors.AppendFormat("Invalid URL {0}. {1}\r\n", (object)uriString, (object)ex); continue; } if (!dictionary.ContainsKey(uriLeftPart)) { dictionary.Add(uriLeftPart, list.Where <string>((Func <string, bool>)(u => { try { Uri result; if (Uri.TryCreate(u, UriKind.Absolute, out result)) { return(strcmp.Equals(uriLeftPart, result.GetLeftPart(UriPartial.Authority))); } errors.AppendFormat("Invalid URL {0} \r\n", (object)u); return(false); } catch (Exception ex) { errors.AppendFormat("Invalid URL {0}. {1}\r\n", (object)u, (object)ex); return(false); } })).ToList <string>()); } } } } catch (Exception ex) { errors.AppendFormat("Unexpected exception {0}", (object)ex); } if (errors.Length > 0) { StringBuilder stringBuilder = new StringBuilder().AppendFormat("Errors in ReportJob-{0}({1}) @ Engine {2} & Website {3} \r\n", (object)config.get_ReportJobID(), (object)config.get_Name(), (object)config.get_EngineId(), (object)config.get_WebsiteID()).Append((object)errors); ReportJobInitializer.log.Error((object)stringBuilder); } return(dictionary); }