/// <summary> /// 获取实体 /// </summary> /// <param name="userInfo">用户</param> /// <param name="id">主键</param> /// <returns>数据表</returns> public BaseItemDetailsEntity GetEntityByCode(BaseUserInfo userInfo, string tableName, string code) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif BaseItemDetailsEntity itemDetailsEntity = new BaseItemDetailsEntity(); using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName); DataTable datatable = itemDetailsManager.GetDataTable(new KeyValuePair<string, object>(BaseItemDetailsEntity.FieldItemCode, code), BaseItemDetailsEntity.FieldSortCode); if((datatable != null)&&(datatable.Rows.Count>0)) { itemDetailsEntity = itemDetailsEntity.GetFrom(datatable.Rows[0]); } BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.ItemDetailsService_GetEntity, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return itemDetailsEntity; }
/// <summary> /// 获取列表 /// </summary> /// <param name="userInfo">用户</param> /// <param name="tableName">目标表</param> /// <returns>数据表</returns> public DataTable GetDataTable(BaseUserInfo userInfo, string tableName) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif DataTable dataTable = new DataTable(tableName); using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseItemDetailsManager itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, tableName); // 检查有其他目标数据库表存储了数据 // BaseItemsManager itemsManager = new BaseItemsManager(dbHelper, userInfo); // BaseItemsEntity itemsEntity = new BaseItemsEntity(itemsManager.Get(BaseItemDetailsEntity.FieldItemCode, itemCode)); // if (!String.IsNullOrEmpty(itemsEntity.TargetTable)) // { // itemDetailsManager = new BaseItemDetailsManager(dbHelper, userInfo, itemsEntity.TargetTable); // } // dataTable = itemDetailsManager.GetDataTable(BaseItemDetailsEntity.FieldDeletionStateCode, 0, BaseItemDetailsEntity.FieldEnabled, 1, BaseItemDetailsEntity.FieldSortCode); // 前台管理时,应该把有效无效的都显示出来,主要是为了管理设置时无效的也可以显示出来,下拉框时需要自己控制一下 dataTable = itemDetailsManager.GetDataTable(new KeyValuePair<string, object>(BaseItemDetailsEntity.FieldDeletionStateCode, 0), BaseItemDetailsEntity.FieldSortCode); dataTable.TableName = tableName; // 添加日志 BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.ItemDetailsService_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; }