public new string GetIdByCode(string permissionItemCode) { string tableName = PiPermissionItemTable.TableName; PiModuleManager moduleManager = new PiModuleManager(dbProvider, UserInfo, tableName); return(moduleManager.GetIdByCode(permissionItemCode)); //PiPermissionItemManager permissionItemManager = new PiPermissionItemManager(DBProvider); //// 这里应该是若不存在就自动加一个操作权限 //return permissionItemManager.GetIdByAdd(permissionItemCode); }
/// <summary> /// 获取实体 /// </summary> /// <param name="userInfo">用户</param> /// <param name="id">主键</param> /// <returns>实体</returns> public PiModuleEntity GetEntity(UserInfo userInfo, string id) { var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_GetEntity); PiModuleEntity moduleEntity = null; ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); moduleEntity = moduleManager.GetEntity(id); }); return(moduleEntity); }
/// <summary> /// 批量保存 /// </summary> /// <param name="userInfo">用户</param> /// <param name="dataTable">数据表</param> /// <returns>影响行数</returns> public int BatchSave(UserInfo userInfo, DataTable dataTable) { int returnValue = 0; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_BatchSave); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); returnValue = moduleManager.BatchSave(dataTable); }); return(returnValue); }
/// <summary> /// 移动模块菜单 /// </summary> /// <param name="userInfo">用户</param> /// <param name="moduleId">模块主键</param> /// <param name="parentId">父结点主键</param> /// <returns>数据表</returns> public int MoveTo(UserInfo userInfo, string moduleId, string parentId) { int returnValue = 0; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_MoveTo); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); returnValue = moduleManager.SetProperty(moduleId, PiModuleTable.FieldParentId, parentId); }); return(returnValue); }
/// <summary> /// 删除模块 /// </summary> /// <param name="userInfo">用户</param> /// <param name="id">主键</param> /// <returns>影响行数</returns> public int Delete(UserInfo userInfo, string id) { int returnValue = 0; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_Delete); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); returnValue = moduleManager.Delete(id); }); return(returnValue); }
/// <summary> /// 通过编号获取模块名称 /// </summary> /// <param name="userInfo">用户</param> /// <param name="code">编号</param> /// <returns>数据表</returns> public string GetFullNameByCode(UserInfo userInfo, string code) { string returnValue = string.Empty; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_GetFullNameByCode); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); returnValue = moduleManager.GetFullNameByCode(code); }); return(returnValue); }
/// <summary> /// 按某个权限范围获取特定用户可访问的模块列表 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userId">用户主键</param> /// <param name="permissionItemCode">权限域编号</param> /// <returns>数据表</returns> public DataTable GetModuleDTByPermissionScope(UserInfo userInfo, string userId, string permissionItemCode) { var dataTable = new DataTable(PiModuleTable.TableName); var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_GetModuleDTByPermissionScope); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { dataTable = new PiModuleManager(dbProvider, userInfo).GetDTByPermission(userId, permissionItemCode); dataTable.TableName = PiModuleTable.TableName; }); return(dataTable); }
/// <summary> /// 批量移动数据 /// </summary> /// <param name="userInfo">用户</param> /// <param name="moduleIds">模块主键数组</param> /// <param name="parentId">父结点主键</param> /// <returns>数据表</returns> public int BatchMoveTo(UserInfo userInfo, string[] moduleIds, string parentId) { int returnValue = 0; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_BatchMoveTo, "模块主键数组:" + BusinessLogic.ArrayToList(moduleIds) + ",父结点主键:" + parentId); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); returnValue += moduleIds.Sum(t => moduleManager.SetProperty(t, PiModuleTable.FieldParentId, parentId)); }); return(returnValue); }
////////////////////////////////////////////////////////////////////////////////////////////////////// /// 用户模块关联关系相关 ////////////////////////////////////////////////////////////////////////////////////////////////////// #region public string[] GetModuleIdsByUserId(UserInfo userInfo, string userId) 获取用户有权限访问的模块 /// <summary> /// 获取用户有权限访问的模块 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userId">用户主键</param> /// <returns>模块主键数组</returns> public string[] GetModuleIdsByUserId(UserInfo userInfo, string userId) { string[] returnValue = null; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_GetModuleDTByUserId); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); returnValue = userInfo.IsAdministrator ? moduleManager.GetIds(PiModuleTable.FieldDeleteMark, "0", PiModuleTable.FieldEnabled, "1", PiModuleTable.FieldId) : moduleManager.GetIDsByUser(userId); }); return(returnValue); }
/// <summary> /// 获取模块列表 /// </summary> /// <param name="userInfo">用户</param> /// <returns>数据表</returns> public DataTable GetDT(UserInfo userInfo) { var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_GetDT); var dataTable = new DataTable(PiModuleTable.TableName); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); dataTable = moduleManager.GetDT(PiModuleTable.FieldDeleteMark, 0, PiModuleTable.FieldSortCode); dataTable.DefaultView.Sort = PiModuleTable.FieldSortCode; dataTable.TableName = PiModuleTable.TableName; }); return(dataTable); }
/// <summary> /// 批量打删除标志 /// </summary> /// <param name="userInfo">用户</param> /// <param name="ids">主键数组</param> /// <returns>影响行数</returns> public int SetDeleted(UserInfo userInfo, string[] ids) { int returnValue = 0; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_SetDeleted); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); returnValue = moduleManager.SetDeleted(ids); //TODO 清除所有用户对应的模块权限等 }); return(returnValue); }
/// <summary> /// 按主键数组获取列表 /// </summary> /// <param name="userInfo">用户</param> /// <param name="ids">角色主键</param> /// <returns>数据表</returns> public DataTable GetDTByIds(UserInfo userInfo, string[] ids) { var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.RoleService_GetDTByIds); var dataTable = new DataTable(PiRoleTable.TableName); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); dataTable = moduleManager.GetDT(PiModuleTable.FieldId, ids, PiModuleTable.FieldSortCode); dataTable = BusinessLogic.SetFilter(dataTable, PiModuleTable.FieldDeleteMark, "0"); dataTable.TableName = PiModuleTable.TableName; }); return(dataTable); }
/// <summary> /// 获得指定用户有权限访问的模块 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userId">用户主键</param> /// <returns>模块数据表</returns> public DataTable GetModuleDTByUserId(UserInfo userInfo, string userId) { var dataTable = new DataTable(PiModuleTable.TableName); var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_GetModuleDTByUserId); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); dataTable = userInfo.IsAdministrator ? moduleManager.GetDT(PiModuleTable.FieldDeleteMark, 0, PiModuleTable.FieldEnabled, 1, PiModuleTable.FieldSortCode) : moduleManager.GetDTByUser(userId); dataTable.TableName = PiModuleTable.TableName; }); return(dataTable); }
/// <summary> /// 保存排序顺序 /// </summary> /// <param name="userInfo">用户</param> /// <param name="ids">主键数组</param> /// <returns>影响行数</returns> public int SetSortCode(UserInfo userInfo, string[] ids) { int returnValue = 0; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_SetSortCode, "主键数组:" + BusinessLogic.ArrayToList(ids)); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { if (userInfo.IsAdministrator) { PiModuleManager moduleManager = new PiModuleManager(dbProvider, userInfo); returnValue = moduleManager.BatchSetSortCode(ids); } }); return(returnValue); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userInfo">用户</param> /// <returns>列表</returns> public List <PiModuleEntity> GetList(UserInfo userInfo) { var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_GetDT); List <PiModuleEntity> entityList = new List <PiModuleEntity>(); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var manager = new PiModuleManager(dbProvider, userInfo); List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(PiModuleTable.FieldDeleteMark, 0) }; entityList = manager.GetList <PiModuleEntity>(parameters, PiModuleTable.FieldSortCode); }); return(entityList); }
/// <summary> /// 更新模块菜单 /// </summary> /// <param name="userInfo">用户</param> /// <param name="moduleEntity">实体</param> /// <param name="statusCode">返回状态码</param> /// <param name="statusMessage">返回状消息</param> /// <returns>影响行数</returns> public int Update(UserInfo userInfo, PiModuleEntity moduleEntity, out string statusCode, out string statusMessage) { string returnCode = string.Empty; string returnMessage = string.Empty; int returnValue = 0; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ModuleService_Update); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); // 调用方法,并且返回运行结果 returnValue = moduleManager.Update(moduleEntity, out returnCode); // 获得状态消息 returnMessage = moduleManager.GetStateMessage(returnCode); }); statusCode = returnCode; statusMessage = returnMessage; 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); }
/// <summary> /// 通过条件得到模块 /// </summary> /// <param name="userInfo">用户</param> /// <param name="condition">条件表达式</param> /// <returns>数据库</returns> public DataTable GetDTByCondition(UserInfo userInfo, string condition) { var parameter = ParameterUtil.CreateWithOutMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName); var dataTable = new DataTable(PiModuleTable.TableName); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var moduleManager = new PiModuleManager(dbProvider, userInfo); if (string.IsNullOrEmpty(condition)) { condition = PiModuleTable.FieldDeleteMark + " = 0 "; } else { condition += " AND " + PiModuleTable.FieldDeleteMark + " = 0 "; } dataTable = moduleManager.GetDTByCondition(condition); dataTable.DefaultView.Sort = PiModuleTable.FieldSortCode; dataTable.TableName = PiModuleTable.TableName; }); return(dataTable); }