Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <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;
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        /// <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);
        }