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