HealthManagerFSM.cpp 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310
  1. #include "stdafx.h"
  2. #include <fstream>
  3. #include <string>
  4. #include <algorithm>
  5. #include <regex>
  6. #include "SpUtility.h"
  7. #include "iniutil.h"
  8. #include "fileutil.h"
  9. #if defined(RVC_OS_WIN)
  10. #include <TlHelp32.h>
  11. #include <iphlpapi.h>
  12. #include <ws2tcpip.h>
  13. #include <Winsock2.h>
  14. #include <io.h>
  15. #include "CSystemStatus.h"
  16. #else
  17. #include <unistd.h>
  18. #include <fcntl.h>
  19. #include <errno.h>
  20. #endif //RVC_OS_WIN
  21. #include <winpr/sysinfo.h>
  22. #include "mod_healthmanager.h"
  23. #include "publicFunExport.h"
  24. using namespace std;
  25. const int MAX_AYSNC_TIMEOUT = 60000;
  26. const int MAX_IGNORE_TIMEOUT = 100;
  27. enum EntityOP
  28. {
  29. OP_STOP_ENTITY,
  30. OP_START_ENTITY,
  31. OP_PAUSE_ENTITY,
  32. OP_TERMINATE_ENTITY,
  33. OP_CONTINUE_ENTITY,
  34. };
  35. ErrorCodeEnum CHealthManagerFSM::Initial()
  36. {
  37. m_netList.Init(0);
  38. CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
  39. CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
  40. CSmartPointer<IAsynWaitSp> spWait;
  41. ErrorCodeEnum err;
  42. GetEntityBase()->GetFunction()->GetSystemStaticInfo(m_sysInfo);
  43. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("machinetype[%s],terminalID[%s]", (LPCTSTR)m_sysInfo.strMachineType, (LPCTSTR)m_sysInfo.strTerminalID);
  44. CSmartPointer<IConfigInfo> spConfigCen;
  45. GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spConfigCen);
  46. spConfigCen->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "WKUpdatePeriod", m_wkUpdatePeriod);
  47. if (m_wkUpdatePeriod <= 0 || m_wkUpdatePeriod > 365)
  48. m_wkUpdatePeriod = 30;//default
  49. spConfigCen->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "DoNotUpdateWKDaily", m_iDoNotUpdateWKDaily);
  50. spConfigCen->ReadConfigValueInt(GetEntityBase()->GetEntityName(), "MaxWaitForPinPad", m_maxWaitForPinPad);
  51. if (m_maxWaitForPinPad <= 0 || m_maxWaitForPinPad > 5000)
  52. m_maxWaitForPinPad = 5000;//default
  53. CSimpleStringA csTmpTS("");
  54. GetEntityBase()->GetFunction()->GetSysVar("TerminalStage", csTmpTS);
  55. if (csTmpTS.Compare("N") != 0)
  56. GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "X");
  57. SP::Module::Net::GetINETMacAddresses(m_netList);
  58. return Error_Succeed;
  59. }
  60. ErrorCodeEnum CHealthManagerFSM::OnInit(void)
  61. {
  62. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Complied at: %s %s", __DATE__, __TIME__);
  63. return Initial();
  64. }
  65. ErrorCodeEnum CHealthManagerFSM::OnExit(void)
  66. {
  67. return Error_Succeed;
  68. }
  69. void CHealthManagerFSM::s0_on_entry(void)
  70. {
  71. LOG_FUNCTION();
  72. m_fsmState = HM_FSM_INIT;
  73. m_ullElapseFromOSStart = SP::Module::Comm::RVCGetTickCount();
  74. m_elapseTimeFromOSStart = m_ullElapseFromOSStart / 1000;
  75. CSimpleStringA xMsg = CSimpleStringA::Format("{\"Decripstion\":\"Entity start\",\"version\":\"%s\",\"elapseTime\":\"%d\"}", m_sysInfo.InstallVersion.ToString().GetData(), m_elapseTimeFromOSStart);
  76. LogWarn(Severity_Low, Error_Unexpect, HealthManager_UserErrorCode_Enter_SafeLoad_State, xMsg.GetData());
  77. FSMEvent* pEvt = new FSMEvent(USER_EVT_WAIT_DEAMON_FINISHED);
  78. pEvt->param1 = 0;
  79. PostEventFIFO(pEvt);
  80. }
  81. void CHealthManagerFSM::s0_on_exit(void)
  82. {
  83. }
  84. unsigned int CHealthManagerFSM::s0_on_event(FSMEvent* pEvt)
  85. {
  86. int ret = 0;
  87. switch(pEvt->iEvt)
  88. {
  89. case USER_EVT_WAIT_DEAMON_FINISHED:
  90. ret = pEvt->param1;
  91. pEvt->SetHandled();
  92. break;
  93. default:
  94. break;
  95. }
  96. return ret;
  97. }
  98. //Idle(Operating finished)
  99. void CHealthManagerFSM::s4_on_entry()
  100. {
  101. m_fsmState = HM_FSM_STATE_IDLE;
  102. }
  103. void CHealthManagerFSM::s4_on_exit()
  104. {
  105. LOG_FUNCTION();
  106. }
  107. unsigned int CHealthManagerFSM::s4_on_event(FSMEvent* pEvt)
  108. {
  109. LOG_FUNCTION();
  110. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("s4 event %d,%d",pEvt->iEvt,pEvt->param1);
  111. switch(pEvt->iEvt)
  112. {
  113. case USER_EVT_ACCESSAUTH_FINISHED:
  114. {
  115. pEvt->SetHandled();
  116. CSimpleStringA csTermStage;
  117. ErrorCodeEnum eErrCode;
  118. eErrCode = GetEntityBase()->GetFunction()->GetSysVar("TerminalStage",csTermStage);
  119. DbgWithLink(LOG_LEVEL_DEBUG,LOG_TYPE_SYSTEM)("after accessauth to get termstage %s",(LPCTSTR)csTermStage);
  120. //oilyang@20220614 添加密钥更新逻辑
  121. if (csTermStage[0] == 'A')
  122. {
  123. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("after auth suc,to call WKUpdatePeriodTask");
  124. WKUpdatePeriodTask* pTask = new WKUpdatePeriodTask(this);
  125. GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
  126. }
  127. LogTermInfoTask* task = new LogTermInfoTask(this);
  128. GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
  129. if (m_iAccessAuth != VtmLoad_AccessAuth_Suc)
  130. PostProcessAfterUpgrade();
  131. }
  132. break;
  133. case USER_EVT_MAITAIN:
  134. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("to maintain...");
  135. m_stateBeforeMaintain = m_fsmState;
  136. pEvt->SetHandled();
  137. break;
  138. case USER_EVT_ENTER_CUSTOMER_MANAGER:
  139. pEvt->SetHandled();
  140. break;
  141. case USER_EVT_VTMLOADER_FINISHED:
  142. {
  143. pEvt->SetHandled();
  144. if (pEvt->param1 == 1)
  145. {
  146. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402501V1").setResultCode("RTA510E")("VtmLoader load SIPphone entity failed, to Set TerminalStage M.");
  147. SetVtmLoadResult(VtmLoad_MediaLoadFail);
  148. return pEvt->param1;
  149. }
  150. else if (pEvt->param1 == 2)
  151. {
  152. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402501V1").setResultCode("RTA510F")("VtmLoader load SYNCSTART(boot cfg = 2) entity failed, to Set TerminalStage C.");
  153. SetVtmLoadResult(VtmLoad_OtherSyncEntityLoadFail);
  154. return pEvt->param1;
  155. }
  156. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402501A1")("VtmLoader load entitys ok.");
  157. if (m_iAccessAuth == VtmLoad_AccessAuth_Init)
  158. {
  159. WaitToCallAccessAuthTask* pTask = new WaitToCallAccessAuthTask(this);
  160. GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
  161. }
  162. }
  163. break;
  164. default:
  165. break;
  166. }
  167. return 0;
  168. }
  169. //Fault
  170. void CHealthManagerFSM::s5_on_entry()
  171. {
  172. LOG_FUNCTION();
  173. LogTermInfoTask* task = new LogTermInfoTask(this);
  174. GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
  175. m_fsmState = HM_FSM_STATE_FAULT;
  176. PostProcessAfterUpgrade();
  177. }
  178. void CHealthManagerFSM::s5_on_exit()
  179. {
  180. LOG_FUNCTION();
  181. }
  182. unsigned int CHealthManagerFSM::s5_on_event(FSMEvent* pEvt)
  183. {
  184. LOG_FUNCTION();
  185. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("s5(Fault) event %d,%d",pEvt->iEvt,pEvt->param1);
  186. switch(pEvt->iEvt)
  187. {
  188. case USER_EVT_MAITAIN:
  189. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("to maintain...");
  190. m_stateBeforeMaintain = m_fsmState;
  191. pEvt->SetHandled();
  192. break;
  193. case USER_EVT_ENTER_CUSTOMER_MANAGER:
  194. pEvt->SetHandled();
  195. break;
  196. case USER_EVT_ACCESSAUTH_FINISHED:
  197. pEvt->SetHandled();
  198. if (pEvt->param1 == 1)
  199. {
  200. return 1;
  201. }
  202. break;
  203. default:
  204. break;
  205. }
  206. return 0;
  207. }
  208. //Maintaining
  209. void CHealthManagerFSM::s6_on_entry()
  210. {
  211. LOG_FUNCTION();
  212. m_preFsmState = m_fsmState;
  213. m_fsmState = HM_FSM_STATE_MAINTAINING;
  214. CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
  215. CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
  216. if (pFuncPrivilege == NULL)
  217. {
  218. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("display screen NoPrivilege");
  219. return;
  220. }
  221. ErrorCodeEnum eErr = pFuncPrivilege->DisplayBlueScreen("暂停服务");
  222. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("display blue screen %d",eErr);
  223. }
  224. void CHealthManagerFSM::s6_on_exit()
  225. {
  226. LOG_FUNCTION();
  227. }
  228. unsigned int CHealthManagerFSM::s6_on_event(FSMEvent* pEvt)
  229. {
  230. LOG_FUNCTION();
  231. int ret = 0;
  232. switch(pEvt->iEvt)
  233. {
  234. case USER_EVT_MAITAIN_FINISHED:
  235. pEvt->SetHandled();
  236. {
  237. CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
  238. CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
  239. if (pFuncPrivilege == NULL)
  240. {
  241. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("un-display screen NoPrivilege");
  242. return 1;
  243. }
  244. ErrorCodeEnum eErr = pFuncPrivilege->UndisplayBlueScreen();
  245. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("un-display blue screen %d",eErr);
  246. if (m_stateBeforeMaintain == HM_FSM_STATE_IDLE)
  247. {
  248. }
  249. ret = m_preFsmState;
  250. }
  251. break;
  252. case USER_EVT_ENTER_CUSTOMER_MANAGER:
  253. pEvt->SetHandled();
  254. break;
  255. default:
  256. break;
  257. }
  258. return ret;
  259. }
  260. //In Customer Manager System
  261. void CHealthManagerFSM::s11_on_entry()
  262. {
  263. LOG_FUNCTION();
  264. m_preFsmState = m_fsmState;
  265. m_fsmState = HM_FSM_STATE_CMS;
  266. }
  267. void CHealthManagerFSM::s11_on_exit()
  268. {
  269. LOG_FUNCTION();
  270. }
  271. unsigned int CHealthManagerFSM::s11_on_event(FSMEvent* pEvt)
  272. {
  273. LOG_FUNCTION();
  274. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("s11(In CMS) event %d",pEvt->iEvt);
  275. int ret = 0;
  276. switch (pEvt->iEvt)
  277. {
  278. case USER_EVT_MAITAIN:
  279. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("to maintain...");
  280. m_stateBeforeMaintain = m_fsmState;
  281. pEvt->SetHandled();
  282. break;
  283. case USER_EVT_SWITCH_BACK_TO_RVC:
  284. pEvt->SetHandled();
  285. ret = m_preFsmState;
  286. break;
  287. default:
  288. break;
  289. }
  290. return ret;
  291. }
  292. //0:auth suc or have already authed;1:auth failed;
  293. int CHealthManagerFSM::AccessAuthDoWork()
  294. {
  295. LOG_FUNCTION();
  296. CheckIfPinPadOK();
  297. m_bInAccessAuthDoWork = true;
  298. CSimpleStringA csTermStage("");
  299. ErrorCodeEnum eErrCode = GetEntityBase()->GetFunction()->GetSysVar("TerminalStage", csTermStage);
  300. if (eErrCode == Error_Succeed)
  301. {
  302. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("before accessauth get TerminalStage %s", csTermStage.GetData());
  303. CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
  304. CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
  305. CEntityRunInfo acInfo;
  306. eErrCode = pFunc->GetEntityRunInfo("AccessAuthorization", acInfo);
  307. if (eErrCode == Error_Succeed)
  308. {
  309. switch (acInfo.eState)
  310. {
  311. case EntityState_NoStart:
  312. {
  313. CSmartPointer<IAsynWaitSp> spWaitAC;
  314. eErrCode = pFuncPrivilege->StartEntity("AccessAuthorization", NULL, spWaitAC);
  315. eErrCode = spWaitAC->WaitAnswer(MAX_AYSNC_TIMEOUT);
  316. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start accessauth %d.", eErrCode);
  317. }
  318. break;
  319. case EntityState_Idle:
  320. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("AccessAuth state idle.");
  321. break;
  322. default:
  323. break;
  324. }
  325. if (m_pACClient == NULL)
  326. {
  327. m_pACClient = new AccessAuthService_ClientBase(this->GetEntityBase());
  328. eErrCode = m_pACClient->Connect();
  329. if (eErrCode != Error_Succeed) {
  330. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("accessauth connected failed:%s", SpStrError(eErrCode));
  331. m_pACClient->SafeDelete();
  332. m_pACClient = NULL;
  333. m_bInAccessAuthDoWork = false;
  334. return 1;
  335. }
  336. else {
  337. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("accessauth connected.");
  338. }
  339. }
  340. }
  341. else
  342. {
  343. DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("Get AccessAuth RunInfo failed(%s).", SpStrError(eErrCode));
  344. m_bInAccessAuthDoWork = false;
  345. return 1;
  346. }
  347. if (m_pACClient != NULL)
  348. {
  349. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to call accessauth regist");
  350. CSystemRunInfo sysRunInfo;
  351. if (GetEntityBase()->GetFunction()->GetSystemRunInfo(sysRunInfo) != Error_Succeed || sysRunInfo.eAppBootState == AppBootState_StartEntity)
  352. GetEntityBase()->GetFunction()->GetPrivilegeFunction()->RefreshAppBootState(AppBootState_CallAccessAuth);
  353. m_ullAuthStart = SP::Module::Comm::RVCGetTickCount();
  354. eErrCode = (*m_pACClient)(EntityResource::getLink().upgradeLink())->Regist();
  355. m_bHasAuthEver = true;
  356. if (eErrCode == Error_Succeed)
  357. {
  358. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402501A4")("call AccessAuth's Regist return succeed");
  359. do {
  360. if (m_iAccessAuth != VtmLoad_AccessAuth_Init)
  361. break;
  362. Sleep(1000);
  363. } while (1);//wait for accessauth send result
  364. m_bFirstAccessAuth = false;
  365. m_bInAccessAuthDoWork = false;
  366. return 0;
  367. }
  368. else
  369. {
  370. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402501A4").setResultCode("RTA5102")("call accessauth Regist failed:%s", SpStrError(eErrCode));
  371. m_bInAccessAuthDoWork = false;
  372. return 1;
  373. }
  374. }
  375. else
  376. {
  377. m_bInAccessAuthDoWork = false;
  378. return 1;
  379. }
  380. }
  381. else {
  382. DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("Get TerminalStage failed(%s).", SpStrError(eErrCode));
  383. }
  384. m_bInAccessAuthDoWork = false;
  385. return 1;
  386. }
  387. void CHealthManagerFSM::SetVtmLoadResult(int bResult)
  388. {
  389. m_iAccessAuth = bResult;
  390. ErrorCodeEnum eErrCode;
  391. if (bResult == VtmLoad_AccessAuth_Suc)
  392. {
  393. eErrCode = GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "A");
  394. m_ullAccessAuthCost = SP::Module::Comm::RVCGetTickCount() - m_ullAuthStart;
  395. }
  396. else if (bResult == VtmLoad_AccessAuth_servFail) //准入服务端返回失败
  397. {
  398. eErrCode = GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "S");
  399. m_ullAccessAuthCost = SP::Module::Comm::RVCGetTickCount() - m_ullAuthStart;
  400. }
  401. else if (bResult == VtmLoad_MediaLoadFail) //音视频校验不通过
  402. {
  403. eErrCode = GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "M");
  404. }
  405. else //其他失败
  406. {
  407. eErrCode = GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "C");
  408. if (bResult != VtmLoad_OtherSyncEntityLoadFail)//if haven't call Regist(), no need to calulate the AccessAuth cost
  409. m_ullAccessAuthCost = SP::Module::Comm::RVCGetTickCount() - m_ullAuthStart;
  410. }
  411. if (eErrCode != Error_Succeed)
  412. DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("set TerminalStage %d,failed:%s", bResult, SpStrError(eErrCode));
  413. else
  414. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set TerminalStage %d", bResult);
  415. }
  416. void CHealthManagerFSM::ToReAccessAuth(bool bEver)
  417. {
  418. Sleep(1500);//for function "AccessAuthDoWork" to quit while
  419. if (m_bFirstAccessAuth)
  420. return;
  421. ToCallAccessAuthDoWork();
  422. }
  423. ErrorCodeEnum CHealthManagerFSM::AsyncStartEntity(const char *entity_name, const char *cmdline, void *pData)
  424. {
  425. CSmartPointer<IEntityFunction> pFunc = m_pEntity->GetFunction();
  426. ErrorCodeEnum errCode;
  427. CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
  428. if (pFuncPrivilege != NULL) {
  429. CSmartPointer<IAsynWaitSp> spWait;
  430. errCode = pFuncPrivilege->StartEntity(entity_name, cmdline, spWait);
  431. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("start entity %s,errCode:%s", entity_name, SpStrError(errCode));
  432. if (errCode == Error_Succeed) {
  433. callback_entry *entry = new callback_entry();
  434. entry->pRawData = pData;
  435. entry->EntityName = entity_name;
  436. entry->ErrorResult = Error_Unexpect;
  437. entry->op = OP_START_ENTITY;
  438. if (spWait != NULL)
  439. spWait->SetCallback(this, entry);
  440. }
  441. return errCode;
  442. } else {
  443. return Error_NoPrivilege;
  444. }
  445. }
  446. ErrorCodeEnum CHealthManagerFSM::AsyncStopEntity(const char *entity_name, void *pData)
  447. {
  448. CSmartPointer<IEntityFunction> pFunc = m_pEntity->GetFunction();
  449. CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
  450. if (pFuncPrivilege != NULL) {
  451. CSmartPointer<IAsynWaitSp> spWait;
  452. ErrorCodeEnum Error = pFuncPrivilege->StopEntity(entity_name, spWait);
  453. if (Error == Error_Succeed) {
  454. callback_entry *entry = new callback_entry();
  455. entry->pRawData = pData;
  456. entry->EntityName = entity_name;
  457. entry->ErrorResult = Error_Unexpect;
  458. entry->op = OP_STOP_ENTITY;
  459. if (spWait != NULL)
  460. spWait->SetCallback(this, entry);
  461. }
  462. return Error;
  463. } else {
  464. return Error_NoPrivilege;
  465. }
  466. }
  467. ErrorCodeEnum CHealthManagerFSM::AsyncPauseEntity(const char *entity_name, void *pData)
  468. {
  469. CSmartPointer<IEntityFunction> pFunc = m_pEntity->GetFunction();
  470. CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
  471. if (pFuncPrivilege != NULL) {
  472. CSmartPointer<IAsynWaitSp> spWait;
  473. ErrorCodeEnum Error = pFuncPrivilege->PauseEntity(entity_name, spWait);
  474. if (Error == Error_Succeed) {
  475. callback_entry *entry = new callback_entry();
  476. entry->pRawData = pData;
  477. entry->EntityName = entity_name;
  478. entry->ErrorResult = Error_Unexpect;
  479. entry->op = OP_PAUSE_ENTITY;
  480. if (spWait != NULL)
  481. spWait->SetCallback(this, entry);
  482. }
  483. return Error;
  484. } else {
  485. return Error_NoPrivilege;
  486. }
  487. }
  488. ErrorCodeEnum CHealthManagerFSM::AsyncContinueEntity(const char *entity_name, void *pData)
  489. {
  490. CSmartPointer<IEntityFunction> pFunc = m_pEntity->GetFunction();
  491. CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
  492. if (pFuncPrivilege != NULL) {
  493. CSmartPointer<IAsynWaitSp> spWait;
  494. ErrorCodeEnum Error = pFuncPrivilege->ContinueEntity(entity_name, spWait);
  495. if (Error == Error_Succeed) {
  496. callback_entry *entry = new callback_entry();
  497. entry->pRawData = pData;
  498. entry->EntityName = entity_name;
  499. entry->ErrorResult = Error_Unexpect;
  500. entry->op = OP_CONTINUE_ENTITY;
  501. if (spWait != NULL)
  502. spWait->SetCallback(this, entry);
  503. }
  504. return Error;
  505. } else {
  506. return Error_NoPrivilege;
  507. }
  508. }
  509. ErrorCodeEnum CHealthManagerFSM::AsyncTerminateEntity(const char *entity_name, void *pData)
  510. {
  511. CSmartPointer<IEntityFunction> pFunc = m_pEntity->GetFunction();
  512. CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
  513. if (pFuncPrivilege != NULL) {
  514. CSmartPointer<IAsynWaitSp> spWait;
  515. ErrorCodeEnum Error = pFuncPrivilege->TerminateEntity(entity_name, spWait);
  516. if (Error == Error_Succeed) {
  517. callback_entry *entry = new callback_entry();
  518. entry->pRawData = pData;
  519. entry->EntityName = entity_name;
  520. entry->ErrorResult = Error_Unexpect;
  521. entry->op = OP_TERMINATE_ENTITY;
  522. if (spWait != NULL)
  523. spWait->SetCallback(this, entry);
  524. }
  525. return Error;
  526. } else {
  527. return Error_NoPrivilege;
  528. }
  529. }
  530. void CHealthManagerFSM::OnAnswer(CSmartPointer<IAsynWaitSp> pAsynWaitSp)
  531. {
  532. }
  533. int CHealthManagerFSM::QuitFrameworkAndSaveInfo(RebootTriggerEnum eTrigger, RebootWayEnum eWay)
  534. {
  535. m_bRebooting = true;
  536. CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
  537. CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
  538. if (pFuncPrivilege == NULL) {
  539. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("has no privilege");
  540. return (int)(Error_NoPrivilege);
  541. }
  542. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("quit framework and info %d,%d.", eTrigger, eWay);
  543. const auto result = pFuncPrivilege->Reboot(eTrigger, eWay);
  544. return (int)result;
  545. }
  546. void CHealthManagerFSM::PostProcessAfterUpgrade()
  547. {
  548. LOG_FUNCTION();
  549. if (IfInUpgradeProcess())
  550. {
  551. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("exist upgrade flag file,to decide if restart framework.");
  552. //存在升级后的启动文件
  553. CSmartPointer<IConfigInfo> spConfigRun;
  554. ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->OpenConfig(Config_Run, spConfigRun);
  555. if (eErr == Error_Succeed)
  556. {
  557. int restartOSTime = 0;
  558. spConfigRun->ReadConfigValueInt("Run", "UpgradeRestartOSTimes", restartOSTime);
  559. if(restartOSTime==1){
  560. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("升级切换已重启过系统");
  561. //重启过的系统过的升级,在重试一定次数后等guardian 10分钟回退
  562. int xTimes = 0;
  563. spConfigRun->ReadConfigValueInt("Run", "UpgradeRestartTimes", xTimes);
  564. if (xTimes < 3)
  565. {
  566. xTimes++;
  567. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("写入: UpgradeRestartTimes:%d", xTimes);
  568. spConfigRun->WriteConfigValueInt("Run", "UpgradeRestartTimes", xTimes);
  569. QuitFrameworkAndSaveInfo(RebootTrigger_Resource, RebootWay_Framework);
  570. }
  571. }else{
  572. //未重启过操作系统
  573. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("升级切换未重启过系统");
  574. int xTimes = 0;
  575. spConfigRun->ReadConfigValueInt("Run", "UpgradeRestartTimes", xTimes);
  576. if (xTimes < 3)
  577. {
  578. xTimes++;
  579. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("写入: UpgradeRestartTimes:%d", xTimes);
  580. spConfigRun->WriteConfigValueInt("Run", "UpgradeRestartTimes", xTimes);
  581. //oilyang@20211130 change from 3 to 2
  582. if (xTimes == 2)
  583. {
  584. //重启操作系统前把重启框架次数重置,重启OS次数置为1
  585. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("准备尝试重启系统后再切换升级");
  586. spConfigRun->WriteConfigValueInt("Run", "UpgradeRestartTimes", 0);
  587. spConfigRun->WriteConfigValueInt("Run", "UpgradeRestartOSTimes", 1);
  588. Sleep(2000);
  589. QuitFrameworkAndSaveInfo(RebootTrigger_Resource, RebootWay_OS);
  590. }
  591. else
  592. QuitFrameworkAndSaveInfo(RebootTrigger_Resource, RebootWay_Framework);
  593. }
  594. }
  595. }
  596. }
  597. }
  598. CSimpleStringA CHealthManagerFSM::GetOsVersion()
  599. {
  600. #if defined(RVC_OS_WIN)
  601. CSimpleStringA runInfoPath;
  602. ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetPath("runinfo", runInfoPath);
  603. if (eErr != Error_Succeed) {
  604. DbgWithLink(LOG_LEVEL_ERROR,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("GetPath runinfo error=%s.", SpStrError(eErr));
  605. return "";
  606. }
  607. runInfoPath += "\\runcfg\\osverion";
  608. ifstream is;
  609. is.open(runInfoPath.GetData(), ios::binary);
  610. if (!is.is_open())
  611. {
  612. DWORD dwErr = GetLastError();
  613. DbgWithLink(LOG_LEVEL_ERROR,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open runcfg\\osverion file failed. [%d]", dwErr);
  614. return "";
  615. }
  616. string line;
  617. while(!is.eof()){
  618. getline(is, line);
  619. int start = line.find("版本");
  620. if (start != string::npos)
  621. //return CSimpleStringA(line.substr(start + 5, line.length() - start - 7).c_str());
  622. return CSimpleStringA(line.c_str());
  623. else
  624. continue;
  625. }
  626. return "";
  627. #else
  628. std::map<std::string, std::string> osInfo;
  629. const char filePath[] = "/etc/os-version";
  630. char tmp[33];
  631. memset(tmp, 0, 33);
  632. inifile_read_str_s("Version", "SystemName", "unknown", tmp, 32, filePath);
  633. osInfo["SystemName"] = tmp;
  634. memset(tmp, 0, 33);
  635. inifile_read_str_s("Version", "ProductType", "unknown", tmp, 32, filePath);
  636. osInfo["ProductType"] = tmp;
  637. memset(tmp, 0, 33);
  638. inifile_read_str_s("Version", "MajorVersion", "unknown", tmp, 32, filePath);
  639. osInfo["MajorVersion"] = tmp;
  640. memset(tmp, 0, 33);
  641. inifile_read_str_s("Version", "MinorVersion", "unknown", tmp, 32, filePath);
  642. osInfo["MinorVersion"] = tmp;
  643. memset(tmp, 0, 33);
  644. inifile_read_str_s("Version", "OsBuild", "unknown", tmp, 32, filePath);
  645. osInfo["OsBuild"] = tmp;
  646. return generateJsonStr(osInfo).second.c_str();
  647. #endif
  648. }
  649. DWORD GetDualTime(SYSTEMTIME& t1, SYSTEMTIME& t2)
  650. {
  651. //assume t2 > t1...
  652. //oiltest for simple
  653. int s1, s2;
  654. s1 = (t1.wMinute * 60 + t1.wSecond) * 1000 + t1.wMilliseconds;
  655. s2 = (t2.wMinute * 60 + t2.wSecond) * 1000 + t2.wMilliseconds;
  656. return s2 - s1;
  657. }
  658. void CHealthManagerFSM::ToLogWarnTermAboutInfo()
  659. {
  660. LOG_FUNCTION();
  661. bool bTmpEtyNewStart = m_bEntityNewStart;
  662. if (m_bEntityNewStart)
  663. {
  664. SYSTEMTIME shellStartTime;
  665. m_ullTotalCost = 0;
  666. m_bEntityNewStart = false;
  667. CAutoArray<CSimpleStringA> strEntityNames;
  668. CAutoArray<int> strEntityIdx;
  669. CAutoArray<CEntityStartInfo> Infos;
  670. ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetAllEntityStartInfo(strEntityNames, strEntityIdx, Infos);
  671. for (int i = 0; i < Infos.GetCount(); ++i)
  672. {
  673. if (strEntityIdx[i] == 0)
  674. {
  675. shellStartTime = Infos[i].startTime;
  676. ULONGLONG dwElapseNow = SP::Module::Comm::RVCGetTickCount();
  677. m_ullTotalCost = dwElapseNow - m_ullElapseFromOSStart;
  678. LogWarn(Severity_Low, Error_Debug, LOG_TRACE_ENTITY_START_TIME,
  679. SP::Module::Util::generateConsumeTimeJson("total", SP::Module::Util::formatTime(shellStartTime).c_str(), m_ullTotalCost).GetData());
  680. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("EntityStartCost")(SP::Module::Util::generateConsumeTimeJson("total", SP::Module::Util::formatTime(shellStartTime).c_str(), m_ullTotalCost).GetData());
  681. //break;
  682. }
  683. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s,%d", strEntityNames[i].GetData(), GetDualTime(Infos[i].startTime, Infos[i].startEndTime));
  684. if (strEntityNames[i].Compare("SIPPhone") == 0)
  685. m_ullSIPPhoneCost = GetDualTime(Infos[i].startTime, Infos[i].startEndTime);
  686. else if (strEntityNames[i].Compare("TokenKeeper") == 0)
  687. m_ullTokenKeeperCost = GetDualTime(Infos[i].startTime, Infos[i].startEndTime);
  688. }
  689. std::map<std::string, std::string> termStartInfo;
  690. termStartInfo["SIPPhoneCost"] = CSimpleStringA::Format("%d", m_ullSIPPhoneCost);
  691. termStartInfo["TokenKeeperCost"] = CSimpleStringA::Format("%d", m_ullTokenKeeperCost);
  692. termStartInfo["WaitForPinPadCost"] = CSimpleStringA::Format("%d", m_ullWaitForPinPad);
  693. termStartInfo["TotalCost"] = CSimpleStringA::Format("%d", m_ullTotalCost);
  694. termStartInfo["AccessAuthCost"] = CSimpleStringA::Format("%d", m_ullAccessAuthCost);
  695. termStartInfo["AccessAuthResult"] = CSimpleStringA::Format("%d", m_iAccessAuth);
  696. termStartInfo["OSElapseTime"] = CSimpleStringA::Format("%d", m_elapseTimeFromOSStart);
  697. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("TerminalStartCost")("%s", generateJsonStr(termStartInfo).second.c_str());
  698. LogWarn(Severity_Low, Error_Debug, HealthManager_UserErrorCode_TerminalAppLoadInfo, generateJsonStr(termStartInfo).second.c_str());
  699. }
  700. QueryAndSaveDNS();
  701. QueryAndSendCPUInfo();
  702. QueryAndSendDisplayInfo();
  703. CSimpleStringA csOSVerion(""), csWarnMsg("");
  704. std::map<std::string, std::string> termInfo;
  705. termInfo["version"] = m_sysInfo.InstallVersion.ToString();
  706. if (m_iAccessAuth == VtmLoad_AccessAuth_Suc)
  707. {
  708. termInfo["AccessAuth"] = "T";
  709. }
  710. else
  711. {
  712. termInfo["AccessAuth"] = "F";
  713. CSimpleStringA tmpAuthErrMsg("");
  714. if (GetEntityBase()->GetFunction()->GetSysVar("AuthErrMsg", tmpAuthErrMsg) == Error_Succeed)
  715. termInfo["AuthErrMsg"] = tmpAuthErrMsg;
  716. }
  717. csOSVerion = GetOsVersion();
  718. if (!csOSVerion.IsNullOrEmpty())
  719. termInfo["OSVersion"] = csOSVerion;
  720. termInfo["Harddisk"] = QueryHarddiskInfo();
  721. #if defined(RVC_OS_WIN)
  722. termInfo["OSType"] = "Windows";
  723. termInfo["AsiaInfo"] = CheckProcessExistByName("NTRtScan.exe") ? "Y" : "N";
  724. termInfo["UniAccess"] = CheckProcessExistByName("UniAccessAgent.exe") ? "Y" : "N";
  725. termInfo["RuiYan"] = CheckProcessExistByName("RuiYan.exe") ? "Y" : "N";
  726. termInfo["Symantec"] = CheckProcessExistByName("SavUI.exe") ? "Y" : "N";
  727. #else
  728. termInfo["OSType"] = "UOS";
  729. #endif
  730. CSmartPointer<IConfigInfo> spConfigRun;
  731. GetEntityBase()->GetFunction()->OpenConfig(Config_Run, spConfigRun);
  732. //CAutoArray<SP::Module::Net::NetworkAdapterItem> netList;
  733. if (m_netList.GetCount() == 0)
  734. SP::Module::Net::GetINETMacAddresses(m_netList);
  735. CSimpleStringA csMac(""), csIP(""), csDNS("");
  736. for (int i = 0; i < m_netList.GetCount(); i++) {
  737. if (!csMac.IsNullOrEmpty()) {
  738. csMac += ";";
  739. }
  740. csMac += m_netList[i].mac.c_str();
  741. if (!csIP.IsNullOrEmpty()) {
  742. csIP += ";";
  743. }
  744. csIP += m_netList[i].ip.c_str();
  745. }
  746. for (int i = 0; i < m_dns.GetCount(); i++) {
  747. if (!csDNS.IsNullOrEmpty()) {
  748. csDNS += ";";
  749. }
  750. csDNS += m_dns[i].c_str();
  751. }
  752. termInfo["MACs"] = csMac;
  753. termInfo["IPs"] = csIP;
  754. termInfo["DNSs"] = csDNS;
  755. char xOSTime[64] = {0};
  756. char elapseTime[64] = {0};//使用机器启动时间秒数
  757. ULONGLONG dwElapse = SP::Module::Comm::RVCGetTickCount();
  758. DWORD elapseTimeTemp = dwElapse / 1000;
  759. termInfo["OSTime"] = _itoa(m_elapseTimeFromOSStart, xOSTime, 10);
  760. termInfo["elapseTime"] = _itoa(elapseTimeTemp, elapseTime, 10);
  761. CSimpleStringA csRunPath("");
  762. GetEntityBase()->GetFunction()->GetPath("Run", csRunPath);
  763. termInfo["AppPath"] = csRunPath;
  764. std::pair<bool, std::string> strResult;
  765. strResult = generateJsonStr(termInfo);
  766. spConfigRun->ReadConfigValue("Run", "WarnMsg", csWarnMsg);
  767. //oilyang@20210323 discard the following rule of throwing LogWarn.Always throw LogWarn
  768. //oilyang@20201201 log warn every time if content of msg has changed
  769. if (bTmpEtyNewStart)
  770. {
  771. LogWarn(Severity_Low, Error_Unexpect, LOG_WARN_HEALTH_UPLOAD_INFO_ABOUT_TERM, strResult.second.c_str());
  772. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutTerm")(strResult.second.c_str());
  773. }
  774. else
  775. {
  776. LogWarn(Severity_Low, Error_Unexpect, LOG_WARN_HEALTH_UPLOAD_INFO_ABOUT_TERM, strResult.second.c_str());
  777. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutTerm")(strResult.second.c_str());
  778. }
  779. }
  780. void CHealthManagerFSM::ToCallAccessAuthDoWork()
  781. {
  782. if (!m_bInAccessAuthDoWork)
  783. {
  784. DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("To Call AccessAuthDoWork");
  785. AccessAuthTask* pTask = new AccessAuthTask(this);
  786. GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
  787. }
  788. }
  789. bool CHealthManagerFSM::IfInUpgradeProcess()
  790. {
  791. CSimpleStringA csRunCfgPath(""), csFileName("");
  792. ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetPath("RunCfg", csRunCfgPath);
  793. csFileName = csRunCfgPath + SPLIT_SLASH_STR + "starttime.dat";
  794. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("csFileName:%s", csFileName.GetData());
  795. if (ExistsFileA(csFileName)) {
  796. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("升级切换中");
  797. return true;
  798. }
  799. else
  800. return false;
  801. }
  802. void CHealthManagerFSM::WaitToCallAccessAuthDoWork()
  803. {
  804. //WaitForSingleObject
  805. bool bHaveShowMsg = false;
  806. while (1)
  807. {
  808. CSimpleStringA csHavePath("N");
  809. GetEntityBase()->GetFunction()->GetSysVar("AccessHavePath", csHavePath);
  810. if (csHavePath.Compare("Y") == 0 || csHavePath.Compare("E") == 0)
  811. {
  812. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402501A2")("AccessAuth entity ok.");
  813. AccessAuthTask* pTask = new AccessAuthTask(this);
  814. GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
  815. break;
  816. }
  817. else
  818. {
  819. Sleep(5000);
  820. LogWarn(Severity_High, Error_Unexpect, HealthManager_UserErrorCode_WaitForAccessAuthEntityIdle, "等待准入实体准备好");
  821. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402501A2").setResultCode("RTA5107")("等待准入实体准备好");
  822. }
  823. }
  824. }
  825. void CHealthManagerFSM::WKUpdatePeriod()
  826. {
  827. if (m_sysInfo.strTerminalID.GetLength() < 7)
  828. {
  829. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("wrong terminalNo:[%s]", m_sysInfo.strTerminalID.GetData());
  830. return;
  831. }
  832. auto pEntity = ((CHealthManagerEntity*)m_pEntity);
  833. //oilyang@20220413 control update working key by CenterSetting
  834. if (m_iDoNotUpdateWKDaily == 1)
  835. {
  836. // 没有密码键盘 或 集中配置告知无需更新,无需更新
  837. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)
  838. (CSimpleStringA::Format("DoNotUpdateWKDaily:%d, ignore update wk"
  839. , m_iDoNotUpdateWKDaily));
  840. return;
  841. }
  842. // 检查上次密钥同步时间(一天只同步一次)
  843. CSmartPointer<IConfigInfo> pConfigRun;
  844. m_pEntity->GetFunction()->OpenConfig(Config_Run, pConfigRun);
  845. int nWKLastSyncTime(0);
  846. pConfigRun->ReadConfigValueInt("Main", "WKSyncSuccTime", nWKLastSyncTime);
  847. int nWKSyncFailCount(0);
  848. pConfigRun->ReadConfigValueInt("Main", "WKSyncFailCount", nWKSyncFailCount);
  849. SYSTEMTIME stSyncTime = CSmallDateTime(nWKLastSyncTime).ToSystemTime();
  850. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)
  851. ("last WK sync time: %04d-%02d-%02d %02d:%02d:%02d",
  852. stSyncTime.wYear, stSyncTime.wMonth, stSyncTime.wDay,
  853. stSyncTime.wHour, stSyncTime.wMinute, stSyncTime.wSecond);
  854. SYSTEMTIME stNow = {};
  855. GetLocalTime(&stNow);
  856. int lastUpdateDays = sumday(stSyncTime.wYear, stSyncTime.wMonth, stSyncTime.wDay);
  857. int todayDays = sumday(stNow.wYear, stNow.wMonth, stNow.wDay);
  858. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("lastUpdateDays:%d,todayDays:%d,x:%d", lastUpdateDays,todayDays, todayDays-lastUpdateDays);
  859. //if ((nWKLastSyncTime > 0 && stSyncTime.wYear == stNow.wYear
  860. // && stSyncTime.wMonth == stNow.wMonth && stSyncTime.wDay == stNow.wDay
  861. // && nWKSyncFailCount == 0)) // 最近一次同步成功,才能跳过
  862. if (todayDays - lastUpdateDays < m_wkUpdatePeriod)
  863. {
  864. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)
  865. ("WK has been updated, last sync time: %s", (const char*)CSmallDateTime(nWKLastSyncTime).ToTimeString());
  866. }
  867. else
  868. {
  869. //if have exceed the time,we should update working key in the next peroid
  870. if (todayDays - lastUpdateDays < m_wkUpdatePeriod * 2)
  871. {
  872. int xTerm = atoi(m_sysInfo.strTerminalID.SubString(m_sysInfo.strTerminalID.GetLength() - 7, 7));
  873. if ((todayDays % m_wkUpdatePeriod) != (xTerm % m_wkUpdatePeriod))
  874. {
  875. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("todayDays:%d, xTerm:%d, m_wkUpdatePeriod:%d", todayDays, xTerm, m_wkUpdatePeriod);
  876. return;
  877. }
  878. }
  879. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("begin update WK now");
  880. ErrorCodeEnum eErrCode = Error_Succeed;
  881. if (m_pACClient == NULL)
  882. {
  883. m_pACClient = new AccessAuthService_ClientBase(this->GetEntityBase());
  884. eErrCode = m_pACClient->Connect();
  885. if (eErrCode != Error_Succeed) {
  886. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("accessauth connected failed:%d", eErrCode);
  887. m_pACClient->SafeDelete();
  888. m_pACClient = NULL;
  889. m_bInAccessAuthDoWork = false;
  890. return;
  891. }
  892. else {
  893. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("accessauth connected.");
  894. }
  895. }
  896. eErrCode = (*m_pACClient)(EntityResource::getLink().upgradeLink())->UpdateWK();
  897. if(Error_Succeed == eErrCode)
  898. {
  899. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402501K1")("accessauth updatewk succ.");
  900. pConfigRun->WriteConfigValue("Main", "WKSyncSuccTime",
  901. (const char*) CSimpleStringA::Format("0x%08X", (DWORD)CSmallDateTime::GetNow()));
  902. pConfigRun->WriteConfigValueInt("Main", "WKSyncFailCount", 0);
  903. }
  904. else
  905. {
  906. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402501K1").setResultCode("RTA5103")("accessauth updatewk failed.");
  907. nWKSyncFailCount++;
  908. pConfigRun->WriteConfigValueInt("Main", "WKSyncFailCount", nWKSyncFailCount);
  909. }
  910. }
  911. }
  912. int CHealthManagerFSM::sumday(int year, int month, int day)
  913. {
  914. 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} };
  915. int iLeapYear = 0;
  916. if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
  917. iLeapYear = 1;
  918. int yearday = year * 365 + year / 4 - year / 100 + year / 400;
  919. int monthday = days[iLeapYear][month - 1];
  920. return yearday + monthday + day;
  921. }
  922. void CHealthManagerFSM::QueryHardwareInfo(SpReqAnsContext<HealthManagerService_QueryHardwareInfo_Req, HealthManagerService_QueryHardwareInfo_Ans>::Pointer ctx)
  923. {
  924. CSystemStaticInfo info;
  925. GetEntityBase()->GetFunction()->GetSystemStaticInfo(info);
  926. //CAutoArray<SP::Module::Net::NetworkAdapterItem> netList;
  927. if (m_netList.GetCount() == 0)
  928. SP::Module::Net::GetINETMacAddresses(m_netList);
  929. CAutoArray<CSimpleStringA> ipAddrs, macAddrs;
  930. for (int i = 0; i < m_netList.GetCount(); i++) {
  931. CSimpleStringA tmpip = m_netList[i].ip.c_str();
  932. CSimpleStringA tmpmac = m_netList[i].mac.c_str();
  933. ipAddrs.Append(&tmpip, 0, 1);
  934. macAddrs.Append(&tmpmac, 0, 1);
  935. }
  936. ctx->Ans.ip = ipAddrs;
  937. ctx->Ans.mac = macAddrs;
  938. ctx->Ans.machineType = info.strMachineType;
  939. ctx->Ans.site = info.strSite;
  940. ctx->Ans.terminalNo = info.strTerminalID;
  941. ctx->Ans.termLimit = "";
  942. ctx->Ans.termVersion = info.InstallVersion.ToString();
  943. //oilyang@20241220 (win)不再获取操作系统信息
  944. ctx->Ans.reserved3 = "";
  945. ctx->Ans.reserved4 = "";
  946. //oilyang@20241220 标准版搜狗输入法推全行已久,默认给1,即走标准输入法。待郭丹下线业务端依赖逻辑后废弃此字段使用
  947. ctx->Ans.reserved2 = 1;
  948. //reserved1
  949. #ifdef DEVOPS_ON_ST /*DevOps流水线编译,ST环境*/
  950. ctx->Ans.reserved1 = 1;
  951. #elif defined(DEVOPS_ON_UAT)/*DevOps流水线编译,UAT环境*/
  952. ctx->Ans.reserved1 = 2;
  953. #elif defined(DEVOPS_ON_PRD)/*DevOps流水线编译,PRD环境*/
  954. ctx->Ans.reserved1 = 3;
  955. #elif defined(DEVOPS_ON_DEV)/*DevOps流水线编译,Dev环境*/
  956. ctx->Ans.reserved1 = 0;
  957. #else/*本地编译等非DevOps环境编译的版本*/
  958. ctx->Ans.reserved1 = 0;
  959. #endif
  960. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402501Q1")("termNo:%s,termVersion:%s,env:%d,machineType:%s", ctx->Ans.terminalNo.GetData(), ctx->Ans.termVersion.GetData(), ctx->Ans.reserved1
  961. , ctx->Ans.machineType.GetData());
  962. ctx->Answer(Error_Succeed);
  963. }
  964. bool CHealthManagerFSM::CheckProcessExistByName(CSimpleStringA procName)
  965. {
  966. if (procName.IsNullOrEmpty())
  967. return false;
  968. #ifdef RVC_OS_WIN
  969. HANDLE hSnapshot;
  970. //find if have "NTRtScan.exe"
  971. hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  972. if (hSnapshot)
  973. {
  974. PROCESSENTRY32 pe;
  975. pe.dwSize = sizeof(pe);
  976. if (Process32First(hSnapshot, &pe))
  977. {
  978. do {
  979. if (_stricmp(&pe.szExeFile[0], procName.GetData()) == 0)
  980. {
  981. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("find %s on this machine.", procName.GetData());
  982. return true;
  983. }
  984. } while (Process32Next(hSnapshot, &pe));
  985. }
  986. CloseHandle(hSnapshot);
  987. }
  988. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("can't find %s on this machine.", procName.GetData());
  989. return false;
  990. #else
  991. return false;
  992. #endif
  993. }
  994. void CHealthManagerFSM::QueryAndSaveDNS()
  995. {
  996. for (int i = 0; i < m_dns.GetCount(); ++i)
  997. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("before to get, the m_dns[%s]", m_dns[i].c_str());
  998. m_dns.Clear();
  999. CSimpleStringA runInfoPath, csDNSKeyword;
  1000. ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetPath("runinfo", runInfoPath);
  1001. if (eErr != Error_Succeed) {
  1002. DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("GetPath runinfo error=%d.", eErr);
  1003. return;
  1004. }
  1005. runInfoPath = runInfoPath + SPLIT_SLASH_STR + "runcfg" + SPLIT_SLASH_STR + "dns";
  1006. #if defined(RVC_OS_WIN)
  1007. CSimpleStringA csCmd;
  1008. csCmd = CSimpleStringA::Format("cmd /c ipconfig /all >%s", runInfoPath.GetData());
  1009. WinExec((LPCSTR)csCmd, SW_HIDE);
  1010. csDNSKeyword = "DNS 服务器";
  1011. #else
  1012. std::string sucContent, failedContent;
  1013. CSimpleStringA strCmd;
  1014. strCmd = CSimpleStringA::Format("cat /etc/resolv.conf | grep \"nameserver\" >%s", runInfoPath.GetData());
  1015. bool ret = SP::Module::Util::ShellExecute(strCmd.GetData(), sucContent, failedContent);
  1016. csDNSKeyword = "nameserver";
  1017. #endif //RVC_OS_WIN
  1018. ifstream is;
  1019. is.open(runInfoPath.GetData(), ios::binary);
  1020. if (!is.is_open())
  1021. {
  1022. DWORD dwErr = GetLastError();
  1023. DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("open %s file failed. [%d]", runInfoPath.GetData(), dwErr);
  1024. return;
  1025. }
  1026. string line;
  1027. while (!is.eof()) {
  1028. getline(is, line);
  1029. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("line:%s", line.c_str());
  1030. size_t start = line.find(csDNSKeyword.GetData());
  1031. if (start != string::npos)
  1032. {
  1033. #if defined(RVC_OS_WIN)
  1034. int dnsStart = line.find(": ");
  1035. if (dnsStart != string::npos)
  1036. {
  1037. string xDns = SP::Utility::ToTrim(line.substr(dnsStart + 1, line.length() - dnsStart - 1));
  1038. m_dns.Append(&xDns, 0, 1);
  1039. }
  1040. #else
  1041. string xDns = SP::Utility::ToTrim(line.substr(start + csDNSKeyword.GetLength() + 1, line.length() - start - csDNSKeyword.GetLength() - 1));
  1042. m_dns.Append(&xDns, 0, 1);
  1043. #endif
  1044. }
  1045. else
  1046. continue;
  1047. }
  1048. return;
  1049. }
  1050. void CHealthManagerFSM::QueryAndSendCPUInfo()
  1051. {
  1052. #if defined(RVC_OS_WIN)
  1053. if (!m_cpuInfo.IsNullOrEmpty())
  1054. {
  1055. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("have queried cpu info, no need to query again, current cpuinfo:%s", m_cpuInfo.GetData());
  1056. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutCPU")(m_cpuInfo.GetData());
  1057. return;
  1058. }
  1059. SYSTEM_INFO si;
  1060. GetSystemInfo(&si);
  1061. std::map<std::string, std::string> map_cpuInfo;
  1062. map_cpuInfo.insert(std::make_pair("dwProcessorType", CSimpleStringA::Format("%d", si.dwProcessorType)));
  1063. map_cpuInfo.insert(std::make_pair("wProcessorLevel", CSimpleStringA::Format("%d", si.wProcessorLevel)));
  1064. map_cpuInfo.insert(std::make_pair("wProcessorArchitecture", CSimpleStringA::Format("%d", si.wProcessorArchitecture)));
  1065. map_cpuInfo.insert(std::make_pair("wProcessorRevision", CSimpleStringA::Format("%d", si.wProcessorRevision)));
  1066. map_cpuInfo.insert(std::make_pair("dwNumberOfProcessors", CSimpleStringA::Format("%d", si.dwNumberOfProcessors)));
  1067. m_cpuInfo = generateJsonStr(map_cpuInfo).second.c_str();
  1068. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutCPU")(m_cpuInfo.GetData());
  1069. #else
  1070. ifstream cpuinfo("/proc/cpuinfo");
  1071. if (!cpuinfo.is_open()) {
  1072. DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("opening /proc/cpuinfo error:%s", strerror(errno));
  1073. return;
  1074. }
  1075. std::map<std::string, std::string> map_cpuInfo;
  1076. string line;
  1077. while (std::getline(cpuinfo, line)) {
  1078. auto elems = SP::Utility::Split(line, ':');
  1079. if (elems.size() > 1) {
  1080. map_cpuInfo[SP::Utility::ToTrim(elems[0])] = SP::Utility::ToTrim(elems[1]);
  1081. if (line.find("CPU revision") != string::npos)
  1082. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutCPU")(generateJsonStr(map_cpuInfo).second.c_str());
  1083. }
  1084. }
  1085. #endif //RVC_OS_WIN
  1086. return;
  1087. }
  1088. void CHealthManagerFSM::QueryAndSendDisplayInfo()
  1089. {
  1090. std::map<std::string, std::string> primaryInfo;
  1091. std::map<std::string, std::string> secondaryInfo;
  1092. std::map<std::string, std::string> displayInfo;
  1093. #if defined(RVC_OS_WIN)
  1094. DISPLAY_DEVICE devDevice;
  1095. devDevice.cb = sizeof(DISPLAY_DEVICE);
  1096. //获取系统中的所有显示设备
  1097. EnumDisplayDevices(NULL, ENUM_CURRENT_SETTINGS, &devDevice, 0);
  1098. bool bPrimary = false;
  1099. // 遍历显示设备列表
  1100. for (int i = 0; EnumDisplayDevices(NULL, i, &devDevice, 0) != 0; i++)
  1101. {
  1102. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("devDevice.StateFlags:%d", devDevice.StateFlags);
  1103. bPrimary = false;
  1104. //if connected
  1105. if (devDevice.StateFlags & DISPLAY_DEVICE_ACTIVE)
  1106. {
  1107. if (devDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
  1108. bPrimary = true;
  1109. // 获取显示设备的分辨率
  1110. DEVMODE devMode;
  1111. devMode.dmSize = sizeof(DEVMODE);
  1112. EnumDisplaySettings(devDevice.DeviceName, ENUM_CURRENT_SETTINGS, &devMode);
  1113. if (bPrimary)
  1114. {
  1115. primaryInfo["dmDeviceName"] = CSimpleStringA::Format("%s", devMode.dmDeviceName);
  1116. primaryInfo["dmPelsWidth"] = CSimpleStringA::Format("%d", devMode.dmPelsWidth);
  1117. primaryInfo["dmPelsHeight"] = CSimpleStringA::Format("%d", devMode.dmPelsHeight);
  1118. primaryInfo["dmDisplayOrientation"] = CSimpleStringA::Format("%d", devMode.dmDisplayOrientation);
  1119. primaryInfo["dmDisplayFixedOutput"] = CSimpleStringA::Format("%d", devMode.dmDisplayFixedOutput);
  1120. primaryInfo["dmPosition.x"] = CSimpleStringA::Format("%d", devMode.dmPosition.x);
  1121. primaryInfo["dmPosition.y"] = CSimpleStringA::Format("%d", devMode.dmPosition.y);
  1122. }
  1123. else
  1124. {
  1125. secondaryInfo["dmDeviceName"] = CSimpleStringA::Format("%s", devMode.dmDeviceName);
  1126. secondaryInfo["dmPelsWidth"] = CSimpleStringA::Format("%d", devMode.dmPelsWidth);
  1127. secondaryInfo["dmPelsHeight"] = CSimpleStringA::Format("%d", devMode.dmPelsHeight);
  1128. secondaryInfo["dmDisplayOrientation"] = CSimpleStringA::Format("%d", devMode.dmDisplayOrientation);
  1129. secondaryInfo["dmDisplayFixedOutput"] = CSimpleStringA::Format("%d", devMode.dmDisplayFixedOutput);
  1130. secondaryInfo["dmPosition.x"] = CSimpleStringA::Format("%d", devMode.dmPosition.x);
  1131. secondaryInfo["dmPosition.y"] = CSimpleStringA::Format("%d", devMode.dmPosition.y);
  1132. }
  1133. }
  1134. }
  1135. displayInfo["PrimaryText"] = generateJsonStr(primaryInfo).second.c_str();
  1136. displayInfo["SecondaryText"] = generateJsonStr(secondaryInfo).second.c_str();
  1137. #else
  1138. CSimpleStringA runInfoPath, csDNSKeyword;
  1139. ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetPath("runinfo", runInfoPath);
  1140. if (eErr != Error_Succeed) {
  1141. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetPath runinfo error=%d.", eErr);
  1142. return;
  1143. }
  1144. runInfoPath = runInfoPath + SPLIT_SLASH_STR + "runcfg" + SPLIT_SLASH_STR + "monitor";
  1145. std::string sucContent, failedContent;
  1146. CSimpleStringA strCmd;
  1147. strCmd = CSimpleStringA::Format("xrandr | grep \" connected\" >%s", runInfoPath.GetData());
  1148. bool ret = SP::Module::Util::ShellExecute(strCmd.GetData(), sucContent, failedContent);
  1149. if (!ret)
  1150. {
  1151. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("failedContent:%s", failedContent.c_str());
  1152. return;
  1153. }
  1154. ifstream is;
  1155. is.open(runInfoPath.GetData(), ios::binary);
  1156. if (!is.is_open())
  1157. {
  1158. DWORD dwErr = GetLastError();
  1159. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("open %s file failed. [%d]", runInfoPath.GetData(), dwErr);
  1160. return;
  1161. }
  1162. string line;
  1163. while (!is.eof()) {
  1164. getline(is, line);
  1165. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("line:%s", line.c_str());
  1166. if (line.find("connected") != string::npos)
  1167. {
  1168. if (line.find("primary") != string::npos)
  1169. displayInfo["PrimaryText"] = line;
  1170. else
  1171. displayInfo["SecondaryText"] = line;
  1172. }
  1173. }
  1174. #endif
  1175. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutDisplay")(generateJsonStr(displayInfo).second.c_str());
  1176. }
  1177. string CHealthManagerFSM::QueryHarddiskInfo()
  1178. {
  1179. CSimpleStringA csRunCfgPath("");
  1180. GetEntityBase()->GetFunction()->GetPath("RunCfg", csRunCfgPath);
  1181. csRunCfgPath = csRunCfgPath + SPLIT_SLASH_STR + "AccessAuthorization.ini";
  1182. char tmp[256];
  1183. memset(tmp, 0, 256);
  1184. inifile_read_str_s("system", "info", "", tmp, 255, csRunCfgPath);
  1185. auto elems = SP::Utility::Split(tmp, '|');
  1186. if (elems.size() > 2) {
  1187. return SP::Utility::ToTrim(elems[2]);
  1188. }
  1189. return "";
  1190. }
  1191. void CHealthManagerFSM::CheckIfPinPadOK()
  1192. {
  1193. //to check if PinPad is ok, wait for 5 seconds,then go on
  1194. //RVC.CardStore have no PinPad
  1195. if (m_sysInfo.strMachineType.Compare("RVC.CardStore", true) == 0)
  1196. {
  1197. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402501A3")("RVC.CardStore have no PinPad");
  1198. return;
  1199. }
  1200. ULONGLONG ullWaitStart, ullWaitEnd;
  1201. ullWaitEnd = ullWaitStart = SP::Module::Comm::RVCGetTickCount();
  1202. PinPadService_ClientBase* pClient = new PinPadService_ClientBase(this->m_pEntity);
  1203. if (pClient != NULL)
  1204. {
  1205. ErrorCodeEnum eErrCode = pClient->Connect();
  1206. if (eErrCode == Error_Succeed)
  1207. {
  1208. do {
  1209. PinPadService_GetDevInfo_Req reqQ;
  1210. PinPadService_GetDevInfo_Ans ansQ;
  1211. eErrCode = (*pClient)(EntityResource::getLink().upgradeLink())->GetDevInfo(reqQ, ansQ, 1000);
  1212. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("eErrCode:%d,ansQ.state:%d", eErrCode, ansQ.state);
  1213. ullWaitEnd = SP::Module::Comm::RVCGetTickCount();
  1214. if (eErrCode == Error_DevNotAvailable)
  1215. {
  1216. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("pinpad open failed");
  1217. break;
  1218. }
  1219. else if (eErrCode == Error_Succeed)
  1220. break;
  1221. if (ullWaitEnd - ullWaitStart > m_maxWaitForPinPad)
  1222. break;
  1223. Sleep(500);
  1224. } while (true);
  1225. }
  1226. else
  1227. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("connect to pinpad failed.error code:%d", eErrCode);
  1228. }
  1229. else
  1230. DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("new PinPadService_ClientBase failed.GetLastError:%d", GetLastError());
  1231. m_ullWaitForPinPad = ullWaitEnd - ullWaitStart;
  1232. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402501A3").setCostTime(m_ullWaitForPinPad)("finish (or time out) check PinPad");
  1233. return;
  1234. }
  1235. bool CHealthManagerFSM::CheckIfAccessAuthSuc()
  1236. {
  1237. if (m_iAccessAuth == VtmLoad_AccessAuth_Suc)
  1238. return true;
  1239. CSimpleStringA csTmpTS("");
  1240. GetEntityBase()->GetFunction()->GetSysVar("TerminalStage", csTmpTS);
  1241. if (csTmpTS.Compare("A") == 0)
  1242. return true;
  1243. else
  1244. return false;
  1245. }