private void addWorkGroupUsers(List <BizProcess.Data.Model.Users> userList, BizProcess.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())); } } }
/// <summary> /// 得到一组机构字符串下所有人员 /// </summary> /// <param name="idString"></param> /// <returns></returns> public List <BizProcess.Data.Model.Users> GetAllUsers(string idString) { if (idString.IsNullOrEmpty()) { return(new List <BizProcess.Data.Model.Users>()); } string[] idArray = idString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <BizProcess.Data.Model.Users> userList = new List <BizProcess.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.Distinct(new UsersEqualityComparer()).ToList()); }