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

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