2023-05-23 16:13:17 +08:00
/// <summary>
///Data Implemention Object
///BASIC CRUD CLASS FOR TABLE t_Log
///By wm
2023-09-04 22:41:19 +08:00
///on 08/04/2023
2023-05-23 16:13:17 +08:00
/// </summary>
using System ;
using DeiNiu.Utils ;
using System.Data.SqlClient ;
using DeiNiu.Data.BaseObject ;
using System.Data ;
namespace DeiNiu.wms.Data.Model
{
#region Log_base_Imp
[Serializable] class Log_base_Imp : BaseModel_Imp {
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
protected override void datarowToModel ( DataRow dr , BaseModel obj )
{
if ( dr ! = null )
{
Log_base tmpObj = ( Log_base ) obj ;
if ( dr . Table . Columns . Contains ( "id" ) & & ! ( dr [ "id" ] is DBNull ) )
{
tmpObj . ID = Convert . ToInt32 ( dr [ "id" ] . ToString ( ) ) ; ;
}
if ( dr . Table . Columns . Contains ( "log_empid" ) & & ! ( dr [ "log_empid" ] is DBNull ) )
{
tmpObj . _log_empid = Convert . ToInt32 ( dr [ "log_empid" ] . ToString ( ) ) ; ;
2023-09-04 22:41:19 +08:00
tmpObj . _Olog_empid = Convert . ToInt32 ( dr [ "log_empid" ] . ToString ( ) ) ; ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "log_account" ) & & ! ( dr [ "log_account" ] is DBNull ) )
{
tmpObj . _log_account = dr [ "log_account" ] . ToString ( ) ;
2023-09-04 22:41:19 +08:00
tmpObj . _Olog_account = dr [ "log_account" ] . ToString ( ) ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "log_sessionid" ) & & ! ( dr [ "log_sessionid" ] is DBNull ) )
{
tmpObj . _log_sessionid = dr [ "log_sessionid" ] . ToString ( ) ;
2023-09-04 22:41:19 +08:00
tmpObj . _Olog_sessionid = dr [ "log_sessionid" ] . ToString ( ) ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "log_page" ) & & ! ( dr [ "log_page" ] is DBNull ) )
{
tmpObj . _log_page = dr [ "log_page" ] . ToString ( ) ;
2023-09-04 22:41:19 +08:00
tmpObj . _Olog_page = dr [ "log_page" ] . ToString ( ) ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "log_method" ) & & ! ( dr [ "log_method" ] is DBNull ) )
{
tmpObj . _log_method = dr [ "log_method" ] . ToString ( ) ;
2023-09-04 22:41:19 +08:00
tmpObj . _Olog_method = dr [ "log_method" ] . ToString ( ) ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "log_sql" ) & & ! ( dr [ "log_sql" ] is DBNull ) )
{
tmpObj . _log_sql = dr [ "log_sql" ] . ToString ( ) ;
2023-09-04 22:41:19 +08:00
tmpObj . _Olog_sql = dr [ "log_sql" ] . ToString ( ) ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "log_parameters" ) & & ! ( dr [ "log_parameters" ] is DBNull ) )
{
tmpObj . _log_parameters = dr [ "log_parameters" ] . ToString ( ) ;
2023-09-04 22:41:19 +08:00
tmpObj . _Olog_parameters = dr [ "log_parameters" ] . ToString ( ) ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "log_exception" ) & & ! ( dr [ "log_exception" ] is DBNull ) )
{
tmpObj . _log_exception = dr [ "log_exception" ] . ToString ( ) ;
2023-09-04 22:41:19 +08:00
tmpObj . _Olog_exception = dr [ "log_exception" ] . ToString ( ) ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "log_clientip" ) & & ! ( dr [ "log_clientip" ] is DBNull ) )
{
tmpObj . _log_clientip = dr [ "log_clientip" ] . ToString ( ) ;
2023-09-04 22:41:19 +08:00
tmpObj . _Olog_clientip = dr [ "log_clientip" ] . ToString ( ) ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "log_browseinfo" ) & & ! ( dr [ "log_browseinfo" ] is DBNull ) )
{
tmpObj . _log_browseinfo = dr [ "log_browseinfo" ] . ToString ( ) ;
2023-09-04 22:41:19 +08:00
tmpObj . _Olog_browseinfo = dr [ "log_browseinfo" ] . ToString ( ) ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "dr" ) & & ! ( dr [ "dr" ] is DBNull ) )
{
tmpObj . _dr = Convert . ToBoolean ( dr [ "dr" ] . ToString ( ) ) ; ;
}
if ( dr . Table . Columns . Contains ( "operater" ) & & ! ( dr [ "operater" ] is DBNull ) )
{
tmpObj . _operater = Convert . ToInt32 ( dr [ "operater" ] . ToString ( ) ) ; ;
2023-09-04 22:41:19 +08:00
tmpObj . _Ooperater = Convert . ToInt32 ( dr [ "operater" ] . ToString ( ) ) ; ;
2023-05-23 16:13:17 +08:00
}
if ( dr . Table . Columns . Contains ( "create_time" ) & & ! ( dr [ "create_time" ] is DBNull ) )
{
tmpObj . _create_time = dr [ "create_time" ] . ToString ( ) ;
}
if ( dr . Table . Columns . Contains ( "lastmodified" ) & & ! ( dr [ "lastmodified" ] is DBNull ) )
{
tmpObj . _lastmodified = dr [ "lastmodified" ] . ToString ( ) ;
}
}
}
protected override void CmdPrepare ( SqlCommand oraCmd ) {
Log_base tmpObj = ( Log_base ) modelObj ;
switch ( this . _op_flag ) {
case ( int ) op_flag . add :
2023-09-04 22:41:19 +08:00
_strSql = "INSERT INTO dbo.T_LOG({0}) VALUES({1} )" ;
_strSql = String . Format ( _strSql , getFields ( tmpObj ) , getValues ( tmpObj ) ) ;
2023-05-23 16:13:17 +08:00
break ;
case ( int ) op_flag . update :
2023-09-04 22:41:19 +08:00
// _strSql = "UPDATE dbo.T_LOG SET LOG_EMPID = @LOG_EMPID,LOG_ACCOUNT = @LOG_ACCOUNT,LOG_SESSIONID = @LOG_SESSIONID,LOG_PAGE = @LOG_PAGE,LOG_METHOD = @LOG_METHOD,LOG_SQL = @LOG_SQL,LOG_PARAMETERS = @LOG_PARAMETERS,LOG_EXCEPTION = @LOG_EXCEPTION,LOG_CLIENTIP = @LOG_CLIENTIP,LOG_BROWSEINFO = @LOG_BROWSEINFO,OPERATER = @OPERATER,LASTMODIFIED = getdate() WHERE ID = @ID";
_strSql = "UPDATE dbo.T_LOG {0} WHERE ID = @ID" ;
_strSql = String . Format ( _strSql , getChangedFields ( tmpObj ) ) ;
2023-05-23 16:13:17 +08:00
break ;
case ( int ) op_flag . delete :
// _strSql = "UPDATE dbo.T_LOG SET DR =0 WHERE ID = @ID";
_strSql = "delete from dbo.T_LOG WHERE ID = @ID" ;
break ;
case ( int ) op_flag . getObj :
_strSql = "SELECT * FROM dbo.T_LOG WHERE ID = @ID" ;
break ;
case ( int ) op_flag . queryAll :
_strSql = "SELECT * FROM dbo.T_LOG WHERE DR =1 " ;
2023-09-04 22:41:19 +08:00
// if (this.rownumEnd >0 )
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
// _strSql = "SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY ID DESC) as sortNo FROM dbo.T_LOG WHERE DR =1 )AS SORTEDTB WHERE DR =1 AND sortNo BETWEEN @START AND @END";
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
// _strSql += ";SELECT COUNT(*) FROM T_LOG WHERE DR =1";
2023-05-23 16:13:17 +08:00
break ;
case ( int ) op_flag . queryActived :
_strSql = "SELECT * FROM dbo.T_LOG WHERE DR =1" ;
_strSql + = ";SELECT COUNT(*) FROM T_LOG WHERE DR =1" ;
break ;
case ( int ) op_flag . getPk :
_strSql = "SELECT MAX(ID) FROM dbo.T_LOG WHERE DR =1" ;
break ;
case ( int ) op_flag . getCount :
_strSql = "SELECT COUNT(*) FROM T_LOG WHERE DR =1" ;
break ;
}
oraCmd . CommandText = _strSql ;
fillParameters ( oraCmd , tmpObj ) ;
}
2023-09-04 22:41:19 +08:00
private string getFields ( Log_base tmpObj )
{
String colums = "" ;
colums + = tmpObj . _log_empid = = null ? "" : "LOG_EMPID" + "," ;
colums + = tmpObj . _log_account = = null ? "" : "LOG_ACCOUNT" + "," ;
colums + = tmpObj . _log_sessionid = = null ? "" : "LOG_SESSIONID" + "," ;
colums + = tmpObj . _log_page = = null ? "" : "LOG_PAGE" + "," ;
colums + = tmpObj . _log_method = = null ? "" : "LOG_METHOD" + "," ;
colums + = tmpObj . _log_sql = = null ? "" : "LOG_SQL" + "," ;
colums + = tmpObj . _log_parameters = = null ? "" : "LOG_PARAMETERS" + "," ;
colums + = tmpObj . _log_exception = = null ? "" : "LOG_EXCEPTION" + "," ;
colums + = tmpObj . _log_clientip = = null ? "" : "LOG_CLIENTIP" + "," ;
colums + = tmpObj . _log_browseinfo = = null ? "" : "LOG_BROWSEINFO" + "," ;
colums + = tmpObj . _operater = = null ? "" : "OPERATER" + "," ;
return colums . Substring ( 0 , colums . Length - 1 ) ;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
private string getValues ( Log_base tmpObj )
{
String values = "" ;
values + = tmpObj . _log_empid = = null ? "" : "@LOG_EMPID" + "," ;
values + = tmpObj . _log_account = = null ? "" : "@LOG_ACCOUNT" + "," ;
values + = tmpObj . _log_sessionid = = null ? "" : "@LOG_SESSIONID" + "," ;
values + = tmpObj . _log_page = = null ? "" : "@LOG_PAGE" + "," ;
values + = tmpObj . _log_method = = null ? "" : "@LOG_METHOD" + "," ;
values + = tmpObj . _log_sql = = null ? "" : "@LOG_SQL" + "," ;
values + = tmpObj . _log_parameters = = null ? "" : "@LOG_PARAMETERS" + "," ;
values + = tmpObj . _log_exception = = null ? "" : "@LOG_EXCEPTION" + "," ;
values + = tmpObj . _log_clientip = = null ? "" : "@LOG_CLIENTIP" + "," ;
values + = tmpObj . _log_browseinfo = = null ? "" : "@LOG_BROWSEINFO" + "," ;
values + = tmpObj . _operater = = null ? "" : "@OPERATER" + "," ;
return values . Substring ( 0 , values . Length - 1 ) ;
}
private string getChangedFields ( Log_base tmpObj )
{
string updateFields = " set " ;
if ( tmpObj . _log_empid ! = null & & tmpObj . _log_empid ! = tmpObj . _Olog_empid )
{
updateFields + = "LOG_EMPID = @LOG_EMPID," ;
}
if ( tmpObj . _log_account ! = null & & tmpObj . _log_account ! = tmpObj . _Olog_account )
{
updateFields + = "LOG_ACCOUNT = @LOG_ACCOUNT," ;
}
if ( tmpObj . _log_sessionid ! = null & & tmpObj . _log_sessionid ! = tmpObj . _Olog_sessionid )
{
updateFields + = "LOG_SESSIONID = @LOG_SESSIONID," ;
}
if ( tmpObj . _log_page ! = null & & tmpObj . _log_page ! = tmpObj . _Olog_page )
{
updateFields + = "LOG_PAGE = @LOG_PAGE," ;
}
if ( tmpObj . _log_method ! = null & & tmpObj . _log_method ! = tmpObj . _Olog_method )
{
updateFields + = "LOG_METHOD = @LOG_METHOD," ;
}
if ( tmpObj . _log_sql ! = null & & tmpObj . _log_sql ! = tmpObj . _Olog_sql )
{
updateFields + = "LOG_SQL = @LOG_SQL," ;
}
if ( tmpObj . _log_parameters ! = null & & tmpObj . _log_parameters ! = tmpObj . _Olog_parameters )
{
updateFields + = "LOG_PARAMETERS = @LOG_PARAMETERS," ;
}
if ( tmpObj . _log_exception ! = null & & tmpObj . _log_exception ! = tmpObj . _Olog_exception )
{
updateFields + = "LOG_EXCEPTION = @LOG_EXCEPTION," ;
}
if ( tmpObj . _log_clientip ! = null & & tmpObj . _log_clientip ! = tmpObj . _Olog_clientip )
{
updateFields + = "LOG_CLIENTIP = @LOG_CLIENTIP," ;
}
if ( tmpObj . _log_browseinfo ! = null & & tmpObj . _log_browseinfo ! = tmpObj . _Olog_browseinfo )
{
updateFields + = "LOG_BROWSEINFO = @LOG_BROWSEINFO," ;
}
if ( tmpObj . _operater ! = null & & tmpObj . _operater ! = tmpObj . _Ooperater )
{
updateFields + = "OPERATER = @OPERATER," ;
}
updateFields + = "LASTMODIFIED = getdate()" ;
return updateFields ;
}
2023-05-23 16:13:17 +08:00
private void fillParameters ( SqlCommand oraCmd , Log_base tmpObj ) {
switch ( this . _op_flag ) {
case ( int ) op_flag . getObj :
case ( int ) op_flag . delete :
oraCmd . Parameters . AddWithValue ( "@ID" , tmpObj . ID ) ;
return ;
case ( int ) op_flag . getPk :
oraCmd . Parameters . AddWithValue ( "@ID" , tmpObj . ID ) ;
return ;
case ( int ) op_flag . queryAll :
if ( this . rownumEnd > 0 )
{
oraCmd . Parameters . AddWithValue ( "@START" , this . _rownumStart ) ;
oraCmd . Parameters . AddWithValue ( "@END" , this . _rownumEnd ) ;
}
return ;
case 0 :
case ( int ) op_flag . queryActived :
return ;
case ( int ) op_flag . update :
2023-09-04 22:41:19 +08:00
oraCmd . Parameters . AddWithValue ( "@ID" , tmpObj . ID ) ;
oraCmd . Parameters . AddWithValue ( "@LOG_EMPID" , VerifyDbnull ( tmpObj . _log_empid ) ) ;
oraCmd . Parameters . AddWithValue ( "@LOG_ACCOUNT" , VerifyDbnull ( tmpObj . _log_account ) ) ;
oraCmd . Parameters . AddWithValue ( "@LOG_SESSIONID" , VerifyDbnull ( tmpObj . _log_sessionid ) ) ;
oraCmd . Parameters . AddWithValue ( "@LOG_PAGE" , VerifyDbnull ( tmpObj . _log_page ) ) ;
oraCmd . Parameters . AddWithValue ( "@LOG_METHOD" , VerifyDbnull ( tmpObj . _log_method ) ) ;
oraCmd . Parameters . AddWithValue ( "@LOG_SQL" , VerifyDbnull ( tmpObj . _log_sql ) ) ;
oraCmd . Parameters . AddWithValue ( "@LOG_PARAMETERS" , VerifyDbnull ( tmpObj . _log_parameters ) ) ;
oraCmd . Parameters . AddWithValue ( "@LOG_EXCEPTION" , VerifyDbnull ( tmpObj . _log_exception ) ) ;
oraCmd . Parameters . AddWithValue ( "@LOG_CLIENTIP" , VerifyDbnull ( tmpObj . _log_clientip ) ) ;
oraCmd . Parameters . AddWithValue ( "@LOG_BROWSEINFO" , VerifyDbnull ( tmpObj . _log_browseinfo ) ) ;
oraCmd . Parameters . AddWithValue ( "@OPERATER" , VerifyDbnull ( tmpObj . _operater ) ) ;
// oraCmd.Parameters.AddWithValue("@LASTMODIFIED", "getdate()") ;
return ;
case ( int ) op_flag . add :
if ( tmpObj . _log_empid ! = null )
oraCmd . Parameters . AddWithValue ( "@LOG_EMPID" , VerifyDbnull ( tmpObj . _log_empid ) ) ;
if ( tmpObj . _log_account ! = null )
oraCmd . Parameters . AddWithValue ( "@LOG_ACCOUNT" , VerifyDbnull ( tmpObj . _log_account ) ) ;
if ( tmpObj . _log_sessionid ! = null )
oraCmd . Parameters . AddWithValue ( "@LOG_SESSIONID" , VerifyDbnull ( tmpObj . _log_sessionid ) ) ;
if ( tmpObj . _log_page ! = null )
oraCmd . Parameters . AddWithValue ( "@LOG_PAGE" , VerifyDbnull ( tmpObj . _log_page ) ) ;
if ( tmpObj . _log_method ! = null )
oraCmd . Parameters . AddWithValue ( "@LOG_METHOD" , VerifyDbnull ( tmpObj . _log_method ) ) ;
if ( tmpObj . _log_sql ! = null )
oraCmd . Parameters . AddWithValue ( "@LOG_SQL" , VerifyDbnull ( tmpObj . _log_sql ) ) ;
if ( tmpObj . _log_parameters ! = null )
oraCmd . Parameters . AddWithValue ( "@LOG_PARAMETERS" , VerifyDbnull ( tmpObj . _log_parameters ) ) ;
if ( tmpObj . _log_exception ! = null )
oraCmd . Parameters . AddWithValue ( "@LOG_EXCEPTION" , VerifyDbnull ( tmpObj . _log_exception ) ) ;
if ( tmpObj . _log_clientip ! = null )
oraCmd . Parameters . AddWithValue ( "@LOG_CLIENTIP" , VerifyDbnull ( tmpObj . _log_clientip ) ) ;
if ( tmpObj . _log_browseinfo ! = null )
oraCmd . Parameters . AddWithValue ( "@LOG_BROWSEINFO" , VerifyDbnull ( tmpObj . _log_browseinfo ) ) ;
if ( tmpObj . _operater ! = null )
oraCmd . Parameters . AddWithValue ( "@OPERATER" , VerifyDbnull ( tmpObj . _operater ) ) ;
return ;
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
}
protected override enumDbInstance instance
{
get
{
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
return enumDbInstance . platForm ;
}
}
}
#endregion
}