public HttpResponseMessage ApplyUserAudit(UserApplyOperateDTO dto) { ResultDTO <UserApplyOperateDTO> resultdto = new ResultDTO <UserApplyOperateDTO>(); try { if (dto.AuditStatus == 1) //通过 { resultdto.SubmitResult = _IUserServices.AuditUserApplyEgis(dto); resultdto.Object = dto; } else if (dto.AuditStatus == 2)//拒绝 { resultdto.SubmitResult = _IUserServices.AuditUserApplyRefuse(dto); resultdto.Object = dto; } } catch (Exception ex) { resultdto.SubmitResult = false; resultdto.Message = ex.Message; } HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(resultdto), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }; return(result); }
/// <summary> /// 变更权限 /// </summary> /// <returns></returns> public static ResultData <object> ChangeUserAut(UserApplyOperateDTO dto) { ResultData <object> result = null; result = PostAPI <ResultData <object> >(WebConfiger.UserServicesUrl + "ExistUser", dto); return(result); }
/// <summary> /// 用户申请审核(拒绝) /// </summary> /// <param name="dto"></param> /// <returns></returns> public static ResultData <UserApplyOperateDTO> AuditUserApplyRefuse(UserApplyOperateDTO dto) { ResultData <UserApplyOperateDTO> result = new ResultData <UserApplyOperateDTO>(); result = PostAPI <ResultData <UserApplyOperateDTO> >(WebConfiger.UserServicesUrl + "ApplyUserAudit", dto); return(result); }
/// <summary> /// 用户申请审核(通过)添加权限 /// </summary> /// <param name="dto"></param> /// <returns></returns> public static ResultData <object> AuditUserApplyAdoptAut(UserApplyOperateDTO dto) { ResultData <object> result = new ResultData <object>(); result = PostAPI <ResultData <object> >(WebConfiger.MasterDataServicesUrl + "UserAudit", dto); return(result); }
/// <summary> /// 用户审核(拒绝) /// </summary> /// <param name="dto"></param> /// <returns></returns> public bool AuditUserApplyRefuse(UserApplyOperateDTO dto) { bool blResult = false; using (var tcdmse = new Entities.TCDMS_UserApplyEntities()) { var pp = tcdmse.UserApply_UserApplyInfo.Where(p => p.UserApplyID == dto.UserApplyID).FirstOrDefault(); if (pp != null) { pp.AuditFalseReason = dto.AuditFalseReason; Mapper.Map <UserApply_UserApplyInfo, UserApplyOperateDTO>(pp, dto); dto.AuditRoleIDList = ","; List <UserApplyAuthority> uaur = new List <UserApplyAuthority>(); foreach (var rl in dto.RoleIDlist) { if (pp.AuditRoleIDList.Contains("," + rl.Value.ToString() + ",")) { dto.AuditRoleIDList = dto.AuditRoleIDList + rl.Value.ToString() + ","; pp.AuditRoleIDList = pp.AuditRoleIDList.Replace("," + rl + ",", ","); List <string> Sid = ModelRoleDTO.ModelRolelist.Where(p => p.RoleID == rl).Select(s => s.ModelID).ToList(); foreach (var s in Sid) { uaur.AddRange(dto.ApplyUserAuthority.Where(ua => ua.StructureID.StartsWith(s)).Select(w => new UserApplyAuthority { StructureID = w.StructureID, AppyUserButtonAuthority = w.AppyUserButtonAuthority })); } } } dto.ApplyUserAuthority = uaur; } if (pp.AuditRoleIDList == ",") { pp.AuditStatus = 1; tcdmse.SaveChanges(); if (pp.BatchID != null) { var qq = tcdmse.UserApply_UserApplyInfo.Where(p => p.BatchID == pp.BatchID).Select(s => s.AuditRoleIDList).Distinct().ToList(); if (qq.Count() == 1) { if (qq.FirstOrDefault() == ",") { var pq = tcdmse.UserApply_ApplyBatch.Where(p => p.BatchID == pp.BatchID).FirstOrDefault(); pq.AuditStatus = 1; } } } } blResult = tcdmse.SaveChanges() > 0; blResult = true; } return(blResult); }
public HttpResponseMessage AuditUserApplyAdopt(UserApplyOperateDTO dto) { ResultDTO <UserApplyOperateDTO> actionresult = new ResultDTO <UserApplyOperateDTO>(); actionresult.SubmitResult = _lUserAuthorityServices.AuditUserApplyAdopt(dto); actionresult.Object = dto; HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(actionresult), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }; return(result); }
/// <summary> /// 用户申请审核(通过) /// </summary> /// <param name="dto"></param> /// <returns></returns> public ActionResult AuditUserApplyAdopt(UserApplyOperateDTO dto) { ResultData <UserApplyOperateDTO> result = new ResultData <UserApplyOperateDTO>(); UserLoginDTO user = (UserLoginDTO)Session["UserLoginInfo"]; try { dto.CreateUser = user.FullName; dto.RoleIDlist = user.CurrentRoleIDList; dto.AuditStatus = 1; result = UserAuthorityProvider.AuditUserApplyAdopt(dto); if (result.SubmitResult) { result.Object.StopTime = DateTime.Now.AddYears(1); UserAuthorityProvider.AuditUserApplyAdoptAut(result.Object); //通过的模块名称 var aut = result.Object.ApplyUserAuthority.Select(s => s.StructureID).ToList(); var modelname = ModelRoleModel.ModelRolelist.Where(m => aut.Contains(m.ModelID)).Select(s => s.ModelName).ToList(); string modelstr = string.Join(",", modelname); //取得申请人邮箱 UserApplySearchDTO batchdto = new UserApplySearchDTO(); batchdto.BatchID = result.Object.BatchID; batchdto.Query = 1; batchdto.page = 1; batchdto.rows = 1; var pp = UserAuthorityProvider.GetBatchUser(batchdto); //发送邮件通知申请人 EmailHelper.SendMessage("用户审核通过", string.Format(WebConfiger.UserAuditPassEmailMessage, result.Object.UserApplyName, dto.Distributor, modelstr), new List <string> { pp.Object.ApplyUserEamil }, null, null); // 发送短信通知申请人 MobileMessage.SendMessage(new List <string> { pp.Object.ApplyUserPhone }, String.Format(WebConfiger.UserAuditPassShortMessage, modelstr)); } } catch (Exception ex) { result.SubmitResult = false; result.Message = ex.Message; } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 用户审核(通过) /// </summary> /// <param name="dto"></param> /// <returns></returns> public bool AuditUserApplyAdopt(UserApplyOperateDTO dto) { bool blResult = false; using (var tcdmse = new Entities.TCDMS_MasterDataEntities()) { List <int?> ridlist = new List <int?>(); //审核的角色 List <string> modellist = new List <string>(); //审核的模块 if (dto != null) { var strauth = tcdmse.dict_Structure.ToList(); var qq = tcdmse.master_UserInfo.Where(p => p.PhoneNumber == dto.UserApplyTelNumber).FirstOrDefault(); if (qq == null) { //从用户申请表 => 用户表 master_UserInfo user = new master_UserInfo(); user.FullName = dto.UserApplyName; user.PhoneNumber = dto.UserApplyTelNumber; user.Email = dto.UserApplyEmail; user.UserType = dto.UserApplyType; user.IsActive = true; user.StopTime = dto.StopTime; user.DepartID = 1; user.CreateTime = dto.CreateTime; user.CreateUser = dto.CreateUser; tcdmse.master_UserInfo.Add(user); tcdmse.SaveChanges(); //用户申请表关联经销商str => 用户经销商表 if (dto.DistributorIDList != null) { List <string> Dlist = dto.DistributorIDList.Split(',').ToList(); List <Guid> Dguidlist = new List <Guid>(); foreach (var d in Dlist) { Guid g = Guid.Empty; if (Guid.TryParse(d, out g)) { Dguidlist.Add(Guid.Parse(d)); } } var dd = tcdmse.master_DistributorInfo.Where(w => Dguidlist.Contains(w.DistributorID)); foreach (var d in dd) { user.master_DistributorInfo.Add(d); } } } qq = tcdmse.master_UserInfo.Where(p => p.PhoneNumber == dto.UserApplyTelNumber).FirstOrDefault(); if (dto.UserChangeID == null)//新用户申请 { List <CurrentAuthorityDTO> uappa = new List <CurrentAuthorityDTO>(); foreach (var rl in dto.RoleIDlist) { if (dto.AuditRoleIDList.Contains("," + rl.Value.ToString() + ",")) { ridlist.Add(rl); //通过静态类取得角色对应的模块ID List <string> Sid = ModelRoleDTO.ModelRolelist.Where(p => p.RoleID == rl).Select(s => s.ModelID).ToList(); foreach (var s in Sid) { uappa.AddRange(dto.ApplyUserAuthority.Where(ua => ua.StructureID.StartsWith(s)).Select(sw => new CurrentAuthorityDTO { StructureID = sw.StructureID, BelongButton = sw.AppyUserButtonAuthority })); } } } //得到通过模块的权限 var userapplyaut = uappa.Select(s => new { s.StructureID, s.BelongButton }).Distinct().ToList(); modellist.AddRange(userapplyaut.Where(s => s.StructureID.Length == 3).Select(ss => ss.StructureID).ToList()); foreach (var q in userapplyaut) { master_UserCustomerAuthority userauthority = new master_UserCustomerAuthority(); userauthority.UserID = qq.UserID; userauthority.StructureID = q.StructureID; userauthority.UserButtonAuthority = q.BelongButton; tcdmse.master_UserCustomerAuthority.Add(userauthority); } } else { List <CurrentAuthorityDTO> uappa = new List <CurrentAuthorityDTO>(); foreach (var rl in dto.RoleIDlist) { if (dto.AuditRoleIDList.Contains("," + rl.Value.ToString() + ",")) { //通过静态类取得角色对应的模块ID List <string> Sid = ModelRoleDTO.ModelRolelist.Where(p => p.RoleID == rl).Select(s => s.ModelID).ToList(); foreach (var s in Sid) { tcdmse.master_UserCustomerAuthority.RemoveRange(qq.master_UserCustomerAuthority.Where(ua => ua.StructureID.StartsWith(s))); uappa.AddRange(dto.ApplyUserAuthority.Where(ua => ua.StructureID.StartsWith(s)).Select(sw => new CurrentAuthorityDTO { StructureID = sw.StructureID, BelongButton = sw.AppyUserButtonAuthority })); } } } //得到通过模块的权限 var userapplyaut = uappa.Select(s => new { s.StructureID, s.BelongButton }).Distinct().ToList(); modellist.AddRange(userapplyaut.Where(s => s.StructureID.Length == 3).Select(ss => ss.StructureID).ToList()); foreach (var q in userapplyaut) { master_UserCustomerAuthority userauthority = new master_UserCustomerAuthority(); userauthority.UserID = qq.UserID; userauthority.StructureID = q.StructureID; userauthority.UserButtonAuthority = q.BelongButton; tcdmse.master_UserCustomerAuthority.Add(userauthority); } } } blResult = tcdmse.SaveChanges() > 0; } return(blResult); }