// 函数名: Error_Deal // 编程 : 陈永华 2004-2-22 16:43:34 // 描述 : 清除原来准备的应答信息,并且在运行时跟踪文件中记录(错误)信息 建议新系统使用本函数替代原来的ERR_DEAL // 合并了原来需要用sprintf生成omsg // 返回 : int SendMsg返回信息 // 参数 : int retcode // 参数 : char *omsg OUT // 参数 : char *pFormat IN // 参数 : ... IN int Error_Deal(int retcode,char *omsg,char *pFormat,...) { va_list pArg; va_start(pArg,pFormat); vsprintf(omsg,pFormat,pArg); va_end(pArg); return(ERR_DEAL(omsg,retcode)); }
int CallBDFunc(int fno,TRUSERID *handle,ST_CPACK *rpack,ST_PACK *pArrays,int *iRetCode, char *szMsg) { int r=0; int rtn=0; int sendtype=0; char param[101]=""; #ifdef _DEBUG1 CMemoryState cm1, cm2, cm3; #endif APPFUNC pFunc = g_XBDefines[fno].pFunc; #ifdef _DEBUG1 cm1.Checkpoint(); #endif *iRetCode=0; *szMsg=0; g_pArrays=pArrays; rtn = (*pFunc)(handle,rpack->head.RequestType,&rpack->pack,iRetCode,szMsg); if(rtn) { //char sErrMsg[101]=""; //char sRetMsg[256]=""; //if(*szMsg) // snprintf(sRetMsg,256," %s",szMsg); //r=get_errcode_msg(*iRetCode, sErrMsg); //db_rollback(); //snprintf(szMsg,256,"%s%s\n%s",sErrMsg,sRetMsg,g_sqlmsg); if(0==*iRetCode) *iRetCode=rtn; writelog(LOG_ERR,"Func[%d]ecode[%d]msg[%s]",rpack->head.RequestType,*iRetCode,szMsg); ERR_DEAL(szMsg,*iRetCode); /* if(r) { AnswerData(handle,*iRetCode,szMsg); db_disconnect(); writelog(LOG_ERR,"数据库错误,系统退出"); exit(1); } */ } return(rtn); }
int CallBDFunc(int fno,TRUSERID *handle,ST_CPACK *rpack,ST_PACK *pArrays,int *iRetCode, char *szMsg) { int r=0; int rtn=0; int sendtype=0; char sRetMsg[256]=""; APPFUNC pFunc = g_XBDefines[fno].pFunc; #ifdef _DEBUG1 CMemoryState cm1, cm2, cm3; #endif #ifdef _DEBUG1 cm1.Checkpoint(); #endif *iRetCode=0; *szMsg=0; g_pArrays=pArrays; //判断是否是结帐时刻,如果是则等待处理 sendtype=rpack->head.RequestType; rtn = (*pFunc)(handle,rpack->head.RequestType,&rpack->pack,iRetCode,szMsg); #ifdef _DEBUG1 cm2.Checkpoint(); if (cm3.Difference(cm1, cm2)) { BCCMsgLogOut(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); g_LogFile.WriteLogEx(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); cm3.DumpStatistics(); } #endif if(rtn) { *iRetCode=rtn; ERR_DEAL(szMsg,*iRetCode); } //writelog(LOG_INFO,"%s:bu[%02d][%d] End",getdbtimestamp(NULL),g_pSvrLink->iThisProcID,rpack->head.RequestType); return(rtn); }
int CallBDFunc(int fno,TRUSERID *handle,ST_CPACK *rpack,ST_PACK *pArrays,int *iRetCode, char *szMsg) { int r=0; int rtn=0; int sendtype=0; char sRetMsg[256]=""; APPFUNC pFunc = g_XBDefines[fno].pFunc; CAccTrans& ats=CAccTrans::GetInst(); *iRetCode = ats.Reset(rpack); if(*iRetCode) goto NEXT; #ifdef _DEBUG1 CMemoryState cm1, cm2, cm3; #endif #ifdef _DEBUG1 cm1.Checkpoint(); #endif *iRetCode=0; *szMsg=0; g_pArrays=pArrays; //判断是否是结帐时刻,如果是则等待处理 sendtype=rpack->head.RequestType; g_pRequestCpack = rpack; //writelog(LOG_INFO,"%s:bu[%02d][%d]Start",getdbtimestamp(NULL),g_pSvrLink->iThisProcID,rpack->head.RequestType); switch(sendtype) { case 95: case 93: //#ifdef _DEBUG_CPACK // rtn=SaveCPackData(rpack); // if(rtn) // { // //writelog(LOG_ERR,"SaveCpackData err "); // strcpy(szMsg,"写流水日志表错误"); // ERR_DEAL( szMsg,rtn); // break; // } //#endif rtn = (*pFunc)(handle,rpack->head.RequestType,&rpack->pack,iRetCode,szMsg); #ifdef _DEBUG1 cm2.Checkpoint(); if (cm3.Difference(cm1, cm2)) { BCCMsgLogOut(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); g_LogFile.WriteLogEx(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); cm3.DumpStatistics(); } #endif break; default: rtn = (*pFunc)(handle,rpack->head.RequestType,&rpack->pack,iRetCode,szMsg); #ifdef _DEBUG1 cm2.Checkpoint(); if (cm3.Difference(cm1, cm2)) { BCCMsgLogOut(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); g_LogFile.WriteLogEx(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); cm3.DumpStatistics(); } #endif break; } if(rtn) { NEXT: if(*szMsg) snprintf(sRetMsg,256," %s",szMsg); if(*iRetCode==0) *iRetCode=rtn; if(*iRetCode<0) *iRetCode=E_COMMON_ERR; //get_errcode_msg(*iRetCode, sErrMsg); db_rollback(); snprintf(szMsg,256,"%s%s\n%s",ats.GetErrMsgTip(*iRetCode).c_str(),sRetMsg,g_sqlmsg); writelog(LOG_ERR,"Func[%d]errcode[%d]errmsg[%s]",rpack->head.RequestType,*iRetCode,szMsg); //writelog(LOG_ERR,"Func[%d]ecode[%d]msg[%s]",rpack->head.RequestType,*iRetCode,szMsg); ERR_DEAL(szMsg,*iRetCode); /* if(r) { AnswerData(handle,*iRetCode,szMsg); db_disconnect(); writelog(LOG_ERR,"数据库错误,系统退出"); exit(1); } */ } else { if(strncmp(rpack->pack.semp,"test",4)==0) db_rollback(); else { r=db_commit(); if(r) { r=E_DB_COMMIT; strcpy(szMsg,"数据库事务提交失败"); } if(r) { *iRetCode=r; db_rollback(); writelog(LOG_ERR,"Func[%d]Msg[%s]",rpack->head.RequestType,szMsg); ERR_DEAL(szMsg,*iRetCode); } } } //writelog(LOG_INFO,"%s:bu[%02d][%d] End",getdbtimestamp(NULL),g_pSvrLink->iThisProcID,rpack->head.RequestType); return(rtn); }
int CallBDFunc(int fno,TRUSERID *handle,ST_CPACK *rpack,ST_PACK *pArrays,int *iRetCode, char *szMsg) { int r=0; int rtn=0; int sendtype=0; char param[101]=""; #ifdef _DEBUG1 CMemoryState cm1, cm2, cm3; #endif APPFUNC pFunc = g_XBDefines[fno].pFunc; #ifdef _DEBUG1 cm1.Checkpoint(); #endif *iRetCode=0; *szMsg=0; g_pArrays=pArrays; //判断是否是结帐时刻,如果是则等待处理 sendtype=rpack->head.RequestType; switch(sendtype) { case 95: case 93: #ifdef _DEBUG_CPACK // rtn=SaveCPackData(rpack); // if(rtn) // { // //writelog(LOG_ERR,"SaveCpackData err "); // strcpy(szMsg,"写流水日志表错误"); // ERR_DEAL( szMsg,rtn); // break; // } #endif rtn = (*pFunc)(handle,rpack->head.RequestType,&rpack->pack,iRetCode,szMsg); #ifdef _DEBUG1 cm2.Checkpoint(); if (cm3.Difference(cm1, cm2)) { BCCMsgLogOut(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); g_LogFile.WriteLogEx(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); cm3.DumpStatistics(); } #endif break; default: rtn=GetParameter(GLOBE_FLAG_BALANCE,param); if(rtn) { *iRetCode=rtn; break; } else if(strncmp(param,"0",1)!=0) { rtn=E_DAYEND_STATUS; *iRetCode=rtn; break; } // rtn=SaveCPackData(rpack); // if(rtn) // { // //writelog(LOG_ERR,"SaveCpackData err "); // strcpy(szMsg,"写流水日志表错误"); // ERR_DEAL( szMsg,rtn); // break; // } rtn = (*pFunc)(handle,rpack->head.RequestType,&rpack->pack,iRetCode,szMsg); #ifdef _DEBUG1 cm2.Checkpoint(); if (cm3.Difference(cm1, cm2)) { BCCMsgLogOut(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); g_LogFile.WriteLogEx(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); cm3.DumpStatistics(); } #endif break; } if(rtn) { char sErrMsg[101]=""; char sRetMsg[256]=""; if(*szMsg) snprintf(sRetMsg,256," %s",szMsg); if(*iRetCode==0) *iRetCode=rtn; r=get_errcode_msg(*iRetCode, sErrMsg); db_rollback(); snprintf(szMsg,256,"%s%s\n%s",sErrMsg,sRetMsg,g_sqlmsg); writelog(LOG_ERR,"Func[%d]ecode[%d]msg[%s]",rpack->head.RequestType,*iRetCode,szMsg); ERR_DEAL(szMsg,*iRetCode); if(r) { AnswerData(handle,*iRetCode,szMsg); db_disconnect(); writelog(LOG_ERR,"数据库错误,系统退出"); exit(1); } } else { writelog(LOG_ERR,"Func[%d]Msg[%s]",rpack->head.RequestType,szMsg); if(strncmp(rpack->pack.scust_limit,"test",4)==0) db_rollback(); else { //记录操作员流水 r=db_commit(); if(r) { *iRetCode=E_DB_COMMIT; strcpy(szMsg,"数据库事务提交失败"); writelog(LOG_ERR,"Func[%d]Msg[%s]",rpack->head.RequestType,szMsg); db_rollback(); ERR_DEAL( szMsg,*iRetCode); } } } return(rtn); }
/* ****** Updated by CHENYH at 2004-4-9 10:06:44 ****** 增加pArrays: 为了能够接收处理多请求记录的情况 */ int CallBDFunc(int fno,TRUSERID *handle,ST_CPACK *rpack,ST_PACK *pArrays,int *iRetCode, char *szMsg) { int r=0; int rtn=0; int sendtype=0; char param[101]=""; #ifdef _DEBUG1 CMemoryState cm1, cm2, cm3; #endif APPFUNC pFunc = g_BDefines[fno].pFunc; #ifdef _DEBUG1 cm1.Checkpoint(); #endif *iRetCode=0; *szMsg=0; //判断是否是结帐时刻,如果是则等待处理 sendtype=rpack->head.RequestType/10000; switch(sendtype) { case 93: rtn = (*pFunc)(handle,rpack->head.RequestType,&rpack->pack,iRetCode,szMsg); break; default: rtn=GetParameter(GLOBE_FLAG_BALANCE,param); if(rtn) { *iRetCode=rtn; break; } else if(strncmp(param,"0",1)!=0) { rtn=E_DAYEND_STATUS; *iRetCode=rtn; break; } rtn = (*pFunc)(handle,rpack->head.RequestType,&rpack->pack,iRetCode,szMsg); break; } if(rtn) { char sErrMsg[60]=""; char sRetMsg[256]=""; if(*szMsg) snprintf(sRetMsg,256," %s",szMsg); r=get_errcode_msg(*iRetCode, sErrMsg); db_rollback(); snprintf(szMsg,256,"%s%s",sErrMsg,sRetMsg); writelog(LOG_ERR,"Func[%d]ecode[%d]msg[%s]",rpack->head.RequestType,*iRetCode,szMsg); ERR_DEAL(szMsg,*iRetCode); if(r) { AnswerData(handle,*iRetCode,szMsg); db_disconnect(); writelog(LOG_ERR,"数据库错误,系统退出"); exit(1); } } else { r=db_commit(); if(r) { *iRetCode=E_DB_COMMIT; strcpy(szMsg,"数据库事务提交失败"); writelog(LOG_ERR,"Func[%d]Msg[%s]",rpack->head.RequestType,szMsg); db_rollback(); ERR_DEAL( szMsg,*iRetCode); } } #ifdef _DEBUG1 cm2.Checkpoint(); if (cm3.Difference(cm1, cm2)) { BCCMsgLogOut(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); g_LogFile.WriteLogEx(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType); cm3.DumpStatistics(); } #endif if (g_BUnit.m_SqlDB.lErrorCode<=-10000) // 出现SQL比较严重的错误 { if (SQLIsConnectOK()==0) { SQLDisconnect(); } g_BUnit.m_SqlDB.lErrorCode = 0; } return(rtn); }