/// <summary> /// 撤销角色权限 /// </summary> /// <param name="userInfo">用户</param> /// <param name="roleName">角色名</param> /// <param name="permissionItemCode">权限编号</param> /// <returns>主键</returns> public int RevokeRolePermission(BaseUserInfo userInfo, string roleName, string permissionItemCode) { // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo); string roleId = roleManager.GetId(new KeyValuePair <string, object>(BaseRoleEntity.FieldRealName, roleName)); BasePermissionItemManager permissionItemManager = new BasePermissionItemManager(dbHelper, userInfo); string permissionItemId = permissionItemManager.GetId(new KeyValuePair <string, object>(BasePermissionItemEntity.FieldCode, permissionItemCode)); if (!String.IsNullOrEmpty(roleId) && !String.IsNullOrEmpty(permissionItemId)) { BaseRolePermissionManager rolePermissionManager = new BaseRolePermissionManager(dbHelper, userInfo); returnValue = rolePermissionManager.Revoke(roleId, permissionItemId); } } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } return(returnValue); }
/// <summary> /// 下个流程发送给谁 /// </summary> /// <param name="id">当前主键</param> /// <returns>影响行数</returns> private int StepAuditTransmit(string currentId, string workFlowCategory, string sendToId, string auditIdea) { BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId); // 1.记录当前的审核时间、审核人信息 workFlowCurrentEntity.ToDepartmentId = this.UserInfo.DepartmentId; workFlowCurrentEntity.ToDepartmentName = this.UserInfo.DepartmentName; workFlowCurrentEntity.ToUserId = this.UserInfo.Id; workFlowCurrentEntity.ToUserRealName = this.UserInfo.RealName; workFlowCurrentEntity.AuditStatus = AuditStatus.Transmit.ToString(); workFlowCurrentEntity.AuditStatusName = AuditStatus.Transmit.ToDescription(); // 2.记录审核日志 this.AddHistory(workFlowCurrentEntity); // 3.上一个审核结束了,新的审核又开始了,更新待审核情况 workFlowCurrentEntity.AuditUserId = this.UserInfo.Id; workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName; workFlowCurrentEntity.AuditDate = DateTime.Now; workFlowCurrentEntity.AuditIdea = auditIdea; // 是否提交给部门审批 if (workFlowCategory.Equals("ByOrganize")) { BaseOrganizeManager organizeManager = new BaseOrganizeManager(UserInfo); BaseOrganizeEntity organizeEntity = organizeManager.GetEntity(sendToId); // 设置审批部门主键 workFlowCurrentEntity.ToDepartmentId = sendToId; // 设置审批部门名称 workFlowCurrentEntity.ToDepartmentName = organizeEntity.FullName; } // 是否提交给角色审批 if (workFlowCategory.Equals("ByRole")) { BaseRoleManager roleManger = new BaseRoleManager(this.UserInfo); BaseRoleEntity roleEntity = roleManger.GetEntity(sendToId); // 设置审批角色主键 workFlowCurrentEntity.ToRoleId = sendToId; // 设置审批角色名称 workFlowCurrentEntity.ToRoleRealName = roleEntity.RealName; } // 是否提交给用户审批 if (workFlowCategory.Equals("ByUser")) { BaseUserManager userManager = new BaseUserManager(UserInfo); BaseUserEntity userEntity = userManager.GetEntity(sendToId); // 设置审批用户主键 workFlowCurrentEntity.ToUserId = sendToId; // 设置审批用户名称 workFlowCurrentEntity.ToUserRealName = userEntity.RealName; // TODO 用户的部门信息需要处理 if (!string.IsNullOrEmpty(userEntity.DepartmentId)) { BaseOrganizeManager organizeManager = new BaseOrganizeManager(UserInfo); BaseOrganizeEntity organizeEntity = organizeManager.GetEntity(userEntity.DepartmentId); workFlowCurrentEntity.ToDepartmentId = userEntity.DepartmentId; workFlowCurrentEntity.ToDepartmentName = organizeEntity.FullName; } } workFlowCurrentEntity.AuditStatus = AuditStatus.WaitForAudit.ToString(); workFlowCurrentEntity.AuditStatusName = AuditStatus.WaitForAudit.ToDescription(); // 当前审核人的信息写入当前工作流 workFlowCurrentEntity.Enabled = 0; workFlowCurrentEntity.DeletionStateCode = 0; return(this.UpdateEntity(workFlowCurrentEntity)); }