void quickrights_SetRights(object sender, SetRightsEventArgs e) { SetRights(TreeViewUtil.GetPath(e.Node, '/'), m_strTempUserName, e.Rights); }
void quickrights_SetRights(object sender, SetRightsEventArgs e) { this.treeView_resRightTree.SetNodeRights(e.Node, e.Rights); }
// 按照预定模式修改一个节点以及以下的全部子节点的权限 void ModiRights(int nFound, List <TreeNode> selectedTreeNodes, TreeNode curtreenode, List <XmlNode> cfgnodes) { for (int i = 0; i < cfgnodes.Count; i++) { // 当前xml节点信息 XmlNode node = cfgnodes[i]; string strType = DomUtil.GetAttr(node, "type"); string strName = DomUtil.GetAttr(node, "name"); string strRights = DomUtil.GetAttrDiff(node, "rights"); int nStyle = QuickRights.GetStyleInt(DomUtil.GetAttr(node, "style")); // 匹配对象名 if (strName != "" && strName != "*") { // @ if (strName != curtreenode.Text) { continue; } } // 匹配对象类型 bool bRet = QuickRights.MatchType(curtreenode.ImageIndex, strType); if (bRet == false) { continue; } // 匹配对象风格 if (nStyle != 0) { if (this.GetNodeStyle == null) { // 缺省行为 /* * if (nStyle != ResRightTree.GetNodeStyle(curtreenode)) * continue; */ } else { GetNodeStyleEventArgs e = new GetNodeStyleEventArgs(); e.Node = curtreenode; e.Style = 0; this.GetNodeStyle(this, e); if (nStyle != e.Style) { continue; } } } int nIndex = -1; if (nFound == 0) { nIndex = selectedTreeNodes.IndexOf(curtreenode); } // 触发事件 // 如果strRights == null,表示当前对象不需修改其rights值,但是递归仍然要进行 if (strRights != null && (nIndex != -1 || nFound > 0)) { if (this.SetRights != null) { SetRightsEventArgs e = new SetRightsEventArgs(); e.Node = curtreenode; if (strRights == "{clear}" || strRights == "{null}") { e.Rights = null; } else { e.Rights = strRights; } this.SetRights(this, e); } } // DOCHILDREN: // 组织树子对象数组 List <TreeNode> nodes = new List <TreeNode>(); for (int j = 0; j < curtreenode.Nodes.Count; j++) { nodes.Add(curtreenode.Nodes[j]); } // 递归 if (nodes.Count != 0) { List <XmlNode> chidrencfgnodes = new List <XmlNode>(); for (int j = 0; j < node.ChildNodes.Count; j++) { XmlNode cur = node.ChildNodes[j]; if (cur.NodeType != XmlNodeType.Element) { continue; } if (cur.Name != "object") { continue; } chidrencfgnodes.Add(cur); } if (nIndex != -1) { nFound++; } ModiRights(nFound, selectedTreeNodes, nodes, chidrencfgnodes); if (nIndex != -1) { nFound--; } } } }
// 按照预定模式修改一个节点以及以下的全部子节点的权限 void ModiRights(int nFound, List<TreeNode> selectedTreeNodes, TreeNode curtreenode, List<XmlNode> cfgnodes) { for (int i = 0; i < cfgnodes.Count; i++) { // 当前xml节点信息 XmlNode node = cfgnodes[i]; string strType = DomUtil.GetAttr(node, "type"); string strName = DomUtil.GetAttr(node, "name"); string strRights = DomUtil.GetAttrDiff(node, "rights"); int nStyle = QuickRights.GetStyleInt(DomUtil.GetAttr(node, "style")); // 匹配对象名 if (strName != "" && strName != "*") { // @ if (strName != curtreenode.Text) continue; } // 匹配对象类型 bool bRet = QuickRights.MatchType(curtreenode.ImageIndex, strType); if (bRet == false) continue; // 匹配对象风格 if (nStyle != 0) { if (this.GetNodeStyle == null) { // 缺省行为 /* if (nStyle != ResRightTree.GetNodeStyle(curtreenode)) continue; */ } else { GetNodeStyleEventArgs e = new GetNodeStyleEventArgs(); e.Node = curtreenode; e.Style = 0; this.GetNodeStyle(this, e); if (nStyle != e.Style) continue; } } int nIndex = -1; if (nFound == 0) nIndex = selectedTreeNodes.IndexOf(curtreenode); // 触发事件 // 如果strRights == null,表示当前对象不需修改其rights值,但是递归仍然要进行 if (strRights != null && (nIndex != -1 || nFound > 0)) { if (this.SetRights != null) { SetRightsEventArgs e = new SetRightsEventArgs(); e.Node = curtreenode; if (strRights == "{clear}" || strRights == "{null}") e.Rights = null; else e.Rights = strRights; this.SetRights(this, e); } } // DOCHILDREN: // 组织树子对象数组 List<TreeNode> nodes = new List<TreeNode>(); for (int j = 0; j < curtreenode.Nodes.Count; j++) { nodes.Add(curtreenode.Nodes[j]); } // 递归 if (nodes.Count != 0) { List<XmlNode> chidrencfgnodes = new List<XmlNode>(); for (int j = 0; j < node.ChildNodes.Count; j++) { XmlNode cur = node.ChildNodes[j]; if (cur.NodeType != XmlNodeType.Element) continue; if (cur.Name != "object") continue; chidrencfgnodes.Add(cur); } if (nIndex != -1) nFound++; ModiRights(nFound, selectedTreeNodes, nodes, chidrencfgnodes); if (nIndex != -1) nFound--; } } }