|
|
@@ -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;
|
|
|
}
|