Ver Fonte

!10791 归并最新的st2分支到卡机日志精简分支
Merge pull request !10791 from 80174520/ST2

刘文涛80174520 há 3 meses atrás
pai
commit
f444fbb6ba

+ 28 - 0
CMakeLists.txt

@@ -887,6 +887,34 @@ if(WITH_PDB_SAVEV2)
 	install(CODE "MESSAGE(\"----Pack PDB File Done----\")" COMPONENT symbols)
 endif(WITH_PDB_SAVEV2)
 
+if(WITH_LABEL_RECORD AND DEVOPS_ON AND NOT DEVOPS_ON_CMAKE_PRD)
+	message(STATUS "PIPELINE_BRANCH: $ENV{PIPELINE_BRANCH}")
+	message(STATUS "PIPELINE_PRE_TAG: $ENV{PIPELINE_PRE_TAG}")
+	
+	set(LABEL_UPLOAD_ENV_STR $ENV{DEVOPS_ENV})
+	string(TOLOWER $ENV{DEVOPS_ENV} LABEL_UPLOAD_ENV_STR) #st|uat
+	
+	if(DEVOPS_ON_CMAKE_ST)
+		set(LABEL_UPLOAD_URL_PREFIX "http://55.11.56.122/rvc/LR04.02_RVCTerminalPlus_ST")
+	else()
+		set(LABEL_UPLOAD_URL_PREFIX "http://55.11.56.122/rvc/LR04.02_RVCTerminalPlus_UAT")
+	endif(DEVOPS_ON_CMAKE_ST)
+	set(LABEL_UPLOAD_URL "${LABEL_UPLOAD_URL_PREFIX}/RVCTerminalPlus-$ENV{PIPELINE_BRANCH}.zip")
+	set(LABEL_UPLOAD_URL_NAME "http://avsuser.paasst.cmbchina.cn/avsui/other-bean/insert-tmp-version-info")
+	if(MSVC)
+		set(LABEL_UPLOAD_PLATFORM "win")
+	else()
+		set(LABEL_UPLOAD_PLATFORM "uos")
+	endif(MSVC)
+	set(LABEL_UPLOAD_VERSION "${RVC_VERSION}")
+	set(LABEL_UPLOAD_UPDATER "DEVOPS_USER")
+	set(LABEL_UPLOADE_JSON_CONTENT "{\"version\":\"${LABEL_UPLOAD_VERSION}\",\"url\":\"${LABEL_UPLOAD_URL}\",\"env\":\"${LABEL_UPLOAD_ENV_STR}\",\"platform\":\"${LABEL_UPLOAD_PLATFORM}\",\"updater\":\"${LABEL_UPLOAD_UPDATER}\"}")
+	install(CODE "MESSAGE(\"----upload label info ${LABEL_UPLOAD_URL}----\")" COMPONENT symbols)
+	install(CODE "execute_process(COMMAND curl -X POST -H \"Content-Type: application/json\" -d ${LABEL_UPLOADE_JSON_CONTENT} ${LABEL_UPLOAD_URL_NAME})" COMPONENT symbols)
+	install(CODE "MESSAGE(\"----finished uploading label info ${LABEL_UPLOAD_URL}----\")" COMPONENT symbols)
+endif(WITH_LABEL_RECORD AND DEVOPS_ON AND NOT DEVOPS_ON_CMAKE_PRD)
+
+
 
 #appoint the component to install , except header file here.
  #set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)

+ 13 - 0
Framework/Common/RVCEventCode.h

@@ -27,4 +27,17 @@ inline CSimpleStringA DWORD2Hex(DWORD cur)
 #define RTAERR_SPHOST_IOM_FAILED			"RTA0021"	//iom create failed
 
 
+#define VTM_LAUNCH_RESERVERD_START			"RTA0030"
+#define VTM_LAUNCH_RESERVERD_END			"RTA003Z"
+
+//for public method of read/write(get/set)
+#define RTAERR_CONFIG_OPEN_FAILED			"RTA0041"	//->OpenConfig failed
+#define RTAERR_CONFIG_READ_FAILED			"RTA0042"	//->ReadConfigXXX failed
+#define RTAERR_CONFIG_WRITE_FAILED			"RTA0043"	//->WriteConfigXXX failed
+#define RTAERR_SYSVAR_REGIST_FAILED			"RTA0044"	//->RegistSysVarEvent failed
+#define RTAERR_SYSVAR_UNREGIST_FAILED		"RTA0045"	//->UnregistSysVarEvent failed
+#define RTAERR_SYSVAR_GET_FAILED			"RTA0046"	//->GetSysVar failed
+#define RTAERR_SYSVAR_SET_FAILED			"RTA0047"	//->SetSysVar failed
+#define RTAERR_GETPATH_FAILED				"RTA0048"	//->GetPath failed
+
 #endif

+ 3 - 3
Module/mod_ResourceWatcher/ResourceWatcherFSM.h

@@ -192,6 +192,7 @@ struct DeleteParam
 		delDirFlag = val;
 		if (delDirFlag) saveBackDay = 0;
 	}
+	//lpszPath:清理路径
 	CSimpleStringA path;
 	//控制是否将目录也一并删除,false 保留目录, true 删除目录
 	bool delDirFlag;
@@ -206,13 +207,12 @@ struct DeleteParam
 struct DeleteResult
 {
 	DeleteResult() :sucCnt(0), failCnt(0) {}
+	//删除成功个数
 	DWORD sucCnt;
+	//删除失败个数
 	DWORD failCnt;
-
 };
 
-const int DEFAULT_DAY_OF_BACKWARD = 90;
-
 class ResourceWatcherFSM : public FSMImpl<ResourceWatcherFSM>
 {
 public:

+ 149 - 129
Module/mod_pinpad/PinPadFSM.cpp

@@ -7,6 +7,7 @@
 #include "RVCComm.h"
 #include "sm4.h"
 #include "publicFunExport.h"
+#include "RVCEventCode.h"
 #include <fstream>
 #if defined(RVC_OS_LINUX)
 #include <thread>
@@ -61,7 +62,7 @@ void CPinPadFSM::s0_on_entry()
 	LOG_FUNCTION();
 	FSMEvent *e = new FSMEvent(USER_EVT_INIT);
 	PostEventFIFO(e);
-	m_ullConnectCost = SP::Module::Comm::RVCGetTickCount();
+	m_ullEntityStart = SP::Module::Comm::RVCGetTickCount();
 }
 void CPinPadFSM::s0_on_exit()
 {
@@ -274,7 +275,7 @@ void CPinPadFSM::s6_on_exit()
 }
 unsigned int CPinPadFSM::s6_on_event(FSMEvent* pEvt)
 {
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("s6 evt %d", pEvt->iEvt);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s6 evt %d", pEvt->iEvt);
 	switch (pEvt->iEvt)
 	{
 	default:
@@ -301,8 +302,7 @@ int CPinPadFSM::Initial()
 	eErrDev = pEntity->LoadVendorLibName();
 	if (eErrDev != Error_Succeed)
 	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("LoadVendorLibName(%d) failed.", eErrDev);
-		LogWarn(Severity_Middle, eErrDev, PinPad_UserErrorCode_Get_DevAdapter_Path_Failed, "Initial:LoadVendorLibName");
+		LogWarn(Severity_Middle, eErrDev, PinPad_UserErrorCode_Get_DevAdapter_Path_Failed, CSimpleStringA::Format("LoadVendorLibName failed,error:%d", eErrDev));
 		m_bOpening = false;
 		return Error_DevLoadFileFailed;
 	}
@@ -314,7 +314,7 @@ int CPinPadFSM::Initial()
 	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 	eErrDev = LoadUpAdapterLibrary();
 	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-	LogWarn(Severity_Low, Error_Unexpect, PinPad_UserErrorCode_LoadAdapterCost, CSimpleStringA::Format("%d", m_ullEndTime - m_ullBeginTime));
+	m_ullAdpFileLoadCost = m_ullEndTime - m_ullBeginTime;
 
 	if (!IS_SUCCEED(eErrDev))
 	{
@@ -334,14 +334,33 @@ int CPinPadFSM::Initial()
 
 		if (eErr == Error_Succeed)
 		{
+			//oiltmp@20240521 add for redundancy to check
+			CSmartPointer<IConfigInfo> spConfigCen;
+			int iTmp = 0;
+			GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spConfigCen);
+			if (spConfigCen->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "UseBackupSN", iTmp) == Error_Succeed)
+			{
+				if (iTmp == 1)
+					m_bUseBackupSN = true;
+				else if (iTmp > 1)//to except default value 0
+					m_bUseBackupSN = false;
+			}
+			iTmp = 0;
+			if (spConfigCen->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "SetParamOnce", iTmp) == Error_Succeed)
+			{
+				if (iTmp == 1)
+					m_bSetParamOnce = true;
+				else if (iTmp > 1)//to except default value 0
+					m_bSetParamOnce = false;
+			}
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::DevOpen").setCostTime(m_ullEndTime - m_ullBeginTime)();
 			initTries = 0;
 			ErrorCodeEnum errCode3, errCode4;
 			m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-			//errCode1 = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD,EPP_ALGO_METHOD_3DES);
-			//errCode2 = m_hDevHelper->SetParam(EPP_PT_SET_MAC_ALGORITH,EPP_MAC_ALGO_ASNIX99);
 			errCode3 = m_hDevHelper->SetParam(EPP_PT_SET_PIN_ALGORITH, EPP_PIN_ALGO_SM4);
-			errCode4 = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_3DEC_CBC);
+			errCode4 = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_3DEC_CBC);//oilyang@20250616 only add comment:for old adapter
+			if (m_bSetParamOnce)
+				errCode4 = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
 			m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
 
 			if (errCode3 != Error_Succeed || errCode4 != Error_Succeed)
@@ -366,23 +385,14 @@ int CPinPadFSM::Initial()
 	} while (initTries < PINPAD_INIT_TRIES);
 	m_bOpening = false;
 	if (initTries != 0)
-	{
-		LogEvent(Severity_Middle, LOG_EVT_PINPAD_OPEN_FAIL, "Open pinpad failed.");
-		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("Open pinpad failed.");
 		return 1;
-	}
 	SetDevInitFlag();
-	//oiltmp comment the following 20160406
-	//update with the version 1.7.1
-	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-	m_encryptkey = m_hDevHelper->GetEncryptFunc();
-	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::GetEncryptFunc").setCostTime(m_ullEndTime - m_ullBeginTime)("Error_Succeed");
+
 	CSmartPointer<IConfigInfo> spConfig;
 	eErrDev = GetEntityBase()->GetFunction()->OpenConfig(Config_Run, spConfig);
 	if (eErrDev != Error_Succeed)
 	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("read run cfg failed(sm).");
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode(RTAERR_CONFIG_OPEN_FAILED).setAPI(__FUNCTION__)("OpenConfig failed:%d", eErrDev);
 		m_bSMLoaded = false;
 		LogWarn(Severity_Middle, eErrDev, PinPad_UserErrorCode_Open_RunCfgFile_Failed, "Initial:OpenConfig");
 	}
@@ -396,7 +406,10 @@ int CPinPadFSM::Initial()
 		spConfig->ReadConfigValue("Load", "SN_SM", m_keySNSM);
 		spConfig->ReadConfigValue("Load", "ckckck", m_lastCheckCode);
 	}
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("encrypt key :%d,load key :%d", m_encryptkey, m_bSMLoaded);
+	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
+	m_encryptkey = m_hDevHelper->GetEncryptFunc();
+	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::GetEncryptFunc").setCostTime(m_ullEndTime - m_ullBeginTime)("encrypt key :%d,loaded key :%d,m_keySNSM:%s", m_encryptkey, m_bSMLoaded, m_keySNSM.GetData());
 	DevCategoryInfo devInfo;
 	ZeroMemory(devInfo.szModel, MAX_DEV_MODEL_LEN);
 	ZeroMemory(devInfo.szType, MAX_DEV_TYPE_LEN);
@@ -418,26 +431,23 @@ int CPinPadFSM::Initial()
 		SetErrorAndLog(eErrDev, MEC_DEVAPI_EPP_GetDevCategory, "DevAdapter::GetDevCategory", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime);
 
 	CSimpleStringA xTmpStr = CSimpleStringA::Format("(hw support):%d,load key :%d,SMSN:%s", m_encryptkey, m_bSMLoaded, m_keySNSM.GetData());
-	LogWarn(Severity_Low, Error_Unexpect, PinPad_UserErrorCode_DevConnect_CostTime, CSimpleStringA::Format("%d", SP::Module::Comm::RVCGetTickCount() - m_ullConnectCost));
+	ULLINT tmpAllCost = SP::Module::Comm::RVCGetTickCount() - m_ullEntityStart;
+	std::map<std::string, std::string> devConnInfo;
+	devConnInfo["AllCost"] = CSimpleStringA::Format("%d", tmpAllCost);
+	devConnInfo["AdpFileLoadCost"] = CSimpleStringA::Format("%d",m_ullAdpFileLoadCost);
+	devConnInfo["DevConnectCost"] = CSimpleStringA::Format("%d", tmpAllCost - m_ullAdpFileLoadCost);
+	std::pair<bool, std::string> strResult;
+	strResult = generateJsonStr(devConnInfo);
+
+	LogWarn(Severity_Low, Error_Unexpect, PinPad_UserErrorCode_DevConnect_CostTime, CSimpleStringA::Format("%s", strResult.second.c_str()));
 	LogWarn(Severity_Low, Error_Unexpect, PinPad_UserErrorCode_PinPad_InfoAboutKey_Onboot, xTmpStr.GetData());
 	LogEvent(Severity_Middle, LOG_EVT_PINPAD_OPEN_SUC, "Open pinpad suc.");
 
-	//oiltmp@20240521 add for redundancy to check
-	CSmartPointer<IConfigInfo> spConfigCen;
-	int iTmp = 0;
-	GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spConfigCen);
-	if (spConfigCen->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "UseBackupSN", iTmp) == Error_Succeed)
-	{
-		if (iTmp == 1)
-			m_bUseBackupSN = true;
-		else if (iTmp > 1)//to except default value 0
-			m_bUseBackupSN = false;
-	}
 	CSimpleStringA csRunInfo, csSNBakFile;
 	if ((eErr = GetEntityBase()->GetFunction()->GetPath("RunInfo", csRunInfo)) == Error_Succeed)
 	{
 		csSNBakFile = csRunInfo + SPLIT_SLASH_STR + "runcfg" + SPLIT_SLASH_STR + "snbak.dat";
-		ifstream infile(csSNBakFile, std::ofstream::binary);
+		ifstream infile(csSNBakFile.GetData(), std::ofstream::binary);
 		char* buffer = new char[16];
 		ZeroMemory(buffer, 16);
 		if (infile.is_open())
@@ -449,7 +459,7 @@ int CPinPadFSM::Initial()
 			if (m_bUseBackupSN)
 			{
 				m_keySNSM = buffer;
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("because save failed, use backup sn:%s", m_keySNSM.GetData());
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA2618")("because save failed, use backup sn : %s", m_keySNSM.GetData());
 			}
 		}
 		delete[] buffer;
@@ -478,10 +488,7 @@ unsigned int __stdcall DoWork(void *pData)
 			SpReqAnsContext<PinPadService_GetInputJS_Req, PinPadService_GetInputJS_Ans>::Pointer ctxJS;
 			bool bRet = pFsm->GetJSCtx(ctxJS);
 			if (!bRet)
-			{
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("get ctx(JS) failed.doing nothing");
 				continue;
-			}
 			ret = pFsm->GetInputJS(ctxJS);
 			evt = new FSMEvent(USER_EVT_GETINPUT_JS_FINISHED);
 		}
@@ -490,10 +497,7 @@ unsigned int __stdcall DoWork(void *pData)
 			SpReqAnsContext<PinPadService_GetInputSM_Req, PinPadService_GetInputSM_Ans>::Pointer ctxSM;
 			bool bRet = pFsm->GetCtx(ctxSM);
 			if (!bRet)
-			{
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("get ctx failed.doing nothing");
 				continue;
-			}
 			ret = pFsm->GetInput(ctxSM);
 			evt = new FSMEvent(USER_EVT_GETINPUT_SM_FINISHED);
 		}
@@ -633,8 +637,6 @@ ErrorCodeEnum CPinPadFSM::GetEncryptText(SpReqAnsContext<PinPadService_GetInputS
 	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
 	if (errCode != Error_Succeed)
 	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("[sm]set accout(%s)(%s) failed(%d).", (const char*)ctxSM->Req.account, accInfo.account, errCode);
-
 		DWORD dwUserCode = SetErrorAndLog(errCode, MEC_DEVAPI_EPP_SetAccNo, "DevAdapter::SetAccNo", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
 		ctxSM->Answer(Error_DevCommFailed, dwUserCode);
 		return Error_DevCommFailed;
@@ -656,17 +658,20 @@ ErrorCodeEnum CPinPadFSM::GetEncryptText(SpReqAnsContext<PinPadService_GetInputS
 		return Error_DevCommFailed;
 	}
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::ActiveWorkingKey").setCostTime(m_ullEndTime - m_ullBeginTime)();
-	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-	errCode = m_hDevHelper->SetParam(EPP_PT_SET_PIN_ALGORITH, EPP_PIN_ALGO_SM4);
-	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-	
-	if (errCode != Error_Succeed)
+	if (!m_bSetParamOnce)
 	{
-		DWORD dwUserCode = SetErrorAndLog(errCode, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
-		ctxSM->Answer(Error_DevCommFailed, dwUserCode);
-		return Error_DevCommFailed;
+		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
+		errCode = m_hDevHelper->SetParam(EPP_PT_SET_PIN_ALGORITH, EPP_PIN_ALGO_SM4);
+		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
+
+		if (errCode != Error_Succeed)
+		{
+			DWORD dwUserCode = SetErrorAndLog(errCode, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
+			ctxSM->Answer(Error_DevCommFailed, dwUserCode);
+			return Error_DevCommFailed;
+		}
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::SetParam").setCostTime(m_ullEndTime - m_ullBeginTime)();
 	}
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::SetParam").setCostTime(m_ullEndTime - m_ullBeginTime)();
 	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 	errCode = m_hDevHelper->StartPinInput(len);
 	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
@@ -761,7 +766,7 @@ ErrorCodeEnum CPinPadFSM::GetEncryptText(SpReqAnsContext<PinPadService_GetInputS
 				}
 				push_char(buf, &readed, '*');
 			}else{
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("else[%d]",btCh);
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode("RTA2619")("else[%d]", btCh);
 			}
 
 		}
@@ -784,7 +789,7 @@ Err:
 		delete[]buf;
 	if (bCancelInput)
 	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR040220602")("input cancel(pin)");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_USER)("input cancel(pin)");
 		ctxSM->Answer(Error_Cancel);
 		return Error_Cancel;
 	}
@@ -827,20 +832,23 @@ Err:
 		memcpy(srcInfo.data, m_devCheckData, m_devCheckData.GetLength());
 		srcInfo.dwSize = m_devCheckData.GetLength();
 		memset(dstInfo.data, 0, MAX_EN_DECRYPT_DATA_SIZE);
-		//set param
-		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-		errCode = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
-		if (errCode == Error_Succeed)
-			errCode = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
-		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-		
-		if (errCode != Error_Succeed)
+		if (!m_bSetParamOnce)
 		{
-			DWORD dwUserCode = SetErrorAndLog(errCode, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
-			ctxSM->Answer(Error_Param, dwUserCode);
-			return Error_Param;
+			//set param
+			m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
+			errCode = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
+			if (errCode == Error_Succeed)
+				errCode = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
+			m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
+
+			if (errCode != Error_Succeed)
+			{
+				DWORD dwUserCode = SetErrorAndLog(errCode, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
+				ctxSM->Answer(Error_Param, dwUserCode);
+				return Error_Param;
+			}
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::SetParam").setCostTime(m_ullEndTime - m_ullBeginTime)();
 		}
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::SetParam").setCostTime(m_ullEndTime - m_ullBeginTime)();
 		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 		errCode = m_hDevHelper->EncryptData(srcInfo, dstInfo);
 		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
@@ -942,7 +950,9 @@ int CPinPadFSM::GetInput(SpReqAnsContext<PinPadService_GetInputSM_Req, PinPadSer
 			.setResultCode(GetEntityBase()->GetFunction()->UserCodeToRTACode(dwUserCode))("OnExit:close pinpad(%d).", SpStrError(errClosePinPad));
 	}
 	else
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)("StopInput cost(%d)ms", m_ullEndTime - m_ullBeginTime);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
+		("StopInput cost:%d(ms), req acc.len:%d,confirm:%d,len:%d. ans:ck.len:%d,traceid[%s]", m_ullEndTime - m_ullBeginTime, m_inputSMCtx->Req.account.GetLength(), m_inputSMCtx->Req.confirm
+			, m_inputSMCtx->Req.length, m_inputSMCtx->Ans.checkcode.IsNullOrEmpty() ? 0 : m_inputSMCtx->Ans.checkcode.GetLength(), m_inputSMCtx->link.traceId.GetData());
 
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)
 		("req acc.len:%d,confirm:%d,len:%d. ans:ck.len:%d,traceid[%s]", m_inputSMCtx->Req.account.GetLength(), m_inputSMCtx->Req.confirm
@@ -972,7 +982,7 @@ int CPinPadFSM::LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadSe
 	eErr = spEntityFunction->OpenConfig(Config_Run, spConfig);
 	if (eErr != Error_Succeed)
 	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("LoadKeySM::OpenConfig failed,eErr:%d", eErr);
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode(RTAERR_CONFIG_OPEN_FAILED).setAPI(__FUNCTION__)("OpenConfig failed,eErr:%d", eErr);
 		spConfig = NULL;
 		ctx->Answer(eErr, PinPad_UserErrorCode_Open_RunCfgFile_Failed);
 		return 0;
@@ -980,7 +990,7 @@ int CPinPadFSM::LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadSe
 
 	if (!(ctx->Req.smflag == 1))
 	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("密钥标识不支持,ctx->Req.smflag:%d", ctx->Req.smflag);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("密钥标识不支持,ctx->Req.smflag:%d", ctx->Req.smflag);
 		ctx->Answer(Error_Unexpect, PinPad_UserErrorCode_UnknownSMFlag);
 		return 0;
 	}
@@ -1059,7 +1069,7 @@ int CPinPadFSM::LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadSe
 		eErr = spConfig->WriteConfigValueInt("Load", "SM", 1);
 		if (eErr != Error_Succeed)
 		{
-			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setResultCode(GetEntityBase()->GetFunction()->UserCodeToRTACode(PinPad_UserErrorCode_Write_RunCfgFile_Failed))("写密钥加载标识失败:%s", SpStrError(eErr));
+			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setResultCode(RTAERR_CONFIG_WRITE_FAILED)("写密钥加载标识失败:%s", SpStrError(eErr));
 			LogWarn(Severity_Middle, Error_Unexpect, PinPad_UserErrorCode_Write_RunCfgFile_Failed, CSimpleStringA::Format("写密钥加载标识失败:%s", SpStrError(eErr)));
 		}
 
@@ -1067,7 +1077,7 @@ int CPinPadFSM::LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadSe
 		{
 			if ((eErr = spConfig->WriteConfigValue("Load", "SN_SM", ctx->Req.reserved3)) != Error_Succeed)
 			{
-				DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setResultCode(GetEntityBase()->GetFunction()->UserCodeToRTACode(PinPad_UserErrorCode_Write_RunCfgFile_Failed))("写密钥序号失败:%s", SpStrError(eErr));
+				DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setResultCode(RTAERR_CONFIG_WRITE_FAILED)("写密钥序号失败:%s", SpStrError(eErr));
 				LogWarn(Severity_Middle, Error_Unexpect, PinPad_UserErrorCode_Write_RunCfgFile_Failed, CSimpleStringA::Format("写密钥序号失败:%s", SpStrError(eErr)));
 			}
 			m_keySNSM = ctx->Req.reserved3;
@@ -1110,22 +1120,24 @@ int CPinPadFSM::EncryptSM(SpReqAnsContext<PinPadService_EncryptDataSM_Req, PinPa
 
 	if (!(ctx->Req.smflag == 1))
 	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("密钥标识不支持,ctx->Req.smflag:%d", ctx->Req.smflag);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("密钥标识不支持,ctx->Req.smflag:%d", ctx->Req.smflag);
 		ctx->Answer(Error_Unexpect, PinPad_UserErrorCode_UnknownSMFlag);
 		return 0;
 	}
-	//set param
-	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-	if (m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4) != Error_Succeed
-		|| m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC) != Error_Succeed)
+	if (!m_bSetParamOnce)
 	{
-		DWORD dwUserCode = SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime);
-		ctx->Answer(Error_Unexpect, dwUserCode);
-		m_bEncrypt = false;
-		return 0;
+		//set param
+		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
+		if (m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4) != Error_Succeed
+			|| m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC) != Error_Succeed)
+		{
+			DWORD dwUserCode = SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime);
+			ctx->Answer(Error_Unexpect, dwUserCode);
+			m_bEncrypt = false;
+			return 0;
+		}
+		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
 	}
-	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-
 	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 	ErrorCodeEnum eErr = m_hDevHelper->ActiveWorkingKey(1, 1);
 	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
@@ -1179,25 +1191,30 @@ ErrorCodeEnum CPinPadFSM::GetCheckCode(SpReqAnsContext<PinPadService_GetCheckCod
 	for (int i = 0; i < ctx->Req.mSN.GetCount(); i++)
 	{
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("mSN:%d,wSN:%d,origData[%s]", ctx->Req.mSN[i], ctx->Req.wSN[i], m_devCheckData.GetData());
-		//set param
-		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-		if (ctx->Req.mSN[i] == 1)
-			eErr = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
-		else
+		if (!m_bSetParamOnce)
 		{
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("mSN:%d", ctx->Req.mSN[i]);
-			ctx->Ans.checkcode[i] = "";
-			ctx->Ans.index[i] = "";
-			continue;
-		}
-		if (eErr == Error_Succeed)
-			eErr = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
-		if (eErr != Error_Succeed)
-		{
-			SetErrorAndLog(eErr, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, false, m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetCheckCode);
-			return Error_DevCommFailed;
+			//set param
+			m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
+			if (ctx->Req.mSN[i] == 1)
+			{
+				eErr = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
+			}
+			else
+			{
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("not sm, mSN:%d", ctx->Req.mSN[i]);
+				ctx->Ans.checkcode[i] = "";
+				ctx->Ans.index[i] = "";
+				continue;
+			}
+			if (eErr == Error_Succeed)
+				eErr = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
+			if (eErr != Error_Succeed)
+			{
+				SetErrorAndLog(eErr, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, false, m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetCheckCode);
+				return Error_DevCommFailed;
+			}
+			m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
 		}
-		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
 
 		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 		eErr = m_hDevHelper->ActiveWorkingKey(ctx->Req.mSN[i], ctx->Req.wSN[i]);
@@ -1328,8 +1345,6 @@ ErrorCodeEnum CPinPadFSM::GetEncryptTextJS(SpReqAnsContext<PinPadService_GetInpu
 	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
 	if (errCode != Error_Succeed)
 	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("[sm]set accout(%s)(%s) failed(%d).", (const char*)ctxJS->Req.account, accInfo.account, errCode);
-
 		DWORD dwUserCode = SetErrorAndLog(errCode, MEC_DEVAPI_EPP_SetAccNo, "DevAdapter::SetAccNo", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
 		ctxJS->Answer(Error_DevCommFailed, dwUserCode);
 		return Error_DevCommFailed;
@@ -1351,17 +1366,20 @@ ErrorCodeEnum CPinPadFSM::GetEncryptTextJS(SpReqAnsContext<PinPadService_GetInpu
 		return Error_DevCommFailed;
 	}
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::ActiveWorkingKey").setCostTime(m_ullEndTime - m_ullBeginTime)();
-	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-	errCode = m_hDevHelper->SetParam(EPP_PT_SET_PIN_ALGORITH, EPP_PIN_ALGO_SM4);
-	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-
-	if (errCode != Error_Succeed)
+	if (!m_bSetParamOnce)
 	{
-		DWORD dwUserCode = SetErrorAndLog(errCode, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
-		ctxJS->Answer(Error_DevCommFailed, dwUserCode);
-		return Error_DevCommFailed;
+		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
+		errCode = m_hDevHelper->SetParam(EPP_PT_SET_PIN_ALGORITH, EPP_PIN_ALGO_SM4);
+		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
+
+		if (errCode != Error_Succeed)
+		{
+			DWORD dwUserCode = SetErrorAndLog(errCode, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
+			ctxJS->Answer(Error_DevCommFailed, dwUserCode);
+			return Error_DevCommFailed;
+		}
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::SetParam").setCostTime(m_ullEndTime - m_ullBeginTime)();
 	}
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::SetParam").setCostTime(m_ullEndTime - m_ullBeginTime)();
 	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 	errCode = m_hDevHelper->StartPinInput(CurrentPasswordLen);
 	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
@@ -1415,7 +1433,7 @@ ErrorCodeEnum CPinPadFSM::GetEncryptTextJS(SpReqAnsContext<PinPadService_GetInpu
 				push_char(buf, &readed, '*');
 			}
 			else {
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("else[%d]", btCh);
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode("RTA2619")("else[%d]", btCh);
 			}
 
 		}
@@ -1432,7 +1450,7 @@ Err:
 		delete[]buf;
 	if (bCancelInput)
 	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR040220602")("input cancel(pin)");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_USER)("input cancel(pin)");
 		ctxJS->Answer(Error_Cancel);
 		return Error_Cancel;
 	}
@@ -1475,20 +1493,23 @@ Err:
 		memcpy(srcInfo.data, m_devCheckData, m_devCheckData.GetLength());
 		srcInfo.dwSize = m_devCheckData.GetLength();
 		memset(dstInfo.data, 0, MAX_EN_DECRYPT_DATA_SIZE);
-		//set param
-		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-		errCode = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
-		if (errCode == Error_Succeed)
-			errCode = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
-		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-
-		if (errCode != Error_Succeed)
+		if (!m_bSetParamOnce)
 		{
-			DWORD dwUserCode = SetErrorAndLog(errCode, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
-			ctxJS->Answer(Error_Param, dwUserCode);
-			return Error_Param;
+			//set param
+			m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
+			errCode = m_hDevHelper->SetParam(EPP_PT_SET_ENCRYPT_METHOD, EPP_ALGO_METHOD_SM4);
+			if (errCode == Error_Succeed)
+				errCode = m_hDevHelper->SetParam(EPP_PT_SET_ECB_CBC_MODE, EPP_ALGO_MODE_CBC);
+			m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
+
+			if (errCode != Error_Succeed)
+			{
+				DWORD dwUserCode = SetErrorAndLog(errCode, MEC_DEVAPI_EPP_SetParam, "DevAdapter::SetParam", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
+				ctxJS->Answer(Error_Param, dwUserCode);
+				return Error_Param;
+			}
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::SetParam").setCostTime(m_ullEndTime - m_ullBeginTime)();
 		}
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::SetParam").setCostTime(m_ullEndTime - m_ullBeginTime)();
 		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 		errCode = m_hDevHelper->EncryptData(srcInfo, dstInfo);
 		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
@@ -1579,13 +1600,12 @@ int CPinPadFSM::GetInputJS(SpReqAnsContext<PinPadService_GetInputJS_Req, PinPadS
 			.setResultCode(GetEntityBase()->GetFunction()->UserCodeToRTACode(dwUserCode))("OnExit:close pinpad(%d).", SpStrError(errClosePinPad));
 	}
 	else
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)("StopInput cost(%d)ms", m_ullEndTime - m_ullBeginTime);
-
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)
-		("req acc.len:%d,ans.ck.len:%d,traceId:[%s]", m_inputJSCtx->Req.account.GetLength(), m_inputJSCtx->Ans.checkcode.IsNullOrEmpty() ? 0 : m_inputJSCtx->Ans.checkcode.GetLength()
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
+		("StopInput cost:%d(ms), req acc.len:%d,ans.ck.len:%d,traceId:[%s]", m_ullEndTime - m_ullBeginTime, m_inputJSCtx->Req.account.GetLength(), m_inputJSCtx->Ans.checkcode.IsNullOrEmpty() ? 0 : m_inputJSCtx->Ans.checkcode.GetLength()
 			, m_inputJSCtx->link.traceId.GetData());
-	DbgToBeidou(m_inputJSCtx->link, "GetInput")();
-	m_bPinInput = false;
+		
+	DbgToBeidou(m_inputJSCtx->link, "GetInputJS")();
+	m_bPinInputJS = false;
 	LogEvent(Severity_Middle, LOG_EVT_PINPAD_GREEN_OFF, "PinPad light off.");
 
 	if (eErrCode == Error_Succeed)

+ 5 - 3
Module/mod_pinpad/PinPadFSM.h

@@ -174,7 +174,7 @@ public:
 		, m_dwDevCommFailCount(0), m_dwPinPadRunCount(0), m_encryptkey(1)
 		, m_bSM(false), m_bSMLoaded(false), m_szModel(""), m_szType("")
 		, m_szVendor(""),m_csMachineType(true), m_terminalNo(true)
-		, m_bPinInputJS(false), m_bUseBackupSN(true){
+		, m_bPinInputJS(false), m_bUseBackupSN(true), m_bSetParamOnce(false){
 			HARDWARE_ENTITY_RESET_ENTITYID(m_entCode, 0x206);
 			ZeroMemory(&m_adapterInfo, sizeof(m_adapterInfo));
 	}
@@ -222,6 +222,7 @@ public:
 	{
 		m_inputSMCtx = ctxSM;
 		m_bPinInput = true;
+		m_bPinInputJS = false;
 	}
 	bool GetCtx(SpReqAnsContext<PinPadService_GetInputSM_Req, PinPadService_GetInputSM_Ans>::Pointer& ctxSM)
 	{
@@ -237,6 +238,7 @@ public:
 	{
 		m_inputJSCtx = ctxJS;
 		m_bPinInputJS = true;
+		m_bPinInput = false;
 	}
 	bool GetJSCtx(SpReqAnsContext<PinPadService_GetInputJS_Req, PinPadService_GetInputJS_Ans>::Pointer& ctxJS)
 	{
@@ -283,8 +285,8 @@ private:
 	SpReqAnsContext<PinPadService_GetInputJS_Req, PinPadService_GetInputJS_Ans>::Pointer m_inputJSCtx;
 	char m_szAccount[MAX_ACCOUNT_LEN];
 	bool m_bFrontCancel,m_bWaitingMore,m_bExit,m_bPlainPin,m_bEntityExit
-		,m_bPinInput,m_bLoadKey,m_bEncrypt,m_bSM,m_bSMLoaded, m_bPinInputJS, m_bUseBackupSN/*if use backup sn*/;
-	ULLINT m_ullBeginTime, m_ullEndTime,m_ullConnectCost;
+		,m_bPinInput,m_bLoadKey,m_bEncrypt,m_bSM,m_bSMLoaded, m_bPinInputJS, m_bUseBackupSN/*if use backup sn*/, m_bSetParamOnce/*call SetParam Only once*/;
+	ULLINT m_ullBeginTime, m_ullEndTime, m_ullAdpFileLoadCost, m_ullEntityStart;
 	CSimpleStringA m_deviceNo, m_devCheckData,m_keySNSM,m_szModel,m_szType,m_szVendor;
 	char m_buf[4];
 	DWORD m_dwDevCommFailCount,m_dwPinPadRunCount;

+ 1 - 1
Module/mod_pinpad/PinPad_UserErrorCode.h

@@ -15,7 +15,7 @@ enum PinPad_UserErrorCode {
 	PinPad_UserErrorCode_KEY_LOST_SM = 0x2060020A,
 	PinPad_UserErrorCode_PINPAD_KEY_LOST = 0x2060020B,
 	PinPad_UserErrorCode_Create_Event_Failed = 0x2060020C,
-	PinPad_UserErrorCode_LoadAdapterCost = 0x2060020d,	//the cost time of load vendor adapter dll/so file
+	//PinPad_UserErrorCode_LoadAdapterCost = 0x2060020d,	//the cost time of load vendor adapter dll/so file
 	PinPad_UserErrorCode_Load_Dll_File_Failed = 0x2060020E,
 	PinPad_UserErrorCode_GET_CDC_ADDR_Failed = 0x2060020F,
 	PinPad_UserErrorCode_GET_RDC_ADDR_Failed = 0x20600210,

+ 141 - 71
Tool/VTMLauncher/VTM_IL.cpp

@@ -5,6 +5,7 @@
 #include "VTM_IL.h"
 
 #include<string>
+#include<regex>
 #include <windows.h>                  
 #include <shellapi.h>
 #include <fstream>
@@ -13,6 +14,7 @@
 using namespace std;
 
 #define MAX_LOADSTRING 100
+#define ERROR_TITILE "可视柜台终端应用程序"
 
 const int HOTKEY_ID = 1;
 
@@ -40,15 +42,14 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
 	UNREFERENCED_PARAMETER(hPrevInstance);
 	UNREFERENCED_PARAMETER(lpCmdLine);
 
- 	// TODO: 在此放置代码。
 	MSG msg;
 	HACCEL hAccelTable;
 
-	// 初始化全局字符串
+	// 初始化全局字符串	
 	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
 	LoadString(hInstance, IDC_TEST, szWindowClass, MAX_LOADSTRING);
 	MyRegisterClass(hInstance);
-
+	Sleep(200);
 	// 执行应用程序初始化:
 	if (!InitInstance (hInstance, nCmdShow))
 	{
@@ -106,6 +107,45 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
 	return RegisterClassEx(&wcex);
 }
 
+BOOL ExistsFileA(LPCSTR lpFilePath)
+{
+	DWORD dwRet = GetFileAttributesA(lpFilePath);
+	return (dwRet != INVALID_FILE_ATTRIBUTES) && !(dwRet & FILE_ATTRIBUTE_DIRECTORY);
+}
+
+BOOL ExistsDirA(LPCSTR lpDirPath)
+{
+	DWORD dwRet = GetFileAttributesA(lpDirPath);
+	return (dwRet != INVALID_FILE_ATTRIBUTES) && (dwRet & FILE_ATTRIBUTE_DIRECTORY);
+}
+
+UINT GetErrorMessage(CString& retMessage, LPCTSTR lpDefault, DWORD error = GetLastError())
+{
+	if (error == 0) {
+		retMessage = lpDefault;
+		return strlen(lpDefault);
+	}
+	LPVOID lpMsgBuf;
+	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
+		| FORMAT_MESSAGE_FROM_SYSTEM
+		| FORMAT_MESSAGE_IGNORE_INSERTS,
+		NULL,
+		error,
+		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+		(LPTSTR)&lpMsgBuf,
+		0,
+		NULL);
+	if (lpMsgBuf == NULL) {
+		retMessage = lpDefault;
+		return strlen(lpDefault);
+	}
+	CString strTemp;
+	strTemp.Format("错误描述:%s", (LPCTSTR)lpMsgBuf);
+	retMessage = strTemp;
+	LocalFree((LPVOID)lpMsgBuf);
+	return retMessage.GetLength();
+}
+
 int GetVersion(char** pVersion)
 {
 	char szFileName[MAX_PATH] = {0};
@@ -115,32 +155,45 @@ int GetVersion(char** pVersion)
 	int nPos = strFileName.find_last_of("\\");
 	string strDir = strFileName.substr(0, nPos);
 	sprintf_s(szFilePath, MAX_PATH,"%s\\active.txt", strDir.c_str());
+	if (!ExistsFileA(szFilePath)) {
+		CString strText;
+		strText.Format("[RTA0031] 版本文件不存在,请重新安装程序版本!");
+		MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
+		return 0;
+	}
 
-	char cVer[MAX_PATH] = {0};
 	ifstream infile(szFilePath);
-	if(infile) // 有该文件
+	if(infile.is_open())
 	{
-		if(infile.getline(cVer, MAX_PATH))
-		{
-			memcpy_s(*pVersion, MAX_PATH, cVer, MAX_PATH);
+		std::string line;
+		if(std::getline(infile, line)){
+			CString strVersionTxt(line.c_str());
+			memcpy_s(*pVersion, MAX_PATH, strVersionTxt.GetString(), MAX_PATH);
 			infile.close();
-
 			return 1;
 		}
 		else
 		{
-			MessageBoxA(NULL,"获取版本信息失败:文件内容为空",NULL,0);
+			CString strText;
+			strText.Format("[RTA0032] 版本文件内容为空,请重新安装程序版本!");
+			MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
+			infile.close();
 			return 0;
-		}		
+		}
 	}
-	else
-	{
-		MessageBoxA(NULL,"获取版本信息失败:文件打开失败",NULL,0);	
+	else {
+		const DWORD dwError = GetLastError();
+		CString strText;
+		CString strError;
+		char szDefault[128];
+		sprintf_s(szDefault, "错误描述:%u", dwError);
+		GetErrorMessage(strError, szDefault, dwError);
+		strText.Format("[RTA0033] 版本文件打开失败,请联系分行IT或厂商排查!\r\n\r\n%s", strError.GetBuffer());
+		MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
 		return 0;
 	}
 
 	infile.close();
-
 	return 0;
 }
 
@@ -156,34 +209,46 @@ BOOL GetSpShellPath(char** pPath)
 	int nPos = strFileName.find_last_of("\\");
 	string strDir = strFileName.substr(0, nPos);
 
-	if(GetVersion(&pVer))
+	if(!GetVersion(&pVer))
 	{
-		sprintf_s(szFilePath, MAX_PATH, "%s\\%s\\bin\\SpShell.exe", strDir.c_str(), pVer);
+		if (NULL != pVer)
+		{
+			delete [] pVer;
+			pVer = NULL;
+		}
+		return FALSE;
 	}
-	else
-	{
+	memset(szFileName, 0, sizeof(szFileName));
+	sprintf_s(szFileName, MAX_PATH, "%s\\%s", strDir.c_str(), pVer);
+	if (!ExistsDirA(szFileName)) {
+		CString strText;
+		strText.Format("[RTA0034] 版本文件夹 [%s] 不存在,请重新安装程序版本!",pVer);
+		MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
+		if (NULL != pVer)
+		{
+			delete[] pVer;
+			pVer = NULL;
+		}
 		return FALSE;
 	}
 
-	
+	sprintf_s(szFilePath, MAX_PATH, "%s\\%s\\bin\\SpShell.exe", strDir.c_str(), pVer);
 	memcpy_s(*pPath, MAX_PATH, szFilePath, MAX_PATH);
 
 	if (NULL != pVer)
 	{
-		free(pVer);
+		delete[] pVer;
 		pVer = NULL;
 	}
 
-	ifstream shellFile(*pPath);
-	if(shellFile)
-	{
-		return TRUE;
-	}
-	else
-	{
-		MessageBoxA(NULL,"获取执行文件失败:文件无效或文件不存在",NULL,0);
+	if (!ExistsFileA(*pPath)) {
+		CString strText;
+		strText.Format("[RTA0035] 程序执行文件不存在,请重新安装程序版本!(文件路径:%s)", *pPath);
+		MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
 		return FALSE;
 	}
+
+	return TRUE;
 }
 
 BOOL Execute(const char* cExeName)
@@ -195,11 +260,14 @@ BOOL Execute(const char* cExeName)
 
 	if (!ShellExecuteExA(&sei))
 	{
-		DWORD dwError = GetLastError();
-		char szError[128];
-		memset(szError, '\0', 128);
-		sprintf_s(szError, 128, "执行应用程序失败:%u", dwError);
-		MessageBoxA(NULL, szError,NULL,0);
+		const DWORD dwError = GetLastError();
+		CString strText;
+		CString strError;
+		char szDefault[128];
+		sprintf_s(szDefault, "错误描述:%u", dwError);
+		GetErrorMessage(strError, szDefault, dwError);
+		strText.Format("[RTA0036] 执行应用程序文件失败,请联系分行IT或厂商排查!\r\n\r\n%s", strError.GetBuffer());
+		MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
 		return FALSE;
 	}
 
@@ -208,53 +276,60 @@ BOOL Execute(const char* cExeName)
 
 BOOL RunSpshell()
 {
+	BOOL ret = FALSE;
+
 	char* pSpPath = new char[MAX_PATH];
 	memset(pSpPath, 0, MAX_PATH);
 
-	if (!GetSpShellPath(&pSpPath))
+	do 
 	{
-		return FALSE;
-	}
+		if (!GetSpShellPath(&pSpPath))
+		{
+			break;
+		}
+		if (!Execute(pSpPath))
+		{
+			break;
+		}
+		ret = TRUE;
 
-	if (!Execute(pSpPath))
-	{
-		return FALSE;
-	}
+	} while (false);
 
 	if (NULL != pSpPath)
 	{
-		free(pSpPath);
+		delete[] pSpPath;
 		pSpPath = NULL;
 	}
-
-	return TRUE;
+	return ret;
 }
 
 //校正
-void checkActiveTxtAttr()
+int checkActiveTxtAttr()
 {
 	char vtmexePath[MAX_PATH] = {0};
 	GetModuleFileNameA(NULL, vtmexePath, sizeof(vtmexePath));
 	string strRunVtmPath = vtmexePath;
-	int nPosVtm = strRunVtmPath.find_first_of("\\version\\VTM.exe");
-	if(nPosVtm<0)
+	const auto nPosVtm = strRunVtmPath.find("\\version\\VTM.exe");
+	if(nPosVtm == -1)
 	{
-		MessageBoxA(NULL,"VTM.exe 不在X:\\version\\VTM.exe下",NULL,0);
-		return ;
+		MessageBoxA(NULL,"[RTA0030] 可视柜台应用程序不在规定路径下执行,请重新安装程序版本!", ERROR_TITILE, MB_OK | MB_ICONERROR);
+		return -1;
 	}
-	int nPos = strRunVtmPath.find_last_of("\\");
+	const int nPos = strRunVtmPath.find_last_of("\\");
 	string strVersionDir = strRunVtmPath.substr(0, nPos);
 	CString strActiveTxtPath=strVersionDir.c_str();//+"active.txt"; 
 	strActiveTxtPath +="\\"; 
 	strActiveTxtPath +="active.txt";
-
-    CFileStatus rStatus;
-    CFile::GetStatus(strActiveTxtPath,rStatus);//获得文件的属性设置
-	//如果文件为只读的,将只读属性去掉
-	if(rStatus.m_attribute&CFile::readOnly){
-		rStatus.m_attribute=rStatus.m_attribute & 0x3E ;      
-        CFile::SetStatus(strActiveTxtPath, rStatus );//更改文件的属性设置
+	if (ExistsFileA(strActiveTxtPath)) {
+		CFileStatus rStatus;
+		CFile::GetStatus(strActiveTxtPath, rStatus);//获得文件的属性设置
+		//如果文件为只读的,将只读属性去掉
+		if (rStatus.m_attribute & CFile::readOnly) {
+			rStatus.m_attribute = rStatus.m_attribute & 0x3E;
+			CFile::SetStatus(strActiveTxtPath, rStatus);//更改文件的属性设置
+		}
 	}
+	return 0;
 }
 
 void RegistHotkey() 
@@ -378,27 +453,22 @@ void GetDisplayScale()
 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
 {
 	// 校正active.txt的属性
-	checkActiveTxtAttr();
-
-   //启动框架
-	if (RunSpshell()) {
+	if (0 == checkActiveTxtAttr() && RunSpshell()) {
 		HideTaskBar(TRUE);
 	}
 
     hInst = hInstance; // 将实例句柄存储在全局变量中
 
-   /*hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
-      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
-
-   if (!hWnd)
-   {
-      return FALSE;
-   }
+   //HWND hWnd = CreateWindowA(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+	  //CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
 
-   ShowWindow(hWnd, nCmdShow);
-   UpdateWindow(hWnd);*/
-   //MessageBoxA(NULL,"Hello",NULL,0);
+   //if (!hWnd)
+   //{
+	  //return FALSE;
+   //}
 
+   //ShowWindow(hWnd, nCmdShow);
+   //UpdateWindow(hWnd);
    return FALSE;
 }
 

+ 4 - 1
addin/cmake/ConfigOptions.cmake

@@ -52,4 +52,7 @@ option(DEVOPS_INSTALL_SWITCH "install at devpos for pkging as zip easily" OFF)
 
 option(WITH_PDB_SAVE "save pdb file, copy pdb 2 version and pack from it" OFF)
 
-option(WITH_PDB_SAVEV2 "save pdb file, pack pdb from build dir directily" OFF)
+option(WITH_PDB_SAVEV2 "save pdb file, pack pdb from build dir directily" OFF)
+
+option(WITH_LABEL_RECORD "save artificatory file label to avs" OFF)
+