本文整理汇总了C++中SACommand类的典型用法代码示例。如果您正苦于以下问题:C++ SACommand类的具体用法?C++ SACommand怎么用?C++ SACommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SACommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trace_log
/**< 更新流水和批次 */
int COperateDB::SaveChannelInfo(SAConnection *pSaconn, TRADEDATA * pData)
{
if(pData == NULL || pSaconn == NULL)
{
trace_log(ERR, "parameter error!");
return -1;
}
SAString sSql;
SACommand Cmd;
try
{
Cmd.setConnection(pSaconn);
sSql.Format("update T_CHANNEL_TERMINAL set CT_VOUCHNO='%s',CT_BATCHNO='%s' where CM_MCHT='%s'"
"and CT_TMNL='%s' and CF_INTERFACE=%d and CT_STATUS = 1", pData->VouchNo, pData->BatchNo,
pData->TransData.HeadData.arrRMerchNo, pData->TransData.HeadData.arrRTermNo,pData->TransData.HeadData.nInterface);
Cmd.setCommandText(sSql);
Cmd.Execute();
pSaconn->Commit();
}catch(SAException &e){
pSaconn->Rollback();
trace_log(ERR,"database exceptions:%s ,SQL = [%s]",_T(e.ErrText()),_T(sSql));
return -1;
}catch (...){
trace_log(ERR, "Execute sql fail[sql:%s]!", _T(sSql));
throw;
return -1;
}
return 0;
}
示例2: Oracle_Cancel
void Oracle_Cancel()
{
SAConnection con2;
SAConnection con;
SACommand cmd2;
SACommand cmd;
cmd2.setConnection(&con2);
cmd.setConnection(&con);
try
{
con2.Connect(
"test", "scott", "tiger", SA_Oracle_Client);
//con.setOption("UseAPI") = "OCI7";
con.Connect(
"test", "scott", "tiger", SA_Oracle_Client);
// block
cmd2.setCommandText("Update DEPT set DNAME=DNAME");
cmd2.Execute();
DWORD ThreadId;
HANDLE hThread;
hThread = ::CreateThread(
NULL, 0,
Oracle_Cancel_Thread, &con,
0, &ThreadId);
WaitForSingleObject(hThread, 1000);
cout << "Calling Cancel!" << endl;
cmd.Open();
cmd.Cancel();
cout << "Cancel has been called!" << endl;
WaitForSingleObject(hThread, 2000);
cout << "Calling con2.Rollback()!" << endl;
con2.Rollback();
cout << "con2.Rollback() has been called!" << endl;
WaitForSingleObject(hThread, INFINITE);
}
catch(SAException &x)
{
// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try
{
// on error rollback changes
con.Rollback();
}
catch(SAException &)
{
}
// print error message
cout << (const char*)x.ErrText() << endl;
}
}
示例3: InterBaseEvents
void InterBaseEvents()
{
SAConnection con;
SACommand cmd;
event_data_t event_data;
try
{
con.Connect(
"transfer:d:/temp/siemens/controller.gdb", // database name
"sysdba", // user name
"masterkey", // password
SA_InterBase_Client);
event_data.pibAPI = (ibAPI *)con.NativeAPI();
event_data.pibConnectionHandles = (ibConnectionHandles *)con.NativeHandles();
con.setAutoCommit(SA_AutoCommitOn);
// register interest for "TestEvent" event
event_data.length = event_data.pibAPI->isc_event_block(
&event_data.event_buffer,
&event_data.result_buffer,
1,
"TestEvent");
event_data.que_events();
// this should fire event
cmd.setConnection(&con);
cmd.setCommandText("a");
cmd.Param("sEvent").setAsString() = "TestEvent";
cmd.Execute();
// wait for event to be fired
getchar();
}
catch(SAException &x)
{
// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try
{
// on error rollback changes
con.Rollback();
}
catch(SAException &)
{
}
// print error message
printf("Err = %s\nCode = %d\n", (const char*)x.ErrText(),
x.ErrNativeCode());
}
}
示例4: OracleRefCursor
void OracleRefCursor()
{
SAConnection con;
try
{
SACommand cmd(&con);
con.Connect(
"demo", "scott", "tiger", SA_Oracle_Client);
cout << "Connected OK!" << "\n";
cmd.setCommandText("TestRefCursorPkg.TestRefCursorProc");
cmd.Execute();
cout << "Stored procedure executed OK!" << "\n";
SACommand *pRefCursor = cmd.Param("REFCURSOR");
while(pRefCursor->FetchNext())
{
cout
<< (const char*)pRefCursor->Field(1).Name() << "="
<< (const char*)pRefCursor->Field(1).asString() << "\n";
}
cout << "Ref cursor fetched OK!" << "\n";
}
catch(SAException &x)
{
// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try
{
// on error rollback changes
con.Rollback();
}
catch(SAException &)
{
}
// print error message
cout << (const char*)x.ErrText() << "\n";
}
}
示例5: Oracle_Cancel_Thread
DWORD WINAPI Oracle_Cancel_Thread(void *_pCon)
{
SAConnection *pCon = (SAConnection *)_pCon;
SACommand cmd;
cmd.setConnection(pCon);
try
{
cmd.setCommandText("Update DEPT set DNAME=DNAME");
//cmd.setCommandText("sys.DBMS_PIPE.receive_message");
//cmd << SAPos("pipename") << "myPipe" << SAPos("timeout") << 10L;
cout << "Calling Execute!" << endl;
cmd.Execute();
cout << "Execute has been called!" << endl;
}
catch(SAException &x)
{
cout << "Oracle_Cancel_Thread: " << (const char*)x.ErrText() << endl;
}
return 0;
}
示例6: main
int main(int argc, char* argv[])
{
SAConnection con; // connection object
SACommand cmd; // command object
try
{
// connect to database (Oracle in our example)
con.Connect("test", "tester", "tester", SA_Oracle_Client);
// associate a command with connection
cmd.setConnection(&con);
// Insert 2 rows
cmd.setCommandText(
"Insert into test_tbl(fid, fvarchar20) values(:1, :2)");
// use first method of binding - param assignment
cmd.Param(1).setAsLong() = 2;
cmd.Param(2).setAsString() = "Some string (2)";
// Insert first row
cmd.Execute();
// use second method of binding - stream binding
cmd << (long)3 << "Some string (3)";
// Insert second row
cmd.Execute();
// commit changes on success
con.Commit();
printf("Input parameters bound, rows inserted!\n");
}
catch(SAException &x)
{
// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try
{
// on error rollback changes
con.Rollback();
}
catch(SAException &)
{
}
// print error message
printf("%s\n", (const char*)x.ErrText());
}
return 0;
}
示例7: main
int main(int argc, char* argv[])
{
SAConnection con; // connection object
SACommand cmd; // create command object
try
{
// connect to database (Oracle in our example)
con.Connect("test", "tester", "tester", SA_Oracle_Client);
// associate a command with connection
// connection can also be specified in SACommand constructor
cmd.setConnection(&con);
// create table
cmd.setCommandText(
"Create table test_tbl(fid integer, fvarchar20 varchar(20), fblob blob)");
cmd.Execute();
// insert value
cmd.setCommandText(
"Insert into test_tbl(fid, fvarchar20) values (1, 'Some string (1)')");
cmd.Execute();
// commit changes on success
con.Commit();
printf("Table created, row inserted!\n");
}
catch(SAException &x)
{
// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try
{
// on error rollback changes
con.Rollback();
}
catch(SAException &)
{
}
// print error message
printf("%s\n", (const char*)x.ErrText());
}
return 0;
}
示例8: GetResetData
/** \brief
* 获取冲正数据
* \param
* \param
* \return
*
*/
int COperateDB::GetResetData(SAConnection *pSaconn, TRADEDATA *pData, CUPS8583 *sendObj)
{
SAString sSql,str;
SACommand Cmd;
Cmd.setConnection(pSaconn);
try
{
POS_TRADE_TYPE posType = (POS_TRADE_TYPE)pData->TransData.HeadData.RTradeType;
map<POS_TRADE_TYPE, POS_TRADE_TYPE> ::iterator it =CTradeDoReset::m_unTradeOrgMap.find( posType);
if(it==CTradeDoReset::m_unTradeOrgMap.end())
{
trace_log(ERR,"No the Reset trade");
return -1;
}
sSql.Format("select FIELD2,FIELD3,FIELD4,FIELD11,FIELD22,FIELD35,FIELD36,FIELD38,FIELD41,"
"FIELD42,FIELD48,FIELD49 from T_CHANNEL_RESETLIST where FIELD11='%s' and FIELD41='%s'"
" and FIELD42='%s' and CRT_TYPE='%c' and CRT_BATCHNO='%s'", pData->TransData.HeadData.OrigLPosSeq,
pData->TransData.HeadData.arrRTermNo, pData->TransData.HeadData.arrRMerchNo,
it->second, pData->TransData.HeadData.OrigLBatchNo);
Cmd.setCommandText(sSql);
Cmd.Execute();
if(!Cmd.FetchNext())
{
trace_log(ERR, " no found the original trans sql=[%s]!", _T(sSql));
memcpy(pData->TransData.HeadData.RspCode, "25",2);
return RET_SYSEXP;
}
//2账号
sendObj->SetValueByStr(2, _T(Cmd.Field("FIELD2").asString()));
//3处理码
sendObj->SetValueByStr(3, _T(Cmd.Field("FIELD3").asString()));
//4金额
sendObj->SetValueByStr(4, _T(Cmd.Field("FIELD4").asString()));
//22 输入方式
sendObj->SetValueByStr(22, _T(Cmd.Field("FIELD22").asString()));
//35 二磁道
str = Cmd.Field("FIELD35").asString();
if(str.GetLength() > 0)
{
sendObj->SetValueByStr(35, _T(str));
}
//36 三磁道
str = Cmd.Field("FIELD36").asString();
if(str.GetLength() > 0)
{
sendObj->SetValueByStr(36, _T(str));
}
//38 预授权
str = Cmd.Field("FIELD38").asString();
if(str.GetLength() > 0)
{
sendObj->SetValueByStr(38, _T(str));
}
//41终端号
sendObj->SetValueByStr(41, _T(Cmd.Field("FIELD41").asString()));
//42商户号
sendObj->SetValueByStr(42, _T(Cmd.Field("FIELD42").asString()));
//48 自定义域
str = Cmd.Field("FIELD48").asString();
if(str.GetLength() > 0)
{
sendObj->SetValueByStr(48, _T(str));
}
//49 货币代码
sendObj->SetValueByStr(49, _T(Cmd.Field("FIELD49").asString()));
//62原始交易信息(信息类型码,系统跟踪号,交易日期和时间)
char cData[7]={0},cTran[5]={0};
BYTE bTmpData[FIELD_MAXLEN]={0};
if( posType==POS_UNPREAUTH||posType==POS_UNPREAUTHREVE)
{
strcpy(cTran,"0100");/**< 预授权和预授权撤销为‘0100’ ,别的四个交易类型为‘0200’*/
}else{
strcpy(cTran,"0200");
}
memcpy(cData,Cmd.Field("FIELD11").asString(),Cmd.Field("FIELD11").asString().GetLength());
memset(bTmpData, 0, sizeof(bTmpData));
sprintf((char *)bTmpData, "%s%s%s",cTran, cData,pData->cOri_DateTime);
sendObj->SetValueByStr(62, (char *)bTmpData);
return 0;
}catch (SAException &e){
pSaconn->Rollback();
trace_log(ERR,"database exceptions:%s ,SQL = [%s]",_T(e.ErrText()),_T(sSql));
return -1;
}catch (...){
trace_log(ERR, "Execute sql fail[sql:%s]!", _T(sSql));
return -1;
}
}
示例9: OnSynData
int OnSynData(QUEUE_LIST *pDataNode)
{
thd_log(LOG_DEBUG,(char *)"OnSynData...");
int MSGLength = pDataNode->Length; //报文(MSG)
unsigned char *pMSG = pDataNode->Buffer; //应先判断pMSG长度 看主账号这些数据是否存在
pMSG++;
MSGLength--;
int iFlag = pMSG[0];
int UpdateNum = 0;
const int MerNoLen = MERNOLENGTH;
char MerNo[MERNOLENGTH+1] = {0};
char Mer_PosNo[1025] = {0};
char SID[11][51] = {{0}};
int DataLen = 0;
int iCount = 0;
if(iFlag == 1)
{
//在数据库中判断IsNew是否为1(1为新添加数据,需要SPOS同步),循环每次取10条记录
try
{
SAString sSql;
SACommand Cmd;
Cmd.setConnection(pDataNode->psaConn);
sSql.Format("select count(*) as num from t_pos_key where isnew = 1 ");
thd_log( LOG_DEBUG,"OnSynData,sSQL: %s", _T(sSql));
Cmd.setCommandText(sSql);
Cmd.Execute();
if (Cmd.FetchNext())
{
UpdateNum = Cmd.Field("num").asShort();
}
else
{
thd_log(LOG_WARNING,(char *)"OnSynData, Port[%d] Peer[%d] : There's no data in t_pos_key!",
pDataNode->SrvrPort, pDataNode->PeerSockId);
return 0;
}
}
catch(SAException &x)
{
thd_log( LOG_ERROR,(char *)"OnSynData, SQLAPI Exception %s", _T(x.ErrText()));
setCmdError(pDataNode);
return 0;
}
if(UpdateNum != 0)
{
try
{
SAString sSql;
SACommand Cmd;
Cmd.setConnection(pDataNode->psaConn);
sSql.Format("select sid,merno,posno,adddate from t_pos_key where isnew = 1 and rownum <=10");
thd_log( LOG_DEBUG,"OnSynData, sSQL: %s", _T(sSql));
Cmd.setCommandText(sSql);
Cmd.Execute();
while(Cmd.FetchNext())
{
strcpy(SID[iCount],_T(Cmd.Field("sid").asString()));
strcpy(MerNo,_T(Cmd.Field("merno").asString()));
int tmpLen = strlen(MerNo);
if(tmpLen < 20)
{
memset(&MerNo[tmpLen],' ',20-tmpLen);
}
memcpy(&Mer_PosNo[DataLen],MerNo,MerNoLen);
DataLen += MerNoLen;
memcpy(&Mer_PosNo[DataLen],_T(Cmd.Field("posno").asString()),POSNOLENGTH);
DataLen += POSNOLENGTH;
memcpy(&Mer_PosNo[DataLen],_T(Cmd.Field("adddate").asString()),8); //2011-09-08修改:同步时加上增加日期
DataLen += 8; //2011-09-08修改:同步时加上增加日期
iCount++;
}
}
catch(SAException &x)
{
thd_log( LOG_ERROR,(char *)"OnSynData, SQLAPI Exception %s", _T(x.ErrText()));
setCmdError(pDataNode);
return 0;
}
int iOutLen = 0;
// 输出缓存
char OutBuf[1024];
memset(OutBuf, 0, sizeof(OutBuf));
OutBuf[iOutLen] = pDataNode->Buffer[0];
iOutLen += 1;
OutBuf[iOutLen] = CMD_OK;
iOutLen += 1;
OutBuf[iOutLen] = iCount;
iOutLen += 1;
memcpy(&OutBuf[iOutLen],Mer_PosNo,iCount*(MerNoLen+POSNOLENGTH));
iOutLen += iCount*(MerNoLen+POSNOLENGTH +8); //2011-09-08修改:同步时加上增加日期
memcpy(pDataNode->Buffer, OutBuf, iOutLen);
pDataNode->Length = iOutLen ;
thd_log(LOG_DEBUG,(char *)"OnSynData, Output Buffer Data:");
trace_mem(LOG_DEBUG,(unsigned char *)pDataNode->Buffer,iOutLen);
//更新数据库的IsNew字段
try
{
SAString sSql;
//.........这里部分代码省略.........
示例10: OnGetRandom
int OnGetRandom(QUEUE_LIST *pDataNode)
{
thd_log(LOG_DEBUG,(char *)"OnGetRandom...Received Data:");
trace_mem(LOG_DEBUG,(unsigned char *)pDataNode->Buffer,pDataNode->Length);
int MSGLength = pDataNode->Length;
unsigned char *pMSG = pDataNode->Buffer; //
pMSG++;
MSGLength--;
int iOffset = 0;
int DownKeyLen = 0;
char DownKey[49] = {0};
char TermNo[17] = {0};
unsigned char TRD[9] = {0}; //加密机产生的随机数据,TTEK加密后送给SPOS服务器
// 输出缓存
char OutBuf[1025] = {0};
char EDownKey[17] = {0};
char chTRD[17] = {0};
unsigned char KeyRandom[8] = {0xD6, 0xA7, 0xB8, 0xB6, 0xCE, 0xDE, 0xD3, 0xC7}; //固定密钥 用来加密终端随机数
char TermNo1[9] = {0};
int iFlag = 0;
iOffset += MERNOLENGTH;
MSGLength -= MERNOLENGTH;
memcpy(TermNo,&pMSG[iOffset],BANKNOLENGTH);
// memcpy(TermNo,TermNo,8);
//TermNo1 = trim(TermNo);
memcpy(TermNo1,TermNo,8);
iOffset += BANKNOLENGTH;
MSGLength -= BANKNOLENGTH;
iFlag = pMSG[iOffset]; //标志位:0:产生随机数;1:密钥下载密码
iOffset += 1;
MSGLength -= 1;
if(iFlag == 1)
{
DownKeyLen = pMSG[iOffset]; // 密钥下载密码长度
if(DownKeyLen%8 != 0)
{
setCmdError2(pDataNode);
thd_log(LOG_WARNING,(char *)"OnGetRandom, Data Length is not 8 multiples !");
return 1;
}
// thd_log(LOG_DEBUG,(char *)"OnGetRandom, Data Length : %d",DownKeyLen);
iOffset += 1;
MSGLength -= 1;
memcpy(DownKey,&pMSG[iOffset],DownKeyLen); //随机数/密钥下载密码
}
else if(iFlag == 0) //需要产生随机数
{
GetRandom((unsigned char *)DownKey,8); //随机数长度为8
////测试数据,固定随机数
/* DownKey[0] = 0x88;
DownKey[1] = 0x77;
DownKey[2] = 0x66;
DownKey[3] = 0x55;
DownKey[4] = 0x44;
DownKey[5] = 0x33;
DownKey[6] = 0x22;
DownKey[7] = 0x11;*/
/////////////
DownKeyLen = 8;
memcpy(TRD,DownKey,8) ;
DesEncrypt(1,TRD,TRD,8,KeyRandom); //将随机数用固定密钥加密存放到数据库
bcd2asc(chTRD,(unsigned char *)TRD,8);
/*将产生的随机数根据终端号保存到数据库t_bank_key 的random字段*/
SAString sSql;
SACommand Cmd;
try
{
Cmd.setConnection(pDataNode->psaConn);
sSql.Format("update t_bank_key set random = trim('%s') where termno = trim('%s') ", chTRD,TermNo);
Cmd.setCommandText(sSql);
Cmd.Execute();
}
catch(SAException &x)
{
thd_log( LOG_ERROR,(char *)"SQLAPI Exception %s", _T(x.ErrText()));
thd_log( LOG_ERROR,(char *)"sSQL: %s", _T(sSql));
return false;
}
}
thd_log(LOG_DEBUG,(char *)"OnGetRandom...Random Data:");
trace_mem(LOG_DEBUG,(unsigned char *)DownKey,8);
unsigned char TTEK[17] ={0};
if( !CountTTEK(TermNo1, TTEK) ) //用终端号计算TTEK
{
setCmdError2(pDataNode);
return 1;
}
Des3Encrypt(1,(unsigned char *)EDownKey,(unsigned char *)DownKey,8,TTEK); //用产生的TTEK加密随机数或者下载密钥,返回给服务器
int iOutLen = 0;
iOutLen = 2+MERNOLENGTH+POSNOLENGTH+1;
setCmdToSeverSucceed(pDataNode,iOutLen,OutBuf);
OutBuf[iOutLen] = DownKeyLen;
iOutLen += 1;
if(DownKeyLen > 1023)
{
//.........这里部分代码省略.........
示例11: OnEncrypt0405
int OnEncrypt0405(QUEUE_LIST *pDataNode) //PinBlock转换,将终端加密的PinBlock转换为成员行密钥加密的PinBlock并将转换后的PinBlock发给sever,再传给银行
{
thd_log(LOG_DEBUG,(char *)"OnEncrypt0405...Received Data:");
trace_mem(LOG_DEBUG,(unsigned char *)pDataNode->Buffer,pDataNode->Length);
int MSGLength = pDataNode->Length; //报文(MSG)
unsigned char *pMSG = pDataNode->Buffer; //应先判断pMSG长度 看主账号这些数据是否存在
pMSG++;
MSGLength--;
int iOffset = 0;
char MerNo[MERNOLENGTH+1] = {0};
char TermNo[BANKNOLENGTH+1] = {0};
char destype;
char data[9]= {0}; //加密机返回的转换后data
memcpy(MerNo,&pMSG[0],MERNOLENGTH);
iOffset += MERNOLENGTH; //加字节商户号
MSGLength -=MERNOLENGTH;
memcpy(TermNo, &pMSG[iOffset], BANKNOLENGTH);
iOffset += BANKNOLENGTH; //加16字节银行终端号
MSGLength -= BANKNOLENGTH;
//char flag;
// flag = pMSG[iOffset]; //标志位‘0’:不对PINBLOCK作特殊处理 ,‘1’:对PINBLOCK作特殊处理
// iOffset += 1;
// MSGLength -=1;
destype = pMSG[iOffset]; //加密类型
iOffset += 1;
MSGLength -=1;
memcpy(data,&pMSG[iOffset],8); //转换前PinBlock
iOffset += 8;
MSGLength -=8;
int macklen = 0;
unsigned char mack[33] = {0};
try
{
SAString sSql;
SACommand Cmd;
Cmd.setConnection(pDataNode->psaConn);
sSql.Format("select b.MACKLEN,b.MACK from t_bank_key b where b.termno = trim('%s') and b.merno =trim('%s') ", TermNo,MerNo);
thd_log(LOG_DEBUG,(char *) "sSQL: %s", _T(sSql));
Cmd.setCommandText(sSql);
Cmd.Execute();
if (Cmd.FetchNext())
{
macklen = Cmd.Field("MACKLEN").asShort();
asc2bcd(mack,(char*)_T(Cmd.Field("MACK").asString())); //t_bank_key数据库中查找pink;
thd_log(LOG_DEBUG,(char *) "MACK :");
trace_mem(LOG_DEBUG, mack, 32);
}
else
{
thd_log(LOG_WARNING,(char *)"Port[%d] Peer[%d] Terminal[%s]: There's no MacK in t_bank_key!",
pDataNode->SrvrPort, pDataNode->PeerSockId, TermNo);
return false;
}
}
catch(SAException &x)
{
thd_log( LOG_ERROR,(char *)"OnEncrypt0405, SQLAPI Exception %s", _T(x.ErrText()));
return false;
}
char OutBuf[1024]; // 输出缓存
memset(OutBuf, 0, sizeof(OutBuf));
if(!PospEncryptPin(g_Cfg.forbankwk, destype, macklen, mack, data, pDataNode))
{
setCmdError1(pDataNode);
return 1;
}
int iOutLen = 0;
/* iOffset = 0;
memcpy(&OutBuf[iOutLen],&pDataNode->Buffer[0] ,1); //指令号CMD
iOutLen++;
OutBuf[iOutLen] = CMD_OK; //执行SQL成功
iOutLen++;
/////////////////////////////
//2011-07-01:修改协议,返回数据加上商户号和终端号
memcpy(&OutBuf[iOutLen],&pDataNode->Buffer[iOffset] ,MERNOLENGTH);
iOutLen += MERNOLENGTH;
iOffset += MERNOLENGTH;
memcpy(&OutBuf[iOutLen],&pDataNode->Buffer[iOffset] ,POSNOLENGTH);
iOutLen += POSNOLENGTH;
iOffset += POSNOLENGTH;
memcpy(&OutBuf[iOutLen],&pDataNode->Buffer[iOffset] ,BANKNOLENGTH);
iOutLen += BANKNOLENGTH;
iOffset += BANKNOLENGTH;
/////////////////////////////////*/
iOutLen = 2+MERNOLENGTH+BANKNOLENGTH;
setCmdToSeverSucceed(pDataNode,iOutLen,OutBuf);
memcpy(&OutBuf[iOutLen],data,8); //加密机返回的转换后的PinBlock
iOutLen += 8;
memcpy(pDataNode->Buffer, OutBuf, iOutLen);
pDataNode->Length = iOutLen ;
thd_log(LOG_DEBUG,(char *)"OnEncrypt0405, Output Buffer Data:");
trace_mem(LOG_DEBUG,(unsigned char *)pDataNode->Buffer,iOutLen);
return 1;
}
示例12: OnExecSQL
//CMD_EXECSQL
//远程客户端请求执行SQL
//请求: [B0: 协议字] [B1:是否需要返回结果集] [B2~B5: 请求的起始记录号] [B6~B9: 最大返回的记录数] [B10~Bn: SQL语句]
//响应: [B0: 协议字] [B1: 执行结果0|1] [B2: 是否还有后续数据0|1] [B3..Bn: CDS结果集]
int OnExecSQL(QUEUE_LIST *pDataNode)
{
#ifdef _SUPPORT_CLITR //支持客户端事务连接
if (NULL != pDataNode->psaConn)
{
SAConnection *p = pDataNode->pCliTr->getCliTrConn(pDataNode->SrvrPort, pDataNode->PeerSockId);
if (p) pDataNode->psaConn = p;
}
#endif
//报文(MSG)
unsigned char *p = pDataNode->Buffer;
p++;
int iStartRecNo, iMaxCount, iSqlLen;
bool bNeedReturnData = (*p == 1);
p++;
P2DW(iStartRecNo, p);
p += 4;
P2DW(iMaxCount, p);
p += 4;
P2W(iSqlLen, p);
p += 2;
if (iSqlLen > 8 * ONE_PACKSIZE)
{
setCmdError(pDataNode);
return 1;
}
unsigned char *pSQL = (unsigned char *) GetMem(iSqlLen + 1);
memcpy(pSQL, p, iSqlLen);
pSQL[iSqlLen] = 0;
thd_log(LOG_DEBUG,"Execute SQL: %s", pSQL);
SACommand saCmd;
try{
saCmd.setConnection(pDataNode->psaConn);
saCmd.setCommandText(_TSA(pSQL));
saCmd.Execute();
}
catch(SAException &x)
{
thd_log( LOG_ERROR,(char *)"SQLAPI Exception %s", _T(x.ErrText()));
setCmdError(pDataNode);
return 1;
}
p = &pDataNode->Buffer[1];
int iOutLen = 1;
*p++ = CMD_OK; //执行SQL成功
iOutLen++;
*p++ = 0x0;
iOutLen++;
//不需要返回数据
if (!bNeedReturnData)
{
//m_pDataNode->psaConn->Commit();
int rowUpd = saCmd.RowsAffected(); //更新的记录数
W2P(p, rowUpd);
iOutLen += 2;
pDataNode->Length = iOutLen;
FreeMem(pSQL);
return 1;
}
bool bHasNext = false;
p += 2;
//返回数据
int iRet = CopyDataSet(&bHasNext, p, ALL_PACKSIZE, &saCmd, iStartRecNo, iMaxCount);
p -= 2;
W2P(p, iRet); //记录集大小
if (bHasNext) pDataNode->Buffer[2] = 0x1; //存在未返回记录
iOutLen += 2 + iRet;
pDataNode->Length = iOutLen;
thd_log(LOG_DEBUG,"cdsfmt2 len = %d",pDataNode->Length);
trace_mem( LOG_DEBUG,pDataNode->Buffer, pDataNode->Length);
FreeMem(pSQL);
return 1;
}
示例13: Oracle_OCI_ATTR_CHARSET_FORM_OCI_ATTR_CHARSET_ID
void Oracle_OCI_ATTR_CHARSET_FORM_OCI_ATTR_CHARSET_ID()
{
SAConnection con;
SACommand cmd;
cmd.setConnection(&con);
try
{
con.Connect("cit", "dwadm", "dwadm", SA_Oracle_Client);
bool bDropTable = !false;
bool bCreateTable = !false;
if(bDropTable)
{
cmd.setCommandText(
"drop table test_charset");
cmd.Execute();
}
if(bCreateTable)
{
cmd.setCommandText(
"Create table test_charset (f1 nchar(254), f2 char(254))");
cmd.Execute();
}
cmd.setCommandText("delete from test_charset");
cmd.Execute();
cmd.setCommandText("insert into test_charset values (:1, :2)");
cmd.Param(1).setOption("OCI_ATTR_CHARSET_FORM") = "SQLCS_NCHAR";
cmd.Param(1).setOption("OCI_ATTR_CHARSET_ID") = "171";
cmd.Param(2).setOption("OCI_ATTR_CHARSET_ID") = "CL8MSWIN1251";
cmd.Param(1).setAsString() = "string f1 - 1";
cmd.Param(2).setAsValueRead() = cmd.Param(1);
cmd.Execute();
cmd.Param(1).setAsString() = "������ f1 - 2";
cmd.Param(2).setAsValueRead() = cmd.Param(1);
cmd.Execute();
cmd.setCommandText("select * from test_charset");
cmd.Execute();
cmd.Field(1).setOption("OCI_ATTR_CHARSET_ID") = "171";
cmd.Field(2).setOption("OCI_ATTR_CHARSET_ID") = "CL8MSWIN1251";
while(cmd.FetchNext())
{
cout
<< (const char*)cmd[1].asString()
<< ""
<< (const char*)cmd[2].asString()
<< endl;
}
}
catch(SAException &x)
{
try
{
con.Rollback();
}
catch(SAException &)
{
}
printf("%s\n", (const char*)x.ErrText());
}
}
示例14: trace_log
//冲正
int CTradeDoReset::DoPack(SAConnection *saConn, void * pNode,
unsigned char * pBuffer, unsigned & iBufLen)
{
if(saConn == NULL || pNode == NULL || pBuffer == NULL)
{
trace_log(ERR, "Paramter error!");
return RET_SYSEXP;
}
TRADEDATA * pData = (TRADEDATA *)pNode;
CTLVTemplet tlvObj;
if(1 != tlvObj.UnPackTLVData(pData->TransData.TlvDataLen, pData->TransData.TlvData))
{
trace_log(ERR, "UnPackTLVData fail!");
return RET_SYSEXP;
}
bool bFlag = true;
//unsigned char cFieldData[FIELD_MAXLEN]={0}, bFieldData[FIELD_MAXLEN]={0},
//unsigned int iFieldDataLen = 0;
POS_TRADE_TYPE posType = (POS_TRADE_TYPE)pData->TransData.HeadData.RTradeType;
if(m_unTradeOrgMap.empty())
initTredeTypeMap();
//冲正的时候不能隔批次
if(strcmp(pData->BatchNo, pData->TransData.HeadData.OrigLBatchNo))
{
trace_log(ERR, "The original BatchNo is different with the current one");
return RET_SYSEXP;
}
SAString sSql;
SACommand Cmd;
Cmd.setConnection(saConn);
try
{
//trace_log(DBG, "posType = %c, m_unTradeOrgMap[posType] = %c", posType, m_unTradeOrgMap[posType]);
sSql.Format("select FIELD2,FIELD3,FIELD4,FIELD11,FIELD14,FIELD22,FIELD32,FIELD33,FIELD35,FIELD36,FIELD41,"
"FIELD42,FIELD48,FIELD49,FIELD60,FIELD62 from T_CHANNEL_RESETLIST where FIELD11='%s' and FIELD41='%s'"
" and FIELD42='%s' and CRT_TYPE='%c' and CRT_BATCHNO='%s'", pData->TransData.HeadData.OrigLPosSeq,
pData->TransData.HeadData.arrRTermNo, pData->TransData.HeadData.arrRMerchNo,
m_unTradeOrgMap[posType], pData->TransData.HeadData.OrigLBatchNo);
Cmd.setCommandText(sSql);
Cmd.Execute();
if(!Cmd.FetchNext())
{
trace_log(ERR, "select original trade record fail[%s]!", _T(sSql));
strcpy(pData->TransData.HeadData.RspCode, "25");
return RET_SYSEXP;
}
//0消息类型
bFlag &= sndObj.SetValueByStr(0, "0420");
//2账号
bFlag &= sndObj.SetValueByStr(2, _T(Cmd.Field("FIELD2").asString()));
//3处理码
bFlag &= sndObj.SetValueByStr(3, _T(Cmd.Field("FIELD3").asString()));
//4金额
bFlag &= sndObj.SetValueByStr(4, _T(Cmd.Field("FIELD4").asString()));
//11流水号:此处需要新流水号,而62域要原流水号
bFlag &= sndObj.SetValueByStr(11, pData->VouchNo);
//14 卡有效期
SAString str = Cmd.Field("FIELD14").asString();
if(str.GetLength() > 0)
{
bFlag &= sndObj.SetValueByStr(14, _T(str));
}
if( posType >= 0x63 && posType <= 0x66)
{
//22 输入方式
bFlag &= sndObj.SetValueByStr(22, _T(Cmd.Field("FIELD22").asString()));
//35 二磁道
str = Cmd.Field("FIELD35").asString();
if(str.GetLength() > 0)
{
bFlag &= sndObj.SetValueByStr(35, _T(str));
}
//36 三磁道
str = Cmd.Field("FIELD36").asString();
if(str.GetLength() > 0)
{
bFlag &= sndObj.SetValueByStr(36, _T(str));
}
//48 自定义域
str = Cmd.Field("FIELD48").asString();
if(str.GetLength() > 0)
{
bFlag &= sndObj.SetValueByStr(48, _T(str));
}
//49 货币代码
bFlag &= sndObj.SetValueByStr(49, _T(Cmd.Field("FIELD49").asString()));
}
//32 受理机构代码
//.........这里部分代码省略.........
示例15: OnExecProc
int OnExecProc(QUEUE_LIST *pDataNode)
{
//报文(MSG)
unsigned char *p = pDataNode->Buffer;
p++;
char ProcName[255];
memset(ProcName, 0, sizeof(ProcName));
int iProcNameLen, iInputParaNums, iOutputParaNums;
P2W(iProcNameLen, p);
p += 2;
memcpy(ProcName, p, iProcNameLen);
p += iProcNameLen;
// 输入参数个数
P2W(iInputParaNums, p);
p += 2;
SACommand Cmd;
Cmd.setConnection(pDataNode->psaConn);
Cmd.setCommandText(ProcName);
char ParaName[255], ParaVaule[255];
int iLen;
for (int i = 0; i < iInputParaNums; i++)
{
BYTE ParaType = *p;
p++;
memset(ParaName, 0, sizeof(ParaName));
memset(ParaVaule, 0, sizeof(ParaVaule));
P2W(iLen, p);
p += 2;
memcpy(ParaName, p, iLen);
p += iLen;
P2W(iLen, p);
p += 2;
memcpy(ParaVaule, p, iLen);
p += iLen;
if (ParaType == 0x00)
Cmd.Param(ParaName).setAsLong() = atoi(ParaVaule);
else if (ParaType == 0x01)
Cmd.Param(ParaName).setAsString() = ParaVaule;
}
Cmd.Execute();
// 输出缓存
BYTE OutBuf[1024];
memset(OutBuf, 0, sizeof(OutBuf));
int iOffset = 0;
// 输出参数个数
memcpy(&OutBuf[iOffset], p, 2);
P2W(iOutputParaNums, p);
p += 2;
iOffset += 2;
for (int i = 0; i < iOutputParaNums; i++)
{
memset(ParaName, 0, sizeof(ParaName));
memset(ParaVaule, 0, sizeof(ParaVaule));
// 参数类型
BYTE ParaType = *p;
memcpy(&OutBuf[iOffset], p, 1);
p++;
iOffset ++;
// 参数名称
P2W(iLen, p);
memcpy(&OutBuf[iOffset], p, 2);
p += 2;
iOffset += 2;
memcpy(ParaName, p, iLen);
memcpy(&OutBuf[iOffset], p, iLen);
p += iLen;
iOffset += iLen;
// 参数值
if (ParaType == 0x00)
sprintf(ParaVaule, "%ld", Cmd.Param(ParaName).asLong());
else if (ParaType == 0x01)
strcpy(ParaVaule, Cmd.Param(ParaName).asString());
int iTempLen = strlen(ParaVaule);
BYTE *pLen = &OutBuf[iOffset];
W2P(pLen, iTempLen);
iOffset += 2;
memcpy(&OutBuf[iOffset], ParaVaule, iTempLen);
iOffset += iTempLen;
}
p = &pDataNode->Buffer[1];
int iOutLen = 1;
*p++ = CMD_OK; //执行SQL成功
iOutLen++;
//.........这里部分代码省略.........