예제 #1
0
 public ActionResult MultiaxisSettings()
 {
     var artifactViewModel = new ArtifactDesignerViewModel();
     artifactViewModel.MultiaxisChart = new MultiaxisChartViewModel();
     var chart = new MultiaxisChartViewModel.ChartViewModel();
     artifactViewModel.MultiaxisChart.Charts.Add(chart);
     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);
                 artifactViewModel.MultiaxisChart.Charts[0].BarChart = viewModel;
                 //arti.BarChart = viewModel;
                 return PartialView("~/Views/MultiaxisChart/_BarChartCreate.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);
                 artifactViewModel.MultiaxisChart.Charts[0].BarChart = viewModel;
                 //arti.BarChart = viewModel;
                 return PartialView("~/Views/MultiaxisChart/_BarChartCreate.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);
                 artifactViewModel.MultiaxisChart.Charts[0].BarChart = viewModel;
                 //arti.BarChart = viewModel;
                 return PartialView("~/Views/MultiaxisChart/_BarChartCreate.cshtml", artifactViewModel);
             }
         case "line":
             {
                 var viewModel = new LineChartViewModel();
                 this.SetValueAxes(viewModel.ValueAxes, false);
                 var series = new LineChartViewModel.SeriesViewModel();
                 viewModel.Series.Add(series);
                 artifactViewModel.MultiaxisChart.Charts[0].LineChart = viewModel;
                 //arti.BarChart = viewModel;
                 return PartialView("~/Views/MultiaxisChart/_LineChartCreate.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);
                 artifactViewModel.MultiaxisChart.Charts[0].AreaChart = viewModel;
                 //arti.BarChart = viewModel;
                 return PartialView("~/Views/MultiaxisChart/_AreaChartCreate.cshtml", artifactViewModel);
             }
         default:
             return PartialView("NotImplementedChart.cshtml");
     }
 }
예제 #2
0
        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);
        }
예제 #3
0
        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");
            }
        }
예제 #4
0
        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 = "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.Measurements = _measurementService.GetMeasurements(new GetMeasurementsRequest()).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();
                        viewModel.AreaChart = artifact.MapPropertiesToInstance<AreaChartViewModel>(areaChart);
                        this.SetValueAxes(viewModel.AreaChart.ValueAxes);
                        var series = new AreaChartViewModel.SeriesViewModel();
                        viewModel.AreaChart.Series.Insert(0, series);
                    }
                    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.Insert(0, new TabularViewModel.RowViewModel());
                        this.SetPeriodeTypes(viewModel.Tabular.PeriodeTypes);
                        this.SetRangeFilters(viewModel.Tabular.RangeFilters);
                    }
                    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);
        }