示例#1
0
        private static List<JsonTreeNode> ConvertXmlNodeToJsonNode(XmlNodeList nodes)
        {
            List<JsonTreeNode> treenodelist = new List<JsonTreeNode>();
            foreach (XmlNode node in nodes)
            {
                JsonTreeNode treenode = new JsonTreeNode();
                treenode.id = node.Attributes["id"].Value;
                treenode.text = node.Attributes["text"].Value;
                treenode.value = node.Attributes["url"].Value;
                treenode.isexpand = node.Attributes["isexpand"].Value == "true";
                treenode.showcheck = false;
                treenode.complete = true;
                treenode.hasChildren = node.ChildNodes != null && node.ChildNodes.Count > 0;

                if (treenode.hasChildren)
                {
                    treenode.ChildNodes.AddRange(ConvertXmlNodeToJsonNode(node.ChildNodes));
                }
                treenodelist.Add(treenode);
            }
            return treenodelist;
        }
示例#2
0
        private List<JsonTreeNode> BuildTreeNode(List<Privilege> allmenus, List<Privilege> menus, List<string> usermenuids)
        {
            List<JsonTreeNode> treenodelist = new List<JsonTreeNode>();
            bool isSupperAdmin = base.IsInRole(AppConfig.SuperAdminRoleCode);
            foreach (Privilege p in menus)
            {
                if (isSupperAdmin || usermenuids.Contains(p.PrivilegeCode))
                {
                    JsonTreeNode treenode = new JsonTreeNode();
                    treenode.id = p.PrivilegeCode;
                    treenode.text = p.PrivilegeName;

                    treenode.value = GetTruePath(p.Uri);
                    treenode.isexpand = false;
                    treenode.showcheck = false;
                    treenode.complete = true;
                    List<Privilege> cmenus = allmenus.FindAll(x => x.ParentID == p.PrivilegeCode);
                    if (cmenus != null && cmenus.Count > 0)
                    {
                        treenode.ChildNodes.AddRange(BuildTreeNode(allmenus, cmenus, usermenuids));
                        if (treenode.ChildNodes.Count > 0)
                        {
                            treenode.isexpand = true;
                            treenode.hasChildren = true;
                        }
                    }
                    treenodelist.Add(treenode);
                }

            }
            return treenodelist;
        }
示例#3
0
        public JsonResult RoleTreeList(FormCollection form)
        {
            List<JsonTreeNode> nodes = new List<JsonTreeNode>();
            string strparentId = form["id"];// ?? "0";
            int? parentId = null;
            if (!string.IsNullOrEmpty(strparentId))
            {
                parentId = Convert.ToInt32(strparentId);

            }
            var list = sysManageService.GetRoles(parentId, base.UserId);
            foreach (var item in list)
            {
                JsonTreeNode cnode = new JsonTreeNode();
                cnode.id = item.RoleID.ToString();
                cnode.text = item.RoleName;
                cnode.value = item.RoleCode;
                cnode.hasChildren = item.HasChild;
                cnode.classes = item.IsSystem ? "system" : "normal";
                nodes.Add(cnode);
            }
            return Json(nodes);
        }
示例#4
0
        public JsonResult QueryUserPrivilegeTree(FormCollection form)
        {
            List<JsonTreeNode> treelist = new List<JsonTreeNode>();
            string usercode = form["UserCode"];
            string parentId = form["id"] ?? "";

            List<Privilege> list = sysManageService.GetUserPrivilegesByParentID(usercode, parentId);
            foreach (Privilege pri in list)
            {

                JsonTreeNode node = new JsonTreeNode();
                node.hasChildren = pri.HasChild;
                node.id = pri.PrivilegeCode;
                node.text = pri.PrivilegeName;
                node.value = pri.PrivilegeCode;
                if (parentId == "" && node.hasChildren)
                {
                    List<Privilege> clist = sysManageService.GetUserPrivilegesByParentID(usercode, node.id);
                    foreach (Privilege cpri in clist)
                    {
                        JsonTreeNode cnode = new JsonTreeNode();
                        cnode.hasChildren = cpri.HasChild;
                        cnode.id = cpri.PrivilegeCode;
                        cnode.text = cpri.PrivilegeName;
                        cnode.value = cpri.PrivilegeCode;
                        node.ChildNodes.Add(cnode);
                    }
                    node.isexpand = true;
                    node.complete = true;
                }
                treelist.Add(node);
            }
            return Json(treelist);
        }
示例#5
0
 public JsonResult QueryOrgTree(string ExtId, FormCollection form)
 {
     var nodes = new List<JsonTreeNode>();
     string parentId = form["id"];// ?? "0";
     if (string.IsNullOrEmpty(parentId))
     {
         Organization root = sysManageService.GetRootOrganization();
         JsonTreeNode node = new JsonTreeNode();
         node.id = root.OrgCode;
         node.text = root.OrgName;
         node.value = root.OrgCode;
         node.isexpand = true;
         node.complete = true;
         var clist = sysManageService.GetChildOrgsByParentCode(root.OrgCode);
         if (clist != null)
         {
             node.hasChildren = true;
             foreach (var item in clist)
             {
                 if (item.OrgCode == ExtId)
                 {
                     continue;
                 }
                 JsonTreeNode cnode = new JsonTreeNode();
                 cnode.id = item.OrgCode;
                 cnode.text = item.OrgName;
                 cnode.value = item.OrgCode;
                 cnode.hasChildren = item.HasChild;
                 node.ChildNodes.Add(cnode);
             }
         }
         nodes.Add(node);
     }
     else
     {
         var list = sysManageService.GetChildOrgsByParentCode(parentId);
         foreach (var item in list)
         {
             if (item.OrgCode == ExtId)
             {
                 continue;
             }
             JsonTreeNode cnode = new JsonTreeNode();
             cnode.id = item.OrgCode;
             cnode.text = item.OrgName;
             cnode.value = item.OrgCode;
             cnode.hasChildren = item.HasChild;
             nodes.Add(cnode);
         }
     }
     return Json(nodes);
 }
示例#6
0
 public JsonResult QueryAllUserTree(FormCollection form)
 {
     var nodes = new List<JsonTreeNode>();
     string parentId = form["id"];// ?? "0";
     if (string.IsNullOrEmpty(parentId))
     {
         Organization root = sysManageService.GetRootOrganization();
         JsonTreeNode node = new JsonTreeNode();
         node.id = root.OrgCode;
         node.text = root.OrgName;
         node.classes = "group";
         node.value = "1";
         node.isexpand = true;
         node.complete = true;
         GetChild(root.OrgCode, node.ChildNodes);
         node.hasChildren = true;
         nodes.Add(node);
     }
     else
     {
         GetChild(parentId, nodes);
     }
     return Json(nodes);
 }
示例#7
0
        public JsonResult PrivilegeTreeList(FormCollection form)
        {
            var nodes = new List<JsonTreeNode>();
            string parentId = form["id"];// ?? "0";

            List<Privilege> list = sysManageService.GetChildPrivileges(parentId);
            if (list != null)
            {
                foreach (var item in list)
                {
                    JsonTreeNode node = new JsonTreeNode();
                    node.id = item.PrivilegeCode;
                    node.text = item.PrivilegeName;
                    node.value = item.Uri;
                    node.hasChildren = item.HasChild;
                    nodes.Add(node);
                }
                if (parentId == null && nodes.Count > 0 && nodes[0].hasChildren) //如果是根
                {
                    List<Privilege> clist = sysManageService.GetChildPrivileges(nodes[0].id);
                    nodes[0].complete = true;
                    nodes[0].isexpand = true;
                    if (clist != null)
                    {
                        foreach (var citem in clist)
                        {
                            JsonTreeNode cnode = new JsonTreeNode();
                            cnode.id = citem.PrivilegeCode;
                            cnode.text = citem.PrivilegeName;
                            cnode.value = citem.Uri;
                            cnode.hasChildren = citem.HasChild;
                            nodes[0].ChildNodes.Add(cnode);
                        }
                    }
                }
            }
            return Json(nodes);
        }
示例#8
0
        public JsonResult GetRolePrivileges(int RoleID, FormCollection form)
        {
            List<JsonTreeNode> treelist = new List<JsonTreeNode>();

            string parentId = form["id"];

            List<Privilege> list = sysManageService.GetRoleAuthorizationPermissions(RoleID, base.UserId, parentId);
            foreach (Privilege p in list)
            {
                JsonTreeNode node = new JsonTreeNode();
                node.hasChildren = p.HasChild;
                node.id = p.PrivilegeCode;
                node.text = p.PrivilegeName;
                node.value = p.IsChecked ? "true" : "false";
                node.showcheck = true;
                node.checkstate = p.IsChecked ? (byte)1 : (byte)0;
                if (string.IsNullOrEmpty(parentId) && node.hasChildren && treelist.Count == 0) //如果是第一层就再获取一层
                {
                    List<Privilege> clist = sysManageService.GetRoleAuthorizationPermissions(RoleID, base.UserId, node.id);
                    foreach (Privilege cp in clist)
                    {
                        JsonTreeNode cnode = new JsonTreeNode();
                        cnode.hasChildren = cp.HasChild;
                        cnode.id = cp.PrivilegeCode;
                        cnode.text = cp.PrivilegeName;
                        cnode.value = cp.IsChecked ? "true" : "false";
                        cnode.showcheck = true;
                        cnode.checkstate = cp.IsChecked ? (byte)1 : (byte)0;
                        node.ChildNodes.Add(cnode);
                    }
                    node.complete = true;
                    node.isexpand = true;
                }

                treelist.Add(node);
            }
            return Json(treelist);
        }
示例#9
0
        private void GetChild(string OrgCode, List<JsonTreeNode> parentNodes)
        {
            var glist = sysManageService.GetChildOrgsByParentCode(OrgCode);
            if (glist != null)
            {
                foreach (var item in glist)
                {
                    JsonTreeNode gnode = new JsonTreeNode();
                    gnode.id = item.OrgCode;
                    gnode.text = item.OrgName;
                    gnode.value = "1";
                    gnode.hasChildren = true;

                    gnode.classes = "group";
                    parentNodes.Add(gnode);
                }
            }
            var ulist = sysManageService.GetUserListByOrgCode(OrgCode);
            if (ulist != null)
            {
                foreach (var user in ulist)
                {
                    JsonTreeNode unode = new JsonTreeNode();
                    unode.id = user.UserUID;
                    unode.text = user.FullName;
                    unode.value = "2";
                    unode.showcheck = true;
                    unode.hasChildren = false;
                    unode.classes = "user";
                    parentNodes.Add(unode);
                }
            }
        }