|
|
@@ -18,7 +18,7 @@
|
|
|
#include "path.h"
|
|
|
#include "guitask/guitask.h"
|
|
|
#include "EventCode.h"
|
|
|
-
|
|
|
+#include "../mod_upload/Upload_client_g.h"
|
|
|
|
|
|
|
|
|
#define COMPKEY_TERMINATE ((UINT_PTR) 0)
|
|
|
@@ -120,8 +120,6 @@ namespace Chromium {
|
|
|
void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
{
|
|
|
GetFunction()->GetSystemStaticInfo(m_sysInfo);
|
|
|
- //
|
|
|
- //MessageBox(0,0,0,0);
|
|
|
|
|
|
ErrorCodeEnum Error;
|
|
|
Error = GetFunction()->StartTcpBridgeServer(m_iTcpBridgePort);
|
|
|
@@ -141,7 +139,8 @@ namespace Chromium {
|
|
|
pTransactionContext->SendAnswer(Error);
|
|
|
return;
|
|
|
}
|
|
|
- CModTools::killAllChromium();
|
|
|
+ CModTools::get_mutable_instance().InitCModTools(this);
|
|
|
+ CModTools::get_mutable_instance().killAllChromium();
|
|
|
// load all struct define xml & start websocket server
|
|
|
CSimpleStringA strStructPath;
|
|
|
GetFunction()->GetPath("Base", strStructPath);
|
|
|
@@ -158,20 +157,45 @@ namespace Chromium {
|
|
|
DbgEx("open rpcTask failed");
|
|
|
}
|
|
|
|
|
|
+ /*低柜
|
|
|
//LOG_EVT_BEGIN_CAMERA_CONFIG, LOG_EVT_END_CAMERA_CONFIG
|
|
|
Error = GetFunction()->SubscribeLog(m_uidCameraListener, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "CameraConfigManage");
|
|
|
if (Error != Error_Succeed)
|
|
|
LOG_TRACE("subscribe Camera log failed!"); //非必须
|
|
|
-
|
|
|
- Error = GetFunction()->SubscribeLog(m_uuidAccessAuth, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "AccessAuthorization");
|
|
|
+ */
|
|
|
+ Error = GetFunction()->SubscribeLog(m_uuidAccessAuth, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "AccessAuthorization");
|
|
|
if (Error != Error_Succeed)
|
|
|
LOG_TRACE("subscribe AccessAuthorization log failed!");
|
|
|
+ else
|
|
|
+ LOG_TRACE("subscribe AccessAuthorization success!");
|
|
|
+ GetFunction()->SubscribeLog(m_uuidAccessAuth, this, Log_Error, Severity_None, Error_IgnoreAll, -1, "AccessAuthorization");
|
|
|
+
|
|
|
+ GetFunction()->RegistSysVarEvent("UIState", 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(pszValue, "M", strlen("M")) == 0)
|
|
|
+ {
|
|
|
+ static bool firstEnter = true;
|
|
|
+ if (firstEnter)
|
|
|
+ {
|
|
|
+ firstEnter = false;
|
|
|
+ Dbg("first Enter main page");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
void CChromiumEntity::OnPreClose(EntityCloseCauseEnum eCloseCause, CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
{
|
|
|
if (m_pTimerListener != NULL)
|
|
|
@@ -191,10 +215,14 @@ namespace Chromium {
|
|
|
switch (dwUserCode)
|
|
|
{
|
|
|
case LOG_EVT_BEGIN_CAMERA_CONFIG:
|
|
|
- Dbg("show Screen Camera config, open page cameraconfig");
|
|
|
+ {
|
|
|
+ auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::CameraConfig);
|
|
|
+ Dbg("show Screen Camera config, open page cameraconfig, %d", openRet.first);
|
|
|
+ }
|
|
|
break;
|
|
|
case LOG_EVT_END_CAMERA_CONFIG:
|
|
|
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");
|
|
|
@@ -205,9 +233,12 @@ namespace Chromium {
|
|
|
generateCefclientTimer();//非--test时,才会打开浏览器
|
|
|
}
|
|
|
break;
|
|
|
- case EVENT_ACCESSAUTH_FAILED:
|
|
|
- case EVENT_ACCESSAUTH_TIMEOUT:
|
|
|
- Dbg("access failed, open page breakdown");
|
|
|
+ case ERR_ACCESSAUTH_FAILED:
|
|
|
+ case ERR_ACCESSAUTH_TIMEOUT:
|
|
|
+ {
|
|
|
+ auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::breakdown);
|
|
|
+ Dbg("access failed, open page breakdown, %d", openRet.first);
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -221,21 +252,248 @@ namespace Chromium {
|
|
|
{
|
|
|
case 0:
|
|
|
GetFunction()->SetSysVar("TerminalManagerState", "L", true);
|
|
|
+ {
|
|
|
+ auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::TerminalManagerOff);
|
|
|
+ Dbg("TerminalManagerState L, open page TerminalManagerOff, %d", openRet.first);
|
|
|
+ }
|
|
|
break;
|
|
|
case 1:
|
|
|
GetFunction()->SetSysVar("TerminalManagerState", "N", true);
|
|
|
+ {
|
|
|
+ Dbg("TerminalManagerState N, try close TerminalManager");
|
|
|
+ CModTools::get_mutable_instance().killChromiumByName((+PAGE_TYPE::TerminalManager)._to_string());
|
|
|
+ }
|
|
|
break;
|
|
|
case 2:
|
|
|
GetFunction()->SetSysVar("TerminalManagerState", "K", true);
|
|
|
+ {
|
|
|
+ auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::TerminalManagerKickOut);
|
|
|
+ Dbg("TerminalManagerState K, open page TerminalManagerKickOut, %d", openRet.first);
|
|
|
+ }
|
|
|
break;
|
|
|
case 99:
|
|
|
GetFunction()->SetSysVar("TerminalManagerState", "N", true);
|
|
|
+ {
|
|
|
+ Dbg("TerminalManagerState N, try close TerminalManager");
|
|
|
+ CModTools::get_mutable_instance().killChromiumByName((+PAGE_TYPE::TerminalManager)._to_string());
|
|
|
+ }
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 输入为北京时间 输出为北京时间戳
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ bool CChromiumEntity::CheckTradeRecord() {
|
|
|
+ std::list<int> timeList;
|
|
|
+
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ void CChromiumEntity::OnBusinessLimitTimerListener(void* pData)
|
|
|
+ {
|
|
|
+ Dbg("定时任务检查业务禁用");
|
|
|
+ // 检查是否禁用业务
|
|
|
+ //ShowLimitScreen();
|
|
|
+ GetFunction()->ResetTimer(BROWSER_TIMER_ID, BROWSER_TIMER_INTERVAL);
|
|
|
+ }
|
|
|
+
|
|
|
void CChromiumEntity::CefClintNotify()
|
|
|
{
|
|
|
#if(defined _WIN32 || defined _WIN64)
|
|
|
@@ -364,11 +622,16 @@ namespace Chromium {
|
|
|
GetFunction()->SetTimer(CHROMIUM_TIMER_ID, m_pTimerListener, 3000); //间隔执行时间
|
|
|
}
|
|
|
|
|
|
+ void CChromiumEntity::generateBussinessLimitTimer() {
|
|
|
+ DbgEx("Start BusinessLimitTimer");
|
|
|
+ pBusinessLimitTimerListener = new TimerOutHelper<CChromiumEntity>(this, &CChromiumEntity::OnBusinessLimitTimerListener, NULL, false);
|
|
|
+ GetFunction()->SetTimer(BROWSER_TIMER_ID, pBusinessLimitTimerListener, 5000);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
void CChromiumEntity::OnTaskTimerListener(void* pData)
|
|
|
{
|
|
|
static int max_restartTime = 3;
|
|
|
- static CModTools modTools(this);
|
|
|
DbgEx("OnTaskTimerListener");
|
|
|
if (max_restartTime == 0)
|
|
|
{
|
|
|
@@ -380,9 +643,9 @@ namespace Chromium {
|
|
|
|
|
|
//基于Desk2S功能判断,当当前并未启动cefclient时,对cefclient.exe进行清理
|
|
|
if (0 == m_cefArr.size())
|
|
|
- DbgEx("kill chromium %s", modTools.killAllChromium() ? "success" : "fail");
|
|
|
+ DbgEx("kill chromium %s", CModTools::get_mutable_instance().killAllChromium() ? "success" : "fail");
|
|
|
|
|
|
- auto rc = modTools.StartChromiumBrowser();
|
|
|
+ auto rc = CModTools::get_mutable_instance().StartChromiumBrowser();
|
|
|
max_restartTime--;
|
|
|
DbgEx("TaskTimerListen, startChromiumBrowser, rc:%d, pid:%d", rc.first, rc.second);
|
|
|
if (0 == rc.first)
|