/// <summary> /// 得到一组机构字符串下所有人员 /// </summary> /// <param name="idString"></param> /// <returns></returns> public List <RoadFlow.Data.Model.Users> GetAllUsers(string idString) { if (idString.IsNullOrEmpty()) { return(new List <RoadFlow.Data.Model.Users>()); } string[] idArray = idString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <RoadFlow.Data.Model.Users> userList = new List <RoadFlow.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()); }
private void addWorkGroupUsers(List <RoadFlow.Data.Model.Users> userList, RoadFlow.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())); } } }
public string GetName(string id) { string empty = string.Empty; if (id.IsGuid()) { return(GetName(id.ToGuid())); } if (id.StartsWith("u_")) { Guid test; if (!Users.RemovePrefix(id).IsGuid(out test)) { return(""); } return(new Users().GetName(test)); } if (id.StartsWith("w_")) { Guid test2; if (!WorkGroup.RemovePrefix(id).IsGuid(out test2)) { return(""); } return(new WorkGroup().GetName(test2)); } return(""); }
private void addWorkGroupUsers(List <RoadFlow.Data.Model.Users> userList, Guid workGroupID) { RoadFlow.Data.Model.WorkGroup workGroup = new WorkGroup().Get(workGroupID); if (workGroup != null && !workGroup.Members.IsNullOrEmpty()) { string[] array = workGroup.Members.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); Users users = new Users(); new WorkGroup(); string[] array2 = array; foreach (string text in array2) { if (text.StartsWith("u_")) { userList.Add(users.Get(Users.RemovePrefix(text).ToGuid())); } else if (text.IsGuid()) { userList.AddRange(GetAllUsers(text.ToGuid())); } else if (text.StartsWith("w_")) { addWorkGroupUsers(userList, WorkGroup.RemovePrefix(text).ToGuid()); } } } }
public List <RoadFlow.Data.Model.Users> GetAllUsers(string idString) { if (idString.IsNullOrEmpty()) { return(new List <RoadFlow.Data.Model.Users>()); } string[] array = idString.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <RoadFlow.Data.Model.Users> list = new List <RoadFlow.Data.Model.Users>(); Users users = new Users(); new WorkGroup(); string[] array2 = array; foreach (string text in array2) { if (text.StartsWith("u_")) { list.Add(users.Get(Users.RemovePrefix(text).ToGuid())); } else if (text.IsGuid()) { list.AddRange(GetAllUsers(text.ToGuid())); } else if (text.StartsWith("w_")) { addWorkGroupUsers(list, WorkGroup.RemovePrefix(text).ToGuid()); } } list.RemoveAll((RoadFlow.Data.Model.Users p) => p == null); return(list.Distinct(new UsersEqualityComparer()).ToList()); }
private void addWorkGroupUsers(List <RoadFlow.Data.Model.Users> userList, Guid workGroupID) { RoadFlow.Data.Model.WorkGroup workGroup1 = new WorkGroup().Get(workGroupID); if (workGroup1 == null || workGroup1.Members.IsNullOrEmpty()) { return; } string[] strArray = workGroup1.Members.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); Users users = new Users(); WorkGroup workGroup2 = new WorkGroup(); foreach (string str in strArray) { if (str.StartsWith("u_")) { userList.Add(users.Get(Users.RemovePrefix(str).ToGuid())); } else if (str.IsGuid()) { userList.AddRange((IEnumerable <RoadFlow.Data.Model.Users>) this.GetAllUsers(str.ToGuid())); } else if (str.StartsWith("w_")) { this.addWorkGroupUsers(userList, WorkGroup.RemovePrefix(str).ToGuid()); } } }
public List <RoadFlow.Data.Model.Users> GetAllUsers(string idString) { if (idString.IsNullOrEmpty()) { return(new List <RoadFlow.Data.Model.Users>()); } string[] strArray = idString.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <RoadFlow.Data.Model.Users> usersList = new List <RoadFlow.Data.Model.Users>(); Users users = new Users(); WorkGroup workGroup = new WorkGroup(); foreach (string str in strArray) { if (str.StartsWith("u_")) { usersList.Add(users.Get(Users.RemovePrefix(str).ToGuid())); } else if (str.IsGuid()) { usersList.AddRange((IEnumerable <RoadFlow.Data.Model.Users>) this.GetAllUsers(str.ToGuid())); } else if (str.StartsWith("w_")) { this.addWorkGroupUsers(usersList, WorkGroup.RemovePrefix(str).ToGuid()); } } usersList.RemoveAll((Predicate <RoadFlow.Data.Model.Users>)(p => p == null)); return(usersList.Distinct <RoadFlow.Data.Model.Users>((IEqualityComparer <RoadFlow.Data.Model.Users>) new UsersEqualityComparer()).ToList <RoadFlow.Data.Model.Users>()); }
/// <summary> /// 根据ID得到名称(有前缀的情况) /// </summary> /// <param name="id"></param> /// <returns></returns> public string GetName(string id) { string name = string.Empty; if (id.IsGuid())//机构 { return(GetName(id.ToGuid())); } else if (id.StartsWith(Users.PREFIX))//用户 { string uid = Users.RemovePrefix(id); Guid userID; if (!uid.IsGuid(out userID)) { return(""); } else { return(new Users().GetName(userID)); } } else if (id.StartsWith(WorkGroup.PREFIX))//工作组 { string uid = WorkGroup.RemovePrefix(id); Guid wid; if (!uid.IsGuid(out wid)) { return(""); } else { return(new WorkGroup().GetName(wid)); } } return(""); }