Browse Source

#IQRV #comment [Module] 准入实体处理错误页乱码问题

gifur 4 năm trước cách đây
mục cha
commit
6c9c1106db

+ 11 - 34
Module/mod_accessauth/AccessAuthConn.cpp

@@ -95,9 +95,7 @@ DWORD CAccessAuthConn::HandleUpdateWKRet(const CSmartPointer<IPackage> &pRecvPkg
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg))
 	{
 		rc = dwUserCode;
-		LogWarn(Severity_Middle, (ErrorCodeEnum)dwSysCode, dwUserCode,
-			GetOutPutStr("%s%08X%s%s", "GetErrMsg", rc,"strErrMsg", strErrMsg.c_str()).c_str());
-		
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, rc, strErrMsg);
 	}
 	else
 	{
@@ -146,11 +144,7 @@ DWORD CAccessAuthConn::HandleReqTokenRet(const CSmartPointer<IPackage> &pRecvPkg
 	{
 		rc = dwUserCode;
 		((CAccessAuthEntity*)m_pEntity)->SetAuthErrMsg(strErrMsg.c_str());
-		spFunction->SetSysVar("AuthErrMsg", strErrMsg.c_str(), false);
-
-		LogWarn(Severity_Middle, Error_Unexpect, rc,
-			GetOutPutStr("%s%s%s%08X%s%s", "GetErrMsg", 
-						 "False", "dwUserCode", rc,"strErrMsg", strErrMsg.c_str()).c_str());
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, rc, strErrMsg, true);
 	}
 	else
 	{
@@ -237,9 +231,7 @@ DWORD CAccessAuthConn::HandleTermExitRet(const CSmartPointer<IPackage> &pRecvPkg
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg))
 	{
 		rc = (ErrorCodeEnum)dwSysCode;
-
-		LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_TERM_EXIT,
-			GetOutPutStr("%s%08X%s%s", "GetErrMsg", dwSysCode, "strErrMsg", strErrMsg.c_str()).c_str());
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, ERR_ACCESSAUTH_TERM_EXIT, strErrMsg);
 		return rc;
 	}
 
@@ -254,8 +246,7 @@ DWORD CAccessAuthConn::HandleReportStageRet(const CSmartPointer<IPackage> &pRecv
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg))
 	{
 		rc = (ErrorCodeEnum)dwSysCode;
-		LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_REPORT_STATE,
-			GetOutPutStr("%s%08X%s%s", "GetErrMsg", dwSysCode, "strErrMsg", strErrMsg.c_str()).c_str());
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, ERR_ACCESSAUTH_REPORT_STATE, strErrMsg);
 		return rc;
 	}
 
@@ -959,8 +950,7 @@ DWORD CAccessAuthConn::SendSyncTimePackageNew()
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg))
 	{
 		rc = dwUserCode;
-		LogWarn(Severity_Middle, Error_Unexpect, rc,
-			GetOutPutStr("%s%08X%s%s", "GetErrMsg", rc, "strErrMsg", strErrMsg.c_str()).c_str());
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, rc, strErrMsg);
 	}
 	else
 	{
@@ -1026,9 +1016,8 @@ DWORD CAccessAuthConn::HandleSyncTimeRet(const CSmartPointer<IPackage> &pRecvPkg
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg))
 	{
 		rc = dwUserCode;
-		LogWarn(Severity_Middle, Error_Unexpect, rc,
-			GetOutPutStr("%s%08X%s%s", "GetErrMsg", rc,"strErrMsg", strErrMsg.c_str()).c_str());
 		((CAccessAuthEntity*)m_pEntity)->SetAuthErrMsg(strErrMsg.c_str());
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, rc, strErrMsg);
 	}
 	else
 	{
@@ -1136,9 +1125,7 @@ DWORD CAccessAuthConn::HandleInitDeviceRet(const CSmartPointer<IPackage> &pRecvP
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg))
 	{
 		rc = (ErrorCodeEnum)dwSysCode;
-
-		LogWarn(Severity_Middle, Error_Unexpect, ERR_ACCESSAUTH_INIT_DEV,
-			GetOutPutStr("%s%08X%s%s", "GetErrMsg", rc,"strErrMsg", strErrMsg.c_str()).c_str());
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, ERR_ACCESSAUTH_INIT_DEV, strErrMsg);
 	}
 	else if (m_ctxInitDev == NULL)
 	{
@@ -1212,8 +1199,7 @@ DWORD CAccessAuthConn::HandleReportStateRet(const CSmartPointer<IPackage> &pRecv
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg))
 	{
 		rc = dwUserCode;
-		LogWarn(Severity_Middle, Error_Unexpect, rc,
-			GetOutPutStr("%s%08X%s%s", "GetErrMsg", dwSysCode,"strErrMsg", strErrMsg.c_str()).c_str());
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, rc, strErrMsg);
 	}
 
 	return rc;
@@ -1261,12 +1247,7 @@ DWORD CAccessAuthConn::HandleLockStateRet(const CSmartPointer<IPackage> &pRecvPk
 	{
 		rc = dwUserCode;
 		((CAccessAuthEntity*)m_pEntity)->SetAuthErrMsg(strErrMsg.c_str());
-		CSmartPointer<IEntityFunction> spFunction = m_pEntity->GetFunction();
-		spFunction->SetSysVar("AuthErrMsg", strErrMsg.c_str(), false);
-
-		LogWarn(Severity_Middle, Error_Unexpect, rc,
-			GetOutPutStr("%s%08X%s%s", "GetErrMsg", rc,"AuthErrMsg", strErrMsg.c_str()).c_str());
-
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, rc, strErrMsg, true);
 		return rc;
 	}
 
@@ -1367,10 +1348,8 @@ DWORD CAccessAuthConn::HandleCheckMD5Ret(const CSmartPointer<IPackage> &pRecvPkg
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg))
 	{
 		rc = (ErrorCodeEnum)dwSysCode;
-		LogError(Severity_Middle, (ErrorCodeEnum)dwSysCode, dwUserCode, strErrMsg.c_str());
 		((CAccessAuthEntity*)m_pEntity)->SetAuthErrMsg(strErrMsg.c_str());
-		CSmartPointer<IEntityFunction> spFunction = m_pEntity->GetFunction();
-		spFunction->SetSysVar("AuthErrMsg", strErrMsg.c_str(), false);
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, rc, strErrMsg, true);
 	}
 
 	m_pFSM->PostEventFIFO(new FSMEvent(rc==Error_Succeed ? CAccessAuthFSM::Event_CheckMD5Succ:CAccessAuthFSM::Event_CheckMD5Fail));
@@ -1387,10 +1366,8 @@ DWORD CAccessAuthConn::HandleUpdateMD5Ret(const CSmartPointer<IPackage> &pRecvPk
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg))
 	{
 		rc = (ErrorCodeEnum)dwSysCode;
-		LogError(Severity_Middle, (ErrorCodeEnum)dwSysCode, dwUserCode, strErrMsg.c_str());
 		((CAccessAuthEntity*)m_pEntity)->SetAuthErrMsg(strErrMsg.c_str());
-		CSmartPointer<IEntityFunction> spFunction = m_pEntity->GetFunction();
-		spFunction->SetSysVar("AuthErrMsg", strErrMsg.c_str(), false);
+		((CAccessAuthEntity*)m_pEntity)->WarnAuthErrMsg(rc, rc, strErrMsg, true);
 	}
 
 	m_pFSM->PostEventFIFO(new FSMEvent(rc==Error_Succeed ? CAccessAuthFSM::Event_CheckMD5Succ:CAccessAuthFSM::Event_CheckMD5Fail));

+ 10 - 0
Module/mod_accessauth/mod_AccessAuth.cpp

@@ -950,6 +950,16 @@ void CAccessAuthEntity::SetAuthErrMsg(const char* pszErrMsg)
 #endif //RVC_OS_WIN
 }
 
+void CAccessAuthEntity::WarnAuthErrMsg(DWORD dwSrvCode, DWORD dwSysCode, const std::string& strErrMsg, bool setSysVar)
+{
+	const std::string errStr = SP::Utility::GBK2UTF8(strErrMsg);
+	if (setSysVar) {
+		GetFunction()->SetSysVar("AuthErrMsg", errStr.c_str(), false);
+	}
+    LogWarn(Severity_Middle, Error_Unexpect, dwSysCode,
+            GetOutPutStr("%s%08X%s%s", "GetErrMsg", dwSrvCode, "AuthErrMsg", errStr.c_str()).c_str());
+}
+
 DWORD CAccessAuthEntity::InitDevice(SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer &ctx)
 {
 	return m_FSM.InitDevice(ctx);

+ 1 - 0
Module/mod_accessauth/mod_AccessAuth.h

@@ -117,6 +117,7 @@ public:
 	DWORD InitDevice(SpReqAnsContext<AccessAuthService_InitDev_Req, AccessAuthService_InitDev_Ans>::Pointer &ctx);
 
 	void SetAuthErrMsg(const char* pszErrMsg);
+	void WarnAuthErrMsg(DWORD dwSrvCode, DWORD dwSysCode, const std::string& strErrMsg, bool setSysVar = false);
 	const char *GetAuthErrMsg() { return m_strAuthErrMsg; }
 
 	// 获取密码键盘ID和外设ID