Exemplo n.º 1
0
        private void addWorkGroupUsers(List <Data.Model.Users> userList, Data.Model.WorkGroup wg)
        {
            if (wg == null || wg.Members.IsNullOrEmpty())
            {
                return;
            }
            string[]  idArray = wg.Members.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            Users     busers  = new Users();
            WorkGroup bwg     = new WorkGroup();

            foreach (var id in idArray)
            {
                if (id.StartsWith(Users.PREFIX))//人员
                {
                    userList.Add(busers.Get(Users.RemovePrefix(id).ToGuid()));
                }
                else if (id.IsGuid())//机构
                {
                    userList.AddRange(GetAllUsers(id.ToGuid()));
                }
                else if (id.StartsWith(WorkGroup.PREFIX))//工作组
                {
                    addWorkGroupUsers(userList, bwg.Get(WorkGroup.RemovePrefix(id).ToGuid()));
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一组机构字符串下所有人员
        /// </summary>
        /// <param name="idString"></param>
        /// <returns></returns>
        public List <Data.Model.Users> GetAllUsers(string idString)
        {
            if (idString.IsNullOrEmpty())
            {
                return(new List <Data.Model.Users>());
            }
            string[] idArray = idString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            List <Data.Model.Users> userList = new List <Data.Model.Users>();
            Users     busers = new Users();
            WorkGroup bwg    = new WorkGroup();

            foreach (string id in idArray)
            {
                if (id.StartsWith(Users.PREFIX))//人员
                {
                    userList.Add(busers.Get(Users.RemovePrefix(id).ToGuid()));
                }
                else if (id.IsGuid())//机构
                {
                    userList.AddRange(GetAllUsers(id.ToGuid()));
                }
                else if (id.StartsWith(WorkGroup.PREFIX))//工作组
                {
                    addWorkGroupUsers(userList, bwg.Get(WorkGroup.RemovePrefix(id).ToGuid()));
                }
            }
            userList.RemoveAll(p => p == null);
            return(userList);
        }