示例#1
0
        RadTreeNode CreateSubmenuTree(SecurityResourceDto resource, List <SecurityResourceDto> resources)
        {
            RadTreeNode node = new RadTreeNode(resource.DisplayName);

            if (resource.Checked)
            {
                node.Checked = true;
            }
            var image = GetImage(resource.ResourceTypeId);

            if (image != null)
            {
                node.Image = image;
            }

            var subNodes = resources.Where(it => it.ParentId == resource.SecurityResourceId).ToList();

            if (subNodes == null || subNodes.Count == 0)
            {
                return(node);
            }
            foreach (var item in subNodes)
            {
                var subNode = CreateSubmenuTree(item, resources);

                var subimage = GetImage(item.ResourceTypeId);

                var permissions     = resview.LoadPermissions();
                var permissionItems = permissions.Where(it => it.ResourceId == item.SecurityResourceId).ToList();
                if (permissionItems.Count() > 0)
                {
                    foreach (var pitem in permissionItems)
                    {
                        CreateOperationNode(pitem, subNode);
                    }
                }
                if (subNode != null)
                {
                    subNode.Value = item;
                    if (subimage != null)
                    {
                        subNode.Image = subimage;
                    }
                    AddContextMenu(subNode);
                    node.Nodes.Add(subNode);
                }
            }
            return(node);
        }