private CacheZocMon(string tableName, ZocMonGraph.BaseReduceLevels reduceLevel) { switch (reduceLevel) { case ZocMonGraph.BaseReduceLevels.Minutely: Overlap = new TimeSpan(0, -4, 0); break; case ZocMonGraph.BaseReduceLevels.FiveMinutely: Overlap = new TimeSpan(0, -10, 0); break; case ZocMonGraph.BaseReduceLevels.Hourly: Overlap = new TimeSpan(-2, 0, 0); break; case ZocMonGraph.BaseReduceLevels.Daily: Overlap = new TimeSpan(-2, 0, 0, 0); break; } Name = tableName; Data = new List<MonitorRecordUnion<double>>(); WarmedUp = false; LastRefreshed = DateTime.MinValue; }
private List<GraphViewModel> GetGraphs(NameValueCollection values) { var graphsList = new List<GraphViewModel>(); if (values.Get("graphCount") != null) { var graphCount = int.Parse(values.Get("graphCount")); for (var i = 0; i < graphCount; i++) { bool isMonthReview = values.Get("isMonthReview") != null; string reduceLevelNameParams = values.Get("ReduceLevel" + i); if (reduceLevelNameParams != null || isMonthReview) { if (isMonthReview) { //each graph gets a fresh instance of ZocMonGraph to work with //in this case reduceLevelNameParams is equal to the data source //(without reduce level portion of string) zocMonGraph = new ZocMonGraph(reduceLevelNameParams); } else { #region prep line and ratio graphs ZocMonGraph.GraphType type = (ZocMonGraph.GraphType) Enum.Parse(typeof (ZocMonGraph.GraphType), values.Get("graphType" + i), true); #region parse date ranges var isExplicitTimeRange = type != Infrastructure.ZocMonGraph.GraphType.Ratio && values.Get("HistoryRange" + i) != null && "0".Equals(values.Get("HistoryRange" + i)) && values.Get("fromDate" + i) != null && values.Get("fromTime" + i) != null && values.Get("toDate" + i) != null && values.Get("toTime" + i) != null; DateTime from = new DateTime(); DateTime to = new DateTime(); if (isExplicitTimeRange) { if ( !DateTime.TryParse( values.Get("fromDate" + i) + " " + values.Get("fromTime" + i), out from)) { throw new Exception("Failed to parse date time string \"" + values.Get("fromDate" + i) + " " + values.Get("fromTime" + i) + "\""); } if ( !DateTime.TryParse(values.Get("toDate" + i) + " " + values.Get("toTime" + i), out to)) { throw new Exception("Failed to parse date time string \"" + values.Get("toDate" + i) + " " + values.Get("toTime" + i) + "\""); } } else { from = Infrastructure.ZocMonGraph.MinDate; to = DateTime.MaxValue; } #endregion #region parse history range ZocMonGraph.HistoryRangeOptions historyRange; if ( !Infrastructure.ZocMonGraph.HistoryRangeOptions.TryParse( values.Get("HistoryRange" + i), out historyRange)) { SimpleLogger.logException("Failed to convert \"" + values.Get("HistoryRange" + i) + "\" to enum value in HistoryRangeOptions"); throw new Exception("Back up and select a history range..."); } #endregion //if showEvents is in the url it overrides the bool that has been saved bool showEvents = true; if (Request.Params.Get("showevents" + i) != null) { showEvents = Request.Params.Get("showEvents" + i) == "on" || Request.Params.Get("showEvents" + i) == "true" ? true : false; } else { if (values.Get("showevents" + i) != null) { showEvents = values.Get("showevents" + i) == "on" ? true : false; } } //allow for ratio weeks url hack string weeks = ""; if (Request.Params.Get("weeks" + i) != null) { weeks = Request.Params.Get("weeks" + i); } //each graph gets a fresh instance of ZocMonGraph to work with zocMonGraph = new ZocMonGraph(graphCount, values.Get("titleBox" + i), type, values.Get("showYAxis" + i) == "on" ? true : false, values.Get("zeroMinYAxis" + i) == "on" ? true : false, showEvents, reduceLevelNameParams, false, isExplicitTimeRange, from, to, historyRange, weeks); #endregion } graphsList.Add(new GraphViewModel { TickFormatter = zocMonGraph.GetTickFormatter(), MinYAxis = zocMonGraph.GetMinYAxis(), MaxYAxis = zocMonGraph.GetMaxYAxis(), MinXAxis = zocMonGraph.GetMinXAxis(), MaxXAxis = zocMonGraph.GetMaxXAxis(), AlertStatus = zocMonGraph.GetAlertStatus().ToString(), LabeledData = zocMonGraph.GetData(), Events = zocMonGraph.GetMarkerJsString(), ShowEvents = zocMonGraph.ShowEvents, Labels = zocMonGraph.GetLabelJsString(), Index = i, Width = zocMonGraph.DisplayWidth, Height = zocMonGraph.DisplayHeight, Title = zocMonGraph.GraphTitle, Ticks = zocMonGraph.GetTicks(), SubTitle = zocMonGraph.GraphSubTitle, TitleSize = zocMonGraph.DisplayTitleSize, Type = zocMonGraph.Type, IsRatio = zocMonGraph.Type == Infrastructure.ZocMonGraph.GraphType.Ratio, DataSources = Infrastructure.ZocMonGraph.ListOfStringsToJsArrayString( zocMonGraph.DataSources) }); } else { SimpleLogger.logException(new Exception("ReduceLevel" + i + " can't be null"), null, to: "*****@*****.**"); } } } return graphsList; }
public ActionResult ConversionRates() { try { GraphsViewModel model = new GraphsViewModel(); var graph = new ZocMonGraph(Infrastructure.ZocMonGraph.GraphType.ConversionRates); graph.SetConversionRatesData(); model.GraphsList.Add(new GraphViewModel { TickFormatter = graph.GetTickFormatter(), MinYAxis = graph.GetMinYAxis(), MaxYAxis = graph.GetMaxYAxis(), MinXAxis = graph.GetMinXAxis(), MaxXAxis = graph.GetMaxXAxis(), AlertStatus = graph.GetAlertStatus().ToString(), LabeledData = graph.GetConversionRatesData(0), Events = graph.GetMarkerJsString(), Labels = graph.GetLabelJsString(), Index = 0, Width = graph.DisplayWidth, Height = graph.DisplayHeight, Title = "Conversion Rates: Last Day", Ticks = graph.GetTicks(), SubTitle = "", TitleSize = graph.DisplayTitleSize, Type = Infrastructure.ZocMonGraph.GraphType.Line, IsRatio = false, DataSources = Infrastructure.ZocMonGraph.ListOfStringsToJsArrayString( graph.DataSources) }); model.GraphsList.Add(new GraphViewModel { TickFormatter = graph.GetTickFormatter(), MinYAxis = graph.GetMinYAxis(), MaxYAxis = graph.GetMaxYAxis(), MinXAxis = graph.GetMinXAxis(), MaxXAxis = graph.GetMaxXAxis(), AlertStatus = graph.GetAlertStatus().ToString(), LabeledData = graph.GetConversionRatesData(1), Events = graph.GetMarkerJsString(), Labels = graph.GetLabelJsString(), Index = 1, Width = graph.DisplayWidth, Height = graph.DisplayHeight, Title = "Conversion Rates: Last Week", Ticks = graph.GetTicks(), SubTitle = "", TitleSize = graph.DisplayTitleSize, Type = Infrastructure.ZocMonGraph.GraphType.Line, IsRatio = false, DataSources = Infrastructure.ZocMonGraph.ListOfStringsToJsArrayString( graph.DataSources) }); model.GraphsList.Add(new GraphViewModel { TickFormatter = graph.GetTickFormatter(), MinYAxis = "-100", MaxYAxis = "100", MinXAxis = graph.GetMinXAxis(), MaxXAxis = graph.GetMaxXAxis(), AlertStatus = graph.GetAlertStatus().ToString(), LabeledData = graph.GetConversionRatesData(2), Events = graph.GetMarkerJsString(), Labels = graph.GetLabelJsString(), Index = 2, Width = graph.DisplayWidth, Height = 400, Title = "Conversion Rate Ratios", Ticks = graph.GetTicks(), SubTitle = "", TitleSize = graph.DisplayTitleSize, Type = Infrastructure.ZocMonGraph.GraphType.Ratio, IsRatio = true, DataSources = Infrastructure.ZocMonGraph.ListOfStringsToJsArrayString( graph.DataSources) }); return View(model); } catch (Exception e) { SimpleLogger.logException(e, to: "*****@*****.**"); throw; } }