Bladeren bron

#IQRV #comment [Chromium][BugFix] 错误页重启时间展示修复

gifur 3 jaren geleden
bovenliggende
commit
4a0bc536e7
3 gewijzigde bestanden met toevoegingen van 33 en 30 verwijderingen
  1. 29 25
      Module/mod_chromium/CModTools.cpp
  2. 3 1
      Module/mod_chromium/CModTools.h
  3. 1 4
      Module/mod_chromium/mod_chromium.cpp

+ 29 - 25
Module/mod_chromium/CModTools.cpp

@@ -196,17 +196,6 @@ namespace Chromium {
 
 		switch (errType)
 		{
-			/* 不应该有
-		case ERR_PAGE_REASON::CardStoreIsBusy:
-			errPagePath.Append(CSimpleStringA("?reason=") + errType._to_string() + "&errmsg=卡库正在使用中");
-			setLimitReason(errType._to_string());
-			break;
-		case ERR_PAGE_REASON::MachineTypeError:
-			errPagePath.Append(CSimpleStringA("?reason=") + errType._to_string() + "&errmsg=双屏版只检测到单屏");
-			setLimitReason("breakdown");
-			break;
-		case ERR_PAGE_REASON::CameraConfig:
-			*/
 		case ERR_PAGE_REASON::breakdown:
 		{
 			CSimpleStringA m_sAuthErrMsg, ts;
@@ -219,8 +208,9 @@ namespace Chromium {
 			else
 				errPagePath.Append(CSimpleStringA("?reason=")).Append(errType._to_string()).Append("&errmsg=").Append(m_sAuthErrMsg);
 
-			if (findRestartCode(usercode))
-				errPagePath.Append("&reboottime=").Append(GetSpShellBootTime().c_str());
+			if (findRestartCode(usercode)) {
+				errPagePath.Append("&reboottime=").Append(GetSpShellNextRebootTime().c_str());
+			}
 			errPagePath.Append(CSimpleStringA("&showlimit=")).Append(std::to_string((unsigned long long)1).c_str());
 			if (m_withMin)
 			{
@@ -314,13 +304,15 @@ namespace Chromium {
 	std::string formatTime(SYSTEMTIME time)
 	{
 		char tBuf[1024] = "";
-		sprintf(tBuf, "%04u-%02u-%02u %02u:%02u:%02u:%03u", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond, time.wMilliseconds);
+        //sprintf(tBuf, "%04u-%02u-%02u %02u:%02u:%02u:%03u", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond, time.wMilliseconds);
+		sprintf(tBuf, "%04u-%02u-%02u %02u:%02u:%02u", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
 		return tBuf;
 	}
 
-	std::string CModTools::GetSpShellBootTime()
+	std::string CModTools::GetSpShellNextRebootTime()
 	{
 		static std::string shellBootTime;
+
 		if (0 == shellBootTime.length())
 		{
 			CAutoArray<CSimpleStringA> t_names;
@@ -329,9 +321,14 @@ namespace Chromium {
 			this->m_pEntity->GetFunction()->GetAllEntityStartInfo(t_names, t_Idx, t_Infos);
 
 			for (int i = 0; i < t_Infos.GetCount(); i++) {
-				if (0 == t_Idx[i])//shell
-				{
-					shellBootTime = formatTime(t_Infos[i].startTime);
+                //if (0 == t_Idx[i])//shell
+				if (t_names[i].Compare("HealthManager") == 0) {
+					SYSTEMTIME startTime = t_Infos[i].startTime;
+					CSmallDateTime dateTime;
+					dateTime.FromSystemTime(startTime);
+					/** 十分钟后重启 [Gifur@2022324]*/
+					CSmallDateTime dateNewTime((DWORD)dateTime + 10 * 60);
+					shellBootTime = dateNewTime.ToTimeString().GetData();
 					break;
 				}
 			}
@@ -782,15 +779,15 @@ namespace Chromium {
 		else
 		{
 			//open err page
-			
-			if (notifyExist)
-				return std::make_pair(Error_Unexpect, 0);
-
-			if (ERR_PAGE_REASON::breakdown == reason._to_integral() && breakdownExist)
-				return std::make_pair(Error_Unexpect, 0);//只打开一个breakdown页面,后续通过cefclient改动,避免打开同种页面
+			if (notifyExist) {
+                return std::make_pair(Error_Duplication, 0);
+			}
+			//只打开一个breakdown页面,后续通过cefclient改动,避免打开同种页面
+			if (ERR_PAGE_REASON::breakdown == reason._to_integral() && breakdownExist) {
+                return std::make_pair(Error_Duplication, 0);
+			}
 
 			auto errPageUrl = GenerateErrPage(reason, normalParam, exParam);
-
 			if (!errPageUrl.first)
 			{
 				DbgEx("errPage get url failed!");
@@ -990,8 +987,11 @@ namespace Chromium {
 	}
 
 	bool CModTools::findRestartCode(DWORD userCode) {
+
+        /** 救赎之道,就在其外 [Gifur@2022324]*/
 		DWORD authArr_noretry_norestart[] = ERRARR_ACCESSAUTH_NORETRY_NORESTART;
 		DWORD authArr_retry_norestart[] = ERRARR_ACCESSAUTH_RETRY_NORESTART;
+
 		std::vector<DWORD> norestartArr;
 #if (defined _WIN32 || defined _WIN64)
 		for each (auto i in authArr_noretry_norestart)
@@ -999,6 +999,7 @@ namespace Chromium {
 		for (auto i : authArr_noretry_norestart)
 #endif
 			norestartArr.push_back(i);
+
 #if (defined _WIN32 || defined _WIN64)
 		for each (auto i in authArr_retry_norestart)
 #else	
@@ -1006,6 +1007,8 @@ namespace Chromium {
 #endif
 			norestartArr.push_back(i);
 
+//////////////////////////////////////////////////////////////////////////
+
 #if (defined _WIN32 || defined _WIN64)
 		for each (auto i in norestartArr)
 #else	
@@ -1016,6 +1019,7 @@ namespace Chromium {
 				return false;
 			}
 		}
+
 		return true;
 	}
 

+ 3 - 1
Module/mod_chromium/CModTools.h

@@ -86,7 +86,9 @@ namespace Chromium {
 		std::pair<ErrorCodeEnum, int> openCefByFreerdp(std::string cmdline, bool isGuard = false);
 		void openCefByFreerdpGuardian(std::string cmdline);
 		std::pair<bool, std::string> openAdPage();
-		std::string GetSpShellBootTime();
+
+		/** 应该跟健康约定了,准入不过,通过监护进程触发框架重启,这里默认框架启动时间再加上10分钟 [Gifur@2022324]*/
+		std::string GetSpShellNextRebootTime();
 		bool isOutsidePad();
 		void setLimitReason(const char* reason);
 		int StandardToStamp(const char* str_time, bool dateOnly);

+ 1 - 4
Module/mod_chromium/mod_chromium.cpp

@@ -442,6 +442,7 @@ namespace Chromium {
 				GetFunction()->UnregistSysVarEvent("UIState");
 			}
 		}
+		/** 该事件有变化才会触发错误页 [Gifur@2022324]*/
 		else if (0 == CSimpleStringA("TerminalStage").Compare(pszKey, true))
 		{
 			if (0 == CSimpleStringA("A").Compare(pszValue, true))
@@ -557,7 +558,6 @@ namespace Chromium {
 				auto notifyPool = m_pWsServer->getNotifyPool();
 				if (notifyPool.size() > 0)
 				{
-
 					for (auto it : notifyPool)
 					{
 						DbgEx("Log_Notify err, notifyPool to %d, %d", it.first, it.second);
@@ -569,12 +569,9 @@ namespace Chromium {
 					auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::ErrNotify, { m_sysInfo.strTerminalID.GetData(), generateTimeStr() }, { notifyReason, notifymsg, notiryRebootTime, dwSysError, dwUserCode });
 					DbgEx("Log_Notify err, open page %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
 				}
-
-
 			}
 			catch (std::exception& e) {
 				DbgEx("Log_Notify err, %s", e.what());
-
 			}
 			return;
 	}