public virtual JObject GetOUObjects(HttpContext context) { YZRequest request = new YZRequest(context); string path = request.GetString("path", null); //获得数据 using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); RoleCollection roles; MemberCollection members; OU ou = null; if (String.IsNullOrEmpty(path)) { ou = new OU(); roles = new RoleCollection(); members = new MemberCollection(); } else { ou = OU.FromFullName(cn, path); roles = OU.GetRoles(cn, path); members = OU.GetMembers(cn, path); } //将数据转化为Json集合 JObject rv = new JObject(); rv[YZJsonProperty.total] = roles.Count + members.Count; JArray children = new JArray(); rv[YZJsonProperty.children] = children; rv["Editable"] = ou.HasPermision(BPMObjectPermision.Edit); rv["NewRole"] = ou.HasPermision(BPMObjectPermision.NewRole); foreach (Role role in roles) { children.Add(this.SerializeOUObject(role)); } foreach (Member member in members) { children.Add(this.SerializeOUObject(cn, member)); } 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 }); }
public virtual OU SaveOU(HttpContext context) { YZRequest request = new YZRequest(context); JObject post = request.GetPostData <JObject>(); OU ou = post["data"].ToObject <OU>(); ACL acl = post["acl"].ToObject <ACL>(); string mode = request.GetString("mode"); OU newou = null; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (mode == "edit") { string fullname = request.GetString("fullname"); OUProviderInfo providerInfo = OrgSvr.GetProviderInfo(cn, fullname); if (providerInfo.Editable) { newou = OU.UpdateOU(cn, fullname, ou); } else { newou = OU.FromFullName(cn, fullname); } } else { string parentou = request.GetString("parentou", ""); if (String.IsNullOrEmpty(parentou)) { newou = cn.CreateOrg("BPMOU://", ou); } else { newou = OU.AddChildOU(cn, parentou, ou); } } SecurityManager.SaveACL(cn, SecurityResType.OU, newou.FullName, null, acl); return(newou); } }
public virtual JObject GetOUDefine(HttpContext context) { YZRequest request = new YZRequest(context); string oufullname = request.GetString("fullName"); OU ou; DataColumnCollection columns; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); ou = OU.FromFullName(cn, oufullname); columns = OU.GetExtColumns(cn, ou.NameSpace); } JObject rv; rv = JObject.FromObject(ou); rv["ExtAttrsSchema"] = YZJsonHelper.SerializeExtAttrSchema(columns); return(rv); }
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 }); }