//获取某项目的可用角色详单 todo public ActionResult GetRoleListOfProject(string ProjectID) { string _enterpriseID = BCSession.User.EnterpriseID; int? _departmentID = BCSession.User.DepartmentID; string _userID = BCSession.User.UserID; var result = new StandardJsonResult <List <RoleIdName> >(); result.Value = new List <RoleIdName>(); result.Try(() => { //var list = new List<RoleIdName>(); //var r = new RoleIdName //{ // RoleId = "1", // RoleName = "施工员" //}; //list.Add(r); //r.RoleId = "1"; //r.RoleName = "质检员"; //list.Add(r); //result.Value = list; var t = _sceneService.GetRoleUserListOfEnterprise(_enterpriseID, ProjectID); foreach (var roleUsers in t) { RoleIdName item = roleUsers.Key; if (item != null) { result.Value.Add(item); } } result.Value = result.Value.Distinct().ToList(); }); return(result); }
//扩展分组的用户信息 添加名字信息 private List <KeyValuePair <RoleIdName, List <UserIdName> > > processGroupedUsers(List <GroupedUser> users) { var result = new List <KeyValuePair <RoleIdName, List <UserIdName> > >(); foreach (var gpuser in users) { if (gpuser.UserID == null) { continue; } string RoleId = gpuser.roleId + ""; string RoleName; try { RoleName = _roleService.GetEnterpriseRoleByRoleID(gpuser.roleId).Name; } catch (Exception) { RoleName = "(" + RoleId + ")角色不存在"; } RoleIdName rin = new RoleIdName { RoleId = RoleId, RoleName = RoleName }; List <UserIdName> list = new List <UserIdName>(); foreach (var userId in gpuser.UserID) { if (userId == null || userId.Equals("")) { continue; } string UserName; try { UserName = _userService.GetFrontUserByUserID(userId).Name; } catch (Exception) { UserName = "******" + userId + ")用户不存在"; } var uin = new UserIdName { UserId = userId, UserName = UserName }; list.Add(uin); } KeyValuePair <RoleIdName, List <UserIdName> > kv = new KeyValuePair <RoleIdName, List <UserIdName> >(rin, list); result.Add(kv); } return(result); }