Bladeren bron

Z991239-1017 #comment fea errPage策略上传

CardStoreIsBusy、MachineTypeError不实现

TerminalManagerKickOut、TerminalManagerOff
--OnTerminalManage::TerminalManagerState控制

CameraConfig
--Onlog::LOG_EVT_BEGIN_CAMERA_CONFIG

disabled、jobuncomplete
--3600s定时任务OnBusinessLimitTimerListener

breakdown
--EntryPermit
陈良瑜80374463 4 jaren geleden
bovenliggende
commit
72cf48fef6

+ 272 - 20
Module/mod_chromium/CModTools.cpp

@@ -7,7 +7,7 @@ using namespace FreeRDPWrap;
 #include "CModTools.h"
 #include "SpIni.h"
 #include <vector>
-
+#include <list>
 #include <memory>
 #include <iostream>
 #include <mutex>
@@ -16,10 +16,21 @@ using namespace FreeRDPWrap;
 #include <boost/process.hpp>
 #include <boost/thread.hpp>
 
+#include "../mod_upload/Upload_client_g.h"
+
 
 
 extern std::pair<bool, std::string> DetectActiveHttp(std::vector<std::string> urlArr);
 
+auto GetCefHead = [](CEntityBase* curEntity)->CSimpleStringA {
+	CSimpleStringA strChromiumPath, basePath;
+	curEntity->GetFunction()->GetPath("Base", basePath);
+	strChromiumPath.Append("sudo ").Append(basePath);
+	strChromiumPath.Append(CSimpleStringA(SPLIT_SLASH_STR) + "bin" + SPLIT_SLASH_STR + "Chromium" + SPLIT_SLASH_STR);
+	return strChromiumPath;
+};
+
+
 auto detectUrls = [](std::string urls) -> std::string {
 	std::vector<std::string> urlArr;
 	urlArr.push_back(urls);
@@ -36,6 +47,25 @@ namespace Chromium{
 
 void CModTools::InitCModTools(CEntityBase* pEntity){
 	this->m_pEntity = pEntity;
+
+	CSmartPointer<IConfigInfo> spConfig;
+	ErrorCodeEnum Error = m_pEntity->GetFunction()->OpenConfig(Config_Root, spConfig);
+	if (Error == Error_Succeed)
+	{
+		Error = spConfig->ReadConfigValue("Terminal", "MachineType", m_strMachineType);
+		if (Error == Error_Succeed)
+		{
+			Error = spConfig->ReadConfigValue("Terminal", "Site", m_strSite);
+			if (Error != Error_Succeed)
+			{
+				Dbg("ReadConfigValue, get Site value failed");
+			}
+		}
+		else
+		{
+			Dbg("ReadConfigValue, get MachineType value failed");
+		}
+	}
 }
 
 
@@ -90,7 +120,7 @@ std::pair<bool, std::string> CModTools::getErrUrl()
 std::pair<bool, std::string> CModTools::GenerateErrPage(ERR_PAGE_REASON errType)
 {
 	auto errUrlRet = getErrUrl();
-	CSimpleStringA errPagePath = errUrlRet.second.c_str();
+	CSimpleStringA errPagePath = errUrlRet.second.c_str(), strChromiumPath = GetCefHead(this->m_pEntity).Append(CEFCLIENT_NAME);
 	
 	switch (errType)
 	{
@@ -109,7 +139,8 @@ std::pair<bool, std::string> CModTools::GenerateErrPage(ERR_PAGE_REASON errType)
 		this->m_pEntity->GetFunction()->GetSysVar("TerminalStage", ts);
 		auto rc = this->m_pEntity->GetFunction()->GetSysVar("AuthErrMsg", m_sAuthErrMsg);
 		Dbg("准入没过,展示交易暂停页面 TerminalStage=%c, AuthErrMsg=%s", ts[0], m_sAuthErrMsg);
-		errPagePath.Append(CSimpleStringA("?reason=") + errType._to_string() + "&errmsg=" + m_sAuthErrMsg + "&reboottime=" + GetSpShellBootTime().c_str());
+		errPagePath.Append(CSimpleStringA("?reason=") + errType._to_string());// +"&errmsg=" + m_sAuthErrMsg + "&reboottime=" + GetSpShellBootTime().c_str());
+		errPagePath = CSimpleStringA("\'file:///") + errPagePath + CSimpleStringA("\'");
 	}
 		break;
 	case ERR_PAGE_REASON::CameraConfig:
@@ -137,16 +168,23 @@ std::pair<bool, std::string> CModTools::GenerateErrPage(ERR_PAGE_REASON errType)
 	case ERR_PAGE_REASON::TerminalManagerKickOut:
 	case ERR_PAGE_REASON::TerminalManagerOff:
 		errPagePath.Append(" --logextend=").Append((+PAGE_TYPE::TerminalManager)._to_string());
+		break;
 	case ERR_PAGE_REASON::CameraConfig:
 		errPagePath.Append(" --logextend=").Append((+PAGE_TYPE::CameraConfig)._to_string());
+		break;
+	case ERR_PAGE_REASON::disabled:
+	case ERR_PAGE_REASON::jobuncomplete:
+		errPagePath.Append(" --logextend=").Append((+PAGE_TYPE::TradeManager)._to_string());
+		break;
 	default:
 		errPagePath.Append(" --logextend=").Append((+PAGE_TYPE::errPage)._to_string());
+		break;
 	}
 	
+	CSimpleString dstCmd = strChromiumPath + " --url=" + errPagePath;
+	Dbg("GenerateErrPage type=%s, dstPage=%s", errType._to_string(), dstCmd.GetData());
 
-	Dbg("GenerateErrPage type=%s, dstPage=%s", errType._to_string(), errPagePath.GetData());
-
-	return std::make_pair(true, (const char*)errPagePath.GetData());
+	return std::make_pair(true, (const char*)dstCmd.GetData());
 }
 
 std::string formatTime(SYSTEMTIME time)
@@ -245,13 +283,7 @@ std::pair<bool, std::string> CModTools::getMainUrl()
 	return std::make_pair(isOpenExtend, strUrl.GetData());
 }
 
-auto GetCefHead = [](CEntityBase* curEntity)->CSimpleStringA {
-	CSimpleStringA strChromiumPath, basePath;
-	curEntity->GetFunction()->GetPath("Base", basePath);
-	strChromiumPath.Append("sudo ").Append(basePath);
-	strChromiumPath.Append(CSimpleStringA(SPLIT_SLASH_STR) + "bin" + SPLIT_SLASH_STR + "Chromium" + SPLIT_SLASH_STR);
-	return strChromiumPath;
-};
+
 
 std::string CModTools::generateAdCmd(std::string AdUrl) {
 	CSimpleStringA strChromiumPath = GetCefHead(this->m_pEntity), strCmdLine = "";
@@ -344,7 +376,7 @@ std::pair<ErrorCodeEnum, int> CModTools::StartChromiumBrowser(ERR_PAGE_REASON re
 
 		auto strCmdLine = generateCefclientCmd(mainUrlRet.first, mainUrlRet.second);
 
-		auto openCefRet = openCef(strCmdLine);
+		auto openCefRet = openCef(strCmdLine, false);
 		if (Error_Succeed == openCefRet.first)
 			return std::make_pair(Error_Succeed, openCefRet.second);
 	}
@@ -352,13 +384,14 @@ std::pair<ErrorCodeEnum, int> CModTools::StartChromiumBrowser(ERR_PAGE_REASON re
 	{
 		//open err page
 		auto errPageUrl = GenerateErrPage(reason);
+		
 		if (!errPageUrl.first)
 		{
 			DbgEx("errPage get url failed!");
 			return std::make_pair(Error_Unexpect, 0);
 		}
 		auto errPageRet = openCef(errPageUrl.second);
-		return errPageRet;
+		return std::make_pair(Error_Succeed, 0);
 
 	}
 
@@ -392,12 +425,231 @@ void CModTools::cefClientGuardian(std::string cmdline)
 	return;
 }
 
-std::pair<ErrorCodeEnum, int> CModTools::openCef(std::string cmdline)
+// 输入为北京时间 输出为北京时间戳
+int CModTools::StandardToStamp(const char* str_time, bool dateOnly)
 {
-	//mod_chromium相当于cefclient的守护进程
-	std::string guardianStr = cmdline;
-	boost::thread cefGuardian(boost::bind(&CModTools::cefClientGuardian, this, guardianStr));
-	cefGuardian.detach();
+	Dbg("StandardToStamp str = %s", str_time);
+	struct tm stm;
+	int iY, iM, iD, iH, iMin, iS;
+
+	// 检查有效性
+	if ('-' != str_time[4] || '-' != str_time[7])
+	{
+		return 0;
+	}
+
+	memset(&stm, 0, sizeof(stm));
+	iY = atoi(str_time);
+	iM = atoi(str_time + 5);
+	iD = atoi(str_time + 8);
+	if (dateOnly)
+	{
+		iH = 0;
+		iMin = 0;
+		iS = 0;
+	}
+	else {
+		iH = atoi(str_time + 11);
+		iMin = atoi(str_time + 14);
+		iS = atoi(str_time + 17);
+	}
+
+	stm.tm_year = iY - 1900;
+	stm.tm_mon = iM - 1;
+	stm.tm_mday = iD;
+	stm.tm_hour = iH;
+	stm.tm_min = iMin;
+	stm.tm_sec = iS;
+
+	/*printf("%d-%0d-%0d %0d:%0d:%0d\n", iY, iM, iD, iH, iMin, iS);*/   //标准时间格式例如:2016:08:02 12:12:30
+	return (int)mktime(&stm);
+}
+
+bool CModTools::isOutsidePad() {
+	
+	if ((m_strSite.IsEndWith("FLB", true) || m_strSite.IsEndWith("SMM", true)) &&
+		m_strMachineType.IsEndWith("PAD", true))
+	{
+		Dbg("isOutsidePad Yes");
+		return true;
+	}
+	Dbg("isOutsidePad No");
+	return false;
+}
+
+TradeManageCodeEnum CModTools::CheckJobLimited()
+{
+	if (!isOutsidePad())
+	{
+		return TradeManageCodeEnum::Undefined;
+	}
+	CSmartPointer<IConfigInfo> spConfig;
+	ErrorCodeEnum BootTimeCfgError = m_pEntity->GetFunction()->OpenConfig(Config_Run, spConfig);
+	CSimpleStringA strLastRecordTime = "", strControl = "", strExpirationDate = "";
+	time_t now = time(0);
+	localtime(&now);
+	ErrorCodeEnum errorRead = Error_Succeed;
+	if (Error_Succeed != spConfig->ReadConfigValue("Record", "LastRecordTime", strLastRecordTime))
+	{
+		Dbg("Read Record LastRecordTime -> Failed! Maybe LastRecordTime not exist!");
+		strLastRecordTime = "";
+	}
+
+	if (Error_Succeed != spConfig->ReadConfigValue("Record", "Control", strControl))
+	{
+		Dbg("Read Record Control -> Failed! Maybe Control not exist!");
+		strControl = "";
+	}
+
+	if (Error_Succeed != spConfig->ReadConfigValue("Record", "ExpirationDate", strExpirationDate))
+	{
+		Dbg("Read Record ExpirationDate -> Failed! Maybe ExpirationDate not exist!");
+		strExpirationDate = "";
+	}
+	if (strControl.Compare("on") == 0)
+	{
+		// 控制标识为on时,检查过期时间,过期时间之前都设置为启用
+		if (strExpirationDate == "")
+		{
+			Dbg("CheckJobLimited -> on -> strExpirationDate=null ");
+			setLimitReason("");
+			return TradeManageCodeEnum::Trade;
+		}
+		int timestamp_expiration = StandardToStamp(strExpirationDate.Append(" 23:59:59"), false);
+
+		if (now < timestamp_expiration)
+		{
+			// 过期之前都可以进行交易
+			Dbg("CheckJobLimited -> on -> strExpirationDate>now ");
+			setLimitReason("");
+			return TradeManageCodeEnum::Trade;
+		}
+		else {
+			// 过期之后 设置为normal
+			spConfig->WriteConfigValue("Record", "Control", "normal");
+			strControl = "normal";
+			Dbg("CheckJobLimited -> on -> strExpirationDate<now -> control to normal");
+		}
+	}
+
+	if (strControl.Compare("off") == 0)
+	{
+		// 展示交易暂停页面
+		Dbg("CheckJobLimited -> off ");
+		setLimitReason("disabled");
+		return TradeManageCodeEnum::Disabled;
+	}
+
+	if (strControl.Compare("normal") == 0 || strControl.IsNullOrEmpty())
+	{
+		if (strLastRecordTime == "")
+		{
+			Dbg("CheckJobLimited -> normal -> strLastRecordTime=null ");
+			setLimitReason("");
+			return TradeManageCodeEnum::Trade;
+		}
+		int timestamp_lastRecordTime = StandardToStamp(strLastRecordTime, true);
+
+		if (now < timestamp_lastRecordTime + 3600 * 24 * 2)
+		{
+			Dbg("CheckJobLimited -> normal -> now < lastRecordTime + 3600*24*2 ");
+			setLimitReason("");
+			return TradeManageCodeEnum::Trade;
+		}
+		else if (CheckTradeRecord()) {
+			// 展示交易暂停页面
+			Dbg("CheckJobLimited -> normal -> now < CheckTradeRecord = true ");
+			setLimitReason("jobuncomplete");
+			return TradeManageCodeEnum::JobUncomplete;
+		}
+	}
+	// 理论上不会流转到这里来
+	setLimitReason("");
+	return TradeManageCodeEnum::Trade;
+}
+
+bool CModTools::CheckTradeRecord() {
+	std::list<int> timeList;
+
+	using namespace Upload;
+	UploadService_ClientBase* pClient = new UploadService_ClientBase(m_pEntity);
+	auto rc = pClient->Connect();
+	if (rc != Error_Succeed)
+	{
+		Dbg("connect to Upload entity fail: %d", rc);
+	}
+	else
+	{
+		UploadService_UploadDateList_Req req = {};
+		UploadService_UploadDateList_Ans ans = {};
+
+		rc = pClient->UploadDateList(req, ans, 10000);
+
+		if (rc != Error_Succeed)
+			Dbg("UploadDateList fail from Upload: %d", rc);
+		else
+		{
+			Dbg("UploadDateList succeed from Upload");
+			for (int i = 0; i < ans.uploadDateStr.GetCount(); ++i)
+			{
+				CSimpleStringA str = (CSimpleStringA)ans.uploadDateStr[i];
+				int t = StandardToStamp(ans.uploadDateStr[i], true);
+				timeList.push_back(t);
+			}
+		}
+
+		pClient->SafeDelete();
+		pClient = NULL;
+	}
+
+	// 比较时间戳 登记时间 <= 列表时间 < 今天 返回true
+	time_t now = time(0);
+	localtime(&now);
+	now -= now % (3600 * 24);
+	now -= 3600 * 8; //处理东八区问题
+	CSmartPointer<IConfigInfo> spConfig;
+	ErrorCodeEnum BootTimeCfgError = m_pEntity->GetFunction()->OpenConfig(Config_Run, spConfig);
+	CSimpleStringA strLastRecordTime = "";
+	ErrorCodeEnum errorRead = Error_Succeed;
+	errorRead = spConfig->ReadConfigValue("Record", "LastRecordTime", strLastRecordTime);
+	if (errorRead != Error_Succeed)
+	{
+		Dbg("Read Record LastRecordTime -> Failed! Maybe LastRecordTime not exist!");
+		strLastRecordTime = "";
+	}
+
+	int timestamp_lastRecordTime = now;
+	if (!strLastRecordTime.IsNullOrEmpty())
+	{
+		timestamp_lastRecordTime = StandardToStamp(strLastRecordTime, false);
+	}
+	for (std::list<int>::iterator it = timeList.begin(); it != timeList.end(); ++it)
+	{
+		if (timestamp_lastRecordTime <= *it && *it < now)
+		{
+			Dbg("CheckTradeRecord lastRecordTime=%d, time_list=%d, now=%d", timestamp_lastRecordTime, *it, now);
+			return true;
+		}
+	}
+	return false;
+}
+
+
+std::pair<ErrorCodeEnum, int> CModTools::openCef(std::string cmdline, bool isGuard)
+{
+	if (isGuard) {
+		//mod_chromium相当于cefclient的守护进程
+		boost::thread cefGuardian(boost::bind(&CModTools::cefClientGuardian, this, cmdline));
+		cefGuardian.detach();
+	}
+	else
+	{
+		auto systemStartChromium = [](std::string str) {
+			system(str.c_str());
+		};
+		boost::thread(systemStartChromium, cmdline).detach();
+	}
+
 	return std::make_pair(Error_Succeed, 0);
 }
 

+ 16 - 18
Module/mod_chromium/CModTools.h

@@ -5,6 +5,7 @@
 #include <tuple>
 #include <mutex>
 #include "guitask/enum.h"
+#include <memory>
 #include <boost/serialization/singleton.hpp>
 using boost::serialization::singleton;
 
@@ -16,23 +17,14 @@ using boost::serialization::singleton;
 
 namespace Chromium{
 
-	BETTER_ENUM(ERR_PAGE_REASON, int, 
-		CameraConfig,
-		CardStoreIsBusy,
-		MachineTypeError,
-		TerminalManagerKickOut,
-		TerminalManagerOff,
-		breakdown,
-		disabled,
-		jobuncomplete,
-		normal)
-	BETTER_ENUM(PAGE_TYPE, int,
-		CameraConfig,
-		TerminalManager,
-		errPage,
-		Ad,
-		slv,
-		init)
+	BETTER_ENUM(ERR_PAGE_REASON, int, CameraConfig,	CardStoreIsBusy, MachineTypeError, TerminalManagerKickOut,
+		TerminalManagerOff,	breakdown, disabled, jobuncomplete,	normal)
+
+	BETTER_ENUM(PAGE_TYPE, int,	CameraConfig, TerminalManager, errPage,	Ad,	slv, init, TradeManager)
+
+	BETTER_ENUM(TradeManageCodeEnum, int, Undefined, Trade,	JobUncomplete, Disabled)
+
+	BETTER_ENUM(TerminalManageCodeEnum, int, Off, On, KickOut)
 	
 class CModTools : public singleton<CModTools>
 {
@@ -53,11 +45,17 @@ private:
 	std::pair<bool, std::string> getErrUrl();
 	std::string generateCefclientCmd(bool isExtend, std::string mainUrl);
 	std::string generateAdCmd(std::string AdUrl);
-	std::pair<ErrorCodeEnum, int> openCef(std::string cmdline);
+	std::pair<ErrorCodeEnum, int> openCef(std::string cmdline, bool isGuard = false);
 	void cefClientGuardian(std::string cmdline);
 	void openAdPage();
 	std::pair<bool, std::string> GenerateErrPage(ERR_PAGE_REASON errType);
 	std::string GetSpShellBootTime();
+	bool isOutsidePad();
+	TradeManageCodeEnum CheckJobLimited();
+	int StandardToStamp(const char* str_time, bool dateOnly);
+	bool CheckTradeRecord();
+private:
+	CSimpleString m_strSite, m_strMachineType;
 
 };
 

+ 41 - 201
Module/mod_chromium/mod_chromium.cpp

@@ -172,17 +172,20 @@ namespace Chromium {
 
 		GetFunction()->RegistSysVarEvent("UIState", this);
 
+		GetFunction()->RegistSysVarEvent("EntryPermit", this);
+
 		generateBussinessLimitTimer();
 
+
 		// 按照单屏方式
 		pTransactionContext->SendAnswer(Error_Succeed);
 	}
 
 	void CChromiumEntity::OnSysVarEvent(const char* pszKey, const char* pszValue, const char* pszOldValue, const char* pszEntityName)
 	{
-		if ((_strnicmp(pszKey, "UIState", strlen("UIState")) == 0))
+		if ((strnicmp(pszKey, "UIState", strlen("UIState")) == 0))
 		{
-			if (_strnicmp(pszValue, "M", strlen("M")) == 0)
+			if (strnicmp(pszValue, "M", strlen("M")) == 0)
 			{
 				static bool firstEnter = true;
 				if (firstEnter)
@@ -191,8 +194,20 @@ namespace Chromium {
 					Dbg("first Enter main page");
 				}
 			}
-
-
+		}
+		else if (0 == CSimpleStringA("EntryPermit").Compare(pszKey, true))
+		{
+			if (0 == CSimpleStringA("A").Compare(pszValue, true) || 0 == CSimpleStringA("F").Compare(pszValue, true))
+			{
+				auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::breakdown);
+				Dbg("access failed, open page breakdown, %d", openRet.first);
+			}
+			else if (0 == CSimpleStringA("L").Compare(pszValue, true)) {
+				CSystemRunInfo sysruninfo;
+				GetFunction()->GetSystemRunInfo(sysruninfo);
+				if (!(sysruninfo.dwBootOption & SystemBootOptionEnum::BootOption_Test))
+					generateCefclientTimer();//非--test时,才会打开浏览器
+			}
 		}
 	}
 
@@ -224,6 +239,7 @@ namespace Chromium {
 			Dbg("end show Screen Camera config, close page cameraconfig");
 			CModTools::get_mutable_instance().killChromiumByName((+PAGE_TYPE::CameraConfig)._to_string());
 			break;
+			/*
 		case EVENT_ACCESSAUTH_SUCCEED:
 			Dbg("access auth success, open page mainurl");
 			{
@@ -240,6 +256,7 @@ namespace Chromium {
 			Dbg("access failed, open page breakdown, %d", openRet.first);
 		}
 			break;
+			*/
 		default:
 			break;
 		}
@@ -283,214 +300,37 @@ namespace Chromium {
 		}
 	}
 
-	// 输入为北京时间 输出为北京时间戳
-	int CChromiumEntity::StandardToStamp(const char* str_time, bool dateOnly)
-	{
-		Dbg("StandardToStamp str = %s", str_time);
-		struct tm stm;
-		int iY, iM, iD, iH, iMin, iS;
-
-		// 检查有效性
-		if ('-' != str_time[4] || '-' != str_time[7])
-		{
-			return 0;
-		}
-
-		memset(&stm, 0, sizeof(stm));
-		iY = atoi(str_time);
-		iM = atoi(str_time + 5);
-		iD = atoi(str_time + 8);
-		if (dateOnly)
-		{
-			iH = 0;
-			iMin = 0;
-			iS = 0;
-		}
-		else {
-			iH = atoi(str_time + 11);
-			iMin = atoi(str_time + 14);
-			iS = atoi(str_time + 17);
-		}
-
-		stm.tm_year = iY - 1900;
-		stm.tm_mon = iM - 1;
-		stm.tm_mday = iD;
-		stm.tm_hour = iH;
-		stm.tm_min = iMin;
-		stm.tm_sec = iS;
-
-		/*printf("%d-%0d-%0d %0d:%0d:%0d\n", iY, iM, iD, iH, iMin, iS);*/   //标准时间格式例如:2016:08:02 12:12:30
-		return (int)mktime(&stm);
-	}
-
-	TradeManageCodeEnum CChromiumEntity::CheckJobLimited() {
-		/*if (!isOutsidePad())
-		{
-			return Undefined;
-		}*/
-		CSmartPointer<IConfigInfo> spConfig;
-		ErrorCodeEnum BootTimeCfgError = GetFunction()->OpenConfig(Config_Run, spConfig);
-		CSimpleStringA strLastRecordTime = "", strControl = "", strExpirationDate = "";
-		time_t now = time(0);
-		localtime(&now);
-		ErrorCodeEnum errorRead = Error_Succeed;
-		errorRead = spConfig->ReadConfigValue("Record", "LastRecordTime", strLastRecordTime);
-		if (errorRead != Error_Succeed)
-		{
-			Dbg("Read Record LastRecordTime -> Failed! Maybe LastRecordTime not exist!");
-			strLastRecordTime = "";
-		}
-
-		errorRead = spConfig->ReadConfigValue("Record", "Control", strControl);
-		if (errorRead != Error_Succeed)
-		{
-			Dbg("Read Record Control -> Failed! Maybe Control not exist!");
-			strControl = "";
-		}
-
-		errorRead = spConfig->ReadConfigValue("Record", "ExpirationDate", strExpirationDate);
-		if (errorRead != Error_Succeed)
-		{
-			Dbg("Read Record ExpirationDate -> Failed! Maybe ExpirationDate not exist!");
-			strExpirationDate = "";
-		}
-		if (strControl.Compare("on") == 0)
-		{
-			// 控制标识为on时,检查过期时间,过期时间之前都设置为启用
-			if (strExpirationDate == "")
-			{
-				Dbg("CheckJobLimited -> on -> strExpirationDate=null ");
-				CModTools::get_mutable_instance().setLimitReason("");
-				return TradeManageCodeEnum::Trade;
-			}
-			int timestamp_expiration = StandardToStamp(strExpirationDate.Append(" 23:59:59"), false);
 
-			if (now < timestamp_expiration)
-			{
-				// 过期之前都可以进行交易
-				Dbg("CheckJobLimited -> on -> strExpirationDate>now ");
-				CModTools::get_mutable_instance().setLimitReason("");
-				return TradeManageCodeEnum::Trade;
-			}
-			else {
-				// 过期之后 设置为normal
-				Dbg("CheckJobLimited -> on -> strExpirationDate<now -> control to normal");
-				spConfig->WriteConfigValue("Record", "Control", "normal");
-				strControl = "normal";
-				Dbg("过期之后 设置为normal");
-			}
-		}
 
-		if (strControl.Compare("off") == 0)
-		{
-			// 展示交易暂停页面
-			Dbg("CheckJobLimited -> off ");
-			CModTools::get_mutable_instance().setLimitReason("disabled");
-			return TradeManageCodeEnum::Disabled;
-		}
-
-		if (strControl.Compare("normal") == 0 || strControl.IsNullOrEmpty())
-		{
-			if (strLastRecordTime == "")
-			{
-				Dbg("CheckJobLimited -> normal -> strLastRecordTime=null ");
-				CModTools::get_mutable_instance().setLimitReason("");
-				return TradeManageCodeEnum::Trade;
-			}
-			int timestamp_lastRecordTime = StandardToStamp(strLastRecordTime, true);
-
-			if (now < timestamp_lastRecordTime + 3600 * 24 * 2)
-			{
-				Dbg("CheckJobLimited -> normal -> now < lastRecordTime + 3600*24*2 ");
-				CModTools::get_mutable_instance().setLimitReason("");
-				return TradeManageCodeEnum::Trade;
-			}
-			else if (CheckTradeRecord()) {
-				// 展示交易暂停页面
-				Dbg("CheckJobLimited -> normal -> now < CheckTradeRecord = true ");
-				CModTools::get_mutable_instance().setLimitReason("jobuncomplete");
-				return TradeManageCodeEnum::JobUncomplete;
-			}
-		}
-		// 理论上不会流转到这里来
-		CModTools::get_mutable_instance().setLimitReason("");
-		return TradeManageCodeEnum::Trade;
-	}
+	void CChromiumEntity::OnBusinessLimitTimerListener(void* pData)
+	{
+		Dbg("定时任务检查业务禁用");
+		// 检查是否禁用业务,做交易限制的检查
+		TradeManageCodeEnum jobLimit = CModTools::get_mutable_instance().CheckJobLimited();
 
-	bool CChromiumEntity::CheckTradeRecord() {
-		std::list<int> timeList;
+		Dbg("ShowLimitScreen : TradeManageCodeEnum=%s", jobLimt._to_string());
 
-		using namespace Upload;
-		UploadService_ClientBase* pClient = new UploadService_ClientBase(this);
-		auto rc = pClient->Connect();
-		if (rc != Error_Succeed)
-		{
-			Dbg("connect to Upload entity fail: %d", rc);
-		}
-		else
-		{
-			UploadService_UploadDateList_Req req = {};
-			UploadService_UploadDateList_Ans ans = {};
-
-			rc = pClient->UploadDateList(req, ans, 10000);
 
-			if (rc != Error_Succeed)
-			{
-				Dbg("UploadDateList fail from Upload: %d", rc);
-			}
-			else
-			{
-				Dbg("UploadDateList succeed from Upload");
-				for (int i = 0; i < ans.uploadDateStr.GetCount(); ++i)
-				{
-					CSimpleStringA str = (CSimpleStringA)ans.uploadDateStr[i];
-					int t = StandardToStamp(ans.uploadDateStr[i], true);
-					timeList.push_back(t);
-				}
-			}
-
-			pClient->SafeDelete();
-			pClient = NULL;
-		}
-
-		// 比较时间戳 登记时间 <= 列表时间 < 今天 返回true
-		time_t now = time(0);
-		localtime(&now);
-		now -= now % (3600 * 24);
-		now -= 3600 * 8; //处理东八区问题
-		CSmartPointer<IEntityFunction> spFunction = GetFunction();
-		CSmartPointer<IConfigInfo> spConfig;
-		ErrorCodeEnum BootTimeCfgError = spFunction->OpenConfig(Config_Run, spConfig);
-		CSimpleStringA strLastRecordTime = "";
-		ErrorCodeEnum errorRead = Error_Succeed;
-		errorRead = spConfig->ReadConfigValue("Record", "LastRecordTime", strLastRecordTime);
-		if (errorRead != Error_Succeed)
+		switch (jobLimit) {
+		case TradeManageCodeEnum::Trade:
+			CModTools::get_mutable_instance().killChromiumByName((+PAGE_TYPE::TradeManager)._to_string());
+			break;
+		case TradeManageCodeEnum::Disabled:
 		{
-			Dbg("Read Record LastRecordTime -> Failed! Maybe LastRecordTime not exist!");
-			strLastRecordTime = "";
+			auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::disabled);
+			Dbg("TradeManageCodeEnum Disabled, open page %d", openRet.first);
 		}
-
-		int timestamp_lastRecordTime = now;
-		if (!strLastRecordTime.IsNullOrEmpty())
+			break;
+		case TradeManageCodeEnum::JobUncomplete:
 		{
-			timestamp_lastRecordTime = StandardToStamp(strLastRecordTime, false);
+			auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::jobuncomplete);
+			Dbg("TradeManageCodeEnum JobUncomplete, open page %d", openRet.first);
 		}
-		for (std::list<int>::iterator it = timeList.begin(); it != timeList.end(); ++it)
-		{
-			if (timestamp_lastRecordTime <= *it && *it < now)
-			{
-				Dbg("CheckTradeRecord lastRecordTime=%d, time_list=%d, now=%d", timestamp_lastRecordTime, *it, now);
-				return true;
-			}
+			break;
+		default:
+			break;
 		}
-		return false;
-	}
 
-	void CChromiumEntity::OnBusinessLimitTimerListener(void* pData)
-	{
-		Dbg("定时任务检查业务禁用");
-		// 检查是否禁用业务
-		//ShowLimitScreen();
 		GetFunction()->ResetTimer(BROWSER_TIMER_ID, BROWSER_TIMER_INTERVAL);
 	}
 

+ 0 - 13
Module/mod_chromium/mod_chromium.h

@@ -32,16 +32,6 @@
 
 #pragma once
 namespace Chromium {
-	BETTER_ENUM(TradeManageCodeEnum, int,
-		Undefined,
-		Trade,
-		JobUncomplete,
-		Disabled)
-
-	BETTER_ENUM(TerminalManageCodeEnum, int,
-		Off,
-		On,
-		KickOut)
 
 #define BROWSER_TIMER_ID 0xF001
 #define BROWSER_TIMER_INTERVAL 3600000
@@ -87,10 +77,7 @@ namespace Chromium {
 
 		void OnTerminalManage(const char* pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, HealthManager::TerminalManager& evt);//终端锁定罚出
 
-		TradeManageCodeEnum CheckJobLimited();
-		int StandardToStamp(const char* str_time, bool dateOnly);
 		void OnBusinessLimitTimerListener(void* pData);//每3600s检测业务禁用
-		bool CheckTradeRecord();
 
 
 		SP_BEGIN_MSG_DISPATCH_MAP(CChromiumEntity)

+ 4 - 3
addin/cfg/HealthManager.ini

@@ -10,11 +10,12 @@ CardReadAdapter=0
 CustMngrAuth=0
 ;please use --test to boot up the entity
 ;TestDeamon=0
-
+Chromium=0
 
 [SafeLoad.RVC.Stand2S]
 Initializer=2
 CenterSetting=2
+AccessAuthorization=2
 ;SystemCustomization=2
 SelfChecker=2
 ;HeartBeat=2
@@ -45,13 +46,13 @@ Download=0
 TokenKeeper=2
 UpgradeRun=2
 UpgradeManager=2
-AccessAuthorization=2
 PinPad=2
 HSPScanner=0
 ;BranchDevice=0
 ;MaintainWatcher=0
 RemoteController=0
 ResourceWatcher=0
+
 ;CameraConfigManage=0
 ;SalesAudioTrans=0
 
@@ -63,7 +64,7 @@ ScannerSet=0
 ContactlessCard=0
 ThermalPrint=0
 FingerPrint=0
-Chromium=0
+
 
 [IEBrowser.RVC.Stand2S]
 url=http://99.8.42.90/RVC.Web/default.aspx http://99.8.42.90/RVC.Web/default2.aspx