/// <summary> /// 某个用户是否对某个模块有相应的权限 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userId">用户主键</param> /// <param name="moduleCode">模块编号</param> /// <param name="permissionItemCode"></param> /// <returns>是否有权限,true:是,false:否</returns> public bool IsModuleAuthorizedByUserId(UserInfo userInfo, string userId, string moduleCode, string permissionItemCode) { var returnValue = false; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_IsModuleAuthorizedByUserId); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { // 是否超级管理员 var userManager = new PiUserManager(dbProvider, userInfo); returnValue = userManager.IsAdministrator(userId); if (!returnValue) { returnValue = new PiPermissionScopeManager(dbProvider).IsModuleAuthorized(userId, moduleCode, permissionItemCode); } }); return(returnValue); }
/// <summary> /// 指定用户是否对某个模块有相应的权限 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userId">用户主键</param> /// <param name="moduleCode">模块编号</param> /// <returns>是否有权限,true:是,false:否</returns> public bool IsModuleAuthorizedByUserId(UserInfo userInfo, string userId, string moduleCode) { var returnValue = false; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_IsModuleAuthorizedByUserId); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { // 是否超级管理员 var userManager = new PiUserManager(dbProvider, userInfo); returnValue = userManager.IsAdministrator(userId); if (!returnValue) { var dataTable = new PiModuleManager(dbProvider, userInfo).GetDTByUser(userId); if (dataTable.Rows.Cast <DataRow>().Any(dataRow => dataRow[PiModuleTable.FieldCode].ToString().Equals(moduleCode, StringComparison.OrdinalIgnoreCase))) { returnValue = true; } } }); return(returnValue); }