2025-03-27 15:05:14 +08:00

152 lines
7.0 KiB
C#

using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using SuperMap.RealEstate.Configuration;
using SuperMap.RealEstate.ServiceModel;
using SuperMap.RealEstate.ServiceModel.Logging;
using SuperMap.RealEstate.Personnel.Storage.Model;
using SuperMap.RealEstate.Personnel.Storage.Interface;
namespace SuperMap.RealEstate.Personnel.Storage
{
/// <summary>
/// 服务类 T_HEALTH 部分
/// </summary>
partial class Service:IService
{
#region HEALTH_Insert
/// <summary>
/// 插入数据
/// </summary>
/// <param name="hEALTH">HEALTH类</param>
/// <param name="loggingInfo">日志信息</param>
/// <returns>HEALTH类</returns>
public HEALTH HEALTH_Insert(HEALTH hEALTH, ServiceLoggingInfo loggingInfo)
{
using (SQLStringHelper<HEALTH> _SQLStringHelper = new SQLStringHelper<HEALTH>(typeof(TableSchema_HEALTH)))
{
System.Int32 _HEALTH_ID=0;
using (DbCommand _DbCommand = DataBaseHelper.CreateCommand(
_SQLStringHelper.GetInsertSQL(hEALTH, DataBaseHelper.IsOracleClientFactory)))
{
Dictionary<string, object> _Parameters = _SQLStringHelper.Parameters;
if (DataBaseHelper.IsOracleClientFactory)
{
if (hEALTH.HEALTH_ID == null)
_HEALTH_ID= DataBaseHelper.ExecuteScalar<System.Int32>("select "+ TableSchema_HEALTH.SequenceName +".nextval from dual");
else
_HEALTH_ID = hEALTH.HEALTH_ID.Value;
if (_Parameters.ContainsKey(TableSchema_HEALTH.HEALTH_ID.ToLower()))
_Parameters[TableSchema_HEALTH.HEALTH_ID.ToLower()]=_HEALTH_ID;
else
_Parameters.Add(TableSchema_HEALTH.HEALTH_ID.ToLower(),_HEALTH_ID);
}
DataBaseHelper.PrepareCommandParameters(_DbCommand, _Parameters);
_DbCommand.ExecuteNonQuery();
if (DataBaseHelper.IsAccessClientFactory)
{
if (hEALTH.HEALTH_ID == null)
_HEALTH_ID = DataBaseHelper.ExecuteScalar<System.Int32>("select @@IDENTITY");
else
_HEALTH_ID = hEALTH.HEALTH_ID.Value;
}
if (DataBaseHelper.IsSqlClientFactory)
{
if (hEALTH.HEALTH_ID == null)
_HEALTH_ID = DataBaseHelper.ExecuteScalar<System.Int32>("select IDENT_CURRENT('"+ TableSchema_HEALTH.TableName +"');");
else
_HEALTH_ID = hEALTH.HEALTH_ID.Value;
}
if (_DbCommand.Transaction == null)
_DbCommand.Connection.Close();
}
hEALTH.HEALTH_ID = _HEALTH_ID;
LoggingDataForInsert<HEALTH, TableSchema_HEALTH>(hEALTH, loggingInfo);
}
return hEALTH;
}
#endregion
#region HEALTH_Update
/// <summary>
/// 更新数据
/// </summary>
/// <param name="hEALTH">HEALTH类</param>
/// <param name="loggingInfo">日志信息</param>
/// <returns>HEALTH类</returns>
public bool HEALTH_Update(HEALTH hEALTH, ServiceLoggingInfo loggingInfo)
{
using (SQLStringHelper<HEALTH> _SQLStringHelper = new SQLStringHelper<HEALTH>(typeof(TableSchema_HEALTH)))
{
string _SQLStr = _SQLStringHelper.GetUpDateSQL(hEALTH, DataBaseHelper.IsOracleClientFactory);
if (string.IsNullOrEmpty(_SQLStr)) return true;
if (!LoggingDataForUpdate<HEALTH, TableSchema_HEALTH>(hEALTH, loggingInfo))
return true;
if (ConfigurationSetting.HttpRuntimeCache_Enabled == true)
ServiceCacheHelper<HEALTH>.Remove(hEALTH.HEALTH_ID.ToString());
Dictionary<string, object> _Parameters = _SQLStringHelper.Parameters;
return (DataBaseHelper.ExecuteNonQuery(_SQLStr, _Parameters) == 1);
}
}
#endregion
#region HEALTH_Delete
/// <summary>
/// 删除数据
/// </summary>
/// <param name="hEALTH_ID">主键字段</param>
/// <param name="loggingInfo">日志信息</param>
public void HEALTH_Delete(System.Int32 hEALTH_ID, ServiceLoggingInfo loggingInfo)
{
if (ConfigurationSetting.HttpRuntimeCache_Enabled == true)
ServiceCacheHelper<HEALTH>.Remove(hEALTH_ID.ToString());
using (SQLStringHelper<HEALTH> _SQLStringHelper =
new SQLStringHelper<HEALTH>(typeof(TableSchema_HEALTH)))
{
string _SQLStr = _SQLStringHelper.GetDeleteSQL(hEALTH_ID,DataBaseHelper.IsOracleClientFactory);
LoggingDataForDelete<HEALTH, TableSchema_HEALTH>(hEALTH_ID, loggingInfo);
DataBaseHelper.ExecuteNonQuery(_SQLStr, _SQLStringHelper.Parameters);
}
}
#endregion
#region HEALTH_Search
/// <summary>
/// 查询数据
/// </summary>
/// <param name="parameters">参数集合</param>
/// <param name="loggingInfo">日志信息</param>
/// <returns>HEALTH类</returns>
public HEALTH HEALTH_Search(List<SearchParameter> parameters, ServiceLoggingInfo loggingInfo)
{
HEALTH _HEALTH = null;
if (parameters.Count == 0)
return _HEALTH;
if ((ConfigurationSetting.HttpRuntimeCache_Enabled == true) && (parameters.Count == 1) &&
(parameters[0].Name.Equals(TableSchema_HEALTH.HEALTH_ID,System.StringComparison.CurrentCultureIgnoreCase)) &&
ServiceCacheHelper<HEALTH>.Read(parameters[0].Value.ToString(),out _HEALTH))
{
return _HEALTH;
}
using (SQLStringHelper<HEALTH> _SQLStringHelper = new SQLStringHelper<HEALTH>(typeof(TableSchema_HEALTH)))
{
string _SQLStr = _SQLStringHelper.GetSelectSQL(parameters,
DataBaseHelper.IsOracleClientFactory);
DataSet _DataSet = DataBaseHelper.ExecuteDataSet(_SQLStr, _SQLStringHelper.Parameters);
if ((_DataSet.Tables.Count>0) && (_DataSet.Tables[0].Rows.Count > 0))
{
_HEALTH = new HEALTH();
_SQLStringHelper.DataRowToObject(ref _HEALTH, _DataSet.Tables[0].Rows[0]);
}
}
if ((ConfigurationSetting.HttpRuntimeCache_Enabled == true) && (_HEALTH != null))
{
ServiceCacheHelper<HEALTH>.Insert( _HEALTH.HEALTH_ID.ToString(),_HEALTH);
}
return _HEALTH;
}
#endregion
}
}