Beispiel #1
0
        /// <summary>
        /// 按表名获取字段列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">表名</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByTable(BaseUserInfo userInfo, string tableCode)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            DataTable dataTable = new DataTable(BaseTableColumnsEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    // 获得列表
                    List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                    parameters.Add(new KeyValuePair <string, object>(BaseTableColumnsEntity.FieldTableCode, tableCode));
                    parameters.Add(new KeyValuePair <string, object>(BaseTableColumnsEntity.FieldUseConstraint, 1));
                    parameters.Add(new KeyValuePair <string, object>(BaseTableColumnsEntity.FieldDeletionStateCode, 0));

                    BaseTableColumnsManager manager = new BaseTableColumnsManager(dbHelper, userInfo);
                    dataTable           = manager.GetDataTable(parameters, BaseTableColumnsEntity.FieldSortCode);
                    dataTable.TableName = BaseTableColumnsEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.TableColumnsService_GetDataTableByTable, 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);
        }
Beispiel #2
0
        /// <summary>
        /// 按表名获取字段列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="tableName">表名</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByTable(BaseUserInfo userInfo, string tableCode)
        {
            var dt = new DataTable(BaseTableColumnsEntity.TableName);

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

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                // 获得列表
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BaseTableColumnsEntity.FieldTableCode, tableCode));
                parameters.Add(new KeyValuePair <string, object>(BaseTableColumnsEntity.FieldUseConstraint, 1));
                parameters.Add(new KeyValuePair <string, object>(BaseTableColumnsEntity.FieldDeletionStateCode, 0));

                var manager  = new BaseTableColumnsManager(dbHelper, userInfo);
                dt           = manager.GetDataTable(parameters, BaseTableColumnsEntity.FieldSortCode);
                dt.TableName = BaseTableColumnsEntity.TableName;
            });
            return(dt);
        }