Ejemplo n.º 1
0
        public ActionResult SaveLayoutItem(DerLayoutItemViewModel layoutItemViewModel)
        {
            var req = Request;
            var request = new SaveLayoutItemRequest();
            var response = new SaveLayoutItemResponse();
            switch (layoutItemViewModel.Type.ToLowerInvariant())
            {
                case "line":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Artifact = layoutItemViewModel.Artifact.MapTo<SaveLayoutItemRequest.LayoutItemArtifact>();
                        request.Artifact.LineChart = layoutItemViewModel.LineChart.MapTo<SaveLayoutItemRequest.LayoutItemArtifactLine>();
                        response = _derService.SaveLayoutItem(request);

                        break;
                    }

                case "multiaxis":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Artifact = layoutItemViewModel.Artifact.MapTo<SaveLayoutItemRequest.LayoutItemArtifact>();
                        request.Artifact.MultiAxis = layoutItemViewModel.MultiaxisChart.MapTo<SaveLayoutItemRequest.LayoutItemArtifactMultiAxis>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                case "pie":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Artifact = layoutItemViewModel.Artifact.MapTo<SaveLayoutItemRequest.LayoutItemArtifact>();
                        request.Artifact.Pie = layoutItemViewModel.Pie.MapTo<SaveLayoutItemRequest.LayoutItemArtifactPie>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                case "tank":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Artifact = layoutItemViewModel.Artifact.MapTo<SaveLayoutItemRequest.LayoutItemArtifact>();
                        request.Artifact.Tank = layoutItemViewModel.Tank.MapTo<SaveLayoutItemRequest.LayoutItemArtifactTank>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                case "highlight":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Highlight = new SaveLayoutItemRequest.LayoutItemHighlight();
                        request.Highlight.SelectOptionId = layoutItemViewModel.HighlightId;
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                case "alert":
                case "weather":
                case "wave":
                case "nls":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Type = layoutItemViewModel.Type;
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                /*case "avg-ytd-key-statistic":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.KpiInformations =
                            layoutItemViewModel.KpiInformations.MapTo<SaveLayoutItemRequest.DerKpiInformationRequest>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }*/
                case "safety":
                case "security":
                case "job-pmts":
                case "avg-ytd-key-statistic":
                case "lng-and-cds":
                case "total-feed-gas":
                case "table-tank":
                case "mgdp":
                case "hhv":
                case "lng-and-cds-production":
                case "weekly-maintenance":
                case "critical-pm":
                case "procurement":
                case "indicative-commercial-price":
                case "plant-availability":
                case "economic-indicator":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.KpiInformations = layoutItemViewModel.KpiInformations.MapTo<SaveLayoutItemRequest.DerKpiInformationRequest>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                /*case "lng-and-cds":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.KpiInformations =
                            layoutItemViewModel.KpiInformations.MapTo<SaveLayoutItemRequest.DerKpiInformationRequest>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }*/
                case "dafwc":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
            }

            TempData["IsSuccess"] = response.IsSuccess;
            TempData["Message"] = response.Message;

            return RedirectToAction("Config", new { id = layoutItemViewModel.DerLayoutId });
        }
Ejemplo n.º 2
0
        public ActionResult SaveLayoutItem(DerLayoutItemViewModel layoutItemViewModel)
        {
            var req = Request;
            var request = new SaveLayoutItemRequest();
            var response = new SaveLayoutItemResponse();
            switch (layoutItemViewModel.Type.ToLowerInvariant())
            {
                case "line":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Artifact = layoutItemViewModel.Artifact.MapTo<SaveLayoutItemRequest.LayoutItemArtifact>();
                        request.Artifact.LineChart = layoutItemViewModel.LineChart.MapTo<SaveLayoutItemRequest.LayoutItemArtifactLine>();
                        response = _derService.SaveLayoutItem(request);

                        break;
                    }

                case "multiaxis":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Artifact = layoutItemViewModel.Artifact.MapTo<SaveLayoutItemRequest.LayoutItemArtifact>();
                        request.Artifact.MultiAxis = layoutItemViewModel.MultiaxisChart.MapTo<SaveLayoutItemRequest.LayoutItemArtifactMultiAxis>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                case "pie":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Artifact = layoutItemViewModel.Artifact.MapTo<SaveLayoutItemRequest.LayoutItemArtifact>();
                        request.Artifact.Pie = layoutItemViewModel.Pie.MapTo<SaveLayoutItemRequest.LayoutItemArtifactPie>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                case "tank":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Artifact = layoutItemViewModel.Artifact.MapTo<SaveLayoutItemRequest.LayoutItemArtifact>();
                        request.Artifact.Tank = layoutItemViewModel.Tank.MapTo<SaveLayoutItemRequest.LayoutItemArtifactTank>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                case "barmeter":
                case "speedometer":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Artifact = layoutItemViewModel.Artifact.MapTo<SaveLayoutItemRequest.LayoutItemArtifact>();
                        request.Artifact.Speedometer = layoutItemViewModel.SpeedometerChart.MapTo<SaveLayoutItemRequest.LayoutItemArtifactSpeedometer>();
                        response = _derService.SaveLayoutItem(request);

                        break;
                    }
                case "highlight":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Highlight = new SaveLayoutItemRequest.LayoutItemHighlight();
                        request.Highlight.SelectOptionId = layoutItemViewModel.HighlightId;
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                case "alert":
                case "weather":
                case "wave":
                case "nls":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.Type = layoutItemViewModel.Type;
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                case "safety":
                case "security":
                case "avg-ytd-key-statistic":
                case "temperature":
                case "lng-and-cds":
                case "total-feed-gas":
                case "table-tank":
                case "hhv":
                case "lng-and-cds-production":
                case "weekly-maintenance":
                case "critical-pm":
                case "procurement":
                case "indicative-commercial-price":
                case "economic-indicator":
                case "key-equipment-status":
                case "plant-availability":
                case "job-pmts":
                case "mgdp":
                case "global-stock-market":
                case "dafwc":
                case "termometer":
                case "loading-duration":
                case "person-on-board":
                case "flare":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.KpiInformations = layoutItemViewModel.KpiInformations.MapTo<SaveLayoutItemRequest.DerKpiInformationRequest>();
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                case "prepared-by":
                case "reviewed-by":
                    {
                        request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                        request.SignedBy = layoutItemViewModel.SignedBy;
                        response = _derService.SaveLayoutItem(request);
                        break;
                    }
                    /*case "job-pmts":
                    case "mgdp":
                        {
                            request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                            request.KpiInformations = layoutItemViewModel.KpiInformations.MapTo<SaveLayoutItemRequest.DerKpiInformationRequest>();
                            var mbbtuKpi = request.KpiInformations.FirstOrDefault(x => x.Position == 1);
                            if (mbbtuKpi != null)
                            {
                                var newMbbtuKpiTarget = new SaveLayoutItemRequest.DerKpiInformationRequest();
                                newMbbtuKpiTarget.ConfigType = ConfigType.KpiTarget;
                                newMbbtuKpiTarget.KpiId = mbbtuKpi.KpiId;
                                newMbbtuKpiTarget.Position = 3;
                                request.KpiInformations.Add(newMbbtuKpiTarget);
                            }
                            response = _derService.SaveLayoutItem(request);
                            break;
                        }*/
                    /*case "lng-and-cds":
                        {
                            request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                            request.KpiInformations =
                                layoutItemViewModel.KpiInformations.MapTo<SaveLayoutItemRequest.DerKpiInformationRequest>();
                            response = _derService.SaveLayoutItem(request);
                            break;
                        }*/
                    /*case "dafwc":
                        {
                            request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                            response = _derService.SaveLayoutItem(request);
                            break;
                        }*/
                    /*case "plant-availability":
                    {
                            request = layoutItemViewModel.MapTo<SaveLayoutItemRequest>();
                            request.KpiInformations = layoutItemViewModel.KpiInformations.MapTo<SaveLayoutItemRequest.DerKpiInformationRequest>();
                            var mbbtuKpi = request.KpiInformations.FirstOrDefault(x => x.Position == 0 || x.Position == 1 || x.Position == 2 ||
                                x.Position ==3);
                            if (mbbtuKpi != null)
                            {
                                var newMbbtuKpiTarget = new SaveLayoutItemRequest.DerKpiInformationRequest();
                                newMbbtuKpiTarget.ConfigType = ConfigType.KpiTarget;
                                newMbbtuKpiTarget.KpiId = mbbtuKpi.KpiId;
                                newMbbtuKpiTarget.Position = 3;
                                request.KpiInformations.Add(newMbbtuKpiTarget);
                            }
                            response = _derService.SaveLayoutItem(request);
                            break;
                        }*/
            }

            TempData["IsSuccess"] = response.IsSuccess;
            TempData["Message"] = response.Message;

            return RedirectToAction("Config", new { id = layoutItemViewModel.DerLayoutId });
        }