Exemple #1
0
        public ActionResult GeneralAlarm()
        {
            ScadaGreneralAlarmModel model = new ScadaGreneralAlarmModel();

            model.AllDeviceList = DeviceGroupService.GetAll();


            Session["AllDeviceList"] = model.AllDeviceList;
            return(View(model));
        }
Exemple #2
0
        public JsonResult GetAllDevices()
        {
            IEnumerable <DeviceGroupModel> Items = DeviceGroupService.GetAll();

            return(Json(Items.ToList(), JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public override ActionResult Index(int?id)
        {
            string para  = Request.QueryString["id"].Split('?')[0];
            string idstr = Request.QueryString["id"].Split('?')[1].Split('=')[1];

            base.Index(int.Parse(idstr));



            var            rowModel   = TableRowService.GetByWhere("where TableId=" + int.Parse(para)).First();
            var            tableUsers = TableUserRoleService.GetByWhere("where TableId=" + int.Parse(para));
            var            tableModel = TableService.GetById(int.Parse(para));
            TableRealModel model      = new TableRealModel();

            model.TableId = int.Parse(para);
            model.Title   = tableModel != null ? tableModel.Title : "";
            model.RowNum  = tableModel != null ? tableModel.RowNum : 100;

            var AllUsers = UserService.GetAll();

            model.AllUserJson = JsonConvert.SerializeObject(AllUsers);//获取当前的所有用户
            List <UserModel> privatemodels = new List <UserModel>();

            foreach (var item in tableUsers)
            {
                var whereItems = AllUsers.Where(x => x.Id == item.UserId);
                if (whereItems.Count() > 0)
                {
                    var extItem = whereItems.First();
                    privatemodels.Add(extItem);
                }
            }
            model.PrivateUserJson = JsonConvert.SerializeObject(privatemodels); //获取当前的所有用户
                                                                                //获取表的列宽度
            List <string> fontwidthmodels = new List <string>();

            if (tableModel != null && !string.IsNullOrWhiteSpace(tableModel.ColimnWidths))
            {
                fontwidthmodels = tableModel.ColimnWidths.Split(',').ToList();
            }
            else
            {
                for (int i = 0; i < 26; i++)
                {
                    fontwidthmodels.Add("120");
                }
            }

            model.colwidthmodels = JsonConvert.SerializeObject(fontwidthmodels);
            //获取列标题
            //获取表的列宽度
            List <string> columntitlemodels = new List <string>();

            if (tableModel != null && !string.IsNullOrWhiteSpace(tableModel.ColumnTitles))
            {
                columntitlemodels = tableModel.ColumnTitles.Split(',').ToList();
            }
            else
            {
                for (int i = 0; i < 26; i++)
                {
                    columntitlemodels.Add(ExcelConvert.ToName(i));
                }
            }
            model.coltitlesmodels = JsonConvert.SerializeObject(columntitlemodels);
            model.ScadaTable      = tableModel;
            model.FieldBackColors = rowModel.FieldBackColors;
            model.FieldColors     = rowModel.FieldColors;
            model.FieldFontSizes  = rowModel.FieldFontSizes;
            model.FieldIOPaths    = rowModel.FieldIOPaths;
            model.FieldWeights    = rowModel.FieldWeights;
            ///获取设备列表
            JavaScriptSerializer    js              = new JavaScriptSerializer(); //实例化一个能够序列化数据的类
            List <ExcelModel>       excelModels     = js.Deserialize <List <ExcelModel> >(rowModel.FieldIOPaths);
            List <DeviceGroupModel> deviceAllModels = DeviceGroupService.GetAll().ToList();
            List <DeviceGroupModel> deviceModels    = new List <DeviceGroupModel>();

            for (int i = 0; i < excelModels.Count; i++)
            {
                PropertyInfo[] properties = excelModels[i].GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
                if (properties.Length <= 0)
                {
                    continue;
                }
                foreach (PropertyInfo item in properties)
                {
                    string name  = item.Name;
                    object value = item.GetValue(excelModels[i], null);
                    if (value != null && value.ToString() != "")
                    {
                        if (value.ToString().Split('/').Length >= 8)
                        {
                            try
                            {
                                DeviceGroupModel groupDevice = new DeviceGroupModel();
                                groupDevice.GroupId      = int.Parse(value.ToString().Split('/')[1]);
                                groupDevice.IO_SERVER_ID = value.ToString().Split('/')[2];
                                groupDevice.IO_COMM_ID   = value.ToString().Split('/')[3];
                                groupDevice.IO_DEVICE_ID = value.ToString().Split('/')[4];
                                groupDevice.UpdateCycle  = int.Parse(value.ToString().Split('/')[6]);
                                groupDevice.CurrentIO    = value.ToString().Split('/')[5];//当前的iO
                                DeviceGroupModel exitItem = deviceAllModels.Find(x => x.IO_SERVER_ID == groupDevice.IO_SERVER_ID && x.IO_COMM_ID == groupDevice.IO_COMM_ID && x.IO_DEVICE_ID == groupDevice.IO_DEVICE_ID && x.GroupId == groupDevice.GroupId);
                                if (exitItem != null)
                                {
                                    if (!deviceModels.Exists(x => x.IO_SERVER_ID == groupDevice.IO_SERVER_ID && x.IO_COMM_ID == groupDevice.IO_COMM_ID && x.IO_DEVICE_ID == groupDevice.IO_DEVICE_ID && x.GroupId == groupDevice.GroupId))
                                    {
                                        exitItem.CurrentIO = groupDevice.CurrentIO;
                                        deviceModels.Add(exitItem);
                                    }
                                }
                            }
                            catch
                            {
                                continue;
                            }
                        }
                    }
                }
            }
            model.Devices     = deviceModels;
            model.JsonDevices = js.Serialize(deviceModels);
            return(View(model));
        }