2025-03-28 09:49:56 +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.Coop.Merchant.Model;
using SuperMap.RealEstate.Coop.Merchant.Interface;
namespace SuperMap.RealEstate.Coop.Merchant
{
/// <summary>
/// 服务类 T_RTUSER 部分
/// </summary>
partial class Service:IService
{
#region RTUSER_Insert
/// <summary>
/// 插入数据
/// </summary>
/// <param name="rTUSER">RTUSER类</param>
/// <param name="loggingInfo">日志信息</param>
/// <returns>RTUSER类</returns>
public RTUSER RTUSER_Insert(RTUSER rTUSER, ServiceLoggingInfo loggingInfo)
{
using (SQLStringHelper<RTUSER> _SQLStringHelper = new SQLStringHelper<RTUSER>(typeof(TableSchema_RTUSER)))
{
System.Int32 _RTUSER_ID=0;
using (DbCommand _DbCommand = DataBaseHelper.CreateCommand(
_SQLStringHelper.GetInsertSQL(rTUSER, DataBaseHelper.IsOracleClientFactory)))
{
Dictionary<string, object> _Parameters = _SQLStringHelper.Parameters;
if (DataBaseHelper.IsOracleClientFactory)
{
if (rTUSER.RTUSER_ID == null)
_RTUSER_ID= DataBaseHelper.ExecuteScalar<System.Int32>("select "+ TableSchema_RTUSER.SequenceName +".nextval from dual");
else
_RTUSER_ID = rTUSER.RTUSER_ID.Value;
if (_Parameters.ContainsKey(TableSchema_RTUSER.RTUSER_ID.ToLower()))
_Parameters[TableSchema_RTUSER.RTUSER_ID.ToLower()]=_RTUSER_ID;
else
_Parameters.Add(TableSchema_RTUSER.RTUSER_ID.ToLower(),_RTUSER_ID);
}
DataBaseHelper.PrepareCommandParameters(_DbCommand, _Parameters);
_DbCommand.ExecuteNonQuery();
if (DataBaseHelper.IsAccessClientFactory)
{
if (rTUSER.RTUSER_ID == null)
_RTUSER_ID = DataBaseHelper.ExecuteScalar<System.Int32>("select @@IDENTITY");
else
_RTUSER_ID = rTUSER.RTUSER_ID.Value;
}
if (DataBaseHelper.IsSqlClientFactory)
{
if (rTUSER.RTUSER_ID == null)
_RTUSER_ID = DataBaseHelper.ExecuteScalar<System.Int32>("select IDENT_CURRENT('"+ TableSchema_RTUSER.TableName +"');");
else
_RTUSER_ID = rTUSER.RTUSER_ID.Value;
}
if (_DbCommand.Transaction == null)
_DbCommand.Connection.Close();
}
rTUSER.RTUSER_ID = _RTUSER_ID;
LoggingDataForInsert<RTUSER, TableSchema_RTUSER>(rTUSER, loggingInfo);
}
return rTUSER;
}
#endregion
#region RTUSER_Update
/// <summary>
/// 更新数据
/// </summary>
/// <param name="rTUSER">RTUSER类</param>
/// <param name="loggingInfo">日志信息</param>
/// <returns>RTUSER类</returns>
public bool RTUSER_Update(RTUSER rTUSER, ServiceLoggingInfo loggingInfo)
{
using (SQLStringHelper<RTUSER> _SQLStringHelper = new SQLStringHelper<RTUSER>(typeof(TableSchema_RTUSER)))
{
string _SQLStr = _SQLStringHelper.GetUpDateSQL(rTUSER, DataBaseHelper.IsOracleClientFactory);
if (string.IsNullOrEmpty(_SQLStr)) return true;
if (!LoggingDataForUpdate<RTUSER, TableSchema_RTUSER>(rTUSER, loggingInfo))
return true;
if (ConfigurationSetting.HttpRuntimeCache_Enabled == true)
ServiceCacheHelper<RTUSER>.Remove(rTUSER.RTUSER_ID.ToString());
Dictionary<string, object> _Parameters = _SQLStringHelper.Parameters;
return (DataBaseHelper.ExecuteNonQuery(_SQLStr, _Parameters) == 1);
}
}
#endregion
#region RTUSER_Delete
/// <summary>
/// 删除数据
/// </summary>
/// <param name="rTUSER_ID">主键字段</param>
/// <param name="loggingInfo">日志信息</param>
public void RTUSER_Delete(System.Int32 rTUSER_ID, ServiceLoggingInfo loggingInfo)
{
if (ConfigurationSetting.HttpRuntimeCache_Enabled == true)
ServiceCacheHelper<RTUSER>.Remove(rTUSER_ID.ToString());
using (SQLStringHelper<RTUSER> _SQLStringHelper =
new SQLStringHelper<RTUSER>(typeof(TableSchema_RTUSER)))
{
string _SQLStr = _SQLStringHelper.GetDeleteSQL(rTUSER_ID,DataBaseHelper.IsOracleClientFactory);
LoggingDataForDelete<RTUSER, TableSchema_RTUSER>(rTUSER_ID, loggingInfo);
DataBaseHelper.ExecuteNonQuery(_SQLStr, _SQLStringHelper.Parameters);
}
}
#endregion
#region RTUSER_Search
/// <summary>
/// 查询数据
/// </summary>
/// <param name="parameters">参数集合</param>
/// <param name="loggingInfo">日志信息</param>
/// <returns>RTUSER类</returns>
public RTUSER RTUSER_Search(List<SearchParameter> parameters, ServiceLoggingInfo loggingInfo)
{
RTUSER _RTUSER = null;
if (parameters.Count == 0)
return _RTUSER;
if ((ConfigurationSetting.HttpRuntimeCache_Enabled == true) && (parameters.Count == 1) &&
(parameters[0].Name.Equals(TableSchema_RTUSER.RTUSER_ID,System.StringComparison.CurrentCultureIgnoreCase)) &&
ServiceCacheHelper<RTUSER>.Read(parameters[0].Value.ToString(),out _RTUSER))
{
return _RTUSER;
}
using (SQLStringHelper<RTUSER> _SQLStringHelper = new SQLStringHelper<RTUSER>(typeof(TableSchema_RTUSER)))
{
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))
{
_RTUSER = new RTUSER();
_SQLStringHelper.DataRowToObject(ref _RTUSER, _DataSet.Tables[0].Rows[0]);
}
}
if ((ConfigurationSetting.HttpRuntimeCache_Enabled == true) && (_RTUSER != null))
{
ServiceCacheHelper<RTUSER>.Insert( _RTUSER.RTUSER_ID.ToString(),_RTUSER);
}
return _RTUSER;
}
#endregion
}
}