|
|
@@ -118,7 +118,7 @@ CenterSettingsMicroServiceHelper::CenterSettingsMicroServiceHelper(CEntityBase*
|
|
|
InitCenterSettingInfo();
|
|
|
}
|
|
|
|
|
|
-int CenterSettingsMicroServiceHelper::GetCenterSetting()
|
|
|
+int CenterSettingsMicroServiceHelper::GetCenterSetting(bool byHand)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
|
|
|
@@ -132,16 +132,17 @@ int CenterSettingsMicroServiceHelper::GetCenterSetting()
|
|
|
req.m_terminal_no = m_terminalInfo.strTerminalID.GetData();
|
|
|
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("m_strFilePath:%s", m_strFilePath.GetData());
|
|
|
- if (!ExistsFile(m_strFilePath)) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("!ExistsFile(m_strFilePath)");
|
|
|
+ if ((byHand && !m_isFirst) || !ExistsFile(m_strFilePath)) {
|
|
|
+ if (byHand && !m_isFirst && ExistsFileA(m_strFilePath)) {
|
|
|
+ LogWarn(Severity_Low, Error_Debug, EVENT_MOD_CENTERSETTING_UPDATE_CENTER_FORCE, "尝试强制重新下载集中配置");
|
|
|
+ }
|
|
|
req.m_version = "";
|
|
|
req.m_config = "";
|
|
|
} else {
|
|
|
req.m_version = m_strVersion.GetData();
|
|
|
req.m_config = GetLocalConfig();
|
|
|
}
|
|
|
- /** 有什么作用? [Gifur@202397]*/
|
|
|
- if (m_isFirst) m_isFirst = false;
|
|
|
+
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_strVersion:%s", m_strVersion.GetData());
|
|
|
req.m_update_time = GetUpdateTime();
|
|
|
GetTimeoutValue(req.m_timeOut);
|
|
|
@@ -174,7 +175,13 @@ int CenterSettingsMicroServiceHelper::GetCenterSetting()
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ if (byHand) {
|
|
|
+ if (ret1 == EXIST && m_isFirst) {
|
|
|
+ m_isFirst = false;
|
|
|
+ } else if (ret1 == SUCC && !m_isFirst) {
|
|
|
+ m_isFirst = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
return ret1;
|
|
|
}
|
|
|
|
|
|
@@ -231,7 +238,6 @@ void CenterSettingsMicroServiceHelper::InitCenterSettingInfo()
|
|
|
|
|
|
//获取集中配置路径、文件名、场所
|
|
|
m_pEntity->GetFunction()->GetPath("CenterSetting", m_strFilePath);
|
|
|
-
|
|
|
m_pEntity->GetFunction()->GetPath("RunInfo", m_strBakPath);
|
|
|
m_strBakPath += SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR "CenterSetting.ini";
|
|
|
}
|
|
|
@@ -246,8 +252,6 @@ bool CenterSettingsMicroServiceHelper::WriteToConfig(const CenterSettingResponse
|
|
|
string name = it->m_name;
|
|
|
string value = it->m_value;
|
|
|
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write %s:%s:%s...", module.c_str(), name.c_str(), value.c_str());
|
|
|
-
|
|
|
if (inifile_write_str(newPath.GetData(), module.c_str(), name.c_str(), value.c_str()) == -1) {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WriteToConfig")
|
|
|
("write %s:%s:%s fail", module.c_str(), name.c_str(), value.c_str());
|
|
|
@@ -390,16 +394,13 @@ int CenterSettingsMicroServiceHelper::GetCenterSettingsFromHttp(CenterSettingReq
|
|
|
|
|
|
config.PreDo();
|
|
|
client.Do(&config, &result);
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("return do");
|
|
|
if (!result.ResponseOK()) {
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Do failed: %s", result.WhatError().c_str());
|
|
|
errMsg = result.WhatError();
|
|
|
return AccessServiceFail;
|
|
|
}
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%d", __LINE__);
|
|
|
SP::Module::Restful::CommResponseJson responseStatus;
|
|
|
SP::Module::Restful::GetStatusFromDebranchResponse(result.content, responseStatus);
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%d", __LINE__);
|
|
|
if (!responseStatus.IsOperatedOK()) {
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(result.content.c_str());
|
|
|
errMsg = responseStatus.WhatError().c_str();
|
|
|
@@ -453,52 +454,22 @@ int CenterSettingsMicroServiceHelper::GetCenterSettingsFromHttp(CenterSettingReq
|
|
|
|
|
|
BYTE sm3[32] = {};
|
|
|
if (strConfig.length() > 2) {
|
|
|
- //if (!SM3Hash((BYTE*)(strConfig.c_str()), strConfig.length(), sm3)) {
|
|
|
- // errMsg = "计算SM3失败";
|
|
|
- // DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetCenterSettingsFromHttp")("计算SM3失败(%s)", req.m_url.c_str());
|
|
|
- // return CalcSM3Fail;
|
|
|
- //} else {
|
|
|
- // int sm3len = sizeof(sm3);
|
|
|
- // DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("sm3:%s", res.m_sm3.c_str());
|
|
|
- // char* strsm3 = SP::Module::Util::ConvertBytesToHexStr(sm3, 32);
|
|
|
- // if (0 != strcmp(strsm3, res.m_sm3.c_str())) {
|
|
|
- // errMsg = "SM3校验失败";
|
|
|
- // DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetCenterSettingsFromHttp")("SM3校验失败(%s)", req.m_url.c_str());
|
|
|
- // delete[] strsm3;
|
|
|
- // return CheckSM3Fail;
|
|
|
- // }
|
|
|
- // m_strVersion = res.m_version_no.c_str();
|
|
|
- // delete[] strsm3;
|
|
|
- //}
|
|
|
-
|
|
|
- //do {
|
|
|
- // bool fErrOccur(false), fHasContent(false);
|
|
|
- // CSimpleStringA newPath = m_strBakPath + ".new";
|
|
|
- // DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write to %s..", newPath.GetData());
|
|
|
- // for (auto it = res.m_config.cbegin(); it != res.m_config.cend(); ++it) {
|
|
|
- // DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write %s:%s:%s...", it->m_moudle.c_str(), it->m_name.c_str(), it->m_value.c_str());
|
|
|
- // if (inifile_write_str(newPath.GetData(), it->m_moudle.c_str(), it->m_name.c_str(), it->m_value.c_str()) == -1) {
|
|
|
- // DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WriteToConfig")
|
|
|
- // ("write %s:%s:%s fail", it->m_moudle.c_str(), it->m_name.c_str(), it->m_value.c_str());
|
|
|
- // m_strErrMsg = "集中配置写入失败";
|
|
|
- // LogWarn(Severity_Middle, Error_Unexpect, ERR_MOD_CENTERSETTING_WRITE_FAILED,
|
|
|
- // CSimpleStringA::Format("集中配置写入失败:%s:%s:%s", it->m_moudle.c_str(), it->m_name.c_str(), it->m_value.c_str()));
|
|
|
- // fErrOccur = true;
|
|
|
- // break;
|
|
|
- // } else if (!fHasContent) {
|
|
|
- // fHasContent = true;
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // if (fHasContent && !fErrOccur) {
|
|
|
- // DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("WriteToConfig")("集中配置写入成功");
|
|
|
- // fileutil_copy_file(m_strFilePath, newPath);
|
|
|
- // fileutil_delete_file(newPath);
|
|
|
- // } else {
|
|
|
- // }
|
|
|
-
|
|
|
- //} while (false);
|
|
|
-
|
|
|
+ if (!SM3Hash((BYTE*)(strConfig.c_str()), strConfig.length(), sm3)) {
|
|
|
+ errMsg = "计算SM3失败";
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetCenterSettingsFromHttp")("计算SM3失败(%s)", req.m_url.c_str());
|
|
|
+ return CalcSM3Fail;
|
|
|
+ } else {
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("sm3:%s", res.m_sm3.c_str());
|
|
|
+ char* strsm3 = SP::Module::Util::ConvertBytesToHexStr(sm3, 32);
|
|
|
+ if (0 != strcmp(strsm3, res.m_sm3.c_str())) {
|
|
|
+ errMsg = "SM3校验失败";
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetCenterSettingsFromHttp")("SM3校验失败(%s)", req.m_url.c_str());
|
|
|
+ delete[] strsm3;
|
|
|
+ return CheckSM3Fail;
|
|
|
+ }
|
|
|
+ m_strVersion = res.m_version_no.c_str();
|
|
|
+ delete[] strsm3;
|
|
|
+ }
|
|
|
|
|
|
if (WriteToConfig(res)) {
|
|
|
m_strVersion = res.m_version_no.c_str();
|