Example #1
0
        public IHttpActionResult EditChart(HomeConfigurationModel model)
        {
            HomeConfigurationBLL   device        = new HomeConfigurationBLL();
            DashBoardDataListModel DashBoardData = new DashBoardDataListModel()
            {
                x = Convert.ToInt32(model.XAxis),
                y = Convert.ToInt32(model.YAxis),
                w = Convert.ToInt32(model.Width),
                h = Convert.ToInt32(model.Height),
                i = model.ID.ToString()
            };

            model.DashBoardData = JsonConvert.SerializeObject(DashBoardData);
            model.DatabaseType  = "0";//默认设备源
            DashBoardChartConfigModel ChartConfig = new DashBoardChartConfigModel()
            {
                DatabaseType        = model.DatabaseType,
                DataType            = model.DataType,
                RecentInterval      = model.RecentInterval,
                RecentUnit          = model.RecentUnit,
                StartTime           = model.StartTime.ToString(),
                EndTime             = model.EndTime.ToString(),
                StatisticalInterval = model.StatisticalInterval,
                IntervalUnit        = model.IntervalUnit,
                MinValue            = model.MinValue,
                MaxValue            = model.MaxValue,
                ValueType           = model.ValueType,
                TextColor           = model.TextColor,
                BackgroundColor     = model.BackgroundColor
            };
            List <HomeDeviceInfo> HomeDeviceInfoList = new List <HomeDeviceInfo>();

            if (model.DeviceItemList != null)
            {
                for (int i = 0; i < model.DeviceItemList.Count; i++)
                {
                    HomeDeviceInfo HomeDeviceInfo = new HomeDeviceInfo();
                    HomeDeviceInfo.DeviceID     = model.DeviceID;
                    HomeDeviceInfo.DeviceItemID = model.DeviceItemList[i].DeviceItemID;
                    HomeDeviceInfoList.Add(HomeDeviceInfo);
                }
            }
            ChartConfig.HomeDeviceInfoList = HomeDeviceInfoList;
            model.ChartConfig = JsonConvert.SerializeObject(ChartConfig);

            var update = device.EditChart(model);

            return(InspurJson <RetHomeConfiguration>(update));
        }
Example #2
0
        public IHttpActionResult IndexEditChart(HomeConfigurationModel model)
        {
            HomeConfigurationBLL device = new HomeConfigurationBLL();

            model.DashBoardType = "0";//首页
            DashBoardDataListModel DashBoardData = new DashBoardDataListModel()
            {
                x = Convert.ToInt32(model.XAxis),
                y = Convert.ToInt32(model.YAxis),
                w = Convert.ToInt32(model.Width),
                h = Convert.ToInt32(model.Height),
                i = model.ID.ToString()
            };

            model.DashBoardData = JsonConvert.SerializeObject(DashBoardData);

            DashBoardChartConfigModel ChartConfig = new DashBoardChartConfigModel()
            {
                DatabaseType        = model.DatabaseType,
                DataType            = model.DataType,
                RecentInterval      = model.RecentInterval,
                RecentUnit          = model.RecentUnit,
                StartTime           = model.StartTime.ToString(),
                EndTime             = model.EndTime.ToString(),
                StatisticalInterval = model.StatisticalInterval,
                IntervalUnit        = model.IntervalUnit,
                MinValue            = model.MinValue,
                MaxValue            = model.MaxValue,
                ValueType           = model.ValueType,
                TextColor           = model.TextColor,
                BackgroundColor     = model.BackgroundColor
            };
            List <HomeDeviceInfo> HomeDeviceInfoList = new List <HomeDeviceInfo>();

            if (model.Property != null)
            {
                if (model.Property.Count == 1) //设备,总览,表格
                {
                    if (model.Property[0].data[0] == "1")
                    {
                        // 设备
                        ChartConfig.SelectionType = "1";
                        HomeDeviceInfo HomeDeviceInfo = new HomeDeviceInfo();
                        HomeDeviceInfo.DeviceID     = model.Property[0].data[1];
                        HomeDeviceInfo.DeviceItemID = model.Property[0].data[2];
                        HomeDeviceInfoList.Add(HomeDeviceInfo);
                    }
                    else if (model.Property[0].data[0] == "2")
                    {
                        // 总览
                        ChartConfig.SelectionType = "2";
                    }
                    else if (model.Property[0].data[0] == "3")
                    {
                        // 表格
                        ChartConfig.SelectionType = "3";
                    }
                }
                else if (model.Property.Count > 1) //只可能设备
                {
                    for (int i = 0; i < model.Property.Count; i++)
                    {
                        ChartConfig.SelectionType = "1";
                        HomeDeviceInfo HomeDeviceInfo = new HomeDeviceInfo();
                        HomeDeviceInfo.DeviceID     = model.Property[i].data[1];
                        HomeDeviceInfo.DeviceItemID = model.Property[i].data[2];
                        HomeDeviceInfoList.Add(HomeDeviceInfo);
                    }
                }
            }
            ChartConfig.HomeDeviceInfoList = HomeDeviceInfoList;
            model.ChartConfig = JsonConvert.SerializeObject(ChartConfig);

            var update = device.EditChart(model);

            return(InspurJson <RetHomeConfiguration>(update));
        }