示例#1
0
        public virtual object SearchMember(HttpContext context)
        {
            YZRequest request             = new YZRequest(context);
            string    keyword             = request.GetString("keyword", null);
            bool      includeDisabledUser = request.GetBool("includeDisabledUser", false);

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

            JArray children = new JArray();

            rv[YZJsonProperty.children] = children;

            if (!String.IsNullOrEmpty(keyword))
            {
                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();
                    MemberCollection members = OrgSvr.SearchMember(cn, keyword, includeDisabledUser);
                    UserCollection   users   = new UserCollection();
                    foreach (Member member in members)
                    {
                        User user = users.TryGetItem(member.UserAccount);
                        if (user == null)
                        {
                            user = User.FromAccount(cn, member.UserAccount);
                            users.Add(user);
                        }

                        JObject jItem      = this.JObjectFromMember(member, user);
                        string  oufullName = member.GetParentOU(cn).GetFriendlyFullName(cn);
                        jItem["parentouFriendlyName"] = oufullName;
                        jItem["memberFriendlyName"]   = oufullName + "/" + user.Account;
                        jItem["search"] = true;
                        children.Add(jItem);
                    }
                }
            }

            //输出数据
            return(rv);
        }