public virtual object GetOrgTree(HttpContext context) { YZRequest request = new YZRequest(context); string path = request.GetString("node", null); string srcoupath = request.GetString("srcoupath", null); GetRootOUsType getRootOUsType = request.GetEnum <GetRootOUsType>("getRootOUsType", GetRootOUsType.All); if (YZStringHelper.EquName(path, "root")) { path = null; } JObject rv = new JObject(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); JArray children = new JArray(); rv[YZJsonProperty.children] = children; if (String.IsNullOrEmpty(path)) { SecurityToken token = cn.Token; JObject dirParentItem = null; this.Expand(cn, children, path, token, ref dirParentItem, getRootOUsType, srcoupath); if (dirParentItem != null) { dirParentItem["dirou"] = true; //没必要列出所在部门的子部门 //dirParentItem["expanded"] = false; //dirParentItem.ChildItems.Clear(); } } else { OUCollection ous = OU.GetChildren(cn, path); foreach (OU ou in ous) { JObject item = new JObject(); item["leaf"] = false; item["text"] = ou.Name; item["iconCls"] = "folder"; item["id"] = ou.FullName; item["enpandable"] = true; children.Add(item); item["data"] = this.GetNodeData(ou); } } } //输出数据 return(rv); }
protected void LoadChildNode(BPMConnection cn, TreeNode node) { OUCollection ous = OU.GetChildren(cn, node.Value); foreach (OU cou in ous) { TreeNode subNode = CreateNode(cou); node.ChildNodes.Add(subNode); } }
public static JArray Serialize2Array(OUCollection ous) { JArray rv = new JArray(); foreach (OU ou in ous) { rv.Add(new JValue(ou.Name)); } return(rv); }
public static JArray SerializeSimpleOU(OUCollection ous) { JArray rv = new JArray(); foreach (OU ou in ous) { JObject jou = new JObject(); rv.Add(jou); jou["FullName"] = ou.FullName; jou["Name"] = ou.Name; } return(rv); }
private object GetChildOUs(HttpContext context) { YZRequest request = new YZRequest(context); string path = request.GetString("path", null); OUCollection parents = new OUCollection(); OUCollection ous = new OUCollection(); JArray children = new JArray(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (String.IsNullOrEmpty(path)) { ous = cn.GetRootOUs(); parents = new OUCollection(); } else { OU ou = OU.FromFullName(cn, path); parents = this.GetAllParentOU(cn, ou); ous = OU.GetChildren(cn, path); foreach (OU cou in ous) { } } foreach (OU ou in ous) { JObject jou = this.Serialize(ou); OUCollection cous = OU.GetChildren(cn, ou.FullName); jou["isLeaf"] = cous.Count >= 1 ? false : true; children.Add(jou); } } return(new { parents = parents, children = children }); }
protected void Page_Load(object sender, EventArgs e) { if (!AspxHelper.IsAuthenticated) { FormsAuthentication.RedirectToLoginPage(); } this.Page.ClientScript.RegisterClientScriptInclude("FormScript", this.ResolveClientUrl("../Scripts/XForm.js")); BPMConnection cn = new BPMConnection(); if (this._treeView.Nodes.Count != 0) { return; } try { cn.WebOpen(this.Page); OUCollection ous = cn.GetRootOUs(); SecurityToken token = cn.Token; foreach (OU ou in ous) { TreeNode node = CreateNode(ou); this._treeView.Nodes.Add(node); TreeNode firstDeptNode = null; OnNodeCreated(cn, ou, node, token, ref firstDeptNode); if (firstDeptNode != null) { firstDeptNode.Selected = true; } } } finally { cn.Close(); } }
private void OnNodeCreated(BPMConnection cn, OU ou, TreeNode node, SecurityToken token, ref TreeNode firstDeptNode) { if (token.ContainsSID(ou.SID)) { OUCollection ous = OU.GetChildren(cn, node.Value); //用户是否在一个子部门内 bool userInChildOU = false; foreach (OU cou in ous) { if (token.ContainsSID(cou.SID)) { userInChildOU = true; break; } } //不在子级部门则返回 if (!userInChildOU) { if (firstDeptNode == null) { firstDeptNode = node; } return; } node.PopulateOnDemand = false; node.Expand(); foreach (OU cou in ous) { TreeNode subNode = CreateNode(cou); node.ChildNodes.Add(subNode); OnNodeCreated(cn, cou, subNode, token, ref firstDeptNode); } } }
public virtual object GetOUObjects(HttpContext context) { YZRequest request = new YZRequest(context); string path = request.GetString("path", null); bool role = request.GetBool("role", true); bool user = request.GetBool("user", true); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (String.IsNullOrEmpty(path)) { OUCollection ous = cn.GetRootOUs(); if (ous.Count == 1) { return(this.GetOUObjects(cn, ous[0].FullName, role, user)); } } return(this.GetOUObjects(cn, path, role, user)); } }
private OUCollection GetAllParentOU(BPMConnection cn, OU ou) { OUCollection ous = new OUCollection(); while (ou != null) { ous.Insert(0, ou); ou = ou.GetParentOU(cn); } OUCollection roots = cn.GetRootOUs(); if (roots.Count > 1) { ous.Insert(0, new OU() { IsRootOU = true, Name = "组织", FullName = "" }); } return(ous); }
private object GetOUObjects(BPMConnection cn, string path, bool includeRole, bool includeMember) { OUCollection parents = new OUCollection(); OUCollection ous = new OUCollection(); RoleCollection roles = new RoleCollection(); BPMClient.MemberCollection members = new BPMClient.MemberCollection(); if (String.IsNullOrEmpty(path)) { ous = cn.GetRootOUs(); parents = new OUCollection(); } else { OU ou = OU.FromFullName(cn, path); parents = this.GetAllParentOU(cn, ou); ous = OU.GetChildren(cn, path); if (includeRole) { roles = OU.GetRoles(cn, path); } if (includeMember) { members = OU.GetMembers(cn, path); } } List <object> children = new List <object>(); foreach (OU ou in ous) { children.Add(new { Type = "OU", data = ou }); } foreach (Role role in roles) { children.Add(new { Type = "Role", data = role }); } foreach (BPMClient.Member member in members) { User user = User.TryGetUser(cn, member.UserAccount); if (user != null && !user.Disabled) { children.Add(new { Type = "Member", data = new { member = member, user = member.GetUser(cn) } }); } } return(new { parents = parents, children = children }); }