Quellcode durchsuchen

Z991239-4229 #comment feat: 同步s2_on_event的功能函数、以及事件码

陈纪林80310970 vor 2 Jahren
Ursprung
Commit
bde19be89f

+ 104 - 3
Module/mod_accessauth/AccessAuthFSM.cpp

@@ -10,7 +10,7 @@
 #include  <stdio.h>
 #include  <stdlib.h>
 #include "comm.h"
-
+#include "fileutil.h"
 #include "CommEntityUtil.hpp"
 
 #ifdef WITH_CPPRESTSDK
@@ -1301,7 +1301,7 @@ void CAccessAuthFSM::s2_on_exit()
 // 会收到Event_UpdateWKResult和Event_ReqTokenResult和EVT_TIMER
 unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 {
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s2 pEvent:%d",pEvent->iEvt);
+//	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("s2 pEvent:%d",pEvent->iEvt);
 //	if (pEvent->iEvt == EVT_TIMER)
 //	{
 //		if (pEvent->param1 == 2)		// access timeout
@@ -1589,7 +1589,95 @@ unsigned int CAccessAuthFSM::s2_on_event(FSMEvent* pEvent)
 //		GetEntityBase()->GetFunction()->ShowFatalError("终端上网方式不符合规范要求,请整改后重试!");
 //		return 0;
 //	}
-	return 0;
+//	return 0;
+
+DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("s2_on_event")("s2 receives event id: %d", pEvent->iEvt);
+
+if (pEvent->iEvt == Event_ConnectionOK) {
+    DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("s2_on_event")("开始第%d次准入", m_nAccessFailedCount);
+    pEvent->SetHandled();
+
+    CSmartPointer<TimeSynTask> timeSynTask = new TimeSynTask(this);
+    GetEntityBase()->GetFunction()->PostThreadPoolTask(timeSynTask.GetRawPointer());
+
+}
+else if (pEvent->iEvt == Event_EndSyncTime) {
+    DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("s2_on_event")("get token now");
+    pEvent->SetHandled();
+
+    CSmartPointer<GetTokenTask> getTokenTask = new GetTokenTask(this, (CAccessAuthEntity*)m_pEntity);
+    GetEntityBase()->GetFunction()->PostThreadPoolTask(getTokenTask.GetRawPointer());
+    return 0;
+
+}
+else if (pEvent->iEvt == Event_ReqTokenCancel) { //这里貌似会触发健康发起重试
+
+    auto pEntity = (CAccessAuthEntity*)m_pEntity;
+    if (pEvent->param1 == AccessAuthorization_UserErrorCode_AccessAuth_NULL) {
+        CSimpleStringA strMsg = CSimpleStringA::Format("准入Url为空(集中配置文件:%s)", IsCenterSettingFilesExist() ? "存在" : "不存在");
+        pEntity->SetAuthErrMsg(strMsg);
+    }
+    else if (pEvent->param1 == AccessAuthorization_UserErrorCode_ACS_FAIL) {
+        pEntity->SetAuthErrMsg("访问总行ACS失败 Connect ACS failed.");
+    }
+    else {
+        CSimpleStringA strErrMsg = CSimpleStringA::Format("准入超时(%d)", m_finishAccess);
+        pEntity->GetFunction()->ShowFatalError(strErrMsg);
+    }
+
+    SetEntryPermitSysVar("A");
+    m_nAccessFailedCount++;
+    pEvent->SetHandled();
+
+}
+else if (pEvent->iEvt == Event_ReqTokenFail) {  //而这里不会触发健康发起重试
+
+    SetEntryPermitSysVar("F");
+    pEvent->SetHandled();
+
+    auto pEntity = (CAccessAuthEntity*)m_pEntity;
+    CSimpleStringA strErrMsg = CSimpleStringA::Format("(%s)", (const char*)pEntity->GetAuthErrMsg());
+    // 发送准入失败事件,暂时不发送事件进去关门界面,原因关门界面显示中文乱码
+    doWarnMsg(EVENT_ACCESSAUTH_FAILED, strErrMsg.GetData(), true);
+    pEntity->GetFunction()->ShowFatalError(strErrMsg);
+
+    m_nAccessFailedCount = 0;
+
+}
+else if (pEvent->iEvt == Event_ReqTokenSucc) {
+
+    SetEntryPermitSysVar("L");
+    LogEvent(Severity_Middle, EVENT_ACCESSAUTH_SUCCEED, "终端准入成功");
+    m_pEntity->GetFunction()->ShowStartupInfo("准入成功");
+    m_nAccessFailedCount = 0;
+    pEvent->SetHandled();
+    PostEventFIFO(new FSMEvent(Event_AccessAuthSucc));
+
+}
+else if (pEvent->iEvt == Event_NetworkIllegal) {
+
+    pEvent->SetHandled();
+
+    if (pEvent->param1 == 0) {
+        PostEventFIFO(new FSMEvent(Event_ConnectionOK));
+    }
+    else {
+        PostEventFIFO(new FSMEvent(Event_ReqTokenFail));
+    }
+
+}
+else if (pEvent->iEvt == Event_NetworkRecover) {
+
+    pEvent->SetHandled();
+    if (!IsNetworkChecking()) {
+        CSmartPointer<NetworkCheckTask> networkCheck = new NetworkCheckTask(this);
+        GetEntityBase()->GetFunction()->PostThreadPoolTask(networkCheck.GetRawPointer());
+    }
+    else {
+        DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("NetworkCheckTask is doing now!");
+    }
+}
+return 0;
 }
 
 void CAccessAuthFSM::s3_on_entry()
@@ -1952,4 +2040,17 @@ ErrorCodeEnum CAccessAuthFSM::SetEntryPermitSysVar(const CSimpleStringA& newVal)
     CSmartPointer<IEntityFunction> spFunction = m_pEntity->GetFunction();
     DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Set EntryPermit with %s", newVal.GetData());
     return spFunction->SetSysVar("EntryPermit", (const char*)newVal);
+}
+
+
+BOOL CAccessAuthFSM::IsCenterSettingFilesExist()
+{
+    
+    BOOL result(FALSE);
+    CSimpleStringA strPath;
+    GetEntityBase()->GetFunction()->GetPath("CenterSetting", strPath);
+    if (!strPath.IsNullOrEmpty() && ExistsFileA(strPath)) {
+        result = TRUE;
+    }
+    return result;
 }

+ 3 - 0
Module/mod_accessauth/AccessAuthFSM.h

@@ -624,6 +624,7 @@ public:
 
 	/*True: Legal; False: illegal*/
 	BOOL DetectNetworkLegality();
+	BOOL IsCenterSettingFilesExist();
 
 private:
 	
@@ -633,6 +634,8 @@ private:
 
 	ErrorCodeEnum LoadCenterConfig();
 
+	bool IsNetworkChecking() const { return m_fNetworkChecking; }
+
 	int m_nExitReason;
 	int m_nExitWay;
 	CSimpleStringA m_accessAuthHost;

+ 20 - 6
Module/mod_accessauth/Event.h

@@ -1,9 +1,23 @@
 enum AccessAuthorization_UserErrorCode {
 	AccessAuthorization_UserErrorCode_Start = 0x50200200,
-	AccessAuthorization_UserErrorCode_GateUrl_NULL,			//灰度配置为空
-	AccessAuthorization_UserErrorCode_AccessAuth_NULL,		//准入配置为空
-	AccessAuthorization_UserErrorCode_InitDev_NULL,			//加密通道配置为空
-	AccessAuthorization_UserErrorCode_ACS_TURE,				//灰度告知准入走总行ACS
-	AccessAuthorization_UserErrorCode_ACS_FALSE,			//访问灰度失败or灰度告知不走ACS
-	AccessAuthorization_UserErrorCode_AuthPath_Change,		//总/分行切换
+	AccessAuthorization_UserErrorCode_GateUrl_NULL = 0x50200201,			//灰度配置为空
+	AccessAuthorization_UserErrorCode_AccessAuth_NULL = 0x50200202,		//准入配置为空
+	AccessAuthorization_UserErrorCode_InitDev_NULL = 0x50200203,			//加密通道配置为空
+	AccessAuthorization_UserErrorCode_ACS_TURE = 0x50200204,				//灰度告知准入走总行ACS
+	AccessAuthorization_UserErrorCode_ACS_FALSE = 0x50200205,			//灰度告知不走ACS
+	AccessAuthorization_UserErrorCode_AuthPath_Change = 0x50200206,		//总/分行切换
+	AccessAuthorization_UserErrorCode_GRAY_FAIL_CSCfg_TRUE = 0x50200207,	//灰度访问失败,集中配置走总行
+	AccessAuthorization_UserErrorCode_GRAY_FAIL_CSCfg_FALSE = 0x50200208,//灰度访问失败,集中配置走分行
+	AccessAuthorization_UserErrorCode_IPS_WHILE_GRAY = 0x50200209,		//灰度访问的本地ip
+	AccessAuthorization_UserErrorCode_Detect_Blocked = 0x5020020A,		//网络探测不通
+	AccessAuthorization_UserErrorCode_Detect_DelayTime = 0x5020020B,		//网络探测时延
+	AccessAuthorization_UserErrorCode_ACS_FAIL = 0x5020020C,				//访问总行ACS失败
+	AccessAuthorization_UserErrorCode_CMBCHINAURL_TEST_SUCC = 0x5020020D,
+	AccessAuthorization_UserErrorCode_CMBCHINAURL_TEST_FAIL = 0x5020020E,
+	AccessAuthorization_UserErrorCode_ERRORTIPS_UPDATE = 0x5020020F,
+	AccessAuthorization_UserErrorCode_MULTI_NETADAPTERS = 0x50200210,
+	AccessAuthorization_UserErrorCode_GetTermCostTooLong = 0x50200211,	//获取系统信息(cpu、主板、硬盘)超5秒
+	AccessAuthorization_UserErrorCode_Init_From_ClosePage = 0x50200212,
+	AccessAuthorization_UserErrorCode_Sync_Time_Succ = 0x50200213,
+	AccessAuthorization_UserErrorCode_Sync_Time_Failed = 0x50200214
 };