|
@@ -18,14 +18,22 @@ void CCenterSettingEntity::OnStarted()
|
|
|
GetFunction()->OpenConfig(Config_CenterSetting, m_pCenterConfig);
|
|
|
|
|
|
GetFunction()->GetPath("RunInfo", m_strBakPath);
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ m_strBakPath += "\\runcfg\\CenterSetting.ini";
|
|
|
+#else
|
|
|
m_strBakPath += SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR "CenterSetting.ini";
|
|
|
+#endif
|
|
|
|
|
|
m_pMicroServiceHelper = new CenterSettingsMicroServiceHelper(this);
|
|
|
|
|
|
- if (!m_pCenterConfig->storageInMem()) {
|
|
|
+ if(!m_pCenterConfig->storageInMem())
|
|
|
+ {
|
|
|
m_isUseMemCfg = false;
|
|
|
BeginDownloadCenterSetting();
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
m_isUseMemCfg = true;
|
|
|
}
|
|
|
|
|
@@ -49,16 +57,23 @@ ErrorCodeEnum CCenterSettingEntity::BeginDownloadCenterSetting(bool bByHand, con
|
|
|
std::unique_lock<std::mutex> lock1(m_lock);
|
|
|
#endif
|
|
|
|
|
|
- if (!url.empty()) {
|
|
|
+ if(!url.empty())
|
|
|
+ {
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("update centersettings url...");
|
|
|
m_pMicroServiceHelper->UpdateUrl(url);
|
|
|
}
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ int rc = m_pMicroServiceHelper->GetCenterSetting();
|
|
|
+#else
|
|
|
int rc = m_pMicroServiceHelper->GetCenterSetting(bByHand);
|
|
|
+#endif
|
|
|
|
|
|
- if (EXIST == rc) {
|
|
|
-
|
|
|
- } else if (SUCC == rc) {
|
|
|
+ if(EXIST == rc)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ else if(SUCC == rc)
|
|
|
+ {
|
|
|
LogWarn(Severity_Low, Error_Succeed, EVENT_MOD_CENTERSETTING_UPDATE_CENTER,
|
|
|
CSimpleStringA::Format("下载集中配置成功:%s", m_pMicroServiceHelper->GetCurUrl().c_str()));
|
|
|
LogEvent(Severity_Low, EVENT_MOD_CENTERSETTING_UPDATE_CENTER, "Update Centersetting.");
|
|
@@ -66,30 +81,42 @@ ErrorCodeEnum CCenterSettingEntity::BeginDownloadCenterSetting(bool bByHand, con
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR040210101")("手工下载集中配置成功");
|
|
|
else
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402101Z01")("自动下载集中配置成功");
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
LogWarn(Severity_High, Error_Unexpect, ERR_MOD_CENTERSETTING_CONNECT_FAILED,
|
|
|
CSimpleStringA::Format("下载集中配置失败:%s", m_pMicroServiceHelper->GetErrMsg()));
|
|
|
if (!bByHand)
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402101Z01").setResultCode("RTA1104")("集中配置下载失败");
|
|
|
}
|
|
|
|
|
|
- if (m_spDownloadCall != NULL) {
|
|
|
+ if(m_spDownloadCall != NULL)
|
|
|
+ {
|
|
|
m_spDownloadCall->Ans.downloadStat = rc;
|
|
|
m_spDownloadCall->Ans.retCenterConfigUrl = m_pMicroServiceHelper->GetCurUrl().c_str();
|
|
|
|
|
|
- if (rc == AllAddressNull) {
|
|
|
+ if(rc == AllAddressNull)
|
|
|
+ {
|
|
|
m_spDownloadCall->Ans.strErrMsg = "所有地址都为空,请检查终端版本";
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040210101").setResultCode("RTA1101")("所有集中配置下载地址都为空");
|
|
|
- } else if (rc == AccessServiceFail) {
|
|
|
+ }
|
|
|
+ else if(rc == AccessServiceFail)
|
|
|
+ {
|
|
|
m_spDownloadCall->Ans.strErrMsg = "网络异常,请检查网络连接情况";
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040210101").setResultCode("RTA1102")("网络异常,请检查网络连接情况");
|
|
|
- } else if (rc == CalcSM3Fail || rc == CheckSM3Fail) {
|
|
|
+ }
|
|
|
+ else if(rc == CalcSM3Fail || rc == CheckSM3Fail)
|
|
|
+ {
|
|
|
m_spDownloadCall->Ans.strErrMsg = "集中配置内容校验失败,请重试";
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040210101").setResultCode("RTA1103")("集中配置内容校验失败");
|
|
|
- } else if (rc == MANUAL) {
|
|
|
+ }
|
|
|
+ else if(rc == MANUAL)
|
|
|
+ {
|
|
|
m_spDownloadCall->Ans.strErrMsg = "集中配置下载失败";
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040210101").setResultCode("RTA1104")("集中配置下载失败");
|
|
|
- } else if (rc == EXIST) {
|
|
|
+ }
|
|
|
+ else if(rc == EXIST)
|
|
|
+ {
|
|
|
m_spDownloadCall->Ans.strErrMsg = "集中配置已是最新版本";
|
|
|
}
|
|
|
|
|
@@ -108,8 +135,10 @@ ErrorCodeEnum CCenterSettingEntity::BeginDownloadCenterSetting(bool bByHand, con
|
|
|
|
|
|
ErrorCodeEnum CCenterSettingEntity::DownloadCenterSetting(SpReqAnsContext<CenterSettingService_Downloadv2_Req, CenterSettingService_Downloadv2_Ans>::Pointer sp)
|
|
|
{
|
|
|
- if (m_spDownloadCall != NULL) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DownloadCenterSetting")("last download call not complet");
|
|
|
+ if (m_spDownloadCall != NULL)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DownloadCenterSetting")
|
|
|
+ ("last download call not complet");
|
|
|
sp->Answer(Error_Duplication);
|
|
|
return Error_Duplication;
|
|
|
}
|
|
@@ -126,9 +155,45 @@ ErrorCodeEnum CCenterSettingEntity::DownloadCenterSetting(SpReqAnsContext<Center
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+DWORD getCenterCfgThread(LPVOID param)
|
|
|
+{
|
|
|
+ CCenterSettingEntity* req = (CCenterSettingEntity*)param;
|
|
|
+
|
|
|
+ bool isUpdate = false, isReset = false;
|
|
|
+ CSimpleString version;
|
|
|
+ auto ret = req->GetFunction()->GetPrivilegeFunction()->TryUpdateCenterCfg(isUpdate, isReset, version);
|
|
|
+ if (ret != ErrorCodeEnum::Error_Succeed)
|
|
|
+ {
|
|
|
+ LogWarn(Severity_High, Error_Unexpect, ERR_MOD_CENTERSETTING_CONNECT_FAILED,
|
|
|
+ CSimpleStringA::Format("下载集中配置失败:%d", ret));
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402101Z01").setResultCode("RTA1104")("集中配置下载失败");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isUpdate)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetCenterSetting")("Centersetting not changed from spshell");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ LogWarn(Severity_Low, Error_Succeed, EVENT_MOD_CENTERSETTING_UPDATE_CENTER,
|
|
|
+ CSimpleStringA::Format("下载集中配置成功,版本号变更成:%s", version.GetData()));
|
|
|
+ LogEvent(Severity_Low, EVENT_MOD_CENTERSETTING_UPDATE_CENTER, "Update Centersetting.");
|
|
|
+
|
|
|
+ if (isReset)
|
|
|
+ LogEvent(Severity_Middle, EVENT_MOD_CENTERSETTING_CRITICAL_UPDATE, "SpShell:Update centersetting with critical items.");
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
void CCenterSettingEntity::OnTimeout(DWORD dwTimerID)
|
|
|
{
|
|
|
- if (m_isUseMemCfg) {
|
|
|
+ if(m_isUseMemCfg)
|
|
|
+ {
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&getCenterCfgThread, this, 0, NULL));
|
|
|
+#else
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("use memory config....");
|
|
|
bool isUpdate = false, isReset = false;
|
|
|
CSimpleString version;
|
|
@@ -154,8 +219,10 @@ void CCenterSettingEntity::OnTimeout(DWORD dwTimerID)
|
|
|
|
|
|
if (isReset)
|
|
|
LogEvent(Severity_Middle, EVENT_MOD_CENTERSETTING_CRITICAL_UPDATE, "SpShell:Update centersetting with critical items.");
|
|
|
-
|
|
|
- } else {
|
|
|
+#endif
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
BeginDownloadCenterSetting();
|
|
|
}
|
|
|
|
|
@@ -165,7 +232,7 @@ ErrorCodeEnum CCenterSettingEntity::GetAccessUrl(CSimpleStringA& url) //初始
|
|
|
{
|
|
|
CSimpleStringA hostInitUrl;
|
|
|
m_pCenterConfig->ReadConfigValue("AccessAuthorization", "HostInitUrl", hostInitUrl);
|
|
|
- if (hostInitUrl.IsNullOrEmpty())
|
|
|
+ if(hostInitUrl.IsNullOrEmpty())
|
|
|
url = "初始化地址为空";
|
|
|
else
|
|
|
url = hostInitUrl;
|
|
@@ -188,6 +255,6 @@ ErrorCodeEnum CCenterSettingEntity::GetCertainAceessUrl(CSimpleStringA& accessNa
|
|
|
}
|
|
|
|
|
|
SP_BEGIN_ENTITY_MAP()
|
|
|
-SP_ENTITY(CCenterSettingEntity)
|
|
|
+ SP_ENTITY(CCenterSettingEntity)
|
|
|
SP_END_ENTITY_MAP()
|
|
|
|