public void FillReport() { ActualActivityTrend = GetDataFromInput(); Categories = ActualActivityTrend.Select(x => ActualActivityTrend.IndexOf(x).ToString()).ToList(); GetTimeSeriseDate(Categories, ActualActivityTrend); BindActivityCharts(); }
private void BindForecast() { //BindGrids(); int predictCount = Convert.ToInt32(txtPredictCount.Text); int p = Convert.ToInt32(txtp.Text); int q = Convert.ToInt32(txtq.Text); int s = Convert.ToInt32(txts.Text); int d = Convert.ToInt32(txtd.Text); int forcastStep = 4; var forecastType = ((Enums.ForecastsType)Convert.ToInt32(drpForecatsType.SelectedValue)).ToString(); CultureInfo persianCultureInfo = new CultureInfo("en-US"); var values = new Dictionary <string, List <string> > { { "Date", Categories }, { "riders", ActualActivityTrend.Select(x => x.Value.ToString()).ToList() } }; ForecastModel model = new ForecastModel { Data = values, PredictCount = predictCount, ForcastStep = forcastStep, p = p, q = q, d = d, s = s, type = forecastType }; var timeSeriseSrv = TimeSeriesService.Instance(); var serviceResult = timeSeriseSrv.GetTimeSeriesForcastResult(model); if (!serviceResult.IsSuccessful) { lbMessage.Text = serviceResult.Message; return; } var prgressResult = (TimeSeriDto)serviceResult.Data; if (string.IsNullOrEmpty(prgressResult.Exception) == false) { lbMessage.Text = "مقادیر لگهای انتخاب شده متناسب با اعداد دوره های عملکرد نمی باشد!" + "<br />" + prgressResult.Exception; return; } if (prgressResult.Forecast is null || prgressResult.Forecast.Count == 0) { lbMessage.Text = "با مقادیر ارسال شده ، سیستم قادر به انجام عملیات پیش بینی نمی باشد!"; return; } var forecastResult = prgressResult.Forecast; var predictResult = prgressResult.PredictResult; //ChartModel cmActivity = new ChartModel() { ChartType = ChartTypes.Line, Data = chartData }; List <ChartData> cmPrePredicat = predictResult.Select(x => new ChartData() { IntervalDate = x.Key.ToString(), Value = x.Value }).ToList(); List <ChartData> cdPredicate = new List <ChartData>(); foreach (var item in Categories) { double?val = null; if (cmPrePredicat.Any(x => x.IntervalDate == item)) { val = cmPrePredicat.Single(x => x.IntervalDate == item).Value; } cdPredicate.Add(new ChartData(item, val)); } //ChartModel cmPredicat = new ChartModel() { ChartType = ChartTypes.Line, Data = cdPredicate }; List <ChartData> cdForcast = new List <ChartData>(); var joinerPoint = Categories.Last(); var joinerTrendPoint = ActualActivityTrend.Last(); cdForcast.AddRange(Categories.Select(x => new ChartData(x, null)).ToList()); var checkExists = cdForcast.SingleOrDefault(x => x.IntervalDate == joinerPoint); if (checkExists != null) { cdForcast.Remove(checkExists); } cdForcast.Add(new ChartData(joinerPoint, joinerTrendPoint)); for (int i = 0; i < forcastStep; i++) { int forcastIndex = Convert.ToInt32(joinerPoint) + i + 1; cdForcast.Add(new ChartData(forcastIndex.ToString(), forecastResult.ElementAt(i).Value)); } //UcIndicatorView.Visible = true; //ChartModel cmForecast = new ChartModel() { ChartType = ChartTypes.Line, Data = cdForcast }; var chartModelforcast = new HighChartViewModel(Categories); chartModelforcast.HighChartDataItems.Add(new HighChartDataItems("عملکرد", "#2962ff", ActualActivityTrend)); chartModelforcast.HighChartDataItems.Add(new HighChartDataItems("تطبیق", "#d7ccc8", cdPredicate.Select(x => x.Value).ToList())); chartModelforcast.HighChartDataItems.Add(new HighChartDataItems("پیش بینی", "#ab47bc", cdForcast.Select(x => x.Value).ToList())); UCSplineForcast.ChartId = "chartModelforcast"; UCSplineForcast.vmHighChartModel = chartModelforcast; BindActivityCharts(); //var forecastsData = // (from x in cdForcast // let activity = AiFChartData.SingleOrDefault(y => y.IntervalDate == x.IntervalDate) // where // x.IntervalDate != joinerPoint.IntervalDate && x.Value.HasValue // orderby x.IntervalDate // let percent = (activity?.Value.HasValue == true) ? ((x.Value - activity.Value.Value) / ((activity.Value.Value + x.Value) / 2)) * 100 : 0 // select new // { // IntervalDate = x.IntervalDate, // Value = x.Value, // ActivityValue = activity?.Value, // Diff = // activity?.Value.HasValue == true ? // percent.Value.ToString("N2") : "", // Increase = (activity?.Value.HasValue == true) && // ((x.Value < activity.Value.Value && Math.Abs(percent.Value) <= 5) || (x.Value >= activity.Value.Value)) // ? true : false, // Decrease = (activity?.Value.HasValue == true) && // (x.Value < activity.Value.Value && (Math.Abs(percent.Value)) > 5) ? true : false // } // ).ToList(); ////cdForcast.Where(x => x.IntervalDate != joinerPoint.IntervalDate && x.Value.HasValue).OrderBy(x => x.IntervalDate).ToList(); //var statisticDataSource = new List<TimeSeriDto>(); //statisticDataSource.Add(new TimeSeriDto //{ // aic = prgressResult.aic, // hqic = prgressResult.hqic, // Exception = string.Empty, // Forecast = null, // PredictResult = null //}); //lvStatistics.DataSource = statisticDataSource; //lvStatistics.DataBind(); //lvStatistics.Visible = true; //lvForecast.DataSource = forecastsData; //lvForecast.DataBind(); //lvForecast.Visible = true; //UcChartBefore.SetChart(IndicatorTitle, chartModelFirst, new Dictionary<string, string>() { { "جزئیات", "$('.tables2').html($('#pnl3').html()); $('#mainContainer2').dialog('open');" } }); //UcIndicatorView.SetChart(IndicatorTitle, chartModelSecond, new Dictionary<string, string>() { { "جزئیات", "$('.tables1').html($('#pnl2').html()); $('#mainContainer').dialog('open');" } }); }