Эх сурвалжийг харах

#IQRV #comment [Healthmanager] 密码键盘启动及安装时间告警上传

gifur 4 жил өмнө
parent
commit
41cf5793e0

+ 4 - 0
Module/include/EventCode.h

@@ -790,6 +790,10 @@ ERR_ACCESSAUTH_SHA1_HASH}
 #define LOG_EVT_HEALTH_UPS_NO_ELECTOR 0x50100001			//无市电
 #define LOG_EVT_HEALTH_FIRST_ENTER_MAINPADE 0x50100002			//IE启动以来首次进首页
 #define LOG_EVT_HEALTH_FIRST_ENTER_MAINPADE_FROM_HEALTH_START 0x50100003	//健康启动以来首次进首页
+#define LOG_WARN_HEALTH_INSTALL_FINISHED 0x50100004		//安装成功的标识
+#define LOG_WARN_HEALTH_INSTALL_RESET 0x50100005		//请求重新安装的标识
+#define LOG_WARN_HEALTH_INSTALL_TIMESTAMP 0x50100006		//上报安装时间标识
+
 #define LOG_WARN_HEALTH_MODULE_RESTART_TIMES 0x50140001		//模块指定时间内重启次数过多
 #define LOG_WARN_HEALTH_UPLOAD_INFO_ABOUT_TERM		0x50140002	//上传终端配置相关信息
 #define LOG_WARN_HEALTH_ACCESSAUTH_FAILED 0x50140003

+ 9 - 1
Module/mod_healthmanager/EntityBootStruct.h

@@ -128,7 +128,15 @@ struct TerminalDeployStep : public BootStep
 struct TerminalDeploySecondStep : public BootStep
 {
     TerminalDeploySecondStep(const CSimpleStringA& sectionPosix)
-        : BootStep(CSimpleStringA("TerminalDeploy.") + sectionPosix)
+        : BootStep(CSimpleStringA("TerminalDeploySec.") + sectionPosix)
+    {
+    }
+};
+
+struct TerminalDeployThirdStep : public BootStep
+{
+    TerminalDeployThirdStep(const CSimpleStringA& sectionPosix)
+        : BootStep(CSimpleStringA("TerminalDeployTrd.") + sectionPosix)
     {
     }
 };

+ 18 - 0
Module/mod_healthmanager/HealthManagerFSM.cpp

@@ -2265,6 +2265,24 @@ void CHealthManagerFSM::ToLogWarnTermAboutInfo(BOOL bSuccessFlag)
 	if (bSuccessFlag) {
 		UploadEntityStartComsumeTime();
 	}
+
+    CSmartPointer<IConfigInfo> pConfig;
+    GetEntityBase()->GetFunction()->OpenConfig(Config_Cache, pConfig);
+    int stepStatus(0), curStep(0), lastRecordTime(0);
+    pConfig->ReadConfigValueInt("TerminalDeploy", "CurrStep", curStep);
+
+
+    if (curStep == DeployStep_Finished) {
+
+        pConfig->ReadConfigValueInt("TerminalDeploy", "CurrState", stepStatus);
+        pConfig->ReadConfigValueInt("TerminalDeploy", "TimeStamp", lastRecordTime);
+
+        LogWarn(Severity_High, Error_Debug, LOG_WARN_HEALTH_INSTALL_TIMESTAMP, CSmallDateTime(lastRecordTime).ToTimeString());
+
+        pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", DeployStep_Begin);
+        pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_NOTINIT);
+        pConfig->WriteConfigValue("TerminalDeploy", "TimeStamp", CSimpleStringA::Format("0x%08X", (DWORD)CSmallDateTime::GetNow()));
+    }
 }
 
 void CHealthManagerFSM::ShowEntityBootFailedAtFront(LPCTSTR lpcszEntityName, ErrorCodeEnum bootFailedResult, bool isBlock)

+ 73 - 51
Module/mod_healthmanager/mod_healthmanager.cpp

@@ -57,11 +57,6 @@ const DWORD HEALTHMANAGER_TIMER_INTERVAL_MINUTE = (HEALTHMANAGER_TIMER_INTERVAL/
 #define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
 #define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
 
-#define DEPLOYSTATE_NOTINIT 0
-#define DEPLOYSTATE_DONE 1
-#define DEPLOYSTATE_FAILED 2
-
-
 #include "CenterSetting_client_g.h"	
 using namespace CenterSetting;
 
@@ -183,11 +178,13 @@ static inline int GetDeployStepFromStatus(int status)
 		result = 0;
 		break;
 	case DeployStep_AdapterConfig:
-	case DeployStep_MediaConfig:
-    case DeployStep_FetchCenterSettings:
-    case DeployStep_AccessAuthorize:
 		result = 1;
 		break;
+    case DeployStep_MediaConfig:
+    case DeployStep_FetchCenterSettings:
+    case DeployStep_AccessAuthorize:
+        result = 2;
+        break;
 	default:
 		break;
 	}
@@ -209,8 +206,9 @@ U:
 void CHealthManagerEntity::OnStarted()
 {
 	ErrorCodeEnum result(Error_NotInit);
-    int curStep(0);
+	int curStep(0);
     const bool isNeedConfig = IsNotConfigMode(curStep);
+
 	if (isNeedConfig) {
 
 		//kill guardin process if exists
@@ -230,23 +228,28 @@ void CHealthManagerEntity::OnStarted()
 		}
 		//挑一个状态判断为配置模式,以此操作其他实体的逻辑,比如:
 		//集中配置实体不因无集中配置文件进行弹窗报错
-		// 初始化实体不会自行进行准入验证
+		//初始化实体不会自行进行准入验证
 		CSimpleStringA strSysValue = CSimpleStringA::Format("Z=%d", curStep);
 		result = GetFunction()->SetSysVar("TerminalStage", strSysValue);
 		Dbg("update TerminalStage=%s return %s", strSysValue.GetData(), SpStrError(result));
 		
 		CSimpleStringA machineType = SP::Module::Comm::GetCurrMachineType(this);
 		CSimpleStringA configPath = SP::Module::Comm::GetCurrEntityConfigPath(this);
-		std::shared_ptr<TerminalDeployStep> initSteper = std::make_shared<TerminalDeployStep>("");
-		initSteper->LoadConfig(configPath);
-		result = initSteper->StartStartupEntities(this);
-		if (result != Error_Succeed) {
-			return;
-		}
 
 		const int step = GetDeployStepFromStatus(curStep);
-		for (int i = step; i > 0; --i) {
-			switch (i) {
+		for (int i = step, j=0; i >= 0; --i, j++) {
+			switch (j) {
+			case 0:
+			{
+				Dbg("Initial Boot Step.");
+                std::shared_ptr<TerminalDeployStep> step = std::make_shared<TerminalDeployStep>("");
+				step->LoadConfig(configPath);
+                result = step->StartStartupEntities(this);
+                if (result != Error_Succeed) {
+                    return;
+                }
+			}
+			break;
 			case 1:
 			{
 				Dbg("Second Boot Step.");
@@ -259,7 +262,20 @@ void CHealthManagerEntity::OnStarted()
                     return;
                 }
 			}
-				break;
+			break;
+            case 2:
+            {
+                Dbg("Third Boot Step.");
+                LOG_ASSERT(!machineType.IsNullOrEmpty());
+                std::shared_ptr<TerminalDeployThirdStep> step(nullptr);
+                step = std::make_shared<TerminalDeployThirdStep>(machineType);
+                step->LoadConfig(configPath);
+                result = step->StartStartupEntities(this);
+                if (result != Error_Succeed) {
+                    return;
+                }
+            }
+            break;
 			default:
 				break;
 			}
@@ -269,7 +285,6 @@ void CHealthManagerEntity::OnStarted()
 		result = GetGuidePageUrlWithStep(curStep, strUrl);
 		Dbg("Url:{%s}", (LPCTSTR)strUrl);
 		result = TellChromiumOpenGuidePage(strUrl);
-
 	}
 }
 
@@ -2541,7 +2556,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
 				Dbg("delete root.ini");
 				fileutil_delete_file(strRootIniFullPath);
 			}
-
+            LogWarn(Severity_High, Error_Debug, LOG_WARN_HEALTH_INSTALL_RESET, "install reset");
 		} else {
 			result = Error_NotImpl;
 		}
@@ -2787,7 +2802,6 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
     break;
     case DeployStep_MediaConfig:
     {
-
         CSimpleStringA strRootTmpFile;
         CSimpleStringA strRootIniFullPath;
 		tmpResult = GetTmpRootFilePath(strRootIniFullPath, strRootTmpFile);
@@ -2948,37 +2962,41 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
                 pClient->GetFunction()->CloseSession();
 			}
 
-        } else if (ctx->Req.options == 3) { //安装字体,无奈
-            auto pClient = new ResourceWatcherService_ClientBase(this);
-            tmpResult = pClient->Connect();
-            if (tmpResult != 0) {
-                tmpMsg = CSimpleStringA::Format("连接资源管理模块失败: %s", SpStrError((ErrorCodeEnum)tmpResult));
-                pClient->SafeDelete();
-                Dbg(tmpMsg);
-            } else {
-                ResourceWatcherService_InstallThirdPartyProgram_Req req = {};
-                ResourceWatcherService_InstallThirdPartyProgram_Ans ans = {};
-                req.type = 2; //
-                Dbg("to install font....");
-                tmpResult = pClient->InstallThirdPartyProgram(req, ans, 10000);
-                if (tmpResult != 0) {
-                    tmpMsg = CSimpleStringA::Format("调用安装请求返回错误:%s", SpStrError((ErrorCodeEnum)tmpResult));
-                    Dbg(tmpMsg);
-                } else {
-                    tmpResult = ans.result;
-                    tmpMsg = ans.msg;
-                }
-
-                pClient->GetFunction()->CloseSession();
-            }
-
         } else {
 			result = Error_NotSupport;
 		}
 	}
 		break;
+    case DeployStep_3rdParty_FontInstall:
+    {
+        auto pClient = new ResourceWatcherService_ClientBase(this);
+        tmpResult = pClient->Connect();
+        if (tmpResult != 0) {
+            tmpMsg = CSimpleStringA::Format("连接资源管理模块失败: %s", SpStrError((ErrorCodeEnum)tmpResult));
+            pClient->SafeDelete();
+            Dbg(tmpMsg);
+        } else {
+            ResourceWatcherService_InstallThirdPartyProgram_Req req = {};
+            ResourceWatcherService_InstallThirdPartyProgram_Ans ans = {};
+            req.type = 2; //
+            Dbg("to install font....");
+            tmpResult = pClient->InstallThirdPartyProgram(req, ans, 10000);
+            if (tmpResult != 0) {
+                tmpMsg = CSimpleStringA::Format("调用安装请求返回错误:%s", SpStrError((ErrorCodeEnum)tmpResult));
+                Dbg(tmpMsg);
+            } else {
+                tmpResult = ans.result;
+                tmpMsg = ans.msg;
+            }
+
+            pClient->GetFunction()->CloseSession();
+        }
+    }
+    break;
     case DeployStep_Finished:
     {
+		Dbg("received finish install cmd!");
+		LogWarn(Severity_High, Error_Debug, LOG_WARN_HEALTH_INSTALL_FINISHED, "install finished");
 		result = Error_Succeed;
     }
     break;
@@ -3018,6 +3036,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
 
             pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.nextStep);
             pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_NOTINIT);
+			pConfig->WriteConfigValue("TerminalDeploy", "TimeStamp", CSimpleStringA::Format("0x%08X", (DWORD)CSmallDateTime::GetNow()));
 
 			restartApp = ctx->Req.restartApp;
 			restartPC = ctx->Req.restartPC;
@@ -3025,6 +3044,7 @@ void CHealthManagerEntity::DeployTerminal(SpReqAnsContext<HealthManagerService_D
         } else {
             pConfig->WriteConfigValueInt("TerminalDeploy", "CurrStep", ctx->Req.currStep);
             pConfig->WriteConfigValueInt("TerminalDeploy", "CurrState", DEPLOYSTATE_FAILED);
+			pConfig->WriteConfigValue("TerminalDeploy", "TimeStamp", CSimpleStringA::Format("0x%08X", (DWORD)CSmallDateTime::GetNow()));
         }
 	}
 
@@ -3070,6 +3090,7 @@ bool CHealthManagerEntity::IsTestMode()
 bool CHealthManagerEntity::IsNotConfigMode(int& stepMode)
 {
 	stepMode = 0;
+	int lastRecordTime = 0;
 	CSystemRunInfo runInfo;
 	ErrorCodeEnum ec = GetFunction()->GetSystemRunInfo(runInfo);
 	if (ec != Error_Succeed) {
@@ -3085,12 +3106,13 @@ bool CHealthManagerEntity::IsNotConfigMode(int& stepMode)
 	} else {
         CSmartPointer<IConfigInfo> pConfig;
         GetFunction()->OpenConfig(Config_Cache, pConfig);
-		int curStep(0), stepStatus(0);
-		pConfig->ReadConfigValueInt("TerminalDeploy", "CurrStep", curStep);
+		int stepStatus(0);
+		pConfig->ReadConfigValueInt("TerminalDeploy", "CurrStep", stepMode);
 		pConfig->ReadConfigValueInt("TerminalDeploy", "CurrState", stepStatus);
-		if (curStep != 0 && DeployStep_Finished != curStep) {
-			stepMode = curStep;
-            Dbg("not config from cache: step=%d, status=%d", curStep, stepStatus);
+		pConfig->ReadConfigValueInt("TerminalDeploy", "TimeStamp", lastRecordTime);
+
+		if (stepMode != 0 && DeployStep_Finished != stepMode) {
+            Dbg("not config from cache: step=%d, status=%d", stepMode, stepStatus);
 			return true;
 		}
 	}

+ 4 - 1
Module/mod_healthmanager/mod_healthmanager.h

@@ -33,6 +33,10 @@ typedef bool (*pfIsInstalling)();
 typedef int (*pfUpgradeRestart)(const DWORD dwParam1,const DWORD dwParam2);
 typedef int (*pfFrameworkQuit)(RebootTriggerEnum eReason);
 
+#define DEPLOYSTATE_NOTINIT 0
+#define DEPLOYSTATE_DONE 1
+#define DEPLOYSTATE_FAILED 2
+
 enum WatchDogOp
 {
 	WD_OP_START,
@@ -118,7 +122,6 @@ public:
 
 		int curStep(0);
 		bool isNeedConfig = IsNotConfigMode(curStep);
-
 		if (isNeedConfig) {
             m_fsm.SetConfigMode(true);
 		} else {