private void InitPrivilegeTree()//树节点为root时,不显示组织结构信息。 { GetAllPrivilegeList(); LoadResourceType(); foreach (ResourceType resType in resTypes) { TreeNode rootNode = new TreeNode(resType.Name); Neusoft.Privilege.BizLogic.Model.Resource _res = new Neusoft.Privilege.BizLogic.Model.Resource(); _res.Id = "root"; _res.Name = resType.Name; _res.Type = resType.Id; rootNode.Tag = _res; rootNode.Expand(); SetChildNode(rootNode); tvPri.Nodes.Add(rootNode); } }
private void GetResource() { _resTreeListMap[nTabControl1.SelectedTab.Name].Items.Clear(); string _resTypeId = this.nTabControl1.SelectedTab.Name; IList <Priv> _resources = null; PrivilegeService _proxy = Common.Util.CreateProxy(); try { using (_proxy as IDisposable) { _resources = _proxy.GetResource(_resTypeId); } } catch (Exception e) { MessageBox.Show(e.Message, "提示"); return; } TreeListViewItem _root = new TreeListViewItem(nTabControl1.SelectedTab.Text + "包含的资源", 9); Neusoft.Privilege.BizLogic.Model.Resource _res = new Neusoft.Privilege.BizLogic.Model.Resource(); _res.Id = "root"; _res.Name = nTabControl1.SelectedTab.Text; _res.Type = nTabControl1.SelectedTab.Name; _root.Tag = _res; _resTreeListMap[nTabControl1.SelectedTab.Name].Items.Add(_root); //判断单一节点情况,并且要分级授权 IDictionary <Priv, IList <Neusoft.Privilege.BizLogic.Model.Operation> > _permissionsParent = null; IList <Priv> resources = new List <Priv>(); if (IsJudgeOperationForOne(_resTypeId)) { if (tvRole.SelectedNode != null && tvRole.SelectedNode.Tag != null) { if ((tvRole.SelectedNode.Tag as Role).Id == "roleadmin" || (tvRole.SelectedNode.Tag as Role).ParentId == "roleadmin") { addResource(_root, _resources); } else { try { using (_proxy as IDisposable) { _permissionsParent = _proxy.GetPermission(nTabControl1.SelectedTab.Name, (tvRole.SelectedNode.Parent.Tag as Role)); } foreach (KeyValuePair <Priv, IList <Neusoft.Privilege.BizLogic.Model.Operation> > pair in _permissionsParent) { resources.Add(pair.Key); } addResource(_root, resources); } catch (Exception e) { MessageBox.Show(e.Message, "提示"); return; } } } } else { addResource(_root, _resources); } _root.ExpandAll(); }