/// <summary> /// 删除实体 /// </summary> /// <param name="userInfo">用户</param> /// <param name="tableName">目标表</param> /// <param name="id">主键</param> /// <returns>影响的行数</returns> public int Delete(UserInfo userInfo, string tableName, string id) { int returnValue = 0; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ItemsService_Delete); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { returnValue = new CiItemsManager(dbProvider, userInfo, tableName).Delete(id); }); return(returnValue); }
/// <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, "SetDeleted"); ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider => { var manager = new CiItemsManager(dbProvider, userInfo); returnValue = manager.SetDeleted(ids); }); return(returnValue); }
/// <summary> /// 获取实体 /// </summary> /// <param name="userInfo">用户</param> /// <param name="id">主键</param> /// <returns>实体</returns> public CiItemsEntity GetEntity(UserInfo userInfo, string id) { CiItemsEntity itemsEntity = null; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ItemsService_GetEntity); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var itemsManager = new CiItemsManager(dbProvider, userInfo); itemsEntity = itemsManager.GetEntity(id); }); return(itemsEntity); }
/// <summary> /// 按父节点获取列表 /// </summary> /// <param name="userInfo">用户</param> /// <param name="parentId">父级主键</param> /// <returns>数据表</returns> public DataTable GetDTByParent(UserInfo userInfo, string parentId) { var dataTable = new DataTable(CiItemsTable.TableName); var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ItemsService_GetDTByParent); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var itemsManager = new CiItemsManager(dbProvider, userInfo); dataTable = itemsManager.GetDTByParent(parentId); dataTable.TableName = CiItemsTable.TableName; }); return(dataTable); }
/// <summary> /// 创建数据表 /// </summary> /// <param name="userInfo">用户</param> /// <param name="tableName">表名</param> /// <param name="statusCode">状态返回码</param> /// <param name="statusMessage">状态返回信息</param> public void CreateTable(UserInfo userInfo, string tableName, out string statusCode, out string statusMessage) { string returnCode = string.Empty; string returnMessage = string.Empty; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ItemsService_CreateTable); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var itemsManager = new CiItemsManager(dbProvider, userInfo); itemsManager.CreateTable(tableName, out returnCode); returnMessage = itemsManager.GetStateMessage(returnCode); }); statusCode = returnCode; statusMessage = returnMessage; }
/// <summary> /// 更新实体 /// </summary> /// <param name="userInfo">用户</param> /// <param name="itemsEntity">实体</param> /// <param name="statusCode">返回状态码</param> /// <param name="statusMessage">返回状态信息</param> /// <returns>数据表</returns> public int Update(UserInfo userInfo, CiItemsEntity itemsEntity, 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.ItemsService_Update); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var itemsManager = new CiItemsManager(dbProvider, userInfo); returnValue = itemsManager.Update(itemsEntity, out returnCode); returnMessage = itemsManager.GetStateMessage(returnCode); }); statusCode = returnCode; statusMessage = returnMessage; return(returnValue); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userInfo">用户</param> /// <returns>数据表</returns> public DataTable GetDT(UserInfo userInfo) { var dataTable = new DataTable(CiItemsTable.TableName); var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.ItemsService_GetDT); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var itemsManager = new CiItemsManager(dbProvider, userInfo); // 若是系统管理员,那就返回全部数据 if (userInfo.IsAdministrator) { dataTable = itemsManager.GetDT(CiItemsTable.FieldDeleteMark, 0, CiItemsTable.FieldSortCode); } else { // 按数据权限来过滤数据 var permissionScopeManager = new PiPermissionScopeManager(dbProvider, userInfo); string[] ids = permissionScopeManager.GetResourceScopeIds(userInfo.Id, CiItemsTable.TableName, "Resource.ManagePermission"); dataTable = itemsManager.GetDT(ids); } dataTable.TableName = CiItemsTable.TableName; }); return(dataTable); }