コード例 #1
0
ファイル: ArtifactController.cs プロジェクト: cobianwae/Pear
        public ActionResult GraphSettings()
        {
            switch (Request.QueryString["type"])
            {
                case "bar":
                    {
                        var viewModel = new BarChartViewModel();
                        viewModel.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                        viewModel.SeriesTypes.Add(new SelectListItem { Value = SeriesType.MultiStacks.ToString(), Text = "Multi Stacks" });
                        this.SetValueAxes(viewModel.ValueAxes, false);
                        var series = new BarChartViewModel.SeriesViewModel();
                        series.Stacks.Add(new BarChartViewModel.StackViewModel());
                        viewModel.Series.Add(series);
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.BarChart = viewModel;
                        return PartialView("~/Views/BarChart/_Create.cshtml", artifactViewModel);
                    }
                case "baraccumulative":
                    {
                        var viewModel = new BarChartViewModel();
                        viewModel.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                        this.SetValueAxes(viewModel.ValueAxes, false);
                        var series = new BarChartViewModel.SeriesViewModel();
                        series.Stacks.Add(new BarChartViewModel.StackViewModel());
                        viewModel.Series.Add(series);
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.BarChart = viewModel;
                        return PartialView("~/Views/BarChart/_Create.cshtml", artifactViewModel);
                    }
                case "barachievement":
                    {
                        var viewModel = new BarChartViewModel();
                        viewModel.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                        this.SetValueAxes(viewModel.ValueAxes, false);
                        var series = new BarChartViewModel.SeriesViewModel();
                        series.Stacks.Add(new BarChartViewModel.StackViewModel());
                        viewModel.Series.Add(series);
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.BarChart = viewModel;
                        return PartialView("~/Views/BarChart/_Create.cshtml", artifactViewModel);
                    }
                case "line":
                    {
                        var viewModel = new LineChartViewModel();
                        this.SetValueAxes(viewModel.ValueAxes, false);
                        var series = new LineChartViewModel.SeriesViewModel();
                        viewModel.Series.Add(series);
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.LineChart = viewModel;
                        return PartialView("~/Views/LineChart/_Create.cshtml", artifactViewModel);
                    }
                case "area":
                    {
                        var viewModel = new AreaChartViewModel();
                        viewModel.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                        viewModel.SeriesTypes.Add(new SelectListItem { Value = SeriesType.MultiStacks.ToString(), Text = "Multi Stacks" });
                        this.SetValueAxes(viewModel.ValueAxes, false);
                        var series = new AreaChartViewModel.SeriesViewModel();
                        series.Stacks.Add(new AreaChartViewModel.StackViewModel());
                        viewModel.Series.Add(series);
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.AreaChart = viewModel;
                        return PartialView("~/Views/AreaChart/_Create.cshtml", artifactViewModel);
                    }
                case "multiaxis":
                    {
                        var viewModel = new MultiaxisChartViewModel();
                        var chart = new MultiaxisChartViewModel.ChartViewModel();
                        this.SetValueAxes(viewModel.ValueAxes);
                        viewModel.GraphicTypes.Add(new SelectListItem { Value = "bar", Text = "Bar" });
                        viewModel.GraphicTypes.Add(new SelectListItem { Value = "baraccumulative", Text = "Bar Accumulative" });
                        viewModel.GraphicTypes.Add(new SelectListItem { Value = "barachievement", Text = "Bar Achievement" });
                        viewModel.GraphicTypes.Add(new SelectListItem { Value = "line", Text = "Line" });
                        viewModel.GraphicTypes.Add(new SelectListItem { Value = "area", Text = "Area" });
                        viewModel.Charts.Add(chart);
                        viewModel.Measurements = _measurementService.GetMeasurements(new GetMeasurementsRequest {
                            Take = -1,
                            SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
                        }).Measurements
              .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }).ToList();
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.MultiaxisChart = viewModel;
                        return PartialView("~/Views/MultiaxisChart/_Create.cshtml", artifactViewModel);
                    }
                case "combo":
                    {
                        var viewModel = new ComboChartViewModel();
                        var chart = new ComboChartViewModel.ChartViewModel();
                        this.SetValueAxes(viewModel.ValueAxes);
                        viewModel.GraphicTypes.Add(new SelectListItem { Value = "bar", Text = "Bar" });
                        viewModel.GraphicTypes.Add(new SelectListItem { Value = "baraccumulative", Text = "Bar Accumulative" });
                        viewModel.GraphicTypes.Add(new SelectListItem { Value = "barachievement", Text = "Bar Achievement" });
                        viewModel.GraphicTypes.Add(new SelectListItem { Value = "line", Text = "Line" });
                        viewModel.GraphicTypes.Add(new SelectListItem { Value = "area", Text = "Area" });
                        viewModel.Charts.Add(chart);
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.ComboChart = viewModel;
                        return PartialView("~/Views/ComboChart/_Create.cshtml", artifactViewModel);
                    }
                case "speedometer":
                    {
                        var viewModel = new SpeedometerChartViewModel();
                        var plot = new SpeedometerChartViewModel.PlotBand();
                        viewModel.PlotBands.Add(plot);
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.SpeedometerChart = viewModel;
                        return PartialView("~/Views/SpeedometerChart/_Create.cshtml", artifactViewModel);
                    }
                case "trafficlight":
                    {
                        var viewModel = new TrafficLightChartViewModel();
                        var plot = new TrafficLightChartViewModel.PlotBand();
                        viewModel.PlotBands.Add(plot);
                        var trafficLightViewModel = new ArtifactDesignerViewModel();
                        trafficLightViewModel.TrafficLightChart = viewModel;
                        return PartialView("~/Views/TrafficLightChart/_Create.cshtml", trafficLightViewModel);
                    }

                case "tabular":
                    {
                        var viewModel = new TabularViewModel();
                        var row = new TabularViewModel.RowViewModel();
                        this.SetPeriodeTypes(viewModel.PeriodeTypes);
                        this.SetRangeFilters(viewModel.RangeFilters);
                        viewModel.Rows.Add(row);
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.Tabular = viewModel;
                        return PartialView("~/Views/Tabular/_Create.cshtml", artifactViewModel);
                    }
                case "tank":
                    {
                        var viewModel = new TankViewModel();
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.Tank = viewModel;
                        return PartialView("~/Views/Tank/_Create.cshtml", artifactViewModel);
                    }
                case "pie":
                    {
                        var viewModel = new PieViewModel();
                        this.SetValueAxes(viewModel.ValueAxes, false);
                        var series = new PieViewModel.SeriesViewModel();
                        viewModel.Series.Add(series);
                        var artifactViewModel = new ArtifactDesignerViewModel();
                        artifactViewModel.Pie = viewModel;
                        return PartialView("~/Views/Pie/_Create.cshtml", artifactViewModel);
                    }
                default:
                    return PartialView("NotImplementedChart.cshtml");
            }
        }
コード例 #2
0
ファイル: DerLayoutController.cs プロジェクト: cobianwae/Pear
        public ActionResult LayoutItem(DerLayoutItemViewModel viewModel)
        {
            if (viewModel.Id > 0)
            {
                var response = _derService.GetDerLayoutItem(viewModel.Id);
                var editViewModel = response.MapTo<DerLayoutItemViewModel>();
                editViewModel.Types = _dropdownService.GetDerItemTypes().MapTo<SelectListItem>();
                editViewModel.Type = response.Type;
                switch (response.Type.ToLowerInvariant())
                {
                    case "line":
                        {
                            var lineChart = new LineChartViewModel();
                            editViewModel.LineChart = response.Artifact.MapPropertiesToInstance<LineChartViewModel>(lineChart);
                            var series = new LineChartViewModel.SeriesViewModel();
                            editViewModel.LineChart.Series.Insert(0, series);
                            editViewModel.Artifact.Measurements = _measurementService.GetMeasurements(new GetMeasurementsRequest
                            {
                                Take = -1,
                                SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
                            }).Measurements
                            .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }).ToList();
                            break;
                        }

                    case "pie":
                        {
                            var pie = new PieViewModel();
                            editViewModel.Pie = response.Artifact.MapPropertiesToInstance<PieViewModel>(pie);
                            var series = new PieViewModel.SeriesViewModel();
                            editViewModel.Pie.Series.Insert(0, series);
                            editViewModel.Artifact.Measurements = _measurementService.GetMeasurements(new GetMeasurementsRequest
                            {
                                Take = -1,
                                SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
                            }).Measurements
                            .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }).ToList();
                            break;
                        }

                    case "tank":
                        {
                            var tank = new TankViewModel();
                            editViewModel.Tank = response.Artifact.Tank.MapPropertiesToInstance<TankViewModel>(tank);
                            break;
                        }

                    case "multiaxis":
                        {
                            var multiaxisChart = new MultiaxisChartViewModel();
                            editViewModel.MultiaxisChart = response.Artifact.MapPropertiesToInstance<MultiaxisChartViewModel>(multiaxisChart);
                            multiaxisChart.GraphicTypes.Add(new SelectListItem { Value = "line", Text = "Line" });
                            multiaxisChart.ValueAxes.Add(new SelectListItem { Value = ValueAxis.KpiActual.ToString(), Text = "Kpi Actual" });
                            multiaxisChart.Measurements = _measurementService.GetMeasurements(new GetMeasurementsRequest
                            {
                                Take = -1,
                                SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
                            }).Measurements
                  .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }).ToList();
                            foreach (var chartRes in response.Artifact.Charts)
                            {
                                var chartViewModel = chartRes.MapTo<MultiaxisChartViewModel.ChartViewModel>();
                                switch (chartViewModel.GraphicType)
                                {
                                    case "line":
                                        {
                                            chartViewModel.LineChart = chartRes.MapTo<LineChartViewModel>();
                                            chartViewModel.LineChart.ValueAxes.Add(new SelectListItem { Value = ValueAxis.KpiActual.ToString(), Text = "Kpi Actual" });
                                            var series = new LineChartViewModel.SeriesViewModel();
                                            chartViewModel.LineChart.Series.Insert(0, series);
                                        }
                                        break;
                                }
                                multiaxisChart.Charts.Add(chartViewModel);
                            }
                            var chart = new MultiaxisChartViewModel.ChartViewModel();
                            editViewModel.MultiaxisChart.Charts.Insert(0, chart);

                            break;
                        }
                    case "avg-ytd-key-statistic":
                        {
                            break;
                        }
                    case "highlight":
                        {
                            var result = _selectService.GetHighlightTypesDropdown();
                            editViewModel.Highlights = result.Select(item => new SelectListItem() { Text = item.Text, Value = item.Value }).ToList();
                            editViewModel.HighlightId = response.Highlight.SelectOptionId;
                            break;
                        }
                    case "lng-and-cds":
                    case "procurement":
                        {
                            var result = _selectService.GetHighlightTypesDropdown();
                            editViewModel.Highlights = result.Select(item => new SelectListItem() { Text = item.Text, Value = item.Value }).ToList();
                            for (int i = 0; i < response.KpiInformations.Count; i++)
                            {
                                if (response.KpiInformations[i].SelectOption != null)
                                {
                                    editViewModel.KpiInformations[i].HighlightId = response.KpiInformations[i].SelectOption.Id;
                                }
                            }
                            break;
                        }
                }
                return View("EditLayoutItem", editViewModel);
            }
            else
            {
                viewModel.Types = _dropdownService.GetDerItemTypes().MapTo<SelectListItem>();
                return View("LayoutItem", viewModel);
            }
        }
コード例 #3
0
ファイル: ArtifactController.cs プロジェクト: cobianwae/Pear
        public ActionResult Edit(int id)
        {
            var artifact = _artifactServie.GetArtifact(new GetArtifactRequest { Id = id });

            var viewModel = new ArtifactDesignerViewModel();
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "bar", Text = "Bar" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "baraccumulative", Text = "Bar Accumulative" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "barachievement", Text = "Bar Achievement" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "line", Text = "Line" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "area", Text = "Area" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "multiaxis", Text = "Multi Axis" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "combo", Text = "Combination" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "speedometer", Text = "Speedometer" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "tabular", Text = "Tabular" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "tank", Text = "Tank" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "trafficlight", Text = "Traffic Light" });
            viewModel.GraphicTypes.Add(new SelectListItem { Value = "pie", Text = "Pie" });

            viewModel.Measurements = _measurementService.GetMeasurements(new GetMeasurementsRequest {
                Take = -1,
                SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
            }).Measurements
                .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }).ToList();

            this.SetPeriodeTypes(viewModel.PeriodeTypes);
            this.SetRangeFilters(viewModel.RangeFilters);
            this.SetValueAxes(viewModel.ValueAxes);
            artifact.MapPropertiesToInstance<ArtifactDesignerViewModel>(viewModel);
            switch (viewModel.GraphicType)
            {
                case "speedometer":
                    {
                        var speedometerChart = new SpeedometerChartViewModel();
                        viewModel.SpeedometerChart = artifact.MapPropertiesToInstance<SpeedometerChartViewModel>(speedometerChart);
                        var plot = new SpeedometerChartViewModel.PlotBand();
                        viewModel.SpeedometerChart.PlotBands.Insert(0, plot);
                    }
                    break;
                case "line":
                    {
                        var lineChart = new LineChartViewModel();
                        viewModel.LineChart = artifact.MapPropertiesToInstance<LineChartViewModel>(lineChart);
                        this.SetValueAxes(viewModel.LineChart.ValueAxes);
                        var series = new LineChartViewModel.SeriesViewModel();
                        viewModel.LineChart.Series.Insert(0, series);
                    }
                    break;
                case "area":
                    {

                        var areaChart = new AreaChartViewModel();
                        areaChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                        areaChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.MultiStacks.ToString(), Text = "Multi Stacks" });
                        viewModel.AreaChart = artifact.MapPropertiesToInstance<AreaChartViewModel>(areaChart);
                        this.SetValueAxes(viewModel.AreaChart.ValueAxes);
                        var series = new AreaChartViewModel.SeriesViewModel();
                        series.Stacks.Add(new AreaChartViewModel.StackViewModel());
                        viewModel.AreaChart.Series.Insert(0, series);
                    }
                    break;
                case "multiaxis":
                    {
                        var multiaxisChart = new MultiaxisChartViewModel();
                        viewModel.MultiaxisChart = artifact.MapPropertiesToInstance<MultiaxisChartViewModel>(multiaxisChart);
                        this.SetValueAxes(viewModel.MultiaxisChart.ValueAxes);
                        multiaxisChart.GraphicTypes.Add(new SelectListItem { Value = "bar", Text = "Bar" });
                        multiaxisChart.GraphicTypes.Add(new SelectListItem { Value = "baraccumulative", Text = "Bar Accumulative" });
                        multiaxisChart.GraphicTypes.Add(new SelectListItem { Value = "barachievement", Text = "Bar Achievement" });
                        multiaxisChart.GraphicTypes.Add(new SelectListItem { Value = "line", Text = "Line" });
                        multiaxisChart.GraphicTypes.Add(new SelectListItem { Value = "area", Text = "Area" });
                        multiaxisChart.Measurements = _measurementService.GetMeasurements(new GetMeasurementsRequest {
                            Take = -1,
                            SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
                        }).Measurements
              .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }).ToList();
                        foreach (var chartRes in artifact.Charts)
                        {
                            var chartViewModel = chartRes.MapTo<MultiaxisChartViewModel.ChartViewModel>();
                            switch (chartViewModel.GraphicType)
                            {
                                case "line":
                                    {
                                        chartViewModel.LineChart = chartRes.MapTo<LineChartViewModel>();
                                        this.SetValueAxes(chartViewModel.LineChart.ValueAxes);
                                        var series = new LineChartViewModel.SeriesViewModel();
                                        chartViewModel.LineChart.Series.Insert(0, series);
                                    }
                                    break;
                                case "area":
                                    {
                                        chartViewModel.AreaChart = chartRes.MapTo<AreaChartViewModel>();
                                        chartViewModel.AreaChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                                        chartViewModel.AreaChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.MultiStacks.ToString(), Text = "Multi Stacks" });

                                        this.SetValueAxes(chartViewModel.AreaChart.ValueAxes);
                                        var series = new AreaChartViewModel.SeriesViewModel();
                                        series.Stacks.Add(new AreaChartViewModel.StackViewModel());
                                        chartViewModel.AreaChart.Series.Insert(0, series);
                                    }
                                    break;
                                default:
                                    {
                                        chartViewModel.BarChart = chartRes.MapTo<BarChartViewModel>();
                                        chartViewModel.BarChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                                        chartViewModel.BarChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.MultiStacks.ToString(), Text = "Multi Stacks" });
                                        this.SetValueAxes(chartViewModel.BarChart.ValueAxes, false);

                                        var series = new BarChartViewModel.SeriesViewModel();
                                        series.Stacks.Add(new BarChartViewModel.StackViewModel());
                                        chartViewModel.BarChart.Series.Insert(0, series);
                                    }
                                    break;
                            }
                            multiaxisChart.Charts.Add(chartViewModel);
                        }
                        var chart = new MultiaxisChartViewModel.ChartViewModel();
                        viewModel.MultiaxisChart.Charts.Insert(0, chart);
                    }
                    break;
                case "combo":
                    {
                        var comboChart = new ComboChartViewModel();
                        viewModel.ComboChart = artifact.MapPropertiesToInstance<ComboChartViewModel>(comboChart);
                        this.SetValueAxes(viewModel.ComboChart.ValueAxes);
                        comboChart.GraphicTypes.Add(new SelectListItem { Value = "bar", Text = "Bar" });
                        comboChart.GraphicTypes.Add(new SelectListItem { Value = "baraccumulative", Text = "Bar Accumulative" });
                        comboChart.GraphicTypes.Add(new SelectListItem { Value = "barachievement", Text = "Bar Achievement" });
                        comboChart.GraphicTypes.Add(new SelectListItem { Value = "line", Text = "Line" });
                        comboChart.GraphicTypes.Add(new SelectListItem { Value = "area", Text = "Area" });
                        foreach (var chartRes in artifact.Charts)
                        {
                            var chartViewModel = chartRes.MapTo<ComboChartViewModel.ChartViewModel>();
                            switch (chartViewModel.GraphicType)
                            {
                                case "line":
                                    {
                                        chartViewModel.LineChart = chartRes.MapTo<LineChartViewModel>();
                                        this.SetValueAxes(chartViewModel.LineChart.ValueAxes);
                                        var series = new LineChartViewModel.SeriesViewModel();
                                        chartViewModel.LineChart.Series.Insert(0, series);
                                    }
                                    break;
                                case "area":
                                    {
                                        chartViewModel.AreaChart = chartRes.MapTo<AreaChartViewModel>();
                                        chartViewModel.AreaChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                                        chartViewModel.AreaChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.MultiStacks.ToString(), Text = "Multi Stacks" });

                                        this.SetValueAxes(chartViewModel.AreaChart.ValueAxes);
                                        var series = new AreaChartViewModel.SeriesViewModel();
                                        series.Stacks.Add(new AreaChartViewModel.StackViewModel());
                                        chartViewModel.AreaChart.Series.Insert(0, series);
                                    }
                                    break;
                                default:
                                    {
                                        chartViewModel.BarChart = chartRes.MapTo<BarChartViewModel>();
                                        chartViewModel.BarChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                                        chartViewModel.BarChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.MultiStacks.ToString(), Text = "Multi Stacks" });
                                        this.SetValueAxes(chartViewModel.BarChart.ValueAxes, false);

                                        var series = new BarChartViewModel.SeriesViewModel();
                                        series.Stacks.Add(new BarChartViewModel.StackViewModel());
                                        chartViewModel.BarChart.Series.Insert(0, series);
                                    }
                                    break;
                            }
                            comboChart.Charts.Add(chartViewModel);
                        }
                        var chart = new ComboChartViewModel.ChartViewModel();
                        viewModel.ComboChart.Charts.Insert(0, chart);
                    }
                    break;
                case "barachievement":
                    {
                        var barChart = new BarChartViewModel();
                        barChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                        this.SetValueAxes(barChart.ValueAxes, false);
                        viewModel.BarChart = artifact.MapPropertiesToInstance<BarChartViewModel>(barChart);
                        var series = new BarChartViewModel.SeriesViewModel();
                        series.Stacks.Add(new BarChartViewModel.StackViewModel());
                        viewModel.BarChart.Series.Insert(0, series);
                    }
                    break;
                case "baraccumulative":
                    {
                        var barChart = new BarChartViewModel();
                        barChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                        this.SetValueAxes(barChart.ValueAxes, false);
                        viewModel.BarChart = artifact.MapPropertiesToInstance<BarChartViewModel>(barChart);
                        var series = new BarChartViewModel.SeriesViewModel();
                        series.Stacks.Add(new BarChartViewModel.StackViewModel());
                        viewModel.BarChart.Series.Insert(0, series);
                    }
                    break;
                case "trafficlight":
                    {
                        var trafficLightChart = new TrafficLightChartViewModel();
                        viewModel.TrafficLightChart = artifact.MapPropertiesToInstance<TrafficLightChartViewModel>(trafficLightChart);
                        var plot = new TrafficLightChartViewModel.PlotBand();
                        viewModel.TrafficLightChart.PlotBands.Insert(0, plot);
                    }
                    break;
                case "tank":
                    {
                        viewModel.Tank = artifact.Tank.MapTo<TankViewModel>();
                    }
                    break;
                case "tabular":
                    {
                        viewModel.Tabular = artifact.MapPropertiesToInstance(new TabularViewModel());
                        viewModel.Tabular.Rows = new List<TabularViewModel.RowViewModel>();
                        viewModel.Tabular.Rows.Insert(0, new TabularViewModel.RowViewModel());
                        this.SetPeriodeTypes(viewModel.Tabular.PeriodeTypes);
                        this.SetRangeFilters(viewModel.Tabular.RangeFilters);

                        foreach (var row in artifact.Rows)
                        {
                            viewModel.Tabular.Rows.Add(new TabularViewModel.RowViewModel
                                {
                                    KpiId = row.KpiId,
                                    KpiName = row.KpiName,
                                    PeriodeType = row.PeriodeType.ToString(),
                                    EndInDisplay = ParseDateToString(row.PeriodeType, row.End),
                                    StartInDisplay = ParseDateToString(row.PeriodeType, row.Start),
                                    RangeFilter = row.RangeFilter.ToString()
                                });
                        }
                        /*foreach (var item in viewModel.Tabular.Rows)
                        {
                            if (item.Start.HasValue && item.End.HasValue)
                            {
                                item.StartInDisplay = ParseDateToString((PeriodeType)Enum.Parse(typeof(PeriodeType), item.PeriodeType), item.Start);
                                item.EndInDisplay = ParseDateToString((PeriodeType)Enum.Parse(typeof(PeriodeType), item.PeriodeType), item.End);
                            }
                        }*/
                    }
                    break;
                case "pie":
                    {
                        viewModel.Pie = artifact.MapPropertiesToInstance(new PieViewModel());
                        this.SetValueAxes(viewModel.Pie.ValueAxes);
                        var series = new PieViewModel.SeriesViewModel();
                        /*viewModel.Is3D = artifact.Is3D;
                        viewModel.ShowLegend = artifact.ShowLegend;*/
                        viewModel.Pie.Series.Insert(0, series);
                    }
                    break;
                default:
                    {
                        var barChart = new BarChartViewModel();
                        barChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.SingleStack.ToString(), Text = "Single Stack" });
                        barChart.SeriesTypes.Add(new SelectListItem { Value = SeriesType.MultiStacks.ToString(), Text = "Multi Stacks" });
                        this.SetValueAxes(barChart.ValueAxes, false);

                        viewModel.BarChart = artifact.MapPropertiesToInstance<BarChartViewModel>(barChart);
                        var series = new BarChartViewModel.SeriesViewModel();
                        series.Stacks.Add(new BarChartViewModel.StackViewModel());
                        viewModel.BarChart.Series.Insert(0, series);
                    }
                    break;
            }

            viewModel.StartInDisplay = ParseDateToString(artifact.PeriodeType, artifact.Start);
            viewModel.EndInDisplay = ParseDateToString(artifact.PeriodeType, artifact.End);
            return View(viewModel);
        }
コード例 #4
0
ファイル: DerLayoutController.cs プロジェクト: fazar/Pear
        public ActionResult LayoutItem(DerLayoutItemViewModel viewModel)
        {
            if (viewModel.Id > 0)
            {
                #region edit
                var response = _derService.GetDerLayoutItem(viewModel.Id);
                var editViewModel = response.MapTo<DerLayoutItemViewModel>();
                editViewModel.Types = _dropdownService.GetDerItemTypes().OrderBy(x => x.Text).MapTo<SelectListItem>();
                editViewModel.Type = response.Type;
                switch (response.Type.ToLowerInvariant())
                {
                    case "line":
                        {
                            var lineChart = new LineChartViewModel();
                            editViewModel.LineChart = response.Artifact.MapPropertiesToInstance<LineChartViewModel>(lineChart);
                            var series = new LineChartViewModel.SeriesViewModel();
                            editViewModel.LineChart.Series.Insert(0, series);
                            editViewModel.Artifact.Measurements = _measurementService.GetMeasurements(new GetMeasurementsRequest
                            {
                                Take = -1,
                                SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
                            }).Measurements
                            .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }).ToList();
                            break;
                        }

                    case "pie":
                        {
                            var pie = new PieViewModel();
                            editViewModel.Pie = response.Artifact.MapPropertiesToInstance<PieViewModel>(pie);
                            var series = new PieViewModel.SeriesViewModel();
                            editViewModel.Pie.Series.Insert(0, series);
                            editViewModel.Artifact.Measurements = _measurementService.GetMeasurements(new GetMeasurementsRequest
                            {
                                Take = -1,
                                SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
                            }).Measurements
                            .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }).ToList();
                            break;
                        }

                    case "tank":
                        {
                            var tank = new TankViewModel();
                            editViewModel.Tank = response.Artifact.Tank.MapPropertiesToInstance<TankViewModel>(tank);
                            break;
                        }

                    case "multiaxis":
                        {
                            var multiaxisChart = new MultiaxisChartViewModel();
                            editViewModel.MultiaxisChart = response.Artifact.MapPropertiesToInstance<MultiaxisChartViewModel>(multiaxisChart);
                            multiaxisChart.GraphicTypes.Add(new SelectListItem { Value = "line", Text = "Line" });
                            multiaxisChart.ValueAxes.Add(new SelectListItem { Value = ValueAxis.KpiActual.ToString(), Text = "Kpi Actual" });
                            multiaxisChart.Measurements = _measurementService.GetMeasurements(new GetMeasurementsRequest
                            {
                                Take = -1,
                                SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
                            }).Measurements
                  .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }).ToList();
                            foreach (var chartRes in response.Artifact.Charts)
                            {
                                var chartViewModel = chartRes.MapTo<MultiaxisChartViewModel.ChartViewModel>();
                                switch (chartViewModel.GraphicType)
                                {
                                    case "line":
                                        {
                                            chartViewModel.LineChart = chartRes.MapTo<LineChartViewModel>();
                                            chartViewModel.LineChart.ValueAxes.Add(new SelectListItem { Value = ValueAxis.KpiActual.ToString(), Text = "Kpi Actual" });
                                            var series = new LineChartViewModel.SeriesViewModel();
                                            chartViewModel.LineChart.Series.Insert(0, series);
                                        }
                                        break;
                                }
                                multiaxisChart.Charts.Add(chartViewModel);
                            }
                            var chart = new MultiaxisChartViewModel.ChartViewModel();
                            editViewModel.MultiaxisChart.Charts.Insert(0, chart);

                            break;
                        }
                    case "speedometer":
                    case "barmeter":
                        {
                            var speedometerChart = new SpeedometerChartViewModel();
                            editViewModel.SpeedometerChart = response.Artifact.MapPropertiesToInstance<SpeedometerChartViewModel>(speedometerChart);
                            if (response.Artifact.Series.Count > 0)
                            {
                                speedometerChart.LabelSeries = new SpeedometerChartViewModel.SeriesViewModel
                                {
                                    KpiId = response.Artifact.Series[0].KpiId,
                                    KpiName = response.Artifact.Series[0].KpiName,
                                    Label = response.Artifact.Series[0].Label
                                };
                            }
                            else {
                                speedometerChart.LabelSeries = new SpeedometerChartViewModel.SeriesViewModel();
                            }
                            var plot = new SpeedometerChartViewModel.PlotBand();
                            editViewModel.SpeedometerChart.PlotBands.Insert(0, plot);
                            break;
                        }
                    case "highlight":
                        {
                            var result = _selectService.GetHighlightTypesDropdown();
                            editViewModel.Highlights = result.Select(item => new SelectListItem() { Text = item.Text, Value = item.Value }).ToList();
                            editViewModel.HighlightId = response.Highlight.SelectOptionId;
                            break;
                        }
                    case "key-equipment-status":
                        {
                            var result = _selectService.GetHighlightTypesDropdown();
                            editViewModel.Highlights = result.Select(item => new SelectListItem() { Text = item.Text, Value = item.Value }).ToList();
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 24);
                            for (int i = 0; i < response.KpiInformations.Count; i++)
                            {
                                if (response.KpiInformations[i].SelectOption != null)
                                {
                                    editViewModel.KpiInformations[i].HighlightId = response.KpiInformations[i].SelectOption.Id;
                                }
                            }
                        }
                        break;
                    case "termometer":
                    case "person-on-board":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 1);
                            break;
                        }
                    case "hhv":
                    case "procurement":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 2);
                            break;
                        }
                    case "mgdp":
                    case "dafwc":
                    case "job-pmts":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 3);
                            break;
                        }
                    case "indicative-commercial-price":
                    case "total-feed-gas":
                    case "weekly-maintenance":
                    case "critical-pm":
                    case "loading-duration":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 4);
                            break;
                        }
                    case "avg-ytd-key-statistic":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 5);
                            break;
                        }
                    case "temperature":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 2);
                            break;
                        }
                    case "security":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 6);
                            break;
                        }
                    case "plant-availability":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 7);
                            break;
                        }
                    case "lng-and-cds-production":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 10);
                            break;
                        }

                    case "safety":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 11);
                            break;
                        }
                    case "global-stock-market":
                    case "table-tank":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 15);
                            var result = _selectService.GetHighlightTypesDropdown();
                            editViewModel.Highlights = result.Select(item => new SelectListItem() { Text = item.Text, Value = item.Value }).ToList();
                            break;
                        }

                    case "economic-indicator":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 15);
                            break;
                        }
                    case "lng-and-cds":
                        {
                            editViewModel.KpiInformations = AddEmptyKpiInformations(editViewModel.KpiInformations, 17);
                            break;
                        }
                    case "prepared-by":
                    case "reviewed-by":
                        {
                            editViewModel.SignedBy = response.SignedBy;
                            var result = _userService.GetUsers(new GetUsersRequest { SortingDictionary = new Dictionary<string, SortOrder>(), Take = 1000 });
                            editViewModel.Users =
                                result.Users.Select(
                                    item => new SelectListItem() { Text = item.Username, Value = item.Id.ToString() }).ToList();
                            break;
                        }

                }
                return View("EditLayoutItem", editViewModel);
                #endregion
            }
            else
            {
                #region create
                viewModel.Types = _dropdownService.GetDerItemTypes().OrderBy(x => x.Text).MapTo<SelectListItem>();
                var rowCol = viewModel.Row.ToString() + "-and-" + viewModel.Column.ToString();
                switch (rowCol)
                {
                    case "0-and-0":
                        {
                            viewModel.Type = "avg-ytd-key-statistic";
                            break;
                        };
                    case "0-and-2":
                        {
                            viewModel.Type = "speedometer";
                            break;
                        }
                    case "1-and-0":
                        {
                            viewModel.Type = "multiaxis";
                            break;
                        }
                    case "1-and-1":
                    case "1-and-2":
                    case "1-and-3":
                        {
                            viewModel.Type = "line";
                            break;
                        }
                    case "2-and-0":
                        {
                            viewModel.Type = "dafwc";
                            break;
                        }
                    case "2-and-1":
                        {
                            viewModel.Type = "weather";
                            break;
                        }
                    case "2-and-2":
                        {
                            viewModel.Type = "wave";
                            break;
                        }
                    case "2-and-3":
                        {
                            viewModel.Type = "temperature";
                            break;
                        }
                    case "3-and-0":
                        {
                            viewModel.Type = "safety";
                            break;
                        }
                    case "3-and-1":
                    case "3-and-2":
                    case "3-and-3":
                    case "0-and-1":
                    case "0-and-3":
                    case "3-and-5":
                    case "10-and-2":
                    case "11-and-2":
                    case "11-and-1":
                    case "12-and-0":
                    case "12-and-2":
                    case "13-and-0":
                    case "14-and-2":
                    case "15-and-1":
                    case "15-and-2":
                    case "16-and-4":
                    case "16-and-5":
                    case "16-and-6":
                    case "16-and-7":
                        {
                            viewModel.Type = "highlight";
                            break;
                        }
                    case "3-and-4":
                        {
                            viewModel.Type = "pie";
                            break;
                        }
                    case "4-and-0":
                        {
                            viewModel.Type = "dafwc";
                            break;
                        }
                    case "4-and-1":
                        {
                            viewModel.Type = "security";
                            break;
                        }
                    case "4-and-2":
                        {
                            viewModel.Type = "alert";
                            break;
                        }
                    case "5-and-0":
                        {
                            viewModel.Type = "job-pmts";
                            break;
                        }
                    case "5-and-1":
                        {
                            viewModel.Type = "mgdp";
                            break;
                        }
                    case "5-and-2":
                        {
                            viewModel.Type = "hhv";
                            break;
                        }
                    case "6-and-0":
                        {
                            viewModel.Type = "total-feed-gas";
                            break;
                        }
                    case "6-and-2":
                        {
                            viewModel.Type = "plant-availability";
                            break;
                        }
                    case "6-and-3":
                    case "6-and-4":
                    case "6-and-6":
                    case "6-and-7":
                    case "6-and-8":
                    case "6-and-9":
                    case "6-and-10":
                    case "6-and-11":
                        {
                            viewModel.Type = "barmeter";
                            break;
                        }
                    case "6-and-5":
                        {
                            viewModel.Type = "termometer";
                            break;

                        }
                    case "6-and-12":
                        {
                            viewModel.Type = "flare";
                            break;
                        }
                    case "7-and-0":
                        {
                            viewModel.Type = "lng-and-cds-production";
                            break;
                        }
                    case "7-and-1":
                        {
                            viewModel.Type = "lng-and-cds";
                            break;
                        }
                    case "8-and-0":
                    case "8-and-1":
                    case "8-and-2":
                    case "8-and-3":
                        {
                            viewModel.Type = "tank";
                            break;
                        }
                    case "8-and-4":
                        {
                            viewModel.Type = "nls";
                            break;
                        }
                    case "9-and-0":
                        {
                            viewModel.Type = "table-tank";
                            break;
                        }
                    case "10-and-0":
                        {
                            viewModel.Type = "weekly-maintenance";
                            break;
                        }
                    case "10-and-1":
                        {
                            viewModel.Type = "key-equipment-status";
                            break;
                        }
                    case "11-and-0":
                        {
                            viewModel.Type = "critical-pm";
                            break;
                        }
                    case "12-and-1":
                        {
                            viewModel.Type = "loading-duration";
                            break;
                        }
                    case "14-and-0":
                        {
                            viewModel.Type = "procurement";
                            break;
                        }
                    case "15-and-0":
                        {
                            viewModel.Type = "indicative-commercial-price";
                            break;
                        }
                    case "14-and-1":
                        {
                            viewModel.Type = "economic-indicator";
                            break;
                        }
                    case "16-and-1":
                        {
                            viewModel.Type = "global-stock-market";
                            break;
                        }
                    case "16-and-2":
                        {
                            viewModel.Type = "prepared-by";
                            break;
                        }
                    case "16-and-3":
                        {
                            viewModel.Type = "reviewed-by";
                            break;
                        }
                    case "15-and-3":
                        {
                            viewModel.Type = "person-on-board";
                            break;
                        }
                }
                return View("LayoutItem", viewModel);
                #endregion
            }
        }