Browse Source

#IQRV #comment 开机计算函数统一

80374374 1 year ago
parent
commit
0e08a2bb2b

+ 5 - 6
Module/include/CommEntityHelpAgge.hpp

@@ -34,19 +34,18 @@ bool IsValidUrl(const CSimpleStringA& value)
         if (ret) {
             char ebuff[256];
             regerror(ret, &reg, ebuff, 256);
-            Dbg("regex failed: %s", ebuff);
+            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("regex failed: %s", ebuff);
             return false;
         }
 
-        //Dbg("pattern: %s", pattern.GetData());
         ret = regexec(&reg, strUrl.c_str(), 0, NULL, 0);
         if (0 == ret) {
-            Dbg("correct url format: %s", strUrl.c_str());
+            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("correct url format: %s", strUrl.c_str());
             return true;
         } else {
             char ebuff[256];
             regerror(ret, &reg, ebuff, 256);
-            Dbg("%s not match: %s", strUrl.c_str(), ebuff);
+            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("%s not match: %s", strUrl.c_str(), ebuff);
             return false;
         }
     }
@@ -63,7 +62,7 @@ bool IsNum(const std::string& value)
     if (ret) {
         char ebuff[256];
         regerror(ret, &reg, ebuff, 256);
-        Dbg("regex failed: %s", ebuff);
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("regex failed: %s", ebuff);
         return false;
     }
 
@@ -73,7 +72,7 @@ bool IsNum(const std::string& value)
     } else {
         char ebuff[256];
         regerror(ret, &reg, ebuff, 256);
-        Dbg("%s not match: %s", value.c_str(), ebuff);
+        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("%s not match: %s", value.c_str(), ebuff);
         return false;
     }
 }

+ 0 - 61
Module/include/CommEntitySettings.hpp

@@ -14,67 +14,6 @@ namespace Comm
 namespace Settings
 {
 
-
-/*!
- * @brief 判断当前是否处于安装模式,对于某些实体在安装时需要配合执行功能所以会启动,但是又需要屏蔽掉常规模式下的自动执行
- *             就需要通过此接口判断以停止某些功能
- * @param[in]  
- * @param[out] 
- * @return : 
- */
-static inline bool IsInConfigScheduleMode(CEntityBase* pEntity)
-{
-    CSimpleStringA strtermState;
-    pEntity->GetFunction()->GetSysVar("TerminalStage", strtermState);
-    return strtermState.IsStartWith("Z=");
-}
-
-static inline ErrorCodeEnum StoreHeadBranchServicesMode(CEntityBase* pEntity, BOOL fEnable)
-{
-    CSmartPointer<IConfigInfo> pConfig;
-    pEntity->GetFunction()->OpenConfig(Config_Cache, pConfig);
-    return pConfig->WriteConfigValueInt("MicroServicesConfig", "SourceFrom", fEnable? 2 : 1);
-}
-
-/*!
- * @brief 提供另外一种保底的方法检测集中配置从哪里下载
- * @param[in]  实体句柄
- * @return : -1:集中配置文件不存在;0:分行服务;1:总行服务
- */
- //TODO: 移除,现在全部终端已经切总行,过渡的分行逻辑已经不需要了
-static int DetectCenterSettingFilesSyncFromWhere(CEntityBase* pEntity)
-{
-    CSimpleStringA strFilePath;
-    pEntity->GetFunction()->GetPath("CenterSetting", strFilePath);
-    if (!ExistsFileA(strFilePath)) {
-        return -1;
-    }
-    CSmartPointer<IConfigInfo> pConfig;
-    pEntity->GetFunction()->OpenConfig(Config_CenterSetting, pConfig);
-    int fromType(0);
-    pConfig->ReadConfigValueInt("CenterSetting", "ProvideByHeadBank", fromType);
-    return (fromType == 1) ? 1 : 0;
-}
-
-static inline bool IsUsingHeadBranchServices(CEntityBase* pEntity)
-{
-    CSmartPointer<IConfigInfo> pConfig;
-    pEntity->GetFunction()->OpenConfig(Config_Cache, pConfig);
-    int enable(0);
-    pConfig->ReadConfigValueInt("MicroServicesConfig", "SourceFrom", enable);
-
-    return (enable == 2);
-}
-
-static inline bool IsUsingSubBranchServerConfig(CEntityBase* pEntity)
-{
-    CSmartPointer<IConfigInfo> pConfig;
-    pEntity->GetFunction()->OpenConfig(Config_Cache, pConfig);
-    int enable(0);
-    pConfig->ReadConfigValueInt("MicroServicesConfig", "SourceFrom", enable);
-    return (enable == 1);
-}
-
 static inline void InitializeOtherLogSwitch(CEntityBase* pEntity, const CSimpleStringA& strModuleName)
 {
 	LOG_FUNCTION();

+ 59 - 21
Module/include/CommEntityUtil.hpp

@@ -22,6 +22,7 @@
 #include <linux/sockios.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
+#include <sys/sysinfo.h>
 #include <unistd.h>
 #include <thread>
 #include <chrono>
@@ -60,18 +61,19 @@ namespace Module
 		static BOOL GetSystemBootTime(CSmallDateTime& systemBootTime)
 		{
 #if defined(_MSC_VER)
-
+			const char* SystemElapsedQuery = "\\System\\System Up Time";
 			PDH_STATUS Status;
 			HQUERY Query = NULL;
 			HCOUNTER hcElapsedTimeCount;
 			BOOL fSuc = FALSE;
+			/** 杀毒软件会对附件这几个系统调用函数有所监控,导致有时会耗费5s时间 Gifur@20221019]*/
 			Status = PdhOpenQuery(NULL, NULL, &Query);
 			PDH_FMT_COUNTERVALUE counterValue;
 			if (Status != ERROR_SUCCESS) {
 				DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("PdhOpenQuery failed with status 0x%x.", Status);
 				goto Cleanup;
 			}
-			Status = PdhAddCounter(Query, "\\System\\System Up Time", NULL, &hcElapsedTimeCount);
+			Status = PdhAddCounter(Query, SystemElapsedQuery, NULL, &hcElapsedTimeCount);
 			if (Status != ERROR_SUCCESS) {
 				DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("PdhAddCounter for SystemElapsedQuery failed with status 0x%x.", Status);
 				goto Cleanup;
@@ -94,7 +96,7 @@ namespace Module
 				ulSinceSeconds %= MINUS_DIV;
 				seconds = ULONG(ulSinceSeconds);
 
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("SystemElapseTime: %u:%02u:%02u:%02u", days, hours, minutes, seconds);
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("SystemElapseTime: %u %02u:%02u:%02u", days, hours, minutes, seconds);
 
 				FILETIME ftCurTime, ftStartTime;
 				GetSystemTimeAsFileTime(&ftCurTime);
@@ -117,19 +119,49 @@ namespace Module
 				systemBootTime.FromSystemTime(stLocal);
 				fSuc = TRUE;
 			}
-
 		Cleanup:
-
 			Status = PdhRemoveCounter(hcElapsedTimeCount);
 			if (Query) {
 				PdhCloseQuery(Query);
 			}
 			return fSuc;
-
 #else
-            ///*TODO(80374374@3/7/2023):  */
-            return FALSE;
-
+			DWORD ticks = 0;
+			SYSTEMTIME systemTime;
+
+			struct sysinfo info;
+			time_t curTime = 0;
+			time_t bootTime = 0;
+			struct tm* ptm = NULL;
+			if (sysinfo(&info)) {
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Failed to get sysinfo, errno:%u, reason:%s", errno, strerror(errno));
+				return FALSE;
+			}
+			time(&curTime);
+			if (curTime > info.uptime) {
+				bootTime = curTime - info.uptime;
+			}
+			else
+			{
+				bootTime = info.uptime - curTime;
+			}
+			ptm = localtime(&bootTime);
+			struct timespec ts;
+			if (!clock_gettime(CLOCK_MONOTONIC_RAW, &ts))
+				ticks = (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
+
+			systemTime.wYear = (WORD)(ptm->tm_year + 1900);
+			systemTime.wMonth = (WORD)(ptm->tm_mon + 1);
+			systemTime.wDayOfWeek = (WORD)ptm->tm_wday;
+			systemTime.wDay = (WORD)ptm->tm_mday;
+			systemTime.wHour = (WORD)ptm->tm_hour;
+			systemTime.wMinute = (WORD)ptm->tm_min;
+			systemTime.wSecond = (WORD)ptm->tm_sec;
+			systemTime.wMilliseconds = (WORD)(ticks % 1000);
+
+			systemBootTime.FromSystemTime(systemTime);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OSStartTime: %s", systemBootTime.ToTimeString().GetData());
+			return TRUE;
 #endif //_MSC_VER
 		}
 	}//system
@@ -226,7 +258,7 @@ struct LogErrorNotiyStruct : public LogCommNotiyStruct
     ~LogErrorNotiyStruct() {}
 };
 
-static BOOL IsFirsRunAppAfterSystemBoot(CEntityBase* pEntity)
+static BOOL IsFirsRunAppAfterSystemBoot(CEntityBase* pEntity, DWORD theReportUserCode = 0)
 {
 	BOOL result(FALSE);
 	CSystemRunInfo runInfo = { 0 };
@@ -241,6 +273,12 @@ static BOOL IsFirsRunAppAfterSystemBoot(CEntityBase* pEntity)
 		const BOOL bRet = System::GetSystemBootTime(systemBootTime);
 		if (bRet && systemBootTime > bootInfo.tmStart) {
 			result = TRUE;
+			if (theReportUserCode != 0) {
+				std::map<std::string, std::string> srcData;
+				CSimpleStringA strData = CSimpleStringA::Format("{\"AppLastStartTime\":\"%s\",\"AppStartTime\":\"%s\",\"OSStartTime\":\"%s\"}"
+					, (LPCTSTR)bootInfo.tmStart.ToTimeString(), (LPCTSTR)runInfo.tmStart.ToTimeString(), systemBootTime.ToTimeString().GetData());
+				LogWarn(Severity_Low, Error_Debug, theReportUserCode, strData.GetData());
+			}
 		}
 	}
 	return result;
@@ -815,7 +853,7 @@ static ErrorCodeEnum GetINETMacAddresses(CAutoArray<NetworkAdapterItem>& netList
 				netItem.type = pAddresses->IfType;
 				netLists.Append(&netItem, 0, 1);
 			}
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s, %s: OperStatus: %d, IfType = %d, ip=%s, mac=%s"
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s, %s: OperStatus: %d, IfType = %d, ip=%s, mac=%s"
 				, strFriendlyName.GetData(), strDescription.GetData()
 				, pAddresses->OperStatus, pAddresses->IfType, tmpip.GetData(), tmpmac.GetData());
 		}
@@ -834,20 +872,20 @@ static ErrorCodeEnum GetINETMacAddresses(CAutoArray<NetworkAdapterItem>& netList
 	int count, i;
 	toolkit_interface_addresses(&info, &count);
 	i = count;
-	Dbg("Number of interfaces: %d", count);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Number of interfaces: %d", count);
 	while (i--) {
 		toolkit_interface_address_t interface = info[i];
 
-		Dbg("Name: %s", interface.name);
-		Dbg("Internal? %s", interface.is_internal ? "Yes" : "No");
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Name: %s", interface.name);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Internal? %s", interface.is_internal ? "Yes" : "No");
 		if (interface.address.address4.sin_family == AF_INET) {
 			toolkit_ip4_name(&interface.address.address4, buf, sizeof(buf));
-			Dbg("IPv4 address: %s", buf);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("IPv4 address: %s", buf);
 			inteIPs[interface.name] = buf;
 		}
 		else if (interface.address.address4.sin_family == AF_INET6) {
 			toolkit_ip6_name(&interface.address.address6, buf, sizeof(buf));
-			Dbg("IPv6 address: %s", buf);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("IPv6 address: %s", buf);
 			//inteIPs[interface.name] = buf;
 		}
 	}
@@ -864,9 +902,9 @@ static ErrorCodeEnum GetINETMacAddresses(CAutoArray<NetworkAdapterItem>& netList
 		ifc.ifc_buf = (caddr_t)bufIfreq;
 		if (!ioctl(fd, SIOCGIFCONF, (char*)& ifc)) {
 			interface = ifc.ifc_len / sizeof(struct ifreq);
-			Dbg("interface num is %d", interface);
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("interface num is %d", interface);
 			while (i < interface) {
-				Dbg("Name: %s", bufIfreq[i].ifr_name);
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Name: %s", bufIfreq[i].ifr_name);
 				if (!(ioctl(fd, SIOCGIFHWADDR, (char*)& bufIfreq[i]))) {
 					sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X",
 						(unsigned char)bufIfreq[i].ifr_hwaddr.sa_data[0],
@@ -875,7 +913,7 @@ static ErrorCodeEnum GetINETMacAddresses(CAutoArray<NetworkAdapterItem>& netList
 						(unsigned char)bufIfreq[i].ifr_hwaddr.sa_data[3],
 						(unsigned char)bufIfreq[i].ifr_hwaddr.sa_data[4],
 						(unsigned char)bufIfreq[i].ifr_hwaddr.sa_data[5]);
-					Dbg("HWaddr %s", mac);
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("HWaddr %s", mac);
 					inteMacs[bufIfreq[i].ifr_name] = mac;
 				}
 				struct ethtool_value edata;
@@ -886,12 +924,12 @@ static ErrorCodeEnum GetINETMacAddresses(CAutoArray<NetworkAdapterItem>& netList
 				//oiltmp@20231026 只检测了以太网卡
 				if (ioctl(fd, SIOCETHTOOL, (char*)& bufIfreq[i]) == -1) {
 					//up down
-					Dbg("Name: %s is down", bufIfreq[i].ifr_name);
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Name: %s is down", bufIfreq[i].ifr_name);
 					inteStatus[bufIfreq[i].ifr_name] = 0;
 				}
 				else
 				{
-					Dbg("Name: %s is up", bufIfreq[i].ifr_name);
+					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Name: %s is up", bufIfreq[i].ifr_name);
 					inteStatus[bufIfreq[i].ifr_name] = 1;
 				}
 				i++;

+ 12 - 149
Module/mod_ResourceWatcher/ResourceWatcherFSM.cpp

@@ -93,8 +93,6 @@ static int diskCheckFlag = 1;
 #define HOURS_DIV (60 * 60)
 #define MINUS_DIV (60)
 
-const char* SystemElapsedQuery = "\\System\\System Up Time";
-
 #ifndef RVC_OS_LINUX
 #define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING) 
 #define SafeDeleteArraySize(pData) { if(pData){delete []pData;pData=NULL;} }  
@@ -346,9 +344,6 @@ ErrorCodeEnum ResourceWatcherFSM::OnInit()
 
     ErrorCodeEnum erroCode = Error_Succeed;
     DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Complied at: %s %s", __DATE__, __TIME__);
-#ifdef WIDE_CONDITION
-    setlocale(LC_ALL, "chs");
-#endif
     CSmartPointer<IConfigInfo> spRunConfig;
     CSmartPointer<IConfigInfo> spCtSettingConfig;
     GetEntityBase()->GetFunction()->OpenConfig(Config_Run, spRunConfig);
@@ -1391,113 +1386,6 @@ ErrorCodeEnum ResourceWatcherFSM::GetBizLinks(
     return ec;
 }
 
-///*TODO: 使用共用库的接口 (80374374@11/24/2023)*/
-BOOL ResourceWatcherFSM::GetSystemBootTime(CSmallDateTime& systemBootTime)
-{
-#ifdef RVC_OS_LINUX
-    DWORD ticks = 0;
-    SYSTEMTIME systemTime;
-
-    struct sysinfo info;
-    time_t curTime = 0;
-    time_t bootTime = 0;
-    struct tm* ptm = NULL;
-    if (sysinfo(&info)) {
-        DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Failed to get sysinfo, errno:%u, reason:%s", errno, strerror(errno));
-        return FALSE;
-    }
-    time(&curTime);
-    if (curTime > info.uptime) {
-        bootTime = curTime - info.uptime;
-    }
-    else
-    {
-        bootTime = info.uptime - curTime;
-    }
-    ptm = localtime(&bootTime);
-    struct timespec ts;
-    if (!clock_gettime(CLOCK_MONOTONIC_RAW, &ts))
-        ticks = (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
-
-    systemTime.wYear = (WORD)(ptm->tm_year + 1900);
-    systemTime.wMonth = (WORD)(ptm->tm_mon + 1);
-    systemTime.wDayOfWeek = (WORD)ptm->tm_wday;
-    systemTime.wDay = (WORD)ptm->tm_mday;
-    systemTime.wHour = (WORD)ptm->tm_hour;
-    systemTime.wMinute = (WORD)ptm->tm_min;
-    systemTime.wSecond = (WORD)ptm->tm_sec;
-    systemTime.wMilliseconds = (WORD)(ticks % 1000);
-
-    systemBootTime.FromSystemTime(systemTime);
-    DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OSStartTime: %s", systemBootTime.ToTimeString().GetData());
-    return TRUE;
-#else
-    PDH_STATUS Status;
-    HQUERY Query = NULL;
-    HCOUNTER hcElapsedTimeCount;
-    BOOL fSuc = FALSE;
-    /** 杀毒软件会对附件这几个系统调用函数有所监控,导致有时会耗费5s时间 Gifur@20221019]*/
-    Status = PdhOpenQuery(NULL, NULL, &Query);
-    PDH_FMT_COUNTERVALUE counterValue;
-    if (Status != ERROR_SUCCESS) {
-        DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("PdhOpenQuery failed with status 0x%x.", Status);
-        goto Cleanup;
-    }
-    Status = PdhAddCounter(Query, SystemElapsedQuery, NULL, &hcElapsedTimeCount);
-    if (Status != ERROR_SUCCESS) {
-        DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("PdhAddCounter for SystemElapsedQuery failed with status 0x%x.", Status);
-        goto Cleanup;
-    }
-    // 查询性能监视器数据
-    Status = PdhCollectQueryData(Query);
-    if (Status != ERROR_SUCCESS) {
-        DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("PdhCollectQueryData failed with 0x%x.", Status);
-        goto Cleanup;
-    }
-    Status = PdhGetFormattedCounterValue(hcElapsedTimeCount, PDH_FMT_LARGE, NULL, &counterValue);
-    if (Status == ERROR_SUCCESS) {
-        ULONGLONG ulSinceSeconds = counterValue.largeValue;
-        ULONG days = 0, hours = 0, minutes = 0, seconds = 0;
-        days = ULONG(ulSinceSeconds / DAY_DIV);
-        ulSinceSeconds %= DAY_DIV;
-        hours = ULONG(ulSinceSeconds / HOURS_DIV);
-        ulSinceSeconds %= HOURS_DIV;
-        minutes = ULONG(ulSinceSeconds / MINUS_DIV);
-        ulSinceSeconds %= MINUS_DIV;
-        seconds = ULONG(ulSinceSeconds);
-
-        DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("SystemElapseTime: %u %02u:%02u:%02u", days, hours, minutes, seconds);
-
-        FILETIME ftCurTime, ftStartTime;
-        GetSystemTimeAsFileTime(&ftCurTime);
-        ULARGE_INTEGER uliCurTime;
-        uliCurTime.HighPart = ftCurTime.dwHighDateTime;
-        uliCurTime.LowPart = ftCurTime.dwLowDateTime;
-        uliCurTime.QuadPart -= counterValue.largeValue * 1e7;
-
-        ftStartTime.dwHighDateTime = uliCurTime.HighPart;
-        ftStartTime.dwLowDateTime = uliCurTime.LowPart;
-
-        SYSTEMTIME stUTC, stLocal;
-
-        FileTimeToSystemTime(&ftStartTime, &stUTC);
-        char temp[22];
-        SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
-        sprintf_s(temp, 22, "%d-%02d-%02d %02d:%02d:%02d",
-            stLocal.wYear, stLocal.wMonth, stLocal.wDay, stLocal.wHour, stLocal.wMinute, stLocal.wSecond);
-        DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OSStartTime: %s", temp);
-        systemBootTime.FromSystemTime(stLocal);
-        fSuc = TRUE;
-    }
-Cleanup:
-    Status = PdhRemoveCounter(hcElapsedTimeCount);
-    if (Query) {
-        PdhCloseQuery(Query);
-    }
-    return fSuc;
-#endif // RVC_OS_LINUX
-}
-
 #ifdef _MSC_VER
 bool ResourceWatcherFSM::CreateLinkFile(const CSimpleStringA& szStartAppPath, const CSimpleStringA& szAddCmdLine,
     const CSimpleStringA& szDestLnkPath, const CSimpleStringA& szIconPath)
@@ -1975,9 +1863,9 @@ void ResourceWatcherFSM::DetectVersionHasChangedAndWarn()
         CSimpleStringA rootVerPath;
         CSimpleStringA warnInfo = CSimpleStringA::Format("version changed from %s to %s", lastVer.ToString().GetData(), m_RvcSysinfo.InstallVersion.ToString().GetData());
         GetEntityBase()->GetFunction()->GetPath("RootVer", rootVerPath);
-        CSimpleStringA csPath = rootVerPath + "\\active.txt";
+        CSimpleStringA csPath = rootVerPath + SPLIT_SLASH_STR + "active.txt";
         if (!ExistsFileA(csPath)) {
-            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A0A").setAPI("DetectVersionHasChangedAndWarn")
+            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A0A").setAPI(__FUNCTION__)
                 ("%s: active.txt not exist!", warnInfo.GetData());
             LogWarn(Severity_Middle, Error_Debug, LOG_WARN_ACTIVE_FILE_CHANGE, CSimpleStringA::Format("%s: active.txt not exist!", warnInfo.GetData()));
         }
@@ -1993,7 +1881,7 @@ void ResourceWatcherFSM::DetectVersionHasChangedAndWarn()
                 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
                 NULL);
             if (hFile == INVALID_HANDLE_VALUE) {
-                DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A0A").setAPI("DetectVersionHasChangedAndWarn")
+                DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A0A").setAPI(__FUNCTION__)
                     ("%s: active.txt open failed %u", warnInfo.GetData(), GetLastError());
                 LogWarn(Severity_Middle, Error_Debug, LOG_WARN_ACTIVE_FILE_CHANGE, CSimpleStringA::Format("%s: active.txt open failed %u", warnInfo.GetData(), GetLastError()));
             }
@@ -2008,7 +1896,7 @@ void ResourceWatcherFSM::DetectVersionHasChangedAndWarn()
                 GetTimeFormatStr(szFormat2, 128, (FILETIME*)&activeFileInfo.mftAccess);
                 char szFormat3[128] = { 0 };
                 GetTimeFormatStr(szFormat3, 128, (FILETIME*)&activeFileInfo.mftModified);
-                DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A0A").setAPI("DetectVersionHasChangedAndWarn")
+                DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A0A").setAPI(__FUNCTION__)
                     ("%s: active.txt create at %s, access at %s, modified at %s", warnInfo.GetData(), szFormat1, szFormat2, szFormat3);
                 LogWarn(Severity_Middle, Error_Debug, LOG_WARN_ACTIVE_FILE_CHANGE, CSimpleStringA::Format(
                     "%s: active.txt create at %s, access at %s, modified at %s", warnInfo.GetData(), szFormat1, szFormat2, szFormat3));
@@ -3763,31 +3651,15 @@ void ResourceWatcherFSM::AlarmSystemBasicInfo()
 
 BOOL ResourceWatcherFSM::DetectIsFirstRunAtBoot()
 {
-    CSystemRunInfo runInfo = { 0 };
-    GetEntityBase()->GetFunction()->GetSystemRunInfo(runInfo);
-    BOOL bSet = FALSE;
-    CBootInfo bootInfo = { 0 };
-    CSmallDateTime dateTime(0);
-    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("systemRunInfo time: %s", (LPCTSTR)runInfo.tmStart.ToTimeString());
-    ErrorCodeEnum erroCode = GetEntityBase()->GetFunction()->GetRebootInfo(/*runInfo.tmStart*/dateTime, bootInfo);
-    DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("bootInfor time: %s", (LPCTSTR)bootInfo.tmStart.ToTimeString());
-    CSmallDateTime systemBootTime;
-    BOOL bRet = GetSystemBootTime(systemBootTime);
-    if (bRet && systemBootTime > bootInfo.tmStart) {
-        ErrorCodeEnum eRet = GetEntityBase()->GetFunction()->SetSysVar(SYSVAR_FRAMEWORK_FIRST_BOOT, SYSVAR_FRAMEWORK_FIRST_BOOT_YES);
-        if (eRet != Error_Succeed) {
-            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Set %s with %s failed: %d", SYSVAR_FRAMEWORK_FIRST_BOOT, SYSVAR_FRAMEWORK_FIRST_BOOT_YES, eRet);
-        }
-        bSet = TRUE;
-        std::map<std::string, std::string> srcData;
-        CSimpleStringA strData = CSimpleStringA::Format("{\"AppLastStartTime\":\"%s\",\"AppStartTime\":\"%s\",\"OSStartTime\":\"%s\"}"
-            , (LPCTSTR)bootInfo.tmStart.ToTimeString(), (LPCTSTR)runInfo.tmStart.ToTimeString(), systemBootTime.ToTimeString().GetData());
-        LogWarn(Severity_Low, Error_Debug, LOG_RESOURCEWATCHER_FIRST_RUN_AFTER_BOOT, strData.GetData());
+    const BOOL bSet = SP::Module::Comm::IsFirsRunAppAfterSystemBoot(GetEntityBase());
+    if (bSet) {
+		ErrorCodeEnum eRet = GetEntityBase()->GetFunction()->SetSysVar(SYSVAR_FRAMEWORK_FIRST_BOOT, SYSVAR_FRAMEWORK_FIRST_BOOT_YES);
+		if (eRet != Error_Succeed) {
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Set %s with %s failed: %d", SYSVAR_FRAMEWORK_FIRST_BOOT, SYSVAR_FRAMEWORK_FIRST_BOOT_YES, eRet);
+		}
     }
-    else
-    {
-        GetEntityBase()->GetFunction()->SetSysVar(SYSVAR_FRAMEWORK_FIRST_BOOT, SYSVAR_FRAMEWORK_FIRST_BOOT_NO);
-        bSet = FALSE;
+    else {
+		GetEntityBase()->GetFunction()->SetSysVar(SYSVAR_FRAMEWORK_FIRST_BOOT, SYSVAR_FRAMEWORK_FIRST_BOOT_NO);
     }
     return bSet;
 }
@@ -3974,15 +3846,6 @@ void ResourceWatcherFSM::UploadSysVersionInfo(UINT& ver)
         }
         srcData.insert(std::make_pair("cpu-type", sucContent));
     } while (false);
-
-    //#if defined(RVC_OS_LINUX)
-    //    CSystemStaticInfo sysInfo;
-    //    ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetSystemStaticInfo(sysInfo);
-    //    if (eErr == Error_Succeed) {
-    //        termInfo["MachineMode"] = (LPCTSTR)sysInfo.strMachineModel;
-    //        termInfo["MachineSN"] = (LPCTSTR)sysInfo.strMachineSN;
-    //    }
-    //#endif //RVC_OS_LINUX
     auto ret = generateJsonStr(srcData);
     LogWarn(Severity_Low, Error_Hardware, LOG_RESOURCEWATCHER_SYSTEMINFO, ret.second.c_str());
 }

+ 0 - 1
Module/mod_ResourceWatcher/ResourceWatcherFSM.h

@@ -294,7 +294,6 @@ public:
 	void DeleteVideoFiles();
 	int ProcessFileDelete(LPCTSTR lpszPath, int& nDelSucCnt, int& nDelFailedCnt, bool delDir, unsigned int saveBackDay = 0);
 
-	BOOL GetSystemBootTime(CSmallDateTime& systemBootTime);
     BOOL DetectIsFirstRunAtBoot();
 
 #ifdef RVC_OS_LINUX