Ejemplo n.º 1
0
        public GetCartesianChartDataResponse GetChartData(GetCartesianChartDataRequest request)
        {
            var response = new GetCartesianChartDataResponse();
            IList<DateTime> dateTimePeriodes = new List<DateTime>();
            string timeInformation;
            response.Periodes = this._getPeriodes(request.PeriodeType, request.RangeFilter, request.Start, request.End, out dateTimePeriodes, out timeInformation);
            response.Subtitle = timeInformation;
            IList<GetCartesianChartDataResponse.SeriesResponse> seriesResponse = new List<GetCartesianChartDataResponse.SeriesResponse>();
            var seriesType = "single-stack";
            if (request.Series.Count == 1 && (request.GraphicType == "baraccumulative" || request.GraphicType == "barachievement"))
            {
                seriesType = "multi-stacks";
            }
            else if (request.Series.Count > 1)
            {
                if (request.Series.Where(x => x.Stacks.Count > 0).FirstOrDefault() != null || request.GraphicType == "baraccumulative" || request.GraphicType == "barachievement")
                {
                    seriesType = "multi-stacks-grouped";
                }
            }
            else
            {
                if (request.Series.Where(x => x.Stacks.Count > 0).FirstOrDefault() != null || request.GraphicType == "baraccumulative")
                {
                    seriesType = "multi-stack";
                }
            }
            string newTimeInformation;
            IList<DateTime> newDateTimePeriodes;
            switch (request.ValueAxis)
            {
                case ValueAxis.KpiTarget:
                    seriesResponse = this._getKpiTargetSeries(request.Series, request.PeriodeType, dateTimePeriodes, seriesType, request.RangeFilter, request.GraphicType, out newTimeInformation, out newDateTimePeriodes);
                    break;
                case ValueAxis.KpiActual:
                    seriesResponse = this._getKpiActualSeries(request.Series, request.PeriodeType, dateTimePeriodes, seriesType, request.RangeFilter, request.GraphicType, out newTimeInformation, out newDateTimePeriodes);
                    break;
                default:
                    var actualSeries = request.Series.Where(x => x.ValueAxis == ValueAxis.KpiActual).ToList();
                    var targetSeries = request.Series.Where(x => x.ValueAxis == ValueAxis.KpiTarget).ToList();
                    seriesType = "multi-stacks-grouped";
                    var series1 = this._getKpiTargetSeries(targetSeries, request.PeriodeType, dateTimePeriodes, seriesType, request.RangeFilter, request.GraphicType, out newTimeInformation, out newDateTimePeriodes, true);
                    var series2 = this._getKpiActualSeries(actualSeries, request.PeriodeType, dateTimePeriodes, seriesType, request.RangeFilter, request.GraphicType, out newTimeInformation, out newDateTimePeriodes, true);
                    seriesResponse = series1.Concat(series2).ToList();
                    break;

            }
            if ((request.PeriodeType == PeriodeType.Hourly && request.RangeFilter == RangeFilter.CurrentHour) ||
                     (request.PeriodeType == PeriodeType.Daily && request.RangeFilter == RangeFilter.CurrentDay) ||
                     (request.PeriodeType == PeriodeType.Monthly && request.RangeFilter == RangeFilter.CurrentMonth) ||
                     (request.PeriodeType == PeriodeType.Yearly && request.RangeFilter == RangeFilter.CurrentYear))
            {
                response.Subtitle = newTimeInformation;
                if (newDateTimePeriodes.Count > 0)
                {
                    switch (request.PeriodeType)
                    {
                        case PeriodeType.Hourly:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString("hh tt", CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString("dd/MMM/yyyy hh tt", CultureInfo.InvariantCulture);
                            break;
                        case PeriodeType.Daily:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString("dd", CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString("dd/MMM/yyyy", CultureInfo.InvariantCulture);
                            break;
                        case PeriodeType.Monthly:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString("MMMM", CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString("MMM/yyyy", CultureInfo.InvariantCulture);
                            break;
                        case PeriodeType.Yearly:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString("yyyy", CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString("yyyy", CultureInfo.InvariantCulture);
                            break;
                    }
                }

            }

            response.SeriesType = seriesType;
            response.Series = seriesResponse;
            return response;
        }
Ejemplo n.º 2
0
        public GetCartesianChartDataResponse GetChartData(GetCartesianChartDataRequest request, bool multiaxisAsOrigin = false)
        {
            var response = new GetCartesianChartDataResponse();
            IList<DateTime> dateTimePeriodes = new List<DateTime>();
            string timeInformation;
            response.Periodes = this._getPeriodes(request.PeriodeType, request.RangeFilter, request.Start, request.End, out dateTimePeriodes, out timeInformation);
            response.TimePeriodes = dateTimePeriodes;
            response.Subtitle = timeInformation;
            IList<GetCartesianChartDataResponse.SeriesResponse> seriesResponse = new List<GetCartesianChartDataResponse.SeriesResponse>();
            var seriesType = "single-stack";
            if (request.Series.Count == 1 && (request.GraphicType == "baraccumulative" || request.GraphicType == "barachievement"))
            {
                seriesType = "multi-stacks";
            }
            else if (request.Series.Count > 1)
            {
                if (request.Series.Where(x => x.Stacks.Count > 0).FirstOrDefault() != null || request.GraphicType == "baraccumulative" || request.GraphicType == "barachievement" || request.AsNetbackChart)
                {
                    seriesType = "multi-stacks-grouped";
                }
            }
            else
            {
                if (request.Series.Where(x => x.Stacks.Count > 0).FirstOrDefault() != null || request.GraphicType == "baraccumulative")
                {
                    seriesType = "multi-stack";
                }
            }

            //workaround for bar multiaxis bug : multiple stacks
            if (multiaxisAsOrigin = true && request.GraphicType == "bar" && seriesType == "multi-stack") {
                seriesType = "multi-stacks-grouped";
            }

            string newTimeInformation;
            IList<DateTime> newDateTimePeriodes;
            switch (request.ValueAxis)
            {
                case ValueAxis.KpiTarget:
                    seriesResponse = this._getKpiTargetSeries(request.Series, request.PeriodeType, dateTimePeriodes, seriesType, request.RangeFilter, request.GraphicType, out newTimeInformation, out newDateTimePeriodes);
                    break;
                case ValueAxis.KpiActual:
                    seriesResponse = this._getKpiActualSeries(request.Series, request.PeriodeType, dateTimePeriodes, seriesType, request.RangeFilter, request.GraphicType, out newTimeInformation, out newDateTimePeriodes);
                    break;
                case ValueAxis.KpiEconomic:
                    seriesResponse = this._getKpiEconomicSeries(request.Series, request.PeriodeType, dateTimePeriodes, seriesType, request.RangeFilter, request.GraphicType, out newTimeInformation, out newDateTimePeriodes, false, request.AsNetbackChart);
                    break;
                default:
                    var i = 0;
                    foreach (var series in request.Series) {
                        series.Order = i++;
                    }
                    var actualSeries = request.Series.Where(x => x.ValueAxis == ValueAxis.KpiActual).ToList();
                    var targetSeries = request.Series.Where(x => x.ValueAxis == ValueAxis.KpiTarget).ToList();
                    var economicSeries = request.Series.Where(x => x.ValueAxis == ValueAxis.KpiEconomic).ToList();
                    //seriesType = "multi-stacks-grouped";
                    var series1 = this._getKpiTargetSeries(targetSeries, request.PeriodeType, dateTimePeriodes, seriesType, request.RangeFilter, request.GraphicType, out newTimeInformation, out newDateTimePeriodes, false);
                    var series2 = this._getKpiActualSeries(actualSeries, request.PeriodeType, dateTimePeriodes, seriesType, request.RangeFilter, request.GraphicType, out newTimeInformation, out newDateTimePeriodes, false);
                    var series3 = this._getKpiEconomicSeries(economicSeries, request.PeriodeType, dateTimePeriodes, seriesType, request.RangeFilter, request.GraphicType, out newTimeInformation, out newDateTimePeriodes, false, request.AsNetbackChart);
                    seriesResponse = series1.Concat(series2).Concat(series3).ToList();
                    seriesResponse = seriesResponse.OrderBy(x => x.Order).ToList();
                    break;

            }
            if ((request.PeriodeType == PeriodeType.Hourly && request.RangeFilter == RangeFilter.CurrentHour) ||
                     (request.PeriodeType == PeriodeType.Daily && request.RangeFilter == RangeFilter.CurrentDay) ||
                     (request.PeriodeType == PeriodeType.Monthly && request.RangeFilter == RangeFilter.CurrentMonth) ||
                     (request.PeriodeType == PeriodeType.Yearly && request.RangeFilter == RangeFilter.CurrentYear))
            {
                response.Subtitle = newTimeInformation;
                if (newDateTimePeriodes.Count > 0)
                {
                    switch (request.PeriodeType)
                    {
                        case PeriodeType.Hourly:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString("hh tt", CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString(DateFormat.Hourly, CultureInfo.InvariantCulture);
                            break;
                        case PeriodeType.Daily:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString("dd", CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString("dd MMM yy", CultureInfo.InvariantCulture);
                            break;
                        case PeriodeType.Monthly:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString("MMMM", CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString("MMM yy", CultureInfo.InvariantCulture);
                            break;
                        case PeriodeType.Yearly:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString(DateFormat.Yearly, CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString(DateFormat.Yearly, CultureInfo.InvariantCulture);
                            break;
                    }
                }

            }
            if (request.AsNetbackChart)
            {
                response.Subtitle = newTimeInformation;
                if (newDateTimePeriodes.Count > 0)
                {
                    switch (request.PeriodeType)
                    {
                        case PeriodeType.Hourly:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString("hh tt", CultureInfo.InvariantCulture) + " - " + newDateTimePeriodes.Last().ToString("hh tt", CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString(DateFormat.Hourly, CultureInfo.InvariantCulture);
                            break;
                        case PeriodeType.Daily:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString("dd", CultureInfo.InvariantCulture) + " - " + newDateTimePeriodes.Last().ToString("dd", CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString("dd MMM yy", CultureInfo.InvariantCulture);
                            break;
                        case PeriodeType.Monthly:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString("MMMM", CultureInfo.InvariantCulture) + " - " + newDateTimePeriodes.Last().ToString("MMMM", CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString("MMM yy", CultureInfo.InvariantCulture);
                            break;
                        case PeriodeType.Yearly:
                            response.Periodes = new List<string> { newDateTimePeriodes.First().ToString(DateFormat.Yearly, CultureInfo.InvariantCulture) + " - " + newDateTimePeriodes.Last().ToString(DateFormat.Yearly, CultureInfo.InvariantCulture) }.ToArray();
                            //timeInformation = kpiActual.Periode.ToString(DateFormat.Yearly, CultureInfo.InvariantCulture);
                            break;
                    }
                }
            }

            response.SeriesType = seriesType;
            response.Series = seriesResponse;
            return response;
        }