/// <summary> /// 删除角色 /// </summary> /// <param name="userInfo">用户</param> /// <param name="role">角色</param> /// <returns>影响行数</returns> public int DeleteRole(BaseUserInfo userInfo, string role) { // 加强安全验证防止未授权匿名调用 #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 id = roleManager.GetId(new KeyValuePair <string, object>(BaseRoleEntity.FieldRealName, role)); if (!String.IsNullOrEmpty(id)) { // 在删除时,可能会把相关的其他配置角色会删除掉,所以需要调用这个方法。 returnValue = roleManager.Delete(id); } } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } return(returnValue); }
/// <summary> /// 删除角色 /// </summary> /// <param name="userInfo">用户</param> /// <param name="id">主键</param> /// <returns>数据表</returns> public int Delete(BaseUserInfo userInfo, string id) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); string tableName = BaseRoleEntity.TableName; if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode)) { tableName = BaseSystemInfo.SystemCode + "Role"; } BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo, tableName); returnValue = roleManager.Delete(id); BaseLogManager.Instance.Add(dbHelper, userInfo, serviceName, AppMessage.RoleService_Delete, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }