コード例 #1
0
        public virtual object GetRolesInPath(HttpContext context)
        {
            YZRequest      request = new YZRequest(context);
            string         path    = request.GetString("path", null);
            RoleCollection roles   = new RoleCollection();

            if (!String.IsNullOrEmpty(path))
            {
                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();

                    roles = OU.GetRoles(cn, path);
                }
            }

            //将数据转化为Json集合
            JObject rv = new JObject();

            JArray children = new JArray();

            rv[YZJsonProperty.children] = children;

            foreach (Role role in roles)
            {
                JObject item = new JObject();
                children.Add(item);
                item["Name"]     = role.Name;
                item["SID"]      = role.SID;
                item["FullName"] = role.FullName;
            }

            //输出数据
            return(rv);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: Social.cs プロジェクト: radtek/EMIP
        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
            });
        }