public List <RoleDTO> GetListWithModel(RoleSearchDTO searchModel) { log.MethodStart(); List <RoleDTO> objList = new List <RoleDTO>(); //var searchModel = JsonSerializer.Deserialize<RoleSearchDTO>(param); using (var trans = _db.Database.BeginTransaction()) { try { searchModel.sch_rol_name = searchModel.sch_rol_code; var objDataList = _db.RoleDTOs.FromSqlRaw <RoleDTO>("sp_GET_TCRole {0}, {1}", searchModel.sch_rol_code, searchModel.sch_rol_name).ToList(); objList = _mapper.Map <List <RoleDTO> >(objDataList); trans.Commit(); } catch (Exception ex) { // TODO: Handle failure trans.Rollback(); } finally { trans.Dispose(); } } log.MethodFinish(); return(objList); }
/// <summary> /// 得到所有角色信息 /// </summary> /// <returns></returns> public static List <RoleResultDTO> GetRoleList(RoleSearchDTO dto) { List <RoleResultDTO> result = new List <RoleResultDTO>(); result = GetAPI <List <RoleResultDTO> >(WebConfiger.MasterDataServicesUrl + "Role?RoleSearchDTO=" + TransformHelper.ConvertDTOTOBase64JsonString(dto)); return(result); }
public async Task <List <RoleDTO> > GetListByModelAsync(RoleSearchDTO searchData) { List <RoleDTO> objList = new List <RoleDTO>(); objList = await _apiHelper.GetDataListByModelAsync <RoleDTO, RoleSearchDTO>("role_api/Get_ListByModel", searchData); return(objList); }
public PageListResultBO <RoleDTO> GetDataByPage(RoleSearchDTO searchParams, int pageIndex = 1, int pageSize = 20) { var queryResult = (from module in this._roleRepository.GetAllAsQueryable() select new RoleDTO() { Id = module.Id, Name = module.Name, Code = module.Code }); if (searchParams != null) { if (!string.IsNullOrEmpty(searchParams.QueryName)) { searchParams.QueryName = searchParams.QueryName.Trim().ToLower(); queryResult = queryResult.Where(x => x.Name.Trim().ToLower().Contains(searchParams.QueryName)); } if (!string.IsNullOrEmpty(searchParams.QueryCode)) { searchParams.QueryCode = searchParams.QueryCode.Trim().ToLower(); queryResult = queryResult.Where(x => x.Code.Trim().ToLower().Contains(searchParams.QueryCode)); } if (!string.IsNullOrEmpty(searchParams.sortQuery)) { queryResult = queryResult.OrderBy(searchParams.sortQuery); } else { queryResult = queryResult.OrderByDescending(x => x.Id); } } else { queryResult = queryResult.OrderByDescending(x => x.Id); } var result = new PageListResultBO <RoleDTO>(); if (pageSize == -1) { var pagedList = queryResult.ToList(); result.Count = pagedList.Count; result.TotalPage = 1; result.ListItem = pagedList; } else { var dataPageList = queryResult.ToPagedList(pageIndex, pageSize); result.Count = dataPageList.TotalItemCount; result.TotalPage = dataPageList.PageCount; result.ListItem = dataPageList.ToList(); } return(result); }
public IEnumerable <RoleDTO> Get_List() { //var objReturn = _service.GetList(); RoleSearchDTO searchModel = new RoleSearchDTO(); var objReturn = _service.GetListWithModel(searchModel); return(objReturn); }
/// <summary> /// 得到所有角色信息 /// </summary> /// <returns></returns> public static List <RoleResultDTO> GetAllRoleList(int?id) { List <RoleResultDTO> result = new List <RoleResultDTO>(); RoleSearchDTO dto = new RoleSearchDTO(); result = GetRoleList(dto); result = result.Where(p => p.RoleType == id).ToList(); return(result); }
// GET: ModuleArea/Module public ActionResult Index() { var searchModel = new RoleSearchDTO(); SessionManager.SetValue("RoleSearch", new RoleSearchDTO()); RoleIndexViewModel viewModel = new RoleIndexViewModel() { GroupData = _roleService.GetDataByPage(searchModel) }; return(View(viewModel)); }
public async Task <List <RolePermissionDTO> > GetRolePermissionListByModelAsync(string role_code) { List <RolePermissionDTO> objList = new List <RolePermissionDTO>(); RoleSearchDTO searchData = new RoleSearchDTO() { sch_rol_code = role_code }; objList = await _apiHelper.GetDataListByModelAsync <RolePermissionDTO, RoleSearchDTO>("role_api/Get_PermissionListByModel", searchData); return(objList); }
/// <summary> /// 删除角色信息 /// </summary> /// <returns></returns> public ActionResult DeleteRole(RoleSearchDTO dto) { ResultData <object> result = new ResultData <object>(); try { result = UserAuthorityProvider.DeleteRole(dto); } catch (Exception ex) { result.SubmitResult = false; result.Message = ex.Message; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage GetRoleList(string RoleSearchDTO) { RoleSearchDTO dto = TransformHelper.ConvertBase64JsonStringToDTO <RoleSearchDTO>(RoleSearchDTO); List <RoleResultDTO> actionresult = new List <RoleResultDTO>(); actionresult = _IUserAuthorityServices.GetRoleList(dto); HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(actionresult), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }; return(result); }
public JsonResult SearchData(FormCollection form) { var searchModel = SessionManager.GetValue("RoleSearch") as RoleSearchDTO; if (searchModel == null) { searchModel = new RoleSearchDTO(); searchModel.pageSize = 20; } searchModel.QueryName = form["QUERY_NAME"]; searchModel.QueryCode = form["QUERY_CODE"]; SessionManager.SetValue("RoleSearch", searchModel); var data = _roleService.GetDataByPage(searchModel, 1); return(Json(data)); }
/// <summary> /// 得到所有角色信息 /// </summary> /// <returns></returns> public List <RoleResultDTO> GetRoleList(RoleSearchDTO dto) { List <RoleResultDTO> result = new List <RoleResultDTO>(); var tcdmse = SingleQueryObject.GetObj(); var pp = tcdmse.master_RoleInfo.AsNoTracking().Where(m => m.RoleID != null); if (dto.RoleType != null) { pp = pp.Where(m => m.RoleType == dto.RoleType); } if (!string.IsNullOrEmpty(dto.SearchText)) { pp = pp.Where(m => m.RoleName.Contains(dto.SearchText)); } result = AutoMapper.Mapper.Map <List <master_RoleInfo>, List <RoleResultDTO> >(pp.ToList()); return(result); }
public JsonResult GetData(int indexPage, string sortQuery, int pageSize) { var searchModel = SessionManager.GetValue("RoleSearch") as RoleSearchDTO; if (searchModel == null) { searchModel = new RoleSearchDTO(); } if (!string.IsNullOrEmpty(sortQuery)) { searchModel.sortQuery = sortQuery; } if (pageSize > 0) { searchModel.pageSize = pageSize; } SessionManager.SetValue("RoleSearch", searchModel); var data = _roleService.GetDataByPage(searchModel, indexPage, pageSize); return(Json(data)); }
public HttpResponseMessage DeleteRole(string RoleSearchDTO) { RoleSearchDTO dto = TransformHelper.ConvertBase64JsonStringToDTO <RoleSearchDTO>(RoleSearchDTO); ResultDTO <object> actionresult = new ResultDTO <object>(); try { actionresult.SubmitResult = _IUserAuthorityServices.DeleteRole(dto); } catch (Exception e) { actionresult.SubmitResult = false; actionresult.Message = e.Message; } HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(actionresult), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }; return(result); }
/// <summary> /// 删除角色信息 /// </summary> /// <returns></returns> public bool DeleteRole(RoleSearchDTO dto) { var result = false; using (var tcdmse = new Entities.TCDMS_MasterDataEntities()) { var pp = tcdmse.master_RoleInfo.Where(p => p.RoleID == dto.RoleID).FirstOrDefault(); if (pp == null) { throw new Exception("此条信息不存在"); } var auth = tcdmse.master_RoleAuthority.Where(a => a.RoleID == dto.RoleID).ToList(); tcdmse.master_RoleAuthority.RemoveRange(auth); if (pp.master_UserInfo.Count > 0) { throw new Exception("信息已使用,不可删除!"); } tcdmse.master_RoleInfo.Remove(pp); result = tcdmse.SaveChanges() > 0; } return(result); }
public void TestMethod1() { //角色管理 //新增 RoleSearchDTO adddto = new RoleSearchDTO(); var searchdtostr = TransformHelper.ConvertDTOTOBase64JsonString(adddto); testcontroller.GetRoleList(searchdtostr); RoleOperateDTO adddtotest = new RoleOperateDTO(); adddtotest.RoleName = "单元测试角色"; var addresult = JsonConvert.DeserializeObject <ResultDTO <object> >(testcontroller.AddRole(adddtotest).Content.ReadAsStringAsync().Result); var resultlist1 = JsonConvert.DeserializeObject <List <RoleResultDTO> >(testcontroller.GetRoleList(searchdtostr).Content.ReadAsStringAsync().Result); var target = resultlist1.Where(m => m.RoleName == "单元测试角色").FirstOrDefault(); Assert.IsNotNull(target); //修改 adddtotest.RoleID = target.RoleID; adddtotest.RoleName = "修改成功的单元测试角色"; var updateresult = JsonConvert.DeserializeObject <ResultDTO <object> >(testcontroller.UpdateRole(adddtotest).Content.ReadAsStringAsync().Result); var resultlist2 = JsonConvert.DeserializeObject <List <RoleResultDTO> >(testcontroller.GetRoleList(searchdtostr).Content.ReadAsStringAsync().Result); target = resultlist2.Where(m => m.RoleName == "修改成功的单元测试角色").FirstOrDefault(); Assert.IsNotNull(target); //删除 RoleSearchDTO deleteDto = new RoleSearchDTO(); deleteDto.RoleID = target.RoleID; var deleteDtoster = TransformHelper.ConvertDTOTOBase64JsonString(deleteDto); var deleteresult = JsonConvert.DeserializeObject <ResultDTO <object> >(testcontroller.DeleteRole(deleteDtoster).Content.ReadAsStringAsync().Result); var resultlist3 = JsonConvert.DeserializeObject <List <RoleResultDTO> >(testcontroller.GetRoleList(searchdtostr).Content.ReadAsStringAsync().Result); target = resultlist3.Where(m => m.RoleID == target.RoleID).FirstOrDefault(); Assert.IsNull(target); }
public List <RolePermissionDTO> GetPermissionListWithModel(RoleSearchDTO searchModel) { log.MethodStart(); List <RolePermissionDTO> objList = new List <RolePermissionDTO>(); //var searchModel = JsonSerializer.Deserialize<RoleSearchDTO>(param); using (var trans = _db.Database.BeginTransaction()) { try { var menuList = _db.TCMenus.ToList(); var rolePermissionList = _db.TCRolePermissions.Where(x => x.rop_rol_code == searchModel.sch_rol_code).ToList(); foreach (var item in menuList) { var rolPermissionDTO = new RolePermissionDTO(); rolPermissionDTO.mnu_id = item.mnu_id; rolPermissionDTO.mnu_code = item.mnu_code; rolPermissionDTO.mnu_name = item.mnu_name; rolPermissionDTO.mnu_status = item.mnu_status; rolPermissionDTO.mnu_active = item.mnu_active; var rolePermission = rolePermissionList.FirstOrDefault(x => x.rop_mnu_code == item.mnu_code); if (rolePermission != null) { rolPermissionDTO.rop_id = rolePermission.rop_id; rolPermissionDTO.rop_rol_code = rolePermission.rop_rol_code; rolPermissionDTO.rop_mnu_code = rolePermission.rop_mnu_code; rolPermissionDTO.rop_view = rolePermission.rop_view; rolPermissionDTO.rop_create = rolePermission.rop_create; rolPermissionDTO.rop_edit = rolePermission.rop_edit; rolPermissionDTO.rop_approve = rolePermission.rop_approve; rolPermissionDTO.rop_print = rolePermission.rop_print; rolPermissionDTO.rop_reject = rolePermission.rop_reject; rolPermissionDTO.rop_cancel = rolePermission.rop_cancel; rolPermissionDTO.rop_return = rolePermission.rop_return; rolPermissionDTO.rop_complete = rolePermission.rop_complete; rolPermissionDTO.rop_implement = rolePermission.rop_implement; rolPermissionDTO.rop_status = rolePermission.rop_status; rolPermissionDTO.rop_active = rolePermission.rop_active; rolPermissionDTO.rop_createuser = rolePermission.rop_createuser; rolPermissionDTO.rop_createdate = rolePermission.rop_createdate; rolPermissionDTO.rop_updateuser = rolePermission.rop_updateuser; rolPermissionDTO.rop_updatedate = rolePermission.rop_updatedate; } else { rolPermissionDTO.rop_rol_code = searchModel.sch_rol_code; rolPermissionDTO.rop_mnu_code = item.mnu_code; } objList.Add(rolPermissionDTO); } //objList = _db.RolePermissionDTOs.FromSqlRaw<RolePermissionDTO>("sp_GET_TCRolePermission {0}", searchModel.rol_code).ToList(); //objList = _mapper.Map<List<RoleDTO>>(objDataList); trans.Commit(); } catch (Exception ex) { // TODO: Handle failure trans.Rollback(); } finally { trans.Dispose(); } } log.MethodFinish(); return(objList); }
public IEnumerable <RolePermissionDTO> Get_PermissionListByModel([FromBody] RoleSearchDTO searchModel) { var objReturn = _service.GetPermissionListWithModel(searchModel); return(objReturn); }
/// <summary> /// 删除角色信息 /// </summary> /// <returns></returns> public static ResultData <object> DeleteRole(RoleSearchDTO dto) { var result = DeleteAPI <ResultData <object> >(WebConfiger.MasterDataServicesUrl + "Role?RoleSearchDTO=" + TransformHelper.ConvertDTOTOBase64JsonString(dto)); return(result); }
/// <summary> /// 导出角色管理 /// </summary> /// <param name="dto"></param> /// <returns></returns> public ActionResult ExportRole(RoleSearchDTO dto) { string result = null; List <RoleResultDTO> pp = null; pp = UserAuthorityProvider.GetRoleList(dto); string strTemplateFile = Server.MapPath(@"~/TempLate/RoleTemplate.xlsx"); string strGenarateDir = Server.MapPath(@"~/TempFile"); string strGenarateFile = Guid.NewGuid().ToString("N") + ".xlsx"; string strExportFile = strGenarateDir + "\\" + strGenarateFile; List <object> ratelist = new List <object>(); //角色 pp.ForEach(g => { //一级权限 var aa = g.RoleAuthority.Where(w => w.StructureID.Length == 3).ToList(); if (aa.Count == 0) { Models.Model.Excel.ExcelRole er = new Models.Model.Excel.ExcelRole(); er.角色名称 = g.RoleName; er.角色类别 = g.RoleTypeStr; ratelist.Add(er); } aa.ForEach(a => { //二级权限 var bb = g.RoleAuthority.Where(w => w.StructureID.Length == 6 && w.StructureID.StartsWith(a.StructureID)).ToList(); if (bb.Count == 0) { Models.Model.Excel.ExcelRole er = new Models.Model.Excel.ExcelRole(); er.角色名称 = g.RoleName; er.角色类别 = g.RoleTypeStr; er.一级模块权限 = a.StructureName; ratelist.Add(er); } bb.ForEach(b => { //三级权限 var cc = g.RoleAuthority.Where(w => w.StructureID.Length == 9 && w.StructureID.StartsWith(b.StructureID)).ToList(); if (cc.Count == 0) { Models.Model.Excel.ExcelRole er = new Models.Model.Excel.ExcelRole(); er.角色名称 = g.RoleName; er.角色类别 = g.RoleTypeStr; er.一级模块权限 = a.StructureName; er.二级模块权限 = b.StructureName; ratelist.Add(er); } cc.ForEach(c => { //三级权限功能按钮 Models.Model.Excel.ExcelRole er = new Models.Model.Excel.ExcelRole(); er.角色名称 = g.RoleName; er.角色类别 = g.RoleTypeStr; er.一级模块权限 = a.StructureName; er.二级模块权限 = b.StructureName; er.级模块权限 = c.StructureName; er.功能权限 = string.Join(",", GlobalStaticData.ButtonInfo.Where(w => (c.RoleButtonAuthority | w.ButtonID) == c.RoleButtonAuthority).Select(s => s.ButtonValue)); ratelist.Add(er); }); }); }); }); if (Common.ExcelHelper.Export(strTemplateFile, strGenarateDir, strGenarateFile, ratelist, "Sheet1")) { result = strGenarateFile; } return(Json(result)); }
/// <summary> /// 得到所有角色信息 /// </summary> /// <returns></returns> public ActionResult GetRoleList(RoleSearchDTO dto) { var result = UserAuthorityProvider.GetRoleList(dto); return(Json(result, JsonRequestBehavior.AllowGet)); }
private bool CheckUserInfo(object obj) { bool result = true; List <ExcelUser> exceldto = (List <ExcelUser>)obj; UserSearchDTO dto = new UserSearchDTO(); dto.rows = 100000000; dto.page = 1; var UserInfoList = UserAuthorityProvider.GetUser(dto); DistributorSearchDTO disdto = new DistributorSearchDTO(); disdto.page = 1; disdto.rows = 1000000000; var distributorlist = DistributorProvider.GetDistributorList(disdto);//所有经销商 RoleSearchDTO roleSearch = new RoleSearchDTO(); var rolelist = UserAuthorityProvider.GetRoleList(roleSearch); string strimporter = ((UserLoginDTO)Session["UserLoginInfo"]).FullName; foreach (var p in exceldto) { StringBuilder sb = new StringBuilder(); if (String.IsNullOrEmpty(p.UserCode)) { sb.Append("用户编号不可为空! "); } else { var UserID = UserInfoList.Object.Where(m => m.UserCode == p.UserCode).Select(m => m.UserID).FirstOrDefault(); if (UserID != null) { p.UserID = UserID; p.UpLogic = 2; } else { p.UpLogic = 1; } } if (String.IsNullOrEmpty(p.Email)) { sb.Append("用户邮箱不可为空! "); } if (String.IsNullOrEmpty(p.PhoneNumber)) { sb.Append("用户手机号不可为空! "); } else { //手机号在此不做唯一性判断。 //var PhoneNumber = UserInfoList.Object.Where(m => m.PhoneNumber == p.PhoneNumber).Select(m => m.PhoneNumber).FirstOrDefault(); //if (PhoneNumber != null) //{ // sb.Append("用户手机号不可重复"); //} } if (String.IsNullOrEmpty(p.DistributorNamestr)) { //sb.Append("所属经销商不可为空!"); } else { foreach (var dis in p.DistributorNamelist) { var exist = distributorlist.Object.Where(m => m.DistributorName == dis).FirstOrDefault(); if (exist == null) { sb.Append("经销商名称填写错误!错误名称为" + dis + "请检查!"); } else { } } } if (String.IsNullOrEmpty(p.RoleNamestr)) { //sb.Append("用户角色不可为空! "); } else { foreach (var role in p.RoleNamelist) { var exist = rolelist.Where(m => m.RoleName == role).FirstOrDefault(); if (exist == null) { sb.Append("角色" + role + "不存在!"); } } } if (String.IsNullOrEmpty(p.StopTime)) { sb.Append("使用的截止日期不可为空! "); } p.Importer = strimporter; if (sb.Length > 0) { p.CheckInfo = sb.ToString(); result = false; } } return(result); }
public async Task <LoginUser> Check_LoginUser_DataAsync(LoginUserSearchDTO searchModel) { log.MethodStart(); LoginUser loginUser = new LoginUser(); try { //searchModel.usr_clientIp = _httpContextAccessor.HttpContext.Connection.LocalIpAddress.ToString(); searchModel.usr_sessionId = Guid.NewGuid().ToString().ToUpper(); LoginUserDTO objModel = new LoginUserDTO(); List <LoginUserPermissionDTO> objList = new List <LoginUserPermissionDTO>(); //log.Info(JsonSerializer.Serialize(searchModel)); objModel = await _apiHelper.GetDataByModelAsync <LoginUserDTO, LoginUserSearchDTO>("loginuserdata_api/GetLoginUserData", searchModel); //log.Info(JsonSerializer.Serialize(objModel)); if (objModel?.usr_id != 0) { loginUser.Username = objModel.usr_username; loginUser.Firstname = objModel.usr_firstname; loginUser.Lastname = objModel.usr_lastname; loginUser.ClientIp = searchModel.usr_clientIp; loginUser.SessionId = searchModel.usr_sessionId; loginUser.SessionTimeStamp = DateTime.Now; loginUser.SessionTimeout = _timeoutDuration; loginUser.LoginUserPermissionList = JsonSerializer.Deserialize <List <LoginUserPermissionDTO> >(objModel.str_LoginUserPermission_List); loginUser.LoginUserRolePermissionList = JsonSerializer.Deserialize <List <LoginUserRolePermissionDTO> >(objModel.str_LoginUserRolePermission_List); //objList = await _apiHelper.GetDataListByModelAsync<LoginUserPermissionDTO, LoginUserSearchDTO>("loginuserdata_api/GetLoginUserPermissionData", searchModel); //log.Info(JsonSerializer.Serialize(objList)); if (loginUser.LoginUserPermissionList.Count > 0) { var objListFirst = loginUser.LoginUserPermissionList.FirstOrDefault(); loginUser.rol_code = objListFirst.usp_rol_code; loginUser.rol_name = objListFirst.usp_rol_name; loginUser.arh_code = objListFirst.usp_arh_code; loginUser.arh_name = objListFirst.usp_arh_name; loginUser.prv_code = objListFirst.usp_prv_code; loginUser.prv_name = objListFirst.usp_prv_name; loginUser.hos_code = objListFirst.usp_hos_code; loginUser.hos_name = objListFirst.usp_hos_name; loginUser.lab_code = objListFirst.usp_lab_code; loginUser.lab_name = objListFirst.usp_lab_name; RoleSearchDTO searchData = new RoleSearchDTO() { sch_rol_code = loginUser.rol_code }; loginUser.rol_permission_List = await _apiHelper.GetDataListByModelAsync <RolePermissionDTO, RoleSearchDTO>("role_api/Get_PermissionListByModel", searchData); } } } catch (Exception ex) { // TODO: Handle failure //trans.Rollback(); log.Error(ex.Message); log.Error(ex.InnerException.Message); } finally { //trans.Dispose(); } log.MethodFinish(); return(loginUser); }