Пример #1
0
        private void LoadSubTree(int ID, string Keywords = "")
        {
            var TypeList = GetTypeList();
            var subList  = TypeList.Where(p => p.ParentID == ID).ToArray();

            if (!string.IsNullOrEmpty(Keywords))
            {
                subList = subList.Where(p => p.DeviceTypeName.Contains(Keywords)).ToArray();
            }
            if (subList.Length == 0)
            {
                return;
            }
            for (int i = 0; i < subList.Length; i++)
            {
                var typeListTree = new TypeListTree();
                typeListTree.ID             = subList[i].ID;
                typeListTree.DeviceTypeName = subList[i].DeviceTypeName;
                typeListTree.Code           = subList[i].Code;
                typeListTree.Description    = subList[i].Description;
                typeListTree._parentId      = subList[i].ParentID;
                typeListTree.TypeLevel      = subList[i].TypeLevel;
                AllList.Add(typeListTree);
                LoadSubTree(subList[i].ID, Keywords);
            }
            return;
        }
Пример #2
0
        private void loaddevicetype(HttpContext context)
        {
            string page          = context.Request.Form["page"];
            string rows          = context.Request.Form["rows"];
            int    startRowIndex = (int.Parse(page) - 1) * int.Parse(rows);
            int    pageSize      = int.Parse(rows);
            string Keywords      = context.Request["Keywords"];
            var    TypeList      = GetTypeList();
            var    topTypeList   = TypeList.Where(p => p.ParentID == 0 || p.ParentID == int.MinValue).ToArray();

            if (!string.IsNullOrEmpty(Keywords))
            {
                topTypeList = topTypeList.Where(p => p.DeviceTypeName.Contains(Keywords)).ToArray();
            }
            var topList = topTypeList.Skip(startRowIndex).Take(pageSize).ToArray();

            AllList = new List <TypeListTree>();
            for (int i = 0; i < topList.Length; i++)
            {
                var typeListTree = new TypeListTree();
                typeListTree.ID             = topList[i].ID;
                typeListTree.DeviceTypeName = topList[i].DeviceTypeName;
                typeListTree.Code           = topList[i].Code;
                typeListTree.Description    = topList[i].Description;
                typeListTree._parentId      = 0;
                typeListTree.TypeLevel      = topList[i].TypeLevel;
                AllList.Add(typeListTree);
                LoadSubTree(topList[i].ID, Keywords);
            }
            DataGrid dg = new DataGrid();

            dg.total = topTypeList.Length;
            dg.rows  = AllList;
            dg.page  = pageSize;
            WebUtil.WriteJson(context, dg);
        }