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