|
|
@@ -222,6 +222,13 @@ ErrorCodeEnum CHealthManagerFSM::Initial()
|
|
|
}
|
|
|
#endif //RVC_OS_LINUX
|
|
|
|
|
|
+ CSmartPointer<IConfigInfo> spCerConfig;
|
|
|
+ GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spCerConfig);
|
|
|
+ spCerConfig->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "WKUpdatePeriod", m_wkUpdatePeriod);
|
|
|
+ if (m_wkUpdatePeriod < 0 || m_wkUpdatePeriod > 365)
|
|
|
+ m_wkUpdatePeriod = 30;//default
|
|
|
+ spCerConfig->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "DoNotUpdateWKDaily", m_iDoNotUpdateWKDaily);
|
|
|
+
|
|
|
GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "X");
|
|
|
WaitDeamonFinishTask* task = new WaitDeamonFinishTask(this);
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
|
|
|
@@ -1347,55 +1354,55 @@ int CHealthManagerFSM::WaitDeamonFinish()
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
-int CHealthManagerFSM::DoInitialization()
|
|
|
-{
|
|
|
- LOG_FUNCTION();
|
|
|
-
|
|
|
- ErrorCodeEnum eErr;
|
|
|
- CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
|
|
|
- CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
|
|
|
- CEntityRunInfo acInfo;
|
|
|
- eErr = pFunc->GetEntityRunInfo("Initializer",acInfo);
|
|
|
- Dbg("Initializer state return %d",eErr);
|
|
|
- if (eErr == Error_Succeed && (acInfo.eState == EntityState_NoStart || acInfo.eState == EntityState_Idle))
|
|
|
- {
|
|
|
- if (acInfo.eState == EntityState_NoStart)
|
|
|
- {
|
|
|
- CSmartPointer<IAsynWaitSp> spWaitInit;
|
|
|
- eErr = pFuncPrivilege->StartEntity("Initializer",NULL,spWaitInit);
|
|
|
- if (eErr == Error_Succeed)
|
|
|
- eErr = spWaitInit->WaitAnswer(MAX_AYSNC_TIMEOUT);
|
|
|
- eErr = pFunc->GetEntityRunInfo("Initializer",acInfo);
|
|
|
- if (eErr != Error_Succeed || acInfo.eState != EntityState_Idle)
|
|
|
- {
|
|
|
- Dbg("start Initializer failed(%d,%d).",eErr,acInfo.eState);
|
|
|
- return 1;
|
|
|
- }
|
|
|
- }
|
|
|
- if (m_pInitClient == NULL)
|
|
|
- {
|
|
|
- m_pInitClient = new InitializerService_ClientBase(this->GetEntityBase());
|
|
|
- eErr = m_pInitClient->Connect();
|
|
|
- if (eErr != Error_Succeed) {
|
|
|
- Dbg("Initializer connected failed.");
|
|
|
- m_pInitClient->SafeDelete();
|
|
|
- m_pInitClient = NULL;
|
|
|
- return 2;
|
|
|
- }
|
|
|
- else
|
|
|
- Dbg("Initializer connected.");
|
|
|
- }
|
|
|
- InitializerService_Initialize_Info initInfo;
|
|
|
- m_pInitClient->Initialize(initInfo);
|
|
|
- //no need to wait,just go
|
|
|
- return 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dbg("Get Initializer RunInfo failed(%d).",eErr);
|
|
|
- return 3;
|
|
|
- }
|
|
|
-}
|
|
|
+//int CHealthManagerFSM::DoInitialization()
|
|
|
+//{
|
|
|
+// LOG_FUNCTION();
|
|
|
+//
|
|
|
+// ErrorCodeEnum eErr;
|
|
|
+// CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
|
|
|
+// CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
|
|
|
+// CEntityRunInfo acInfo;
|
|
|
+// eErr = pFunc->GetEntityRunInfo("Initializer",acInfo);
|
|
|
+// Dbg("Initializer state return %d",eErr);
|
|
|
+// if (eErr == Error_Succeed && (acInfo.eState == EntityState_NoStart || acInfo.eState == EntityState_Idle))
|
|
|
+// {
|
|
|
+// if (acInfo.eState == EntityState_NoStart)
|
|
|
+// {
|
|
|
+// CSmartPointer<IAsynWaitSp> spWaitInit;
|
|
|
+// eErr = pFuncPrivilege->StartEntity("Initializer",NULL,spWaitInit);
|
|
|
+// if (eErr == Error_Succeed)
|
|
|
+// eErr = spWaitInit->WaitAnswer(MAX_AYSNC_TIMEOUT);
|
|
|
+// eErr = pFunc->GetEntityRunInfo("Initializer",acInfo);
|
|
|
+// if (eErr != Error_Succeed || acInfo.eState != EntityState_Idle)
|
|
|
+// {
|
|
|
+// Dbg("start Initializer failed(%d,%d).",eErr,acInfo.eState);
|
|
|
+// return 1;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (m_pInitClient == NULL)
|
|
|
+// {
|
|
|
+// m_pInitClient = new InitializerService_ClientBase(this->GetEntityBase());
|
|
|
+// eErr = m_pInitClient->Connect();
|
|
|
+// if (eErr != Error_Succeed) {
|
|
|
+// Dbg("Initializer connected failed.");
|
|
|
+// m_pInitClient->SafeDelete();
|
|
|
+// m_pInitClient = NULL;
|
|
|
+// return 2;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// Dbg("Initializer connected.");
|
|
|
+// }
|
|
|
+// InitializerService_Initialize_Info initInfo;
|
|
|
+// m_pInitClient->Initialize(initInfo);
|
|
|
+// //no need to wait,just go
|
|
|
+// return 0;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// Dbg("Get Initializer RunInfo failed(%d).",eErr);
|
|
|
+// return 3;
|
|
|
+// }
|
|
|
+//}
|
|
|
|
|
|
//0:auth suc or have already authed;1:auth failed;
|
|
|
int CHealthManagerFSM::AccessAuthDoWork()
|
|
|
@@ -1421,7 +1428,7 @@ int CHealthManagerFSM::AccessAuthDoWork()
|
|
|
bool bToDoInit = false;
|
|
|
if (eErr == Error_Succeed)
|
|
|
{
|
|
|
- if (csTermStage[0] == 'U')
|
|
|
+ /*if (csTermStage[0] == 'U')
|
|
|
{
|
|
|
bToDoInit = true;
|
|
|
int initTime = 0;
|
|
|
@@ -1452,7 +1459,7 @@ INITIALIZATION:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -2502,6 +2509,7 @@ void CHealthManagerFSM::JudgeIfNeedInitFWB()
|
|
|
}
|
|
|
void CHealthManagerFSM::FWBDoInit()
|
|
|
{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
LOG_FUNCTION();
|
|
|
Sleep(2000);
|
|
|
CSimpleStringA currCheckCode(""), runcfgCkCode("");
|
|
|
@@ -2567,7 +2575,9 @@ void CHealthManagerFSM::FWBDoInit()
|
|
|
LogWarn(Severity_Low, Error_Unexpect, HealthManager_UserErrorCode_InitForFWB_GetAuthAddr_Fail, "Init for fwb,get authaccess address suc.");
|
|
|
}
|
|
|
return;
|
|
|
+#endif
|
|
|
}
|
|
|
+
|
|
|
bool CHealthManagerFSM::IsCutIEBrowser()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
@@ -2589,3 +2599,177 @@ bool CHealthManagerFSM::IsCutIEBrowser()
|
|
|
//else
|
|
|
// return false;
|
|
|
}
|
|
|
+void CHealthManagerFSM::AutoDoInitForAll()
|
|
|
+{
|
|
|
+ LOG_FUNCTION();
|
|
|
+ m_bDoingAutoInit = true;
|
|
|
+ ErrorCodeEnum eErr;
|
|
|
+ if (m_pACClient == NULL || m_pACClient->QuerySessionClosed())
|
|
|
+ {
|
|
|
+ m_pACClient = new AccessAuthService_ClientBase(this->GetEntityBase());
|
|
|
+ eErr = m_pACClient->Connect();
|
|
|
+ if (eErr != Error_Succeed) {
|
|
|
+ m_bDoingAutoInit = false;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("AutoDoInitForAll")("AccessAuth connected failed.");
|
|
|
+ m_pACClient->SafeDelete();
|
|
|
+ m_pACClient = NULL;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("AutoDoInitForAll")("AccessAuth connected.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ AccessAuthService_InitializeNew_Req initReq;
|
|
|
+ AccessAuthService_InitializeNew_Ans initAns;
|
|
|
+ initReq.strAuthServer = "";
|
|
|
+ initReq.strUserID = "admin";
|
|
|
+ initReq.strPassword = "";
|
|
|
+ eErr = m_pACClient->InitializeNew(initReq, initAns, 60000);
|
|
|
+ m_autoDoInitCount++;
|
|
|
+ if (eErr == Error_Succeed)
|
|
|
+ {
|
|
|
+ //Dbg("Auto Init suc.");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("AutoDoInitForAll")("Auto Init suc.");
|
|
|
+ LogWarn(Severity_Low, Error_Unexpect, HealthManager_UserErrorCode_AutoDoInit_Suc, "Auto Init suc.");
|
|
|
+ m_bDoingAutoInit = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //Dbg("Auto Init failed:%d", eErr);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("AutoDoInitForAll")("Auto Init failed:%d", eErr);
|
|
|
+ LogWarn(Severity_Low, Error_Unexpect, HealthManager_UserErrorCode_AutoDoInit_Fail, "Auto Init failed.");
|
|
|
+ }
|
|
|
+
|
|
|
+ m_bDoingAutoInit = false;
|
|
|
+ return;
|
|
|
+}
|
|
|
+void CHealthManagerFSM::CheckIfNeedAutoInit()
|
|
|
+{
|
|
|
+ ErrorCodeEnum eErr = Error_Unexpect;
|
|
|
+ bool bNeedAutoInit = false;
|
|
|
+ PinPadService_ClientBase* pClient = new PinPadService_ClientBase(this->m_pEntity);
|
|
|
+ if (pClient != NULL)
|
|
|
+ {
|
|
|
+ eErr = pClient->Connect();
|
|
|
+ if (eErr == Error_Succeed)
|
|
|
+ {
|
|
|
+ PinPadService_QueryFunc_Req reqQ;
|
|
|
+ PinPadService_QueryFunc_Ans ansQ;
|
|
|
+ eErr = pClient->QueryFunc(reqQ, ansQ, 5000);
|
|
|
+ if (eErr == Error_Succeed)
|
|
|
+ {
|
|
|
+ if ((ansQ.encryptkey == 3 || ansQ.encryptkey == 2) && ansQ.reserved1 == 1)
|
|
|
+ {
|
|
|
+ bNeedAutoInit = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //Dbg("QueryFunc failed.error code:%d", eErr);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("CheckIfNeedAutoInit")("QueryFunc failed.error code:%d", eErr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //Dbg("connect to pinpad failed.error code:%d", eErr);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("CheckIfNeedAutoInit")("connect to pinpad failed.error code:%d", eErr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bNeedAutoInit && !m_bDoingAutoInit && m_autoDoInitCount < 2)
|
|
|
+ {
|
|
|
+ AutoDoInitForAllTask* pTask = new AutoDoInitForAllTask(this);
|
|
|
+ GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CHealthManagerFSM::WKUpdatePeriod()
|
|
|
+{
|
|
|
+ auto pEntity = ((CHealthManagerEntity*)m_pEntity);
|
|
|
+ //oilyang@20220421 if have init fwb from HealthManager start,no need to update working key
|
|
|
+ //oilyang@20220413 control update working key by CenterSetting
|
|
|
+ CSimpleStringA xInitFWBFlag("N");
|
|
|
+ GetEntityBase()->GetFunction()->GetSysVar("InitFWBFromStart", xInitFWBFlag);
|
|
|
+ if (m_iDoNotUpdateWKDaily == 1 || xInitFWBFlag.Compare("Y") == 0)
|
|
|
+ {
|
|
|
+ // 没有密码键盘或集中配置告知无需更新或蓝牙多合一正在更新,无需更新
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WKUpdatePeriod")
|
|
|
+ (CSimpleStringA::Format("DoNotUpdateWKDaily:%d or InitFWB:%s, ignore update wk"
|
|
|
+ , m_iDoNotUpdateWKDaily, xInitFWBFlag.GetData()));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查上次密钥同步时间(一天只同步一次)
|
|
|
+ CSmartPointer<IConfigInfo> pConfigRun;
|
|
|
+ m_pEntity->GetFunction()->OpenConfig(Config_Run, pConfigRun);
|
|
|
+
|
|
|
+ int nWKLastSyncTime(0);
|
|
|
+ pConfigRun->ReadConfigValueInt("Main", "WKSyncSuccTime", nWKLastSyncTime);
|
|
|
+ int nWKSyncFailCount(0);
|
|
|
+ pConfigRun->ReadConfigValueInt("Main", "WKSyncFailCount", nWKSyncFailCount);
|
|
|
+
|
|
|
+ SYSTEMTIME stSyncTime = CSmallDateTime(nWKLastSyncTime).ToSystemTime();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WKUpdatePeriod")
|
|
|
+ ("last WK sync time: %04d-%02d-%02d %02d:%02d:%02d",
|
|
|
+ stSyncTime.wYear, stSyncTime.wMonth, stSyncTime.wDay,
|
|
|
+ stSyncTime.wHour, stSyncTime.wMinute, stSyncTime.wSecond);
|
|
|
+
|
|
|
+ SYSTEMTIME stNow = {};
|
|
|
+ GetLocalTime(&stNow);
|
|
|
+ int lastUpdateDays = sumday(stSyncTime.wYear, stSyncTime.wMonth, stSyncTime.wDay);
|
|
|
+ int todayDays = sumday(stNow.wYear, stNow.wMonth, stNow.wDay);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("lastUpdateDays:%d,todayDays:%d,x:%d", lastUpdateDays, todayDays, todayDays - lastUpdateDays);
|
|
|
+ //if ((nWKLastSyncTime > 0 && stSyncTime.wYear == stNow.wYear
|
|
|
+ // && stSyncTime.wMonth == stNow.wMonth && stSyncTime.wDay == stNow.wDay
|
|
|
+ // && nWKSyncFailCount == 0)) // 最近一次同步成功,才能跳过
|
|
|
+ if (todayDays - lastUpdateDays < m_wkUpdatePeriod)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WKUpdatePeriod")
|
|
|
+ ("WK has been updated, last sync time: %s", (const char*)CSmallDateTime(nWKLastSyncTime).ToTimeString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WKUpdatePeriod")("begin update WK now");
|
|
|
+ ErrorCodeEnum eErrCode = Error_Succeed;
|
|
|
+ if (m_pACClient == NULL)
|
|
|
+ {
|
|
|
+ m_pACClient = new AccessAuthService_ClientBase(this->GetEntityBase());
|
|
|
+ eErrCode = m_pACClient->Connect();
|
|
|
+ if (eErrCode != Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WKUpdatePeriod")("accessauth connected failed.");
|
|
|
+ m_pACClient->SafeDelete();
|
|
|
+ m_pACClient = NULL;
|
|
|
+ m_bInAccessAuthDoWork = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WKUpdatePeriod")("accessauth connected.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ eErrCode = m_pACClient->UpdateWK();
|
|
|
+ if (Error_Succeed == eErrCode)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WKUpdatePeriod")("accessauth updatewk succ.");
|
|
|
+ pConfigRun->WriteConfigValue("Main", "WKSyncSuccTime",
|
|
|
+ (const char*)CSimpleStringA::Format("0x%08X", (DWORD)CSmallDateTime::GetNow()));
|
|
|
+ pConfigRun->WriteConfigValueInt("Main", "WKSyncFailCount", 0);
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WKUpdatePeriod")("accessauth updatewk failed.");
|
|
|
+ nWKSyncFailCount++;
|
|
|
+ pConfigRun->WriteConfigValueInt("Main", "WKSyncFailCount", nWKSyncFailCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int CHealthManagerFSM::sumday(int year, int month, int day)
|
|
|
+{
|
|
|
+ int days[2][13] = { {0,31,59,90,120,151,181,212,243,273,304,334,365},{0,31,60,91,121,152,182,213,244,274,305,335,366} };
|
|
|
+ int iLeapYear = 0;
|
|
|
+ if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
|
|
|
+ iLeapYear = 1;
|
|
|
+ int yearday = year * 365 + year / 4 - year / 100 + year / 400;
|
|
|
+ int monthday = days[iLeapYear][month - 1];
|
|
|
+ return yearday + monthday + day;
|
|
|
+}
|