/// <summary> /// 根据ID字符串得到所有人员 /// </summary> /// <param name="idString">u_人员,id,w_工作且,r_兼职</param> /// <returns></returns> public List <Model.User> GetAllUsers(string idString) { List <Model.User> users = new List <Model.User>(); if (idString.IsNullOrWhiteSpace()) { return(users); } User user = new User(); OrganizeUser organizeUser = new OrganizeUser(); WorkGroup workGroup = new WorkGroup(); foreach (string id in idString.Split(',')) { if (id.IsGuid(out Guid guid)) { users.AddRange(GetAllUsers(guid)); } else if (id.StartsWith(PREFIX_USER)) //ID是一个人员ID { var userModel = user.Get(id.RemoveUserPrefix().ToGuid()); if (null != userModel) { users.Add(userModel); } } else if (id.StartsWith(PREFIX_RELATION)) //ID是一个人员兼职ID { var organizeUserModel = organizeUser.Get(id.RemoveUserRelationPrefix().ToGuid()); if (null != organizeUserModel) { var userModel = user.Get(organizeUserModel.UserId); if (null != userModel) { userModel.PartTimeId = organizeUserModel.Id; users.Add(userModel); } } } else if (id.StartsWith(PREFIX_WORKGROUP)) //ID是一个工作组ID { users.AddRange(workGroup.GetAllUsers(id.RemoveWorkGroupPrefix().ToGuid())); } } var y = users.Distinct(new Model.User()).ToList(); return(users.Distinct(new Model.User()).ToList()); }
/// <summary> /// 得到一个人员所在的工作组 /// </summary> /// <param name="userId"></param> /// <returns></returns> public List <Model.WorkGroup> GetWorkGroups(Guid userId) { List <Model.WorkGroup> workGroups = new List <Model.WorkGroup>(); if (userId.IsEmptyGuid()) { return(workGroups); } WorkGroup workGroup = new WorkGroup(); var wgs = workGroup.GetAll(); foreach (var wg in wgs) { if (workGroup.GetAllUsers(wg.Id).Exists(p => p.Id == userId)) { workGroups.Add(wg); } } return(workGroups); }