123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560 |
- #include "stdafx.h"
- #include "CenterSettingConn.h"
- #include "Event.h"
- #include <map>
- #include <regex>
- using namespace std;
- using std::regex;
- #include "mod_centersetting.h"
- #include "fileutil.h"
- #include "iniutil.h"
- #if defined(RVC_OS_WIN)
- #pragma comment(lib, "crypt32.lib")
- #endif //RVC_OS_WIN
- #ifdef WITH_CPPRESTSDK
- #include "CommEntityRestful.hpp"
- #else
- #define SAFE_DELETE_HTTPCLIENT(obj) \
- do{if(obj != NULL) { obj->Destory(); obj = NULL; }}while(false)
- #endif
- bool CenterSettingResponse::Parse(string strData)
- {
- bSuccess = false;
- errInfo.clear();
- Json::Value root;
- Json::Reader reader;
- if (!reader.parse(strData, root, false)) {
- errInfo = "parse json string failed: ";
- errInfo += strData;
- return false;
- }
- struct CommResponseJson : public MicroServices::API::CommResponse {
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(success, errorCode, returnCode, errorMsg, message)
- JSONCONVERT2OBJECT_MEMEBER_RENAME_REGISTER("success", "code", "return_code", "error_msg", "message")
- } reponseStatus;
- if (!Json2Object(reponseStatus, root)) {
- errInfo = "Json2Object failed";
- return false;
- }
- if (!reponseStatus.IsOperatedOK()) {
- errInfo = reponseStatus.WhatError();
- return false;
- }
- bSuccess = Json2Object(centerSyncInfo, root["data"]);
- if (bSuccess) {
- centerSyncInfo.biz.mapSiteName = "LAN";
- centerSyncInfo.dmz.mapSiteName = "DMZ";
- } else {
- errInfo = "parse json data node failed: ";
- }
- return bSuccess;
- }
- ////////////////////////////////////////////////////////////////////////////////////
- CenterSettingsMicroServiceHelper::CenterSettingsMicroServiceHelper(CEntityBase* pEntity)
- :m_pEntity(pEntity), m_bGrayLaunch(false),m_strGrayLaunchUrl(true)
- ,m_strCallRouteBranchNo(true),m_strLastTime(true)
- ,m_strTerminalList(true),m_strMode(true)
- {
- m_pEntity->GetFunction()->GetSystemStaticInfo(mTerminalInfo);
- InitCenterSettingsInfoFromConfig();
- }
- void CenterSettingsMicroServiceHelper::InitCenterSettingsInfoFromConfig()
- {
- LOG_FUNCTION();
- CSmartPointer<IConfigInfo> centerConfig;
- m_pEntity->GetFunction()->OpenConfig(Config_CenterSetting, centerConfig);
- centerConfig->ReadConfigValue("Common", "GrayLaunchUrl", m_strGrayLaunchUrl);
- centerConfig->ReadConfigValue("Initializer", "SubBankNo", m_strCallRouteBranchNo);
- centerConfig->ReadConfigValue("CenterSetting", "CenterConfigUrl", m_strCenterSettingUrl);
- centerConfig->ReadConfigValue("CenterSetting", "LastUpdateTime", m_strLastTime);
- centerConfig->ReadConfigValue("CenterSetting", "Mode", m_strMode);
- centerConfig->ReadConfigValue("CenterSetting", "TerminalList", m_strTerminalList);
- }
- ErrorCodeEnum CenterSettingsMicroServiceHelper::GetCenterSetting(CSimpleStringA& strErrMsg)
- {
- LOG_FUNCTION();
- #ifdef WITH_CPPRESTSDK
- struct GetCenterSettingsReqJson
- {
- std::string terminalNo;
- std::string lastUpdateTimie;
- JSONCONVERT2OBJECT_MEMEBER_REGISTER(terminalNo, lastUpdateTimie)
- JSONCONVERT2OBJECT_MEMEBER_RENAME_REGISTER("terminal_no", "last_update_time")
- } getCenterSettingsReqJson;
- HttpClientResponseResult result;
- HttpClientRequestConfig config(HttpRequestMethod::POST, m_strCenterSettingUrl.GetData());
- getCenterSettingsReqJson.lastUpdateTimie = m_strLastTime;
- getCenterSettingsReqJson.terminalNo = mTerminalInfo.strTerminalID;
- SP::Module::Restful::FulfillRequestJsonBody(&config, getCenterSettingsReqJson);
- RestfulClient client = RestfulClient::getInstance();
- config.PreDo();
- client.Do(&config, &result);
- if (result.ResponseOK()) {
- SP::Module::Restful::CommResponseJson responseStatus;
- SP::Module::Restful::GetStatusFromDebranchResponse(result.content, responseStatus);
- if (!responseStatus.IsOperatedOK()) {
- strErrMsg = responseStatus.WhatError().c_str();
- } else {
- CenterSettingFileJson getCenterSettingsAns;
- if (!SP::Module::Restful::ExtractDataFromDebranchResponse(result.content, getCenterSettingsAns)) {
- strErrMsg = "parse json data node failed: ";
- } else {
- getCenterSettingsAns.biz.mapSiteName = "LAN";
- getCenterSettingsAns.dmz.mapSiteName = "DMZ";
- if ((mTerminalInfo.strSite.Compare("cmb.LIB", true) == 0 && getCenterSettingsAns.biz.lastUpdateTime == getCenterSettingsReqJson.lastUpdateTimie)
- || (mTerminalInfo.strSite.Compare("cmb.FLB", true) == 0 && getCenterSettingsAns.dmz.lastUpdateTime == getCenterSettingsReqJson.lastUpdateTimie)) {//行内
- Dbg("Centersetting not changed.");
- strErrMsg = "Centersetting not any changed";
- return Error_Succeed;
- }
- CenterSettingConfigJson& cur = getCenterSettingsAns.dmz;
- if (mTerminalInfo.strSite.Compare("cmb.LIB", true) == 0) {
- cur = getCenterSettingsAns.biz;
- }
- Dbg("local last update time(%s) vs server last update time(%s)", getCenterSettingsReqJson.lastUpdateTimie.c_str(), cur.lastUpdateTime.c_str());
- SyncConfigAndRenameCenterFile(cur);
- LogEvent(Severity_Middle, EVENT_MOD_CENTERSETTING_UPDATE,
- CSimpleString::Format("Update CenterSetting.%s.ini.", cur.mapSiteName.c_str()));
- strErrMsg = "Centersetting has changed";
- return Error_Succeed;
- }
- }
- } else {
- strErrMsg = result.WhatError().c_str();
- }
- #else
- CenterSettingReq req;
- req.m_url = m_strCenterSettingUrl;
- req.m_last_update_time = m_strLastTime;
- req.m_terminal_no = mTerminalInfo.strTerminalID;
- Dbg("request url: %s", req.m_url.c_str());
- CenterSettingResponse response;
- IHttpFunc* pHttpFunc = create_http(HTTPLogCallback);
- bool ret = pHttpFunc->Post(req, response);
- pHttpFunc->Destory();
- if (ret) {
- if (response.bSuccess) {
- if ((mTerminalInfo.strSite.Compare("cmb.LIB", true) == 0 && response.centerSyncInfo.biz.lastUpdateTime == req.m_last_update_time)
- || (mTerminalInfo.strSite.Compare("cmb.FLB", true) == 0 && response.centerSyncInfo.dmz.lastUpdateTime == req.m_last_update_time)) {//行内
- Dbg("Centersetting not changed.");
- strErrMsg = "Centersetting not any changed";
- return Error_Succeed;
- }
- CenterSettingConfigJson& cur = response.centerSyncInfo.dmz;
- if (mTerminalInfo.strSite.Compare("cmb.LIB", true) == 0) {
- cur = response.centerSyncInfo.biz;
- }
- Dbg("local last update time(%s) vs server last update time(%s)", cur.lastUpdateTime.c_str(), req.m_last_update_time.c_str());
- SyncConfigAndRenameCenterFile(cur);
- LogEvent(Severity_Middle, EVENT_MOD_CENTERSETTING_UPDATE,
- CSimpleString::Format("Update CenterSetting.%s.ini.", cur.mapSiteName.c_str()));
- strErrMsg = "Centersetting has changed";
- return Error_Succeed;
- } else {
- strErrMsg = response.errInfo.c_str();
- }
- } else {
- strErrMsg = CSimpleStringA::Format("post [%s] failed!", req.m_url.c_str());
- }
- #endif //WITH_CPPRESTSDK
- return Error_Unexpect;
- }
- void CenterSettingsMicroServiceHelper::SyncConfigAndRenameCenterFile(const CenterSettingConfigJson& configOfOneBranch)
- {
- LOG_FUNCTION();
- auto pFunc = m_pEntity->GetFunction();
- CSimpleStringA strPath;
- pFunc->GetPath("Cfg", strPath);
- ///**TODO(Gifur@9/16/2021): GetPath("CenterSetting") 通过此接口来获取集中配置路径地址 */
- CSimpleStringA fileName = CSimpleStringA::Format("CenterSetting.%s.ini", configOfOneBranch.mapSiteName.c_str());
- Dbg("fileName:%s", fileName.GetData());
- CSimpleStringA strCurFile = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", (const char*)strPath, (const char*)fileName);
- CSimpleString strRunInfoPath;
- ///**TODO(Gifur@9/16/2021): GetPath("RunCfg") implement! */
- pFunc->GetPath("RunInfo", strRunInfoPath);
- strRunInfoPath += SPLIT_SLASH_STR;
- strRunInfoPath += "runcfg";
- CSimpleStringA strNewPath = strRunInfoPath + SPLIT_SLASH_STR;
- CSimpleStringA strNewFile = strNewPath + fileName + ".new";
- for (int i = 0; i < configOfOneBranch.config.size(); i++) {
- const string& module = configOfOneBranch.config[i].moudle;
- const string& name = configOfOneBranch.config[i].name;
- const string& value = configOfOneBranch.config[i].value;
- inifile_write_str(strNewFile, module.c_str(), name.c_str(), value.c_str());
- }
- inifile_write_str(strNewFile, "CenterSetting", "ProvideByHeadBank", "1");
- //将服务的修改时间同步到本地,避免每次都去更新
- inifile_write_str(strNewFile, "CenterSetting", "LastUpdateTime", configOfOneBranch.lastUpdateTime.c_str());
-
- // 替换当前配置文件
- fileutil_copy_file(strCurFile, strNewFile);
- fileutil_delete_file(strNewFile);
- Dbg("save config %s succ", fileName.GetData());
- }
- /////////////////////////////////////////////////////////////////////////
- CCenterSettingConn::CCenterSettingConn(CEntityBase *pEntity)
- : SpSecureClient(pEntity)
- {
- }
- CCenterSettingConn::~CCenterSettingConn(void)
- {
- }
- void CCenterSettingConn::OnDisconnect()
- {
- Dbg("connection disconnected");
- }
- void CCenterSettingConn::OnPkgAnswer(const CSmartPointer<IPackage> &pRecvPkg)
- {
- string serviceCode = pRecvPkg->GetServiceCode();
- auto pEntity = (CCenterSettingEntity*) m_pEntity;
-
- if (serviceCode == "PollSM")
- {
- auto rc = OnEndPollConfig(pRecvPkg);
- if (rc == Error_NotExist) {
- CSimpleStringA strFilePath;
- pEntity->GetFunction()->GetPath("CenterSetting", strFilePath);
- if (ExistsFileA(strFilePath) && 0 < pEntity->m_SyncFileInfo.size()) {
- Dbg("maybe local centersetting file is new as the server side one or there are no any centersettings files under server side");
- rc = Error_Succeed; // = Error_AlreadyExist;
- }
- }
- // 通知实体轮询结束
- pEntity->EndDownloadCenterSetting(rc);
- }
- else
- {
- LOG_TRACE("unknown service code: %s", serviceCode.c_str());
- }
- }
- bool CCenterSettingConn::ParseIPAddress(const char *str, CSimpleStringA &ip, int &port)
- {
- if (str)
- {
- char tmp1[32] = {};
- char tmp2[16] = {};
- sscanf(str, "%s %s", tmp1, tmp2);
- if (tmp1[0] != 0 && tmp2[0] != 0)
- {
- ip = tmp1;
- port = atoi(tmp2);
- return true;
- }
- }
-
- return false;
- }
- bool CCenterSettingConn::IsServiceAvailable(const char *pszServiceAddr)
- {
- CSimpleStringA strServer;
- int nPort;
- if (! ParseIPAddress(pszServiceAddr, strServer, nPort))
- return false;
- SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (s == INVALID_SOCKET)
- return false;
- sockaddr_in addr = {0};
-
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = inet_addr(strServer);
- addr.sin_port = htons(nPort);
- bool bRet = (connect(s, (SOCKADDR*)&addr, sizeof(addr)) != SOCKET_ERROR);
- closesocket(s);
- return bRet;
- }
- // 上送多个请求结构,对应多个配置
- ErrorCodeEnum CCenterSettingConn::BeginPollConfig(const CSystemStaticInfo& info)
- {
- assert(IsConnectionOK());
- auto pEntity = (CCenterSettingEntity *)m_pEntity;
- auto pFunc = pEntity->GetFunction();
- CSimpleStringA strPath;
- pFunc->GetPath("Cfg", strPath);
- ClearillegalCenterSettingsFile(strPath);
- auto pPackage = CreateNewPackage("PollSM");
- const int nArrayNum = pEntity->m_SyncFileInfo.size();
- if (nArrayNum> 0)
- {
- PollSMR *pReq = new PollSMR[nArrayNum];
- memset(pReq, 0, sizeof(PollSMR)*nArrayNum);
- int nIndex = 0;
- for (auto it = pEntity->m_SyncFileInfo.begin(); it != pEntity->m_SyncFileInfo.end(); it++)
- {
- auto &fileInfo = it->second;
-
- #ifdef RVC_OS_WIN
- strncpy_s(pReq[nIndex].TerminalNo, sizeof(pReq[nIndex].TerminalNo), info.strTerminalID, _TRUNCATE);
- strncpy_s(pReq[nIndex].MachineType, sizeof(pReq[nIndex].MachineType), info.strMachineType, _TRUNCATE);
- strncpy_s(pReq[nIndex].Sites, sizeof(pReq[nIndex].Sites), it->first.c_str(), _TRUNCATE);
- strncpy_s(pReq[nIndex].LastHash, sizeof(pReq[nIndex].LastHash), fileInfo.strFileHash, _TRUNCATE);
- #else
- strncpy(pReq[nIndex].TerminalNo, info.strTerminalID, strlen(info.strTerminalID));
- strncpy(pReq[nIndex].MachineType, info.strMachineType, strlen(info.strMachineType));
- strncpy(pReq[nIndex].Sites, it->first.c_str(), it->first.length());
- strncpy(pReq[nIndex].LastHash, fileInfo.strFileHash, strlen(fileInfo.strFileHash));
- #endif
- nIndex++;
- }
- pPackage->AddStruct("PollSMR", false, false, (BYTE*) pReq, sizeof(PollSMR)*nArrayNum, nArrayNum);
- delete[] pReq;
- }
- else
- {
- PollSMR req = {};
- #ifdef RVC_OS_WIN
- strncpy_s(req.TerminalNo, sizeof(req.TerminalNo), info.strTerminalID, _TRUNCATE);
- strncpy_s(req.MachineType, sizeof(req.MachineType), info.strMachineType, _TRUNCATE);
- strncpy_s(req.Sites, sizeof(req.Sites), info.strSite, _TRUNCATE);
- #else
- strncpy(req.TerminalNo, info.strTerminalID, strlen(info.strTerminalID));
- strncpy(req.MachineType, info.strMachineType, strlen(info.strMachineType));
- strncpy(req.Sites, info.strSite, strlen(info.strSite));
- #endif
- pPackage->AddStruct("PollSMR", false, false, (BYTE*)&req, sizeof(PollSMR));
- }
- SendPackage(pPackage);
- return Error_Succeed;
- }
- ErrorCodeEnum CCenterSettingConn::OnEndPollConfig(const CSmartPointer<IPackage> &pRecvPkg)
- {
- auto pEntity = (CCenterSettingEntity*)m_pEntity;
- DWORD dwSysCode, dwUserCode;
- string strErrMsg;
- bool bInitMKSuc = false;
- if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg))
- {
- Dbg("poll center config fail, sysCode=%d, usrCode=%d, %s", dwSysCode, dwUserCode, strErrMsg.c_str());
- return Error_Unexpect;
- }
- int nIndex = 1;
- while (true)
- {
- //1.获取包条目结构和内容
- CSimpleStringA strCurStructName = CSimpleStringA::Format("PollSMA%d", nIndex);
-
- int nRetLen = pRecvPkg->GetStructLen(strCurStructName);
- if (nRetLen == -1) {
- Dbg("Get %s pkg struct failed !", strCurStructName.GetData());
- break;
- }
- nIndex++;
- BYTE *pBuf = new BYTE[nRetLen];
- memset(pBuf, 0, nRetLen);
- int nArrayNum(0);
- int nBufLen = nRetLen;
- bool bSuc = pRecvPkg->GetStructData(strCurStructName, pBuf, &nBufLen, &nArrayNum);
- assert(bSuc && nRetLen == nBufLen);
- PollSMA*pRet = (PollSMA*)pBuf;
- Dbg("center config changed, hash: %s, file: %s", (const char*)pRet->FileHash, (const char*)pRet->FileName);
- // 2. 校验Hash是否匹配,以校验内容完整性
- BYTE sm3[32] = {};
- if (!SM3Hash((BYTE*)pRet->FileContent, nRetLen - sizeof(PollSMA), sm3)) {
- Dbg("compute sm3 hash fail");
- delete[] pBuf;
- return Error_CheckSum;
- }
- CSimpleStringA strHash;
- for (int i = 0; i < 32; i++) {
- strHash += CSimpleStringA::Format("%02x", sm3[i]);
- }
- if (stricmp(strHash, pRet->FileHash) != 0) {
- Dbg("computed hash [%s] != return hash [%s]", (const char*)strHash, pRet->FileHash);
- delete[] pBuf;
- return Error_CheckSum;
- }
- auto pFunc = m_pEntity->GetFunction();
- //3. 将结构内容信息存在在临时的集中配置文件中
- CSimpleString strRunInfoPath;
- ///**TODO(Gifur@9/16/2021): GetPath("RunCfg") implement! */
- pFunc->GetPath("RunInfo", strRunInfoPath);
- strRunInfoPath += SPLIT_SLASH_STR;
- strRunInfoPath += "runcfg";
- CSimpleStringA strNewPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", (const char*)strRunInfoPath, (const char*)pRet->FileName);
- // 保存新配置文件
- CSimpleStringA strNewFile = strNewPath + ".new";
- auto hFile = fopen(strNewFile, "wb");
- int nLen = fwrite(pRet->FileContent, 1, nRetLen - sizeof(PollSMA), hFile);
- fflush(hFile);
- fclose(hFile);
- if (nLen < nRetLen - sizeof(PollSMA)) {
- Dbg("save %s fail, fwrite len: %d, act len: %d", pRet->FileName, nLen, nRetLen - sizeof(PollSMA));
- fileutil_delete_file(strNewFile);
- delete[] pBuf;
- return Error_IO;
- }
- // 4. 检测新集中配置地址是否可用
- char tmp[32] = {};
- if(inifile_read_str_s("CenterSetting", "Server", "", tmp, 32, strNewFile) < 10)
- {
- Dbg("read center setting service addr from new file %s fail", (const char*)strNewFile);
- fileutil_delete_file(strNewFile);
- delete[] pBuf;
- return Error_NotConfig;
- }
- else if (!IsServiceAvailable(tmp)) {
- Dbg("the new centersetting server ip[%s] cannot be connectable!!!", tmp);
- }
- // 5. 读出当前集中配置服务地址并写入到新的集中配置文件中
- CSimpleStringA strPath;
- pFunc->GetPath("Cfg", strPath);
- CSimpleStringA strCurFile = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", (const char*)strPath, (const char*)pRet->FileName);
- memset(tmp, 0, 32);
- if (10 > inifile_read_str_s("CenterSetting", "Server", "", tmp, 32, strCurFile)) {
- Dbg("read center setting service addr from exist file %s fail: (%d)", strCurFile.GetData(), GetLastError());
- }
- // 写入同步信息
- inifile_write_str(strNewFile, "Main", "LastServer", tmp);
- DWORD dwSyncTime = CSmallDateTime::GetNow();
- memset(tmp, 0, sizeof(tmp));
- sprintf_s(tmp, sizeof(tmp), "0x%X", dwSyncTime);
- inifile_write_str(strNewFile, "Main", "SyncTime", tmp);
- inifile_write_str(strNewFile, "Main", "SyncHash", pRet->FileHash);
- inifile_write_str(strNewFile, "Main", "SyncFile", pRet->FileName);
- // 6. 备份原配置文件
- #if defined(RVC_OS_WIN)
- SYSTEMTIME st = {};
- GetLocalTime(&st);
- CSimpleStringA strBackFile = CSimpleStringA::Format("%s.%04d%02d%02d%02d%02d", (const char*)strCurFile,
- st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute);
- #else
- time_t t = time(NULL);
- tm* t1 = localtime(&t);
- CSimpleStringA strBackFile = CSimpleStringA::Format("%s.%04d%02d%02d%02d%02d", (const char*)strCurFile,
- t1->tm_year + 1900, t1->tm_mon + 1, t1->tm_mday, t1->tm_hour, t1->tm_min);
- #endif //RVC_OS_WIN
- fileutil_copy_file(strBackFile, strCurFile);
- // 7.替换当前配置文件,并删除临时文件
- fileutil_copy_file(strCurFile, strNewFile);
- fileutil_delete_file(strNewFile);
- Dbg("save config %s succ", (const char*)pRet->FileName);
- // 8. 更新内存中的同步信息
- CCenterSettingEntity::ConfigFileInfo info;
- info.dwSyncTime = dwSyncTime;
- info.strFileHash = pRet->FileHash;
- info.strFileName = pRet->FileName;
-
- CSimpleStringA str1, str2;
- if (pEntity->TryExtractSiteFromFileName(info.strFileName, str1, str2)) {
- pEntity->m_SyncFileInfo[(const char*)str2] = info;
- }
- delete[] pBuf;
- pBuf = NULL;
- } // end while
- if (nIndex > 1)
- {
- LogEvent(Severity_Middle, EVENT_MOD_CENTERSETTING_DOWNOK, "同步集中配置文件成功!");
- // 检查RvcWebVersion是否有变化
- CSimpleStringA strFilePath;
- pEntity->GetFunction()->GetPath("CenterSetting", strFilePath);
- // 缓存当前RVCWeb版本
- char szVersion[64] = {};
- inifile_read_str_s("IEBrowser", "RvcWebVersion", "", szVersion, 64, strFilePath);
- if (pEntity->m_strRvcWebVersion.IsNullOrEmpty() || strcmp(szVersion, pEntity->m_strRvcWebVersion) != 0)
- {
- Dbg("rvc web version changed, last: [%s], current: [%s]", (const char*)pEntity->m_strRvcWebVersion, szVersion);
- pEntity->m_strRvcWebVersion = szVersion;
- LogEvent(Severity_Middle, EVENT_MOD_CENTERSETTING_RVCWEBVER_CHANGE, "RVCWeb version has updated !");
- }
- return Error_Succeed;
- } else {
- return Error_NotExist;
- }
- }
- bool CCenterSettingConn::ClearillegalCenterSettingsFile(CSimpleStringA strCfgDirPath)
- {
- LOG_FUNCTION();
- array_header_t* arr = fileutil_get_sub_files_a(strCfgDirPath);
- if (arr) {
- for (int i = 0; i < arr->nelts; ++i) {
- char* path = (char*)ARRAY_IDX(arr, i, char*);
- regex reg("((DMZ)|(LAN))[^(\.ini)]");
- if (regex_search(path, reg)) {
- Dbg("delete: %s", path);
- fileutil_delete_file(path);
- }
- }
- toolkit_array_free2(arr);
- }
- return true;
- }
|