Beispiel #1
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">目标表</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo, string tableName)
        {
            var dt = new DataTable(tableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName);
                // 若是系统管理员,那就返回全部数据
                if (userInfo.IsAdministrator)
                {
                    dt = itemDetailsManager.GetDataTable(
                        new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldDeletionStateCode, 0)
                        , BaseItemDetailsEntity.FieldSortCode);
                }
                else
                {
                    // 按数据权限来过滤数据
                    BasePermissionScopeManager permissionScopeManager = new BasePermissionScopeManager(dbHelper, userInfo);
                    string[] ids = permissionScopeManager.GetResourceScopeIds(userInfo.SystemCode, userInfo.Id, tableName, "Resource.ManagePermission");
                    dt           = itemDetailsManager.GetDataTable(ids);
                }
                dt.TableName = tableName;
                // 管理时需要把所有的数据显示出来,所以无效的数据也需要显示的
                // , new KeyValuePair<string, object>(BaseItemDetailsEntity.FieldEnabled, 1)
            });
            return(dt);
        }
Beispiel #2
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo)
        {
            var dt = new DataTable(BaseItemsEntity.TableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                string tableName = userInfo.SystemCode + "Items";
                var manager      = new BaseItemsManager(dbHelper, userInfo, tableName);
                // 若是系统管理员,那就返回全部数据
                if (userInfo.IsAdministrator)
                {
                    dt = manager.GetDataTable();
                }
                else
                {
                    // 按数据权限来过滤数据
                    var permissionScopeManager = new BasePermissionScopeManager(dbHelper, userInfo);
                    string[] ids = permissionScopeManager.GetResourceScopeIds(userInfo.SystemCode, userInfo.Id, BaseItemsEntity.TableName, "Resource.ManagePermission");
                    dt           = manager.GetDataTable(ids);
                }
                dt.TableName = tableName;
            });
            return(dt);
        }
Beispiel #3
0
        /// <summary>
        /// 全部清除日志(业务)
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public void TruncateApplication(BaseUserInfo userInfo)
        {
            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                // var manager = new BaseLogManager(dbHelper, result);
                // manager.Truncate();
            });
        }
Beispiel #4
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>数据表</returns>
        public BaseItemDetailsEntity GetObject(BaseUserInfo userInfo, string tableName, string id)
        {
            BaseItemDetailsEntity entity = null;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName);
                entity = itemDetailsManager.GetObject(id);
            });
            return(entity);
        }
Beispiel #5
0
        /// <summary>
        /// 批量删除日志(业务)
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int BatchDeleteApplication(BaseUserInfo userInfo, string[] ids)
        {
            var result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                // var manager = new BaseLogManager(dbHelper, result);
                // result = manager.Delete(BaseLogEntity.FieldId, ids);
            });
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// 按编号获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="code">编号</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByCode(BaseUserInfo userInfo, string code)
        {
            var result = new DataTable(BaseItemDetailsEntity.TableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                result = this.GetDataTableByCode(dbHelper, userInfo, code);
            });

            return(result);
        }
Beispiel #7
0
        public List <BaseItemDetailsEntity> GetListByCode(BaseUserInfo userInfo, string code)
        {
            List <BaseItemDetailsEntity> entityList = new List <BaseItemDetailsEntity>();

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                entityList = this.GetListByCode(dbHelper, userInfo, code);
            });

            return(entityList);
        }
Beispiel #8
0
        /// <summary>
        /// 批量删除实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">目标表</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int BatchDelete(BaseUserInfo userInfo, string tableName, string[] ids)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseItemsManager(dbHelper, userInfo, tableName);
                result      = manager.Delete(ids);
            });
            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="result">数据表</param>
        /// <returns>影响行数</returns>
        public int Save(BaseUserInfo userInfo, DataTable dt)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, dt.TableName);
                result = itemDetailsManager.Save(dt);
            });

            return(result);
        }
Beispiel #10
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseItemsEntity GetObject(BaseUserInfo userInfo, string id)
        {
            BaseItemsEntity itemsEntity = null;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                string tableName = userInfo.SystemCode + "Items";
                var manager      = new BaseItemsManager(dbHelper, userInfo, tableName);
                itemsEntity      = manager.GetObject(id);
            });
            return(itemsEntity);
        }
Beispiel #11
0
        /// <summary>
        /// 按日期获取日志(业务)
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="beginDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableApplicationByDate(BaseUserInfo userInfo, string beginDate, string endDate)
        {
            var dt = new DataTable(BaseLogEntity.CurrentTableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                // var manager = new BaseLogManager(dbHelper, result);
                // dt = manager.GetDataTableByDate(string.Empty, string.Empty, beginDate, endDate);
                dt.TableName = BaseLogEntity.CurrentTableName;
            });
            return(dt);
        }
Beispiel #12
0
        /// <summary>
        /// 移动数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <param name="parentId">父主键</param>
        /// <returns>影响行数</returns>
        public int MoveTo(BaseUserInfo userInfo, string tableName, string id, string parentId)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName);
                result = itemDetailsManager.MoveTo(id, parentId);
            });

            return(result);
        }
Beispiel #13
0
        /// <summary>
        /// 批量保存数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="result">数据表</param>
        /// <returns>影响行数</returns>
        public int BatchSave(BaseUserInfo userInfo, DataTable dt)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                string tableName = userInfo.SystemCode + "Items";
                var manager      = new BaseItemsManager(dbHelper, userInfo, tableName);
                result           = manager.BatchSave(dt);
            });

            return(result);
        }
Beispiel #14
0
        /// <summary>
        /// 获取子列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">目标表</param>
        /// <param name="parentId">父级主键</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByParent(BaseUserInfo userInfo, string tableName, string parentId)
        {
            var dt = new DataTable(tableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName);
                dt           = itemDetailsManager.GetDataTableByParent(parentId);
                dt.TableName = tableName;
            });

            return(dt);
        }
Beispiel #15
0
        /// <summary>
        /// 按父节点获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="parentId">父级主键</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByParent(BaseUserInfo userInfo, string parentId)
        {
            var dt = new DataTable(BaseItemsEntity.TableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                string tableName = userInfo.SystemCode + "Items";
                var manager      = new BaseItemsManager(dbHelper, userInfo, tableName);
                dt           = manager.GetDataTableByParent(parentId);
                dt.TableName = tableName;
            });
            return(dt);
        }
Beispiel #16
0
        /// <summary>
        /// 批量移动数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">目标表</param>
        /// <param name="ids">编码主键数组</param>
        /// <param name="targetId">目标主键</param>
        /// <returns>影响行数</returns>
        public int BatchMoveTo(BaseUserInfo userInfo, string tableName, string[] ids, string targetId)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseItemsManager(dbHelper, userInfo, tableName);
                for (int i = 0; i < ids.Length; i++)
                {
                    result += manager.SetProperty(ids[i], new KeyValuePair <string, object>(BaseItemsEntity.FieldParentId, targetId));
                }
            });
            return(result);
        }
Beispiel #17
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">目标表</param>
        /// <returns>列表</returns>
        public List <BaseItemDetailsEntity> GetList(BaseUserInfo userInfo, string tableName)
        {
            List <BaseItemDetailsEntity> entityList = new List <BaseItemDetailsEntity>();

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName);
                entityList = itemDetailsManager.GetList <BaseItemDetailsEntity>(
                    new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldDeletionStateCode, 0)
                    , BaseItemDetailsEntity.FieldSortCode);
                // 管理时需要把所有的数据显示出来,所以无效的数据也需要显示的
                // , new KeyValuePair<string, object>(BaseItemDetailsEntity.FieldEnabled, 1)
            });
            return(entityList);
        }
Beispiel #18
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>数据表</returns>
        public BaseItemDetailsEntity GetObjectByCode(BaseUserInfo userInfo, string tableName, string code)
        {
            BaseItemDetailsEntity entity = new BaseItemDetailsEntity();

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName);
                var dt = itemDetailsManager.GetDataTable(new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldItemCode, code), BaseItemDetailsEntity.FieldSortCode);
                if ((dt != null) && (dt.Rows.Count > 0))
                {
                    entity = (BaseItemDetailsEntity)entity.GetFrom(dt.Rows[0]);
                }
            });
            return(entity);
        }
Beispiel #19
0
        /// <summary>
        /// 批量获取选项数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="codes">编号数组</param>
        /// <returns>数据权限合</returns>
        public DataSet GetDataSetByCodes(BaseUserInfo userInfo, string[] codes)
        {
            DataSet dataSet = new DataSet();

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                for (int i = 0; i < codes.Length; i++)
                {
                    var dt       = this.GetDataTableByCode(dbHelper, userInfo, codes[i]);
                    dt.TableName = codes[i];
                    dataSet.Tables.Add(dt);
                }
            });

            return(dataSet);
        }
Beispiel #20
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="result">数据表</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>数据表</returns>
        public int Update(BaseUserInfo userInfo, string tableName, BaseItemDetailsEntity entity, out string statusCode, out string statusMessage)
        {
            int result = 0;

            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            var    parameter     = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName);
                // 编辑数据
                result        = itemDetailsManager.Update(entity, out returnCode);
                returnMessage = itemDetailsManager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }
Beispiel #21
0
        /// <summary>
        /// 创建数据表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">表名</param>
        /// <param name="statusCode">状态返回码</param>
        /// <param name="statusMessage">状态返回信息</param>
        public void CreateTable(BaseUserInfo userInfo, string tableName, out string statusCode, out string statusMessage)
        {
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                if (!DbLogic.Exists(dbHelper, tableName))
                {
                    var manager = new BaseItemsManager(dbHelper, userInfo);
                    // 创建表结构
                    manager.CreateTable(tableName, out returnCode);
                    returnMessage = manager.GetStateMessage(returnCode);
                }
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
        }
Beispiel #22
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>数据表</returns>
        public string Add(BaseUserInfo userInfo, BaseItemsEntity entity, out string statusCode, out string statusMessage)
        {
            string result = string.Empty;

            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            var    parameter     = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, (dbHelper) =>
            {
                string tableName = userInfo.SystemCode + "Items";
                var manager      = new BaseItemsManager(dbHelper, userInfo, tableName);
                // 调用方法,并且返回运行结果
                result        = manager.Add(entity, out returnCode);
                returnMessage = manager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }