示例#1
0
        private object GetEquipmentList()
        {
            EquipmentApp equipApp = new EquipmentApp();
            var          data     = equipApp.GetList();
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            foreach (EquipmentEntity item in data)
            {
                var fieldItem = new
                {
                    FId        = item.FId,
                    FShortName = item.FShortName,
                    FNumber    = item.FNumber,
                    FModel     = item.FModel,
                    FUnitId    = item.FUnit,
                };
                dictionary.Add(item.FId, fieldItem);
            }
            return(dictionary);
        }
示例#2
0
        public ActionResult GetTreeJson()
        {
            var equipmentTypeList = equipmentTypeApp.GetList(); //获取所有设备类型
            var equipmentList     = equipmentApp.GetList();     //获取所有设备信息

            var treeList = new List <TreeViewModel>();

            foreach (EquipmentTypeEntity item in equipmentTypeList)
            {
                TreeViewModel tree        = new TreeViewModel();
                bool          hasChildren = (equipmentTypeList.Count(t => t.FParentId == item.FId) + equipmentList.Count(t => t.FEquipmentTypeId == item.FId)) == 0 ? false : true;
                tree.id          = item.FId;
                tree.text        = item.FShortName;
                tree.value       = item.FNumber;
                tree.parentId    = item.FParentId;
                tree.img         = "fa fa-folder-open";
                tree.isexpand    = true;
                tree.complete    = true;
                tree.hasChildren = hasChildren;
                treeList.Add(tree);
            }

            foreach (EquipmentEntity item in equipmentList)
            {
                TreeViewModel tree = new TreeViewModel();
                tree.id          = item.FId;
                tree.text        = item.FShortName;
                tree.value       = item.FNumber;
                tree.parentId    = item.FEquipmentTypeId;
                tree.img         = "fa fa-file-text-o";
                tree.isexpand    = true;
                tree.complete    = true;
                tree.hasChildren = false;
                treeList.Add(tree);
            }
            return(Content(treeList.TreeViewJson()));
        }