Пример #1
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            GraphInformation.HasReportTypeChanged = GeneralParams.ReportTypeControl.HasReportTypeChanged;


            if (GraphInformation.RefreshData || GraphInformation.UsingCachedGraphingData)
            {
                FutureTrendDataType futureTrendDataType;
                Enum.TryParse(GeneralParams.ReportTypeControl.SelectedForecastType.SelectedValue, out futureTrendDataType);

                var constrained = futureTrendDataType == FutureTrendDataType.Constrained ? true : false;

                var refreshDataFromDatabase = false;

                if (constrained && SavedConstrainedSeriesData == null)
                {
                    refreshDataFromDatabase = true;
                }

                if (!constrained && SavedUnconstrainedSeriesData == null)
                {
                    refreshDataFromDatabase = true;
                }

                if (GraphInformation.HaveDatesChanged || GraphInformation.HaveDynamicParametersChanged)
                {
                    refreshDataFromDatabase      = true;
                    SavedConstrainedSeriesData   = null;
                    SavedUnconstrainedSeriesData = null;
                }

                if (refreshDataFromDatabase || GraphInformation.RefreshData)
                {
                    var seriesData = BenchMarkDataAccess.GetBenchMarkGraphingData(GeneralParams.SelectedParameters, constrained);

                    if (constrained)
                    {
                        SavedConstrainedSeriesData = seriesData;
                    }
                    else
                    {
                        SavedUnconstrainedSeriesData = seriesData;
                    }

                    GraphInformation.SeriesData = seriesData;
                    GraphInformation.DataDate   = ParameterDataAccess.GetLastDateFromCmsForecast();
                    GraphInformation.UsingCachedGraphingData = false;
                }
                else
                {
                    GraphInformation.UsingCachedGraphingData = true;
                    GraphInformation.SeriesData = constrained
                                  ? SavedConstrainedSeriesData
                                  : SavedUnconstrainedSeriesData;
                }

                GraphInformation.TitleAdditional = string.Format("{0}",
                                                                 GeneralParams.ReportTypeControl.SelectedForecastType.SelectedItem.Text);

                GraphInformation.CalculateYEntriesCount();
                GraphInformation.RefreshData = false;

                this.SetPreviousDates(GeneralParams);

                GraphInformation.HaveDynamicParametersChanged = false;
            }
        }
Пример #2
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            //If this page is being being loaded but we have parameters from a previous visit
            if (!IsPostBack && GraphInformation.SelectedParameters[ParameterNames.Country].Length != 0)
            {
                SetQuickNavigationMenu();
            }

            //Don't allow drilldown past Pool
            if (GraphInformation.ReportParameters.First(p => p.Name == ParameterNames.Pool).SelectedValue != "")
            {
                GraphInformation.AllowDrillDown = false;
            }


            if (GraphInformation.RefreshData || GraphInformation.CheckIfCachedDataCanBeUsed)
            {
                SetQuickNavigationMenu();

                var topicId    = int.Parse(GeneralParams.ReportTypeControl.SelectedTopic.Value);
                var scenarioId = int.Parse(GeneralParams.ReportTypeControl.SelectedScenario.SelectedValue);

                if (topicId > 2)
                {
                    GraphInformation.LabelFormat            = "0%";
                    GraphInformation.DataPointsYAxisTooltip = "#VALY{0%}";
                    GraphInformation.YAxisNumberFormat      = "0%";
                }
                else
                {
                    GraphInformation.LabelFormat            = "#,##0";
                    GraphInformation.DataPointsYAxisTooltip = "#VALY{0,0}";
                    GraphInformation.YAxisNumberFormat      = "#,##0";
                }

                if (SiteComparisonGraphData[CurrentKey] == null || GraphInformation.RefreshData)
                {
                    //SiteComparisonGraphData[CurrentKey] = new SiteComparisonLogic(new SiteComparisonRepository()).GetData(GeneralParams.SelectedParameters, topicId, scenarioId);
                    SiteComparisonGraphData[CurrentKey] =
                        SiteComparisonDataAccess.GetSiteComparisonData(GeneralParams.SelectedParameters, topicId,
                                                                       scenarioId);
                    GraphInformation.DataDate = ParameterDataAccess.GetLastDateFromCmsForecast();
                }
                else
                {
                    GraphInformation.UsingCachedGraphingData = true;
                }

                GraphInformation.SeriesData = SiteComparisonGraphData[CurrentKey];

                if (string.IsNullOrEmpty(GraphInformation.TitleDate))
                {
                    GraphInformation.ShowLabelSeriesNames.Add(GraphInformation.SeriesData.First().SeriesName);
                }

                GraphInformation.TitleDate       = string.Format("{0} - {1}", GeneralParams.SelectedParameters[ParameterNames.FromDate], GeneralParams.SelectedParameters[ParameterNames.ToDate]);
                GraphInformation.TitleAdditional = string.Format("{0}", GeneralParams.ReportTypeControl.SelectedTopic.Text);

                GraphInformation.CalculateYEntriesCount();

                this.SetPreviousDates(GeneralParams);

                GraphInformation.RefreshData = false;
            }
        }