941 lines
23 KiB
C++
941 lines
23 KiB
C++
|
|
// Version: 2019.12.10 14:56:52
|
||
|
|
|
||
|
|
// File: T_DRIVE_ALARMDBAX.cpp
|
||
|
|
|
||
|
|
#include <log4cplus/LOG.h>
|
||
|
|
|
||
|
|
#include "T_DRIVE_ALARMDBAX.h"
|
||
|
|
#include "T_DRIVE_ALARM.h"
|
||
|
|
|
||
|
|
#define NORECORD 100
|
||
|
|
|
||
|
|
|
||
|
|
using namespace log4cplus;
|
||
|
|
|
||
|
|
extern iDA::Connection cn;
|
||
|
|
extern char sqlErrMsg[4000];
|
||
|
|
|
||
|
|
#define DB_EXECUTE() try{ cmd.Execute();}catch( iDA::Exception &e){ dbSqlCode=-1;strcpy( sqlErrMsg,e.ErrMsg().c_str());return sqlErrMsg;}
|
||
|
|
#define DB_UPDEXECUTE() try{ updatecmd.Execute();}catch( iDA::Exception &e){ dbSqlCode=-1;strcpy( sqlErrMsg,e.ErrMsg().c_str());return sqlErrMsg;}
|
||
|
|
#define DB_RDEXECUTE() try{ readcmd.Execute();}catch( iDA::Exception &e){ dbSqlCode=-1;strcpy( sqlErrMsg,e.ErrMsg().c_str());return sqlErrMsg;}
|
||
|
|
#define DB_INSEXECUTE() try{ insertcmd.Execute();}catch( iDA::Exception &e){ dbSqlCode=-1;strcpy( sqlErrMsg,e.ErrMsg().c_str());return sqlErrMsg;}
|
||
|
|
#define DB_FETCH() try{ if( !readcmd.FetchNext()){ dbSqlCode = NORECORD;strcpy( sqlErrMsg, "No record found");return sqlErrMsg;}}catch( iDA::Exception &e){ dbSqlCode=-1;strcpy( sqlErrMsg,e.ErrMsg().c_str());return sqlErrMsg;}
|
||
|
|
#define DB_UPDAFFECTED() if( updatecmd.RowsAffected() <= 0){ strcpy( sqlErrMsg, "No record affected");return sqlErrMsg;}
|
||
|
|
|
||
|
|
//
|
||
|
|
// Declare DB Hostvariables
|
||
|
|
//
|
||
|
|
|
||
|
|
#define OPENED 1
|
||
|
|
#define CLOSED 2
|
||
|
|
/* ****************************************************************************** */
|
||
|
|
/* */
|
||
|
|
/* define DB */
|
||
|
|
/* Hostvariables */
|
||
|
|
/* */
|
||
|
|
/* ****************************************************************************** */
|
||
|
|
static char db_item[100+1];
|
||
|
|
static char db_code[100+1];
|
||
|
|
static short db_codeZi;
|
||
|
|
static char db_chinese[100+1];
|
||
|
|
static short db_chineseZi;
|
||
|
|
static long db_result_ind0;
|
||
|
|
static short db_result_ind0Zi;
|
||
|
|
static long db_result_ind1;
|
||
|
|
static short db_result_ind1Zi;
|
||
|
|
static long db_result_ind2;
|
||
|
|
static short db_result_ind2Zi;
|
||
|
|
static long db_result_ind3;
|
||
|
|
static short db_result_ind3Zi;
|
||
|
|
static long db_result_ind4;
|
||
|
|
static short db_result_ind4Zi;
|
||
|
|
static long db_result_ind5;
|
||
|
|
static short db_result_ind5Zi;
|
||
|
|
static long db_result_ind6;
|
||
|
|
static short db_result_ind6Zi;
|
||
|
|
static long db_result_ind7;
|
||
|
|
static short db_result_ind7Zi;
|
||
|
|
static long db_result_ind8;
|
||
|
|
static short db_result_ind8Zi;
|
||
|
|
static long db_result_ind9;
|
||
|
|
static short db_result_ind9Zi;
|
||
|
|
static long db_result_ind10;
|
||
|
|
static short db_result_ind10Zi;
|
||
|
|
static long db_result_ind11;
|
||
|
|
static short db_result_ind11Zi;
|
||
|
|
static long db_result_ind12;
|
||
|
|
static short db_result_ind12Zi;
|
||
|
|
static long db_result_ind13;
|
||
|
|
static short db_result_ind13Zi;
|
||
|
|
static long db_result_ind14;
|
||
|
|
static short db_result_ind14Zi;
|
||
|
|
static long db_result_ind15;
|
||
|
|
static short db_result_ind15Zi;
|
||
|
|
static long rowCnt;
|
||
|
|
// Host arguments for Primary key
|
||
|
|
static char k_db_item[100+1];
|
||
|
|
|
||
|
|
//
|
||
|
|
// constructor
|
||
|
|
//
|
||
|
|
T_DRIVE_ALARMDBAX::T_DRIVE_ALARMDBAX()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
//
|
||
|
|
// destructor
|
||
|
|
//
|
||
|
|
T_DRIVE_ALARMDBAX::~T_DRIVE_ALARMDBAX()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
char* T_DRIVE_ALARMDBAX::execute(const char* sql , long* count ){
|
||
|
|
dbSqlCode = 0;
|
||
|
|
cmd.SetConnection( &cn);
|
||
|
|
cmd.SetCommandText( sql);
|
||
|
|
DB_EXECUTE();
|
||
|
|
|
||
|
|
if( count != NULL)
|
||
|
|
{
|
||
|
|
*count = cmd.RowsAffected();
|
||
|
|
}
|
||
|
|
|
||
|
|
return ( NULL );
|
||
|
|
}
|
||
|
|
|
||
|
|
char* T_DRIVE_ALARMDBAX::dbCommit(){
|
||
|
|
dbSqlCode = 0;
|
||
|
|
try{
|
||
|
|
cn.Commit();
|
||
|
|
}catch( iDA::Exception &e)
|
||
|
|
{
|
||
|
|
dbSqlCode = -1;
|
||
|
|
strcpy( sqlErrMsg,e.ErrMsg().c_str());
|
||
|
|
return sqlErrMsg;
|
||
|
|
}
|
||
|
|
|
||
|
|
return ( NULL );
|
||
|
|
}
|
||
|
|
|
||
|
|
char* T_DRIVE_ALARMDBAX::dbRollback(){
|
||
|
|
dbSqlCode = 0;
|
||
|
|
try{
|
||
|
|
cn.Rollback();
|
||
|
|
}catch( iDA::Exception &e)
|
||
|
|
{
|
||
|
|
dbSqlCode = -1;
|
||
|
|
strcpy( sqlErrMsg,e.ErrMsg().c_str());
|
||
|
|
return sqlErrMsg;
|
||
|
|
}
|
||
|
|
return ( NULL );
|
||
|
|
}
|
||
|
|
|
||
|
|
//
|
||
|
|
// private methode copyDB2Attribute
|
||
|
|
//
|
||
|
|
void T_DRIVE_ALARMDBAX::copyDB2Attribute( T_DRIVE_ALARM &dbObj ){
|
||
|
|
dbObj.set_item((char*)db_item);
|
||
|
|
dbObj.set_code((char*)db_code);
|
||
|
|
dbObj.set_codeZi((short)db_codeZi);
|
||
|
|
dbObj.set_chinese((char*)db_chinese);
|
||
|
|
dbObj.set_chineseZi((short)db_chineseZi);
|
||
|
|
dbObj.set_result(0 , (long)db_result_ind0);
|
||
|
|
dbObj.set_resultZi(0 , (short)db_result_ind0Zi);
|
||
|
|
dbObj.set_result(1 , (long)db_result_ind1);
|
||
|
|
dbObj.set_resultZi(1 , (short)db_result_ind1Zi);
|
||
|
|
dbObj.set_result(2 , (long)db_result_ind2);
|
||
|
|
dbObj.set_resultZi(2 , (short)db_result_ind2Zi);
|
||
|
|
dbObj.set_result(3 , (long)db_result_ind3);
|
||
|
|
dbObj.set_resultZi(3 , (short)db_result_ind3Zi);
|
||
|
|
dbObj.set_result(4 , (long)db_result_ind4);
|
||
|
|
dbObj.set_resultZi(4 , (short)db_result_ind4Zi);
|
||
|
|
dbObj.set_result(5 , (long)db_result_ind5);
|
||
|
|
dbObj.set_resultZi(5 , (short)db_result_ind5Zi);
|
||
|
|
dbObj.set_result(6 , (long)db_result_ind6);
|
||
|
|
dbObj.set_resultZi(6 , (short)db_result_ind6Zi);
|
||
|
|
dbObj.set_result(7 , (long)db_result_ind7);
|
||
|
|
dbObj.set_resultZi(7 , (short)db_result_ind7Zi);
|
||
|
|
dbObj.set_result(8 , (long)db_result_ind8);
|
||
|
|
dbObj.set_resultZi(8 , (short)db_result_ind8Zi);
|
||
|
|
dbObj.set_result(9 , (long)db_result_ind9);
|
||
|
|
dbObj.set_resultZi(9 , (short)db_result_ind9Zi);
|
||
|
|
dbObj.set_result(10 , (long)db_result_ind10);
|
||
|
|
dbObj.set_resultZi(10 , (short)db_result_ind10Zi);
|
||
|
|
dbObj.set_result(11 , (long)db_result_ind11);
|
||
|
|
dbObj.set_resultZi(11 , (short)db_result_ind11Zi);
|
||
|
|
dbObj.set_result(12 , (long)db_result_ind12);
|
||
|
|
dbObj.set_resultZi(12 , (short)db_result_ind12Zi);
|
||
|
|
dbObj.set_result(13 , (long)db_result_ind13);
|
||
|
|
dbObj.set_resultZi(13 , (short)db_result_ind13Zi);
|
||
|
|
dbObj.set_result(14 , (long)db_result_ind14);
|
||
|
|
dbObj.set_resultZi(14 , (short)db_result_ind14Zi);
|
||
|
|
dbObj.set_result(15 , (long)db_result_ind15);
|
||
|
|
dbObj.set_resultZi(15 , (short)db_result_ind15Zi);
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// private methode copyAttribute2DB
|
||
|
|
//
|
||
|
|
void T_DRIVE_ALARMDBAX::copyAttribute2DB( T_DRIVE_ALARM &dbObj ){
|
||
|
|
if (strlen(dbObj.item()) < sizeof(db_item)){
|
||
|
|
strncpy ((char*)db_item, dbObj.item(), sizeof(db_item));
|
||
|
|
}
|
||
|
|
if (strlen(dbObj.code()) < sizeof(db_code)){
|
||
|
|
strncpy ((char*)db_code, dbObj.code(), sizeof(db_code));
|
||
|
|
}
|
||
|
|
db_codeZi = dbObj.codeZi();
|
||
|
|
if (strlen(dbObj.chinese()) < sizeof(db_chinese)){
|
||
|
|
strncpy ((char*)db_chinese, dbObj.chinese(), sizeof(db_chinese));
|
||
|
|
}
|
||
|
|
db_chineseZi = dbObj.chineseZi();
|
||
|
|
db_result_ind0 = dbObj.result(0);
|
||
|
|
db_result_ind0Zi = dbObj.resultZi(0);
|
||
|
|
db_result_ind1 = dbObj.result(1);
|
||
|
|
db_result_ind1Zi = dbObj.resultZi(1);
|
||
|
|
db_result_ind2 = dbObj.result(2);
|
||
|
|
db_result_ind2Zi = dbObj.resultZi(2);
|
||
|
|
db_result_ind3 = dbObj.result(3);
|
||
|
|
db_result_ind3Zi = dbObj.resultZi(3);
|
||
|
|
db_result_ind4 = dbObj.result(4);
|
||
|
|
db_result_ind4Zi = dbObj.resultZi(4);
|
||
|
|
db_result_ind5 = dbObj.result(5);
|
||
|
|
db_result_ind5Zi = dbObj.resultZi(5);
|
||
|
|
db_result_ind6 = dbObj.result(6);
|
||
|
|
db_result_ind6Zi = dbObj.resultZi(6);
|
||
|
|
db_result_ind7 = dbObj.result(7);
|
||
|
|
db_result_ind7Zi = dbObj.resultZi(7);
|
||
|
|
db_result_ind8 = dbObj.result(8);
|
||
|
|
db_result_ind8Zi = dbObj.resultZi(8);
|
||
|
|
db_result_ind9 = dbObj.result(9);
|
||
|
|
db_result_ind9Zi = dbObj.resultZi(9);
|
||
|
|
db_result_ind10 = dbObj.result(10);
|
||
|
|
db_result_ind10Zi = dbObj.resultZi(10);
|
||
|
|
db_result_ind11 = dbObj.result(11);
|
||
|
|
db_result_ind11Zi = dbObj.resultZi(11);
|
||
|
|
db_result_ind12 = dbObj.result(12);
|
||
|
|
db_result_ind12Zi = dbObj.resultZi(12);
|
||
|
|
db_result_ind13 = dbObj.result(13);
|
||
|
|
db_result_ind13Zi = dbObj.resultZi(13);
|
||
|
|
db_result_ind14 = dbObj.result(14);
|
||
|
|
db_result_ind14Zi = dbObj.resultZi(14);
|
||
|
|
db_result_ind15 = dbObj.result(15);
|
||
|
|
db_result_ind15Zi = dbObj.resultZi(15);
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// private methode copyKey2Host
|
||
|
|
//
|
||
|
|
void T_DRIVE_ALARMDBAX::copyKey2Host( T_DRIVE_ALARM &dbObj ){
|
||
|
|
if (strlen(dbObj.k_item()) < sizeof(k_db_item)){
|
||
|
|
strncpy ((char*)k_db_item, dbObj.k_item(), sizeof(k_db_item));
|
||
|
|
}
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// private methode copyHost2Key
|
||
|
|
//
|
||
|
|
void T_DRIVE_ALARMDBAX::copyHost2Key( T_DRIVE_ALARM &dbObj ){
|
||
|
|
dbObj.set_k_item((char*)db_item);
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// public methode readDB
|
||
|
|
//
|
||
|
|
char* T_DRIVE_ALARMDBAX::readDB(T_DRIVE_ALARM &dbObj ){
|
||
|
|
copyKey2Host( dbObj );
|
||
|
|
ostringstream ostr;
|
||
|
|
dbSqlCode = 0;
|
||
|
|
|
||
|
|
ostr << "SELECT ";
|
||
|
|
|
||
|
|
// all columns
|
||
|
|
ostr << "item";
|
||
|
|
ostr << ",code";
|
||
|
|
ostr << ",chinese";
|
||
|
|
ostr << ",result_ind0";
|
||
|
|
ostr << ",result_ind1";
|
||
|
|
ostr << ",result_ind2";
|
||
|
|
ostr << ",result_ind3";
|
||
|
|
ostr << ",result_ind4";
|
||
|
|
ostr << ",result_ind5";
|
||
|
|
ostr << ",result_ind6";
|
||
|
|
ostr << ",result_ind7";
|
||
|
|
ostr << ",result_ind8";
|
||
|
|
ostr << ",result_ind9";
|
||
|
|
ostr << ",result_ind10";
|
||
|
|
ostr << ",result_ind11";
|
||
|
|
ostr << ",result_ind12";
|
||
|
|
ostr << ",result_ind13";
|
||
|
|
ostr << ",result_ind14";
|
||
|
|
ostr << ",result_ind15";
|
||
|
|
|
||
|
|
ostr << " FROM T_DRIVE_ALARM WHERE ";
|
||
|
|
|
||
|
|
// where
|
||
|
|
ostr << "item = '" << k_db_item << "'";
|
||
|
|
|
||
|
|
readcmd.SetConnection(&cn);
|
||
|
|
readcmd.SetCommandText( ostr.str());
|
||
|
|
|
||
|
|
DB_RDEXECUTE();
|
||
|
|
|
||
|
|
DB_FETCH();
|
||
|
|
|
||
|
|
// Primary Keys
|
||
|
|
strncpy( db_item, readcmd.Field(1).AsString().c_str(), sizeof( db_item));
|
||
|
|
|
||
|
|
// Normal columns
|
||
|
|
// code
|
||
|
|
if( readcmd.Field(2).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_codeZi = 0;
|
||
|
|
strncpy( db_code, readcmd.Field(2).AsString().c_str(), sizeof( db_code));
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_codeZi = -1;
|
||
|
|
memset( db_code, 0x00, sizeof( db_code));
|
||
|
|
}
|
||
|
|
|
||
|
|
// Normal columns
|
||
|
|
// chinese
|
||
|
|
if( readcmd.Field(3).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_chineseZi = 0;
|
||
|
|
strncpy( db_chinese, readcmd.Field(3).AsString().c_str(), sizeof( db_chinese));
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_chineseZi = -1;
|
||
|
|
memset( db_chinese, 0x00, sizeof( db_chinese));
|
||
|
|
}
|
||
|
|
|
||
|
|
// Normal columns
|
||
|
|
// result_ind0
|
||
|
|
if( readcmd.Field(4).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind0Zi = 0;
|
||
|
|
db_result_ind0 = ( int)readcmd.Field(4).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind0Zi = -1;
|
||
|
|
db_result_ind0 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind1
|
||
|
|
if( readcmd.Field(5).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind1Zi = 0;
|
||
|
|
db_result_ind1 = ( int)readcmd.Field(5).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind1Zi = -1;
|
||
|
|
db_result_ind1 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind2
|
||
|
|
if( readcmd.Field(6).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind2Zi = 0;
|
||
|
|
db_result_ind2 = ( int)readcmd.Field(6).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind2Zi = -1;
|
||
|
|
db_result_ind2 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind3
|
||
|
|
if( readcmd.Field(7).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind3Zi = 0;
|
||
|
|
db_result_ind3 = ( int)readcmd.Field(7).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind3Zi = -1;
|
||
|
|
db_result_ind3 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind4
|
||
|
|
if( readcmd.Field(8).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind4Zi = 0;
|
||
|
|
db_result_ind4 = ( int)readcmd.Field(8).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind4Zi = -1;
|
||
|
|
db_result_ind4 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind5
|
||
|
|
if( readcmd.Field(9).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind5Zi = 0;
|
||
|
|
db_result_ind5 = ( int)readcmd.Field(9).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind5Zi = -1;
|
||
|
|
db_result_ind5 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind6
|
||
|
|
if( readcmd.Field(10).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind6Zi = 0;
|
||
|
|
db_result_ind6 = ( int)readcmd.Field(10).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind6Zi = -1;
|
||
|
|
db_result_ind6 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind7
|
||
|
|
if( readcmd.Field(11).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind7Zi = 0;
|
||
|
|
db_result_ind7 = ( int)readcmd.Field(11).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind7Zi = -1;
|
||
|
|
db_result_ind7 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind8
|
||
|
|
if( readcmd.Field(12).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind8Zi = 0;
|
||
|
|
db_result_ind8 = ( int)readcmd.Field(12).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind8Zi = -1;
|
||
|
|
db_result_ind8 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind9
|
||
|
|
if( readcmd.Field(13).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind9Zi = 0;
|
||
|
|
db_result_ind9 = ( int)readcmd.Field(13).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind9Zi = -1;
|
||
|
|
db_result_ind9 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind10
|
||
|
|
if( readcmd.Field(14).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind10Zi = 0;
|
||
|
|
db_result_ind10 = ( int)readcmd.Field(14).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind10Zi = -1;
|
||
|
|
db_result_ind10 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind11
|
||
|
|
if( readcmd.Field(15).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind11Zi = 0;
|
||
|
|
db_result_ind11 = ( int)readcmd.Field(15).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind11Zi = -1;
|
||
|
|
db_result_ind11 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind12
|
||
|
|
if( readcmd.Field(16).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind12Zi = 0;
|
||
|
|
db_result_ind12 = ( int)readcmd.Field(16).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind12Zi = -1;
|
||
|
|
db_result_ind12 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind13
|
||
|
|
if( readcmd.Field(17).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind13Zi = 0;
|
||
|
|
db_result_ind13 = ( int)readcmd.Field(17).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind13Zi = -1;
|
||
|
|
db_result_ind13 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind14
|
||
|
|
if( readcmd.Field(18).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind14Zi = 0;
|
||
|
|
db_result_ind14 = ( int)readcmd.Field(18).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind14Zi = -1;
|
||
|
|
db_result_ind14 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind15
|
||
|
|
if( readcmd.Field(19).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind15Zi = 0;
|
||
|
|
db_result_ind15 = ( int)readcmd.Field(19).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind15Zi = -1;
|
||
|
|
db_result_ind15 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// copy host variables into Class attributes
|
||
|
|
copyDB2Attribute( dbObj );
|
||
|
|
return ( NULL );
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// public methode updateDB
|
||
|
|
//
|
||
|
|
char* T_DRIVE_ALARMDBAX::updateDB(T_DRIVE_ALARM &dbObj ){
|
||
|
|
copyKey2Host( dbObj );
|
||
|
|
|
||
|
|
copyAttribute2DB( dbObj );
|
||
|
|
dbSqlCode = 0;
|
||
|
|
|
||
|
|
ostringstream ostr;
|
||
|
|
ostr << "UPDATE T_DRIVE_ALARM SET ";
|
||
|
|
|
||
|
|
// Material Keys & Primary Keys
|
||
|
|
ostr << "item='" << db_item << "'";
|
||
|
|
|
||
|
|
// Normal column
|
||
|
|
if( db_codeZi != -1) ostr << ", code = '" << db_code << "'"; else ostr<<",code = NULL";
|
||
|
|
if( db_chineseZi != -1) ostr << ", chinese = '" << db_chinese << "'"; else ostr<<",chinese = NULL";
|
||
|
|
if( db_result_ind0Zi != -1) ostr << ", result_ind0 = " << db_result_ind0; else ostr<<",result_ind0 = 0";
|
||
|
|
if( db_result_ind1Zi != -1) ostr << ", result_ind1 = " << db_result_ind1; else ostr<<",result_ind1 = 0";
|
||
|
|
if( db_result_ind2Zi != -1) ostr << ", result_ind2 = " << db_result_ind2; else ostr<<",result_ind2 = 0";
|
||
|
|
if( db_result_ind3Zi != -1) ostr << ", result_ind3 = " << db_result_ind3; else ostr<<",result_ind3 = 0";
|
||
|
|
if( db_result_ind4Zi != -1) ostr << ", result_ind4 = " << db_result_ind4; else ostr<<",result_ind4 = 0";
|
||
|
|
if( db_result_ind5Zi != -1) ostr << ", result_ind5 = " << db_result_ind5; else ostr<<",result_ind5 = 0";
|
||
|
|
if( db_result_ind6Zi != -1) ostr << ", result_ind6 = " << db_result_ind6; else ostr<<",result_ind6 = 0";
|
||
|
|
if( db_result_ind7Zi != -1) ostr << ", result_ind7 = " << db_result_ind7; else ostr<<",result_ind7 = 0";
|
||
|
|
if( db_result_ind8Zi != -1) ostr << ", result_ind8 = " << db_result_ind8; else ostr<<",result_ind8 = 0";
|
||
|
|
if( db_result_ind9Zi != -1) ostr << ", result_ind9 = " << db_result_ind9; else ostr<<",result_ind9 = 0";
|
||
|
|
if( db_result_ind10Zi != -1) ostr << ", result_ind10 = " << db_result_ind10; else ostr<<",result_ind10 = 0";
|
||
|
|
if( db_result_ind11Zi != -1) ostr << ", result_ind11 = " << db_result_ind11; else ostr<<",result_ind11 = 0";
|
||
|
|
if( db_result_ind12Zi != -1) ostr << ", result_ind12 = " << db_result_ind12; else ostr<<",result_ind12 = 0";
|
||
|
|
if( db_result_ind13Zi != -1) ostr << ", result_ind13 = " << db_result_ind13; else ostr<<",result_ind13 = 0";
|
||
|
|
if( db_result_ind14Zi != -1) ostr << ", result_ind14 = " << db_result_ind14; else ostr<<",result_ind14 = 0";
|
||
|
|
if( db_result_ind15Zi != -1) ostr << ", result_ind15 = " << db_result_ind15; else ostr<<",result_ind15 = 0";
|
||
|
|
|
||
|
|
// where
|
||
|
|
ostr << " WHERE ";
|
||
|
|
ostr << "item = '" << db_item << "'";
|
||
|
|
|
||
|
|
updatecmd.SetConnection(&cn);
|
||
|
|
updatecmd.SetCommandText( ostr.str());
|
||
|
|
DB_UPDEXECUTE();
|
||
|
|
DB_UPDAFFECTED();
|
||
|
|
|
||
|
|
return ( NULL );
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// public methode insertDB
|
||
|
|
//
|
||
|
|
char* T_DRIVE_ALARMDBAX::insertDB(T_DRIVE_ALARM &dbObj ){
|
||
|
|
copyAttribute2DB( dbObj );
|
||
|
|
dbSqlCode = 0;
|
||
|
|
|
||
|
|
m_sql = "INSERT INTO T_DRIVE_ALARM VALUES( :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19)";
|
||
|
|
insertcmd.SetConnection(&cn);
|
||
|
|
insertcmd.SetCommandText( m_sql);
|
||
|
|
|
||
|
|
|
||
|
|
// Primary columns
|
||
|
|
insertcmd.Param(1) = ( char *)db_item;
|
||
|
|
|
||
|
|
// Normal columns
|
||
|
|
if( db_codeZi != -1) insertcmd.Param(2) = ( char *)db_code; else insertcmd.Param(2).SetAsNull();
|
||
|
|
|
||
|
|
// Normal columns
|
||
|
|
if( db_chineseZi != -1) insertcmd.Param(3) = ( char *)db_chinese; else insertcmd.Param(3).SetAsNull();
|
||
|
|
|
||
|
|
// Normal columns
|
||
|
|
if( db_result_ind0Zi != -1) insertcmd.Param(4) = ( long)db_result_ind0; else insertcmd.Param(4) = ( long)0;
|
||
|
|
if( db_result_ind1Zi != -1) insertcmd.Param(5) = ( long)db_result_ind1; else insertcmd.Param(5) = ( long)0;
|
||
|
|
if( db_result_ind2Zi != -1) insertcmd.Param(6) = ( long)db_result_ind2; else insertcmd.Param(6) = ( long)0;
|
||
|
|
if( db_result_ind3Zi != -1) insertcmd.Param(7) = ( long)db_result_ind3; else insertcmd.Param(7) = ( long)0;
|
||
|
|
if( db_result_ind4Zi != -1) insertcmd.Param(8) = ( long)db_result_ind4; else insertcmd.Param(8) = ( long)0;
|
||
|
|
if( db_result_ind5Zi != -1) insertcmd.Param(9) = ( long)db_result_ind5; else insertcmd.Param(9) = ( long)0;
|
||
|
|
if( db_result_ind6Zi != -1) insertcmd.Param(10) = ( long)db_result_ind6; else insertcmd.Param(10) = ( long)0;
|
||
|
|
if( db_result_ind7Zi != -1) insertcmd.Param(11) = ( long)db_result_ind7; else insertcmd.Param(11) = ( long)0;
|
||
|
|
if( db_result_ind8Zi != -1) insertcmd.Param(12) = ( long)db_result_ind8; else insertcmd.Param(12) = ( long)0;
|
||
|
|
if( db_result_ind9Zi != -1) insertcmd.Param(13) = ( long)db_result_ind9; else insertcmd.Param(13) = ( long)0;
|
||
|
|
if( db_result_ind10Zi != -1) insertcmd.Param(14) = ( long)db_result_ind10; else insertcmd.Param(14) = ( long)0;
|
||
|
|
if( db_result_ind11Zi != -1) insertcmd.Param(15) = ( long)db_result_ind11; else insertcmd.Param(15) = ( long)0;
|
||
|
|
if( db_result_ind12Zi != -1) insertcmd.Param(16) = ( long)db_result_ind12; else insertcmd.Param(16) = ( long)0;
|
||
|
|
if( db_result_ind13Zi != -1) insertcmd.Param(17) = ( long)db_result_ind13; else insertcmd.Param(17) = ( long)0;
|
||
|
|
if( db_result_ind14Zi != -1) insertcmd.Param(18) = ( long)db_result_ind14; else insertcmd.Param(18) = ( long)0;
|
||
|
|
if( db_result_ind15Zi != -1) insertcmd.Param(19) = ( long)db_result_ind15; else insertcmd.Param(19) = ( long)0;
|
||
|
|
|
||
|
|
|
||
|
|
DB_INSEXECUTE();
|
||
|
|
|
||
|
|
return ( NULL );
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// public methode deleteDB
|
||
|
|
//
|
||
|
|
char* T_DRIVE_ALARMDBAX::deleteDB(T_DRIVE_ALARM &dbObj ){
|
||
|
|
ostringstream ostr;
|
||
|
|
dbSqlCode = 0;
|
||
|
|
copyKey2Host( dbObj );
|
||
|
|
|
||
|
|
ostr << "DELETE FROM T_DRIVE_ALARM WHERE ";
|
||
|
|
|
||
|
|
ostr << "item = '" << db_item << "'";
|
||
|
|
cmd.SetConnection( &cn);
|
||
|
|
cmd.SetCommandText( ostr.str());
|
||
|
|
|
||
|
|
DB_EXECUTE();
|
||
|
|
|
||
|
|
return ( NULL );
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// public methode deleteDB delete in case of a where clause
|
||
|
|
//
|
||
|
|
char* T_DRIVE_ALARMDBAX::deleteDB(const char* where , long* count){
|
||
|
|
dbSqlCode = 0;
|
||
|
|
*(count) = -1L;
|
||
|
|
|
||
|
|
m_sql = "DELETE FROM T_DRIVE_ALARM ";
|
||
|
|
|
||
|
|
if ( where != (char*)NULL ) {
|
||
|
|
m_sql.append( where );
|
||
|
|
}
|
||
|
|
|
||
|
|
cmd.SetConnection( &cn);
|
||
|
|
cmd.SetCommandText( m_sql);
|
||
|
|
|
||
|
|
DB_EXECUTE();
|
||
|
|
|
||
|
|
if( count != NULL){
|
||
|
|
*count = cmd.RowsAffected();
|
||
|
|
}
|
||
|
|
|
||
|
|
return ( NULL );
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// public methode openSetDB
|
||
|
|
//
|
||
|
|
char* T_DRIVE_ALARMDBAX::openSetDB(const char* where , const char* order){
|
||
|
|
dbSqlCode = 0;
|
||
|
|
|
||
|
|
m_sql = "SELECT item, code, chinese, result_ind0, result_ind1, result_ind2, result_ind3, result_ind4, result_ind5, result_ind6, result_ind7, result_ind8, result_ind9, result_ind10, result_ind11, result_ind12, result_ind13, result_ind14, result_ind15 FROM T_DRIVE_ALARM ";
|
||
|
|
|
||
|
|
if ( where != (char*)NULL ) {
|
||
|
|
m_sql.append( where);
|
||
|
|
m_sql.append( " ");
|
||
|
|
}
|
||
|
|
if (order != (char*)NULL){
|
||
|
|
m_sql.append( order);
|
||
|
|
}
|
||
|
|
|
||
|
|
readcmd.SetConnection(&cn);
|
||
|
|
readcmd.SetCommandText( m_sql);
|
||
|
|
|
||
|
|
DB_RDEXECUTE();
|
||
|
|
|
||
|
|
return ( NULL );
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// public methode getSetDB
|
||
|
|
//
|
||
|
|
char* T_DRIVE_ALARMDBAX::getSetDB( T_DRIVE_ALARM &dbObj ){
|
||
|
|
dbSqlCode = 0;
|
||
|
|
|
||
|
|
DB_FETCH();
|
||
|
|
|
||
|
|
// Primary columns
|
||
|
|
strncpy( db_item, readcmd.Field(1).AsString().c_str(), sizeof( db_item));
|
||
|
|
|
||
|
|
// Normal columns
|
||
|
|
// code
|
||
|
|
if( readcmd.Field(2).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_codeZi = 0;
|
||
|
|
strncpy( db_code, readcmd.Field(2).AsString().c_str(), sizeof( db_code));
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_codeZi = -1;
|
||
|
|
memset( db_code, 0x00, sizeof( db_code));
|
||
|
|
}
|
||
|
|
|
||
|
|
// Normal columns
|
||
|
|
// chinese
|
||
|
|
if( readcmd.Field(3).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_chineseZi = 0;
|
||
|
|
strncpy( db_chinese, readcmd.Field(3).AsString().c_str(), sizeof( db_chinese));
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_chineseZi = -1;
|
||
|
|
memset( db_chinese, 0x00, sizeof( db_chinese));
|
||
|
|
}
|
||
|
|
|
||
|
|
// Normal columns
|
||
|
|
// result_ind0
|
||
|
|
if( readcmd.Field(4).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind0Zi = 0;
|
||
|
|
db_result_ind0 = ( long)readcmd.Field(4).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind0Zi = -1;
|
||
|
|
db_result_ind0 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind1
|
||
|
|
if( readcmd.Field(5).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind1Zi = 0;
|
||
|
|
db_result_ind1 = ( long)readcmd.Field(5).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind1Zi = -1;
|
||
|
|
db_result_ind1 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind2
|
||
|
|
if( readcmd.Field(6).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind2Zi = 0;
|
||
|
|
db_result_ind2 = ( long)readcmd.Field(6).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind2Zi = -1;
|
||
|
|
db_result_ind2 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind3
|
||
|
|
if( readcmd.Field(7).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind3Zi = 0;
|
||
|
|
db_result_ind3 = ( long)readcmd.Field(7).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind3Zi = -1;
|
||
|
|
db_result_ind3 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind4
|
||
|
|
if( readcmd.Field(8).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind4Zi = 0;
|
||
|
|
db_result_ind4 = ( long)readcmd.Field(8).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind4Zi = -1;
|
||
|
|
db_result_ind4 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind5
|
||
|
|
if( readcmd.Field(9).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind5Zi = 0;
|
||
|
|
db_result_ind5 = ( long)readcmd.Field(9).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind5Zi = -1;
|
||
|
|
db_result_ind5 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind6
|
||
|
|
if( readcmd.Field(10).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind6Zi = 0;
|
||
|
|
db_result_ind6 = ( long)readcmd.Field(10).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind6Zi = -1;
|
||
|
|
db_result_ind6 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind7
|
||
|
|
if( readcmd.Field(11).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind7Zi = 0;
|
||
|
|
db_result_ind7 = ( long)readcmd.Field(11).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind7Zi = -1;
|
||
|
|
db_result_ind7 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind8
|
||
|
|
if( readcmd.Field(12).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind8Zi = 0;
|
||
|
|
db_result_ind8 = ( long)readcmd.Field(12).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind8Zi = -1;
|
||
|
|
db_result_ind8 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind9
|
||
|
|
if( readcmd.Field(13).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind9Zi = 0;
|
||
|
|
db_result_ind9 = ( long)readcmd.Field(13).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind9Zi = -1;
|
||
|
|
db_result_ind9 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind10
|
||
|
|
if( readcmd.Field(14).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind10Zi = 0;
|
||
|
|
db_result_ind10 = ( long)readcmd.Field(14).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind10Zi = -1;
|
||
|
|
db_result_ind10 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind11
|
||
|
|
if( readcmd.Field(15).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind11Zi = 0;
|
||
|
|
db_result_ind11 = ( long)readcmd.Field(15).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind11Zi = -1;
|
||
|
|
db_result_ind11 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind12
|
||
|
|
if( readcmd.Field(16).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind12Zi = 0;
|
||
|
|
db_result_ind12 = ( long)readcmd.Field(16).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind12Zi = -1;
|
||
|
|
db_result_ind12 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind13
|
||
|
|
if( readcmd.Field(17).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind13Zi = 0;
|
||
|
|
db_result_ind13 = ( long)readcmd.Field(17).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind13Zi = -1;
|
||
|
|
db_result_ind13 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind14
|
||
|
|
if( readcmd.Field(18).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind14Zi = 0;
|
||
|
|
db_result_ind14 = ( long)readcmd.Field(18).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind14Zi = -1;
|
||
|
|
db_result_ind14 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// result_ind15
|
||
|
|
if( readcmd.Field(19).IsNull() == false)
|
||
|
|
{
|
||
|
|
db_result_ind15Zi = 0;
|
||
|
|
db_result_ind15 = ( long)readcmd.Field(19).AsLong();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
db_result_ind15Zi = -1;
|
||
|
|
db_result_ind15 = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
copyDB2Attribute( dbObj );
|
||
|
|
copyHost2Key( dbObj );
|
||
|
|
|
||
|
|
return ( NULL );
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// public methode closeSetDB
|
||
|
|
//
|
||
|
|
char* T_DRIVE_ALARMDBAX::closeSetDB(){
|
||
|
|
dbSqlCode = 0;
|
||
|
|
return ( NULL );
|
||
|
|
} // end of methode
|
||
|
|
|
||
|
|
//
|
||
|
|
// public methode countDB
|
||
|
|
//
|
||
|
|
char* T_DRIVE_ALARMDBAX::countDB(const char* where , long* count){
|
||
|
|
dbSqlCode = 0;
|
||
|
|
*(count) = -1L;
|
||
|
|
|
||
|
|
m_sql = "SELECT count(*) FROM T_DRIVE_ALARM ";
|
||
|
|
|
||
|
|
if ( where != (char*)NULL ) {
|
||
|
|
m_sql.append( where);
|
||
|
|
}
|
||
|
|
|
||
|
|
readcmd.SetConnection(&cn);
|
||
|
|
readcmd.SetCommandText( m_sql);
|
||
|
|
|
||
|
|
DB_RDEXECUTE();
|
||
|
|
|
||
|
|
DB_FETCH();
|
||
|
|
*count = ( long)readcmd.Field(1).AsLong();
|
||
|
|
return ( NULL );
|
||
|
|
} // end of methode
|