Exemple #1
0
        private void SetChildren(
            EasyUI_TreeGrid treeRow,
            Organization org,
            List <Organization> orgList,
            params Action <EasyUI_TreeGrid, Organization>[] actions
            )
        {
            if (actions != null)
            {
                foreach (var action in actions)
                {
                    action(treeRow, org);
                }
            }
            var orgChildrens = orgList.Where(t => t.ParentId.Equals(org.Id)).ToList();

            if (orgChildrens.Count <= 0)
            {
                return;
            }
            treeRow.Children = treeRow.Children ?? new List <UIModels.EasyUI_TreeGrid>();
            foreach (var entity in orgChildrens)
            {
                var treeChildrenInfo = new EasyUI_TreeGrid()
                {
                    Id   = entity.Id,
                    Name = entity.Name,
                    Type = 1
                };
                treeRow.Children.Add(treeChildrenInfo);
                SetChildren(treeChildrenInfo, entity, orgList);
            }
        }
Exemple #2
0
        private void SetAssets(
            EasyUI_TreeGrid treeRow,
            Organization org,
            List <Re_Organization> reList,
            List <Assets> assetsList
            )
        {
            var res = reList.Where(t => t.OrganizationId.Equals(org.Id)).ToList();

            if (res.Count <= 0)
            {
                return;
            }
            treeRow.Children = treeRow.Children ?? new List <UIModels.EasyUI_TreeGrid>();
            foreach (var re in res)
            {
                var assetsInfo = assetsList.FirstOrDefault(t => t.Id.Equals(re.AssetsId));
                if (assetsInfo != null)
                {
                    var treeChildrenInfo = new EasyUI_TreeGrid()
                    {
                        Id   = assetsInfo.Id,
                        Name = assetsInfo.Name,
                        Type = 3
                    };
                    treeRow.Children.Add(treeChildrenInfo);
                }
            }
        }
Exemple #3
0
        private void SetEquitpment(
            EasyUI_TreeGrid treeRow,
            Organization org,
            List <Re_Organization> reList,
            List <Equipment> equipmentList
            )
        {
            var res = reList.Where(t => t.OrganizationId.Equals(org.Id)).ToList();

            if (res.Count <= 0)
            {
                return;
            }
            treeRow.Children = treeRow.Children ?? new List <UIModels.EasyUI_TreeGrid>();
            foreach (var re in res)
            {
                var equitpmentInfo = equipmentList.FirstOrDefault(t => t.Id.Equals(re.EquipmentId));
                if (equitpmentInfo != null)
                {
                    var treeChildrenInfo = new EasyUI_TreeGrid()
                    {
                        Id   = equitpmentInfo.Id,
                        Name = equitpmentInfo.Name,
                        Type = 2
                    };
                    treeRow.Children.Add(treeChildrenInfo);
                }
            }
        }
Exemple #4
0
        private List <EasyUI_TreeGrid> BuildTree(
            Guid tenantId,
            Guid parentId,
            List <Organization> orgList,
            params Action <EasyUI_TreeGrid, Organization>[] actions
            )
        {
            var result = new List <EasyUI_TreeGrid>();
            var orgs   = orgList.Where(t => t.ParentId.Equals(parentId));

            foreach (var org in orgs)
            {
                var treeRow = new EasyUI_TreeGrid()
                {
                    Id   = org.Id,
                    Name = org.Name,
                    Type = 1
                };
                result.Add(treeRow);
                SetChildren(treeRow, org, orgList, actions);
            }
            return(result);
        }