Esempio n. 1
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            DataTable dataTable = new DataTable(BaseItemsEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    string tableName = BaseItemsEntity.TableName;
                    if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
                    {
                        tableName = BaseSystemInfo.SystemCode + "Items";
                    }
                    BaseItemsManager itemsManager = new BaseItemsManager(dbHelper, userInfo, tableName);
                    // 若是系统管理员,那就返回全部数据
                    if (userInfo.IsAdministrator)
                    {
                        dataTable = itemsManager.GetDataTable();
                    }
                    else
                    {
                        // 按数据权限来过滤数据
                        BasePermissionScopeManager permissionScopeManager = new BasePermissionScopeManager(dbHelper, userInfo);
                        string[] ids = permissionScopeManager.GetResourceScopeIds(userInfo.Id, BaseItemsEntity.TableName, "Resource.ManagePermission");
                        dataTable = itemsManager.GetDataTable(ids);
                    }
                    dataTable.TableName = tableName;
                    // 添加日志
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.ItemsService_GetDataTable, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return(dataTable);
        }
Esempio n. 2
0
        public DataTable GetDataTableByCode(IDbHelper dbHelper, BaseUserInfo userInfo, string code)
        {
            // 加强安全验证防止未授权匿名调用
#if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
#endif

            DataTable dataTable = new DataTable(BaseItemDetailsEntity.TableName);
            BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo);
            // 检查有其他目标数据库表存储了数据
            BaseItemsManager itemsManager = new BaseItemsManager(dbHelper, userInfo);
            BaseItemsEntity  itemsEntity  = new BaseItemsEntity(itemsManager.GetDataTable(new KeyValuePair <string, object>(BaseItemsEntity.FieldCode, code)));
            if (!String.IsNullOrEmpty(itemsEntity.TargetTable))
            {
                itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, itemsEntity.TargetTable);
            }
            // 这里只要有效的,没被删除的
            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
            parameters.Add(new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair <string, object>(BaseItemDetailsEntity.FieldDeletionStateCode, 0));

            dataTable           = itemDetailsManager.GetDataTable(parameters, BaseItemDetailsEntity.FieldSortCode);
            dataTable.TableName = itemsEntity.TargetTable;
            return(dataTable);
        }