Quellcode durchsuchen

#IQRV #comment 同步部分GUiConsole

gifur vor 2 Jahren
Ursprung
Commit
df88cd0b4b

+ 1 - 0
Module/mod_guiconsole/CMakeLists.txt

@@ -41,6 +41,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${MODULE_BASE_DIR}/mod_cardissuer
 	${CONAN_INCLUDE_DIRS_JSONCPP}
 	${OTHER_LIB_BASE_DIR}/libRestfulFunc
+	${MODULE_BASE_DIR}
 )
 
 target_link_directories(${MODULE_NAME} PRIVATE

+ 57 - 35
Module/mod_guiconsole/MaterialMgrCnn.cpp

@@ -2,6 +2,8 @@
 #include "MaterialMgrCnn.h"
 #include "md5.h"
 #include "SpUtility.h"
+#include "EventCode.h"
+
 
 #if defined(RVC_OS_LINUX)
 
@@ -20,9 +22,6 @@ CMaterialMgrCnn::CMaterialMgrCnn(CEntityBase* pEntity)
 
 	CSmartPointer<IConfigInfo> pConfig;
 	auto rc = pEntity->GetFunction()->OpenConfig(Config_CenterSetting, pConfig);
-
-	assert(rc == Error_Succeed);
-
 	rc = pConfig->ReadConfigValue("Initializer", "SubBankNo", m_strCallRouteBranchNo);
 	if (0 != m_strCallRouteBranchNo.GetLength())
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_strCallRouteBranchNo:%s", m_strCallRouteBranchNo.GetData());
@@ -32,7 +31,7 @@ CMaterialMgrCnn::CMaterialMgrCnn(CEntityBase* pEntity)
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_materialUrl:%s", m_materialUrl.GetData());
 
 	rc = pConfig->ReadConfigValueInt("GUIConsole", "forceBranch", m_forceBranch);
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("forceBranch:%d", m_forceBranch);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("forceBranch:%d", m_forceBranch); 
 	/*对于旧版本
 	forceBranch为0,则只使用总行;forceBranch为1,则分行和总行都使用,以分行为准
 	基于有可能存在SyncMaterial数据异常问题
@@ -175,9 +174,11 @@ ErrorCodeEnum CMaterialMgrCnn::QueryMaterialInfo(const char* pszDeviceNo, unsign
 		subBranch = useSub = true;
 	}
 
-	if (totalBranch) {
+	if (totalBranch)
+	{
 		do {
-			if (m_materialUrl.GetLength() == 0) {
+			if (m_materialUrl.GetLength() == 0)
+			{
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("QueryMaterialInfo")("QueryMaterialInfo m_materialUrl is null");
 				break;
 			}
@@ -186,12 +187,15 @@ ErrorCodeEnum CMaterialMgrCnn::QueryMaterialInfo(const char* pszDeviceNo, unsign
 			req.DeviceNo = pszDeviceNo;
 			req.m_url = m_materialUrl.Append("/cardIssue/getCardIssueInfo");
 			req.m_headers.emplace(std::make_pair("Content-Type", "application/json"));
+			req.m_printDbg = true;
 			QueryMaterialInfoHTTPRet materialRet;
-			if (!m_pHttpFunc->Post(req, materialRet)) {//post failed
-				if (useSub == false) {
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("QueryMaterialInfo")("QueryMaterialInfo by totalBranch return false");
+			if (!m_pHttpFunc->Post(req, materialRet))
+			{//post failed
+				if (useSub == false)
+				{
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("QueryMaterialInfo")("QueryMaterialInfo by totalBranch return false, DeviceNo:%s", pszDeviceNo);
 					return Error_TimeOut;
-				}
+				}					
 				break;
 			}
 
@@ -199,14 +203,19 @@ ErrorCodeEnum CMaterialMgrCnn::QueryMaterialInfo(const char* pszDeviceNo, unsign
 			arrDeviceNo.Init(count + 1); arrMateriel.Init(count + 1); CardGroove.Init(count + 1); CardBoxNo.Init(count + 1); PsbCode.Init(count + 1); PsbName.Init(count + 1); CardInit.Init(count + 1);
 			CardRemains.Init(count + 1); CardIssued.Init(count + 1);	CardMixed.Init(count + 1); CardPercent.Init(count + 1); TerminalNo.Init(count + 1); Maintainer.Init(count + 1);
 			MaintainTime.Init(count + 1); UpdateTime.Init(count + 1);
-			for (int i = 0; i < count; i++) {
+			for (int i = 0; i < count; i++)
+			{
 				QueryMaterialInfoRetDate* curData = &(materialRet.retData[i]);
 				arrDeviceNo[i] = curData->DeviceNo;
 				arrMateriel[i] = curData->Materiel;
 				CardGroove[i] = curData->CardGroove;
 				CardBoxNo[i] = curData->CardBoxNo;
 				char tempStr[200] = "";
+#if defined(RVC_OS_LINUX)
 				memcpy(tempStr, curData->PsbCode, sizeof(curData->PsbCode));
+#else
+				strncpy_s(tempStr, curData->PsbCode, sizeof(curData->PsbCode));
+#endif //RVC_OS_LINUX
 				tempStr[4] = '\0';
 				PsbCode[i] = tempStr;
 				PsbName[i] = curData->PsbName;
@@ -220,11 +229,12 @@ ErrorCodeEnum CMaterialMgrCnn::QueryMaterialInfo(const char* pszDeviceNo, unsign
 				MaintainTime[i] = curData->MaintainTime;
 				UpdateTime[i] = curData->UpdateTime;
 			}
-			if (useSub == false) {
+			if (useSub == false)
+			{
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("QueryMaterialInfo")("QueryMaterialInfo by totalBranch return true");
 				return Error_Succeed;
 			}
-
+				
 		} while (false);
 	}
 
@@ -250,7 +260,7 @@ ErrorCodeEnum CMaterialMgrCnn::QueryMaterialInfo(const char* pszDeviceNo, unsign
 		}
 		else
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("conect to branch failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("连接物料服务失败");
 			return Error_NetBroken;
 		}
 	}
@@ -363,12 +373,17 @@ ErrorCodeEnum CMaterialMgrCnn::SyncMaterialCount(const char* pszDeviceNo, DWORD
 	LOG_FUNCTION();
 
 	bool totalBranch = false, subBranch = false, useSub = true;
-	if (m_forceBranch == 0) {
+	if (m_forceBranch == 0)
+	{
 		totalBranch = true;
 		subBranch = useSub = false;
-	} else if (m_forceBranch == 1) {
+	}
+	else if (m_forceBranch == 1)
+	{
 		totalBranch = subBranch = useSub = true;
-	} else if (m_forceBranch == 2) {
+	}
+	else if (m_forceBranch == 2)
+	{
 		totalBranch = false;
 		subBranch = useSub = true;
 	}
@@ -376,10 +391,12 @@ ErrorCodeEnum CMaterialMgrCnn::SyncMaterialCount(const char* pszDeviceNo, DWORD
 	CSystemStaticInfo info;
 	m_pEntity->GetFunction()->GetSystemStaticInfo(info);
 
-	if (totalBranch) {
+	if (totalBranch)
+	{
 		do {
-
-			if (m_materialUrl.GetLength() == 0) {
+			
+			if(m_materialUrl.GetLength() == 0)
+			{
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("SyncMaterialCount")("SyncMaterialCount m_materialUrl is null");
 				break;
 			}
@@ -392,11 +409,13 @@ ErrorCodeEnum CMaterialMgrCnn::SyncMaterialCount(const char* pszDeviceNo, DWORD
 			strncpy_s(req1.DeviceNo, sizeof(req1.DeviceNo), pszDeviceNo, _TRUNCATE);
 			strncpy_s(req1.Material, sizeof(req1.Material), "DebitCard", _TRUNCATE);
 			req1.CardBoxNum = dwCardBoxNum;
-			for (int i = 0; i <= dwCardBoxNum; i++) {
+			for (int i = 0; i <= dwCardBoxNum; i++)
+			{
 				SyncMaterialCountReq2 pReq2;
 				memset(&pReq2, 0, sizeof(SyncMaterialCountReq2));
 				pReq2.bMaintain = arrMaintainFlag[i];
-				if (arrMaintainFlag[i]) {
+				if (arrMaintainFlag[i])
+				{
 					strncpy_s(pReq2.Maintainer, sizeof(pReq2.Maintainer), arrMaintainer[i], _TRUNCATE);
 					pReq2.MaintainTime = arrMaintainTime[i];
 				}
@@ -414,6 +433,7 @@ ErrorCodeEnum CMaterialMgrCnn::SyncMaterialCount(const char* pszDeviceNo, DWORD
 			SyncMaterialCountHTTPRet materialRet;
 			bool ret = m_pHttpFunc->Post(req, materialRet);
             DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("SyncMaterialCount")("SyncMaterialCount by totalBranch %s", ret ? "succ" : "failed");
+			
             if (!useSub)	//不是一定要分行服务,以分行服务同步为准
             {
                 if (!ret)
@@ -439,9 +459,11 @@ ErrorCodeEnum CMaterialMgrCnn::SyncMaterialCount(const char* pszDeviceNo, DWORD
 			char buf[2048] = {};
 			assert(sizeof(SyncMaterialCountReq2) * (dwCardBoxNum + 1) < 2048);
 			SyncMaterialCountReq2* pReq2 = (SyncMaterialCountReq2*)buf;
-			for (int i = 0; i <= dwCardBoxNum; i++) {
+			for (int i = 0; i <= dwCardBoxNum; i++)
+			{
 				pReq2[i].bMaintain = arrMaintainFlag[i];
-				if (arrMaintainFlag[i]) {
+				if (arrMaintainFlag[i])
+				{
 					strncpy_s(pReq2[i].Maintainer, sizeof(pReq2[i].Maintainer), arrMaintainer[i], _TRUNCATE);
 					pReq2[i].MaintainTime = arrMaintainTime[i];
 				}
@@ -478,7 +500,7 @@ ErrorCodeEnum CMaterialMgrCnn::SyncMaterialCount(const char* pszDeviceNo, DWORD
 		}
 		else
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect to branch failed");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("连接物料服务失败");
 			return Error_NetBroken;
 		}
 	}
@@ -531,7 +553,7 @@ ErrorCodeEnum CMaterialMgrCnn::HandleModifyEnrollInfoRet(const CSmartPointer<IPa
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg)) {
 		rc = (ErrorCodeEnum)dwSysCode;
         const std::string errStr = SP::Utility::GBK2UTF8(strErrMsg);
-		LogError(Severity_Middle, rc, dwUserCode, 
+		LogWarn(Severity_Middle, rc, dwUserCode, 
 			CSimpleStringA::Format("modify terminal enroll info fail, %s", errStr.c_str()));
 		
 		return rc;
@@ -549,7 +571,7 @@ ErrorCodeEnum CMaterialMgrCnn::HandleAddTradeManageRet(const CSmartPointer<IPack
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg)) {
 		rc = (ErrorCodeEnum)dwSysCode;
         const std::string errStr = SP::Utility::GBK2UTF8(strErrMsg);
-		LogError(Severity_Middle, rc, dwUserCode,
+		LogWarn(Severity_Middle, rc, dwUserCode,
 			CSimpleStringA::Format("add terminal trade manage fail, %s", errStr.c_str()));
 
 		return rc;
@@ -568,7 +590,7 @@ ErrorCodeEnum CMaterialMgrCnn::HandleAddMaterialCounterRet(const CSmartPointer<I
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg)) {
 		rc = (ErrorCodeEnum)dwSysCode;
         const std::string errStr = SP::Utility::GBK2UTF8(strErrMsg);
-		LogError(Severity_Middle, rc, dwUserCode, 
+		LogWarn(Severity_Middle, rc, dwUserCode, 
 			CSimpleStringA::Format("add terminal material counter fail, %s", errStr.c_str()));
 		
 		return rc;
@@ -591,7 +613,7 @@ ErrorCodeEnum CMaterialMgrCnn::HandleQueryMaterialInfoRet(const CSmartPointer<IP
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg)) {
 		rc = (ErrorCodeEnum)dwSysCode;
         const std::string errStr = SP::Utility::GBK2UTF8(strErrMsg);
-		LogError(Severity_Middle, rc, dwUserCode, CSimpleStringA::Format("query material info fail, %s", errStr.c_str()));
+		LogWarn(Severity_Middle, rc, dwUserCode, CSimpleStringA::Format("query material info fail, %s", errStr.c_str()));
 
 		return rc;
 	}
@@ -669,7 +691,7 @@ ErrorCodeEnum CMaterialMgrCnn::HandleGetMaterialCounterRet(const CSmartPointer<I
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg)) {
 		rc = (ErrorCodeEnum)dwSysCode;
         const std::string errStr = SP::Utility::GBK2UTF8(strErrMsg);
-		LogError(Severity_Middle, rc, dwUserCode, CSimpleStringA::Format("get material counter fail, %s", errStr.c_str()));
+		LogWarn(Severity_Middle, rc, dwUserCode, CSimpleStringA::Format("get material counter fail, %s", errStr.c_str()));
 
 		return rc;
 	}
@@ -679,7 +701,7 @@ ErrorCodeEnum CMaterialMgrCnn::HandleGetMaterialCounterRet(const CSmartPointer<I
 	int nRetSize = sizeof(ret);
 	int nArrayNum = 0;
 	if (!pRecvPkg->GetStructData("GetMCA", (BYTE*)&ret, &nRetSize, &nArrayNum)) {
-		LogError(Severity_Middle, Error_Param, 0, "get struct {GetMCA} fail");
+		LogWarn(Severity_Middle, Error_Param, 0, "get struct {GetMCA} fail");
 		return Error_Param;
 	}
 
@@ -697,7 +719,7 @@ ErrorCodeEnum CMaterialMgrCnn::HandleResetMaterialCounterRet(const CSmartPointer
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg)) {
 		rc = (ErrorCodeEnum)dwSysCode;
         const std::string errStr = SP::Utility::GBK2UTF8(strErrMsg);
-		LogError(Severity_Middle, rc, dwUserCode, 
+		LogWarn(Severity_Middle, rc, dwUserCode, 
 			CSimpleStringA::Format("reset material counter fail, %s", errStr.c_str()));
 		
 		return rc;
@@ -716,7 +738,7 @@ ErrorCodeEnum CMaterialMgrCnn::HandleMaintainerLoginRet(const CSmartPointer<IPac
 	{
 		rc = (ErrorCodeEnum)dwSysCode;	
         const std::string errStr = SP::Utility::GBK2UTF8(strErrMsg);
-		LogError(Severity_Middle, rc, dwUserCode,  CSimpleStringA::Format("maintainer login fail, %s", errStr.c_str()));
+		LogWarn(Severity_Middle, rc, dwUserCode,  CSimpleStringA::Format("maintainer login fail, %s", errStr.c_str()));
 		
 		return rc;
 	}
@@ -734,7 +756,7 @@ ErrorCodeEnum CMaterialMgrCnn::HandleRegistSwallowedCardRet(const CSmartPointer<
 	{
 		std::string errStr = SP::Utility::GBK2UTF8(strErrMsg);
 		rc = (ErrorCodeEnum)dwSysCode;
-		LogError(Severity_Middle, rc, dwUserCode, CSimpleStringA::Format("regist swallowed card fail, %s", strErrMsg.c_str()));
+		LogWarn(Severity_Middle, rc, dwUserCode, CSimpleStringA::Format("regist swallowed card fail, %s", strErrMsg.c_str()));
 	}
 	else
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("regist swallowed card succeed");
@@ -751,7 +773,7 @@ ErrorCodeEnum CMaterialMgrCnn::HandleSyncMaterialCount(const CSmartPointer<IPack
 	if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, strErrMsg)) {
 		rc = (ErrorCodeEnum)dwSysCode;
         const std::string errStr = SP::Utility::GBK2UTF8(strErrMsg);
-		LogError(Severity_Middle, rc, dwUserCode, CSimpleStringA::Format("sync material count fail, %s", errStr.c_str()));
+		LogWarn(Severity_Middle, rc, dwUserCode, CSimpleStringA::Format("sync material count fail, %s", errStr.c_str()));
 	}
 	else
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("sync material count succeed");

+ 52 - 33
Module/mod_guiconsole/MaterialMgrCnn.h

@@ -4,9 +4,14 @@
 #pragma once
 #include "IHttpFunc.h"
 #include <vector>
+#if defined(_MSC_VER)
+#include "json.h"
+#else
 #include "json/json.h"
+#endif //_MSC_VER
 #include "SpSecureClient.h"
 #include "GUIConsole_def_g.h"
+#include <ctime>
 using namespace GUIConsole;
 
 #pragma pack(1)
@@ -374,39 +379,53 @@ struct SyncMaterialCountHTTPReq : CHTTPReq
     SyncMaterialCountReq1 reqInfo;
     std::vector<SyncMaterialCountReq2> reqData;
 
-
-    virtual string ToJson()
-    {
-        Json::Value root;
-        Json::Value arrayObj;
-        root["terminalNo"] = reqInfo.TerminalNo;
-        root["deviceNo"] = reqInfo.DeviceNo;
-        root["materiel"] = reqInfo.Material;
-        root["cardBoxNum"] = (int)reqInfo.CardBoxNum;
-        for (int i = 0; i <= reqInfo.CardBoxNum; i++) {
-            Json::Value item;
-            item["CardBoxNo"] = reqData[i].CardBoxNo;
-            item["PsbCode"] = reqData[i].PsbCode;
-            item["PsbName"] = reqData[i].PsbName;
-            item["CardInit"] = (int)reqData[i].CardInit;
-            item["CardRemains"] = (int)reqData[i].CardRemains;
-            item["CardIssued"] = (int)reqData[i].CardIssued;
-            item["CardMixed"] = (int)reqData[i].CardMixed;
-            item["CardPercent"] = (int)reqData[i].CardPercent;
-            item["Maintainer"] = reqData[i].Maintainer;
-            if (reqData[i].MaintainTime == 0)
-                item["MaintainTime"] = "";
-            else {
-                item["MaintainTime"] = CSmallDateTime::GetNow().ToTimeString().GetData();
-                //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("MaintainTime:%d", (DWORD)CSmallDateTime::GetNow());
-            }
-
-            item["bMaintain"] = reqData[i].bMaintain;
-            arrayObj.append(item);
-        }
-        root["cardIssueList"] = arrayObj;
-        return root.toStyledString();
-    }
+	SYSTEMTIME Time_tToSystemTime(__int64 t)
+	{
+		auto temptm = std::gmtime(&t);
+		SYSTEMTIME st = { 1900 + temptm->tm_year,  1 + temptm->tm_mon,  temptm->tm_wday,  temptm->tm_mday,  temptm->tm_hour + 8, temptm->tm_min,  temptm->tm_sec, 0 };
+		return st;
+	}
+
+	std::string formatTime(__int64 time)
+	{
+		char tBuf[1024] = "";
+		auto sysTime = Time_tToSystemTime(time);
+		sprintf(tBuf, "%04u-%02u-%02u %02u:%02u:%02u", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
+		return tBuf;
+	}
+
+	virtual string ToJson() {
+		Json::Value root;
+		Json::Value arrayObj;
+		root["terminalNo"] = reqInfo.TerminalNo;
+		root["deviceNo"] = reqInfo.DeviceNo;
+		root["materiel"] = reqInfo.Material;
+		root["cardBoxNum"] = (int)reqInfo.CardBoxNum;
+		for (int i = 0; i <= reqInfo.CardBoxNum; i++)
+		{
+			Json::Value item;
+			item["CardBoxNo"] = reqData[i].CardBoxNo;
+			item["PsbCode"] = reqData[i].PsbCode;
+			item["PsbName"] = reqData[i].PsbName;
+			item["CardInit"] = (int)reqData[i].CardInit;
+			item["CardRemains"] = (int)reqData[i].CardRemains;
+			item["CardIssued"] = (int)reqData[i].CardIssued;
+			item["CardMixed"] = (int)reqData[i].CardMixed;
+			item["CardPercent"] = (int)reqData[i].CardPercent;
+			item["Maintainer"] = reqData[i].Maintainer;
+			if (reqData[i].MaintainTime == 0)
+				item["MaintainTime"] = "";
+			else {
+				item["MaintainTime"] = CSmallDateTime::GetNow().ToTimeString().GetData();
+				//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("MaintainTime:%d", (DWORD)CSmallDateTime::GetNow());
+			}
+				
+			item["bMaintain"] = reqData[i].bMaintain;
+			arrayObj.append(item);
+		}
+		root["cardIssueList"] = arrayObj;
+		return root.toStyledString();
+	}
 };
 
 struct SyncMaterialCountHTTPRet : CHTTPRet

+ 266 - 59
Module/mod_guiconsole/guitask.cpp

@@ -3,16 +3,21 @@
 #include "guitask.h"
 #include "mainfrm.h"
 #include "SpIni.h"
+#include "path.h"
 
 #include "AccessAuthorization_client_g.h"
 using namespace AccessAuthorization;
-#include "Initializer_client_g.h"
-using namespace Initializer;
 
-GUITask::GUITask() : m_pEntity(NULL), m_hWndMainFrame(NULL), m_hThread(NULL)
+#include "mod_CenterSetting/Event.h"
+
+int level = 2;
+
+GUITask::GUITask() : m_pEntity(NULL), m_hWndMainFrame(NULL), m_hThread(NULL), m_hThread2(NULL), m_hWndStartPage(NULL),
+	m_idleNum(0), m_totalNum(0)
 {
 	m_hEventStartReady = ::CreateEventA(NULL, TRUE, FALSE, NULL);
 	m_hEventStopReady = ::CreateEventA(NULL, TRUE, FALSE, NULL);
+	m_hWndStartPage =NULL;
 }
 
 GUITask::~GUITask()
@@ -23,21 +28,42 @@ GUITask::~GUITask()
 
 ErrorCodeEnum GUITask::Kickoff(CEntityBase *pEntity)
 {
+	LOG_FUNCTION();
+	
 #if defined(RVC_OS_WIN)
 
-    if (m_hThread) {
-        return Error_Duplication;
-    }
+	if (m_hThread) {
+		return Error_Duplication;
+	}
+	
+	m_pEntity = pEntity;
+	m_pEntity->GetFunction()->RegistSysVarEvent("UIState", this);
 
-    m_pEntity = pEntity;
+	CSmartPointer<IEntityFunction> pFunc = m_pEntity->GetFunction();
+	CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
+	ErrorCodeEnum errCode = pFuncPrivilege->RegistEntityStateEvent(NULL,this);
+	if (errCode != Error_Succeed)
+	{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("RegistEntityState failed(%d).",errCode);
+		return Error_Unexpect;
+	}
 
-    m_hThread = (HANDLE)_beginthreadex(0, 0, &__Process, this, 0, 0);
-    if (!m_hThread) {
-        return Error_Resource;
-    }
+	m_totalNum = GetWillWorkEntityCountFromHealthmanager();
+	if (m_totalNum == 0) {
+		CAutoArray<EntityEntry> Entities;
+		ErrorCodeEnum err = GetAllEntity(Entities);
+		m_totalNum = Entities.GetCount();
+	}
+
+	m_hThread = (HANDLE)_beginthreadex(0, 0, &__Process, this, 0, 0);
+	if (!m_hThread) {
+		return Error_Resource;
+	}
+
+	WaitForSingleObject(m_hEventStartReady, INFINITE);
+	//SubscribeLog();
+	return RegistEntityStateEvent();
 
-    WaitForSingleObject(m_hEventStartReady, INFINITE);
-    return RegistEntityStateEvent();
 
 #else
 
@@ -53,7 +79,7 @@ ErrorCodeEnum GUITask::Close()
 
     if (!m_hThread) {
         return Error_NotInit;
-}
+	}
 
     UnSubscribeLog();
     UnregistEntityStateEvent();
@@ -86,39 +112,68 @@ void GUITask::Process()
     ResetEvent(m_hEventStartReady);
     m_pEntity->GetFunction()->InitLogCurrentThread();
 
-    HRESULT hRes = ::CoInitialize(NULL);
-    // If you are running on NT 4.0 or higher you can use the following call instead to 
-    // make the EXE free threaded. This means that calls come in on a random RPC thread.
-    //	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
-    ATLASSERT(SUCCEEDED(hRes));
+	HRESULT hRes = ::CoInitialize(NULL);
+	// If you are running on NT 4.0 or higher you can use the following call instead to 
+	// make the EXE free threaded. This means that calls come in on a random RPC thread.
+	//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
+	ATLASSERT(SUCCEEDED(hRes));
 
-    // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
-    ::DefWindowProc(NULL, 0, 0, 0L);
+	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
+	::DefWindowProc(NULL, 0, 0, 0L);
 
-    AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES);	// add flags to support other controls	
-    hRes = _Module.Init(NULL, ModuleBase::GetModuleBase()->GetInstance());
-    ATLASSERT(SUCCEEDED(hRes));
+	AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES);	// add flags to support other controls	
+	hRes = _Module.Init(NULL, ModuleBase::GetModuleBase()->GetInstance());
+	ATLASSERT(SUCCEEDED(hRes));
 
-    ATL::AtlAxWinInit();
+	ATL::AtlAxWinInit();
 
-    CMessageLoop theLoop;
-    _Module.AddMessageLoop(&theLoop);
+	CMessageLoop theLoop;
+	_Module.AddMessageLoop(&theLoop);
 
-    CMainFrame wndMain(this);
-    if (wndMain.CreateEx() == NULL) {
-        ATLTRACE(_T("Main window creation failed!\n"));
-        return;
-    }
+	CMainFrame wndMain(this);	
+	if(wndMain.CreateEx() == NULL)
+	{
+		ATLTRACE(_T("Main window creation failed!\n"));
+		return;
+	}
 
-    m_hWndMainFrame = wndMain.m_hWnd;
-    SetEvent(m_hEventStartReady);
+	m_hWndMainFrame = wndMain.m_hWnd;
+
+	CSmartPointer<IConfigInfo> pConfig;
+	auto rc = m_pEntity->GetFunction()->OpenConfig(Config_CenterSetting, pConfig);
+	CSimpleStringA csimpleStrMachineTypeCfg(true);
+	StartPageDlg dlg(this);
+	if (IS_SUCCEED(rc)) {
+		rc = pConfig->ReadConfigValue("NonExclusive", "NewStartPage", csimpleStrMachineTypeCfg);
+		CSystemStaticInfo staticInfo;
+		m_pEntity->GetFunction()->GetSystemStaticInfo(staticInfo);
+		if (csimpleStrMachineTypeCfg.IndexOf(staticInfo.strMachineType) >= 0) {
+			TerminalBaseInfo info;
+			info.strMachineType = staticInfo.strMachineType;
+			info.strTerminalNo = staticInfo.strTerminalID;
+			info.strSoftwareVersion = staticInfo.InstallVersion.ToString();
+			dlg.SetTerminalBasicInfo(info);
+
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Enter newpage...");
+			if (dlg.Create(NULL) == NULL) {
+				ATLTRACE(_T("Main window creation failed!\n"));
+				return;
+			}
+			m_hWndStartPage = dlg.m_hWnd;
+		}
+	}
+	SetEvent(m_hEventStartReady);
+	wndMain.ShowWindow(SW_MINIMIZE);
+	if(m_hWndStartPage)
+		dlg.ShowWindow(SW_SHOW);
+	else
+		ShowOutputConsole();
 
-    wndMain.ShowWindow(SW_SHOW);
-    int nRet = theLoop.Run();
+	int nRet = theLoop.Run();
 
-    _Module.RemoveMessageLoop();
-    _Module.Term();
-    ::CoUninitialize();
+	_Module.RemoveMessageLoop();
+	_Module.Term();
+	::CoUninitialize();
 
 
     SetEvent(m_hEventStopReady);
@@ -155,6 +210,16 @@ ErrorCodeEnum GUITask::ReqFrameworkQuit(bool bRebootOS)
 	CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
 	if (pFuncPrivilege != NULL) 
 	{
+		CSmartPointer<IConfigInfo> pConfig;
+		auto rc = m_pEntity->GetFunction()->OpenConfig(Config_CenterSetting, pConfig);
+		int iNoRestart;
+		CSimpleStringA csimpleStrMachineTypeCfg;
+		rc = pConfig->ReadConfigValue("NonExclusive", "NonGuardian", csimpleStrMachineTypeCfg);
+		CSystemStaticInfo staticInfo;
+		m_pEntity->GetFunction()->GetSystemStaticInfo(staticInfo);	
+
+		if(csimpleStrMachineTypeCfg.IndexOf(staticInfo.strMachineType)>=0)
+			return pFuncPrivilege->Reboot(RebootTrigger_ManualLocal, bRebootOS ? RebootWay_OS : RebootWay_Power );
 		return pFuncPrivilege->Reboot(RebootTrigger_ManualLocal, bRebootOS ? RebootWay_OS : RebootWay_Framework );
 	}
 
@@ -209,7 +274,7 @@ ErrorCodeEnum GUITask::BeginAccessAuth()
 	}
 	else
 	{
-		LogError(Severity_Low, rc, 0, "connect to entity [AccessAuthorization] fail");
+		LogWarn(Severity_Low, rc, 0, "connect to entity [AccessAuthorization] fail");
 		pClient->SafeDelete();
 	}
 	
@@ -218,23 +283,7 @@ ErrorCodeEnum GUITask::BeginAccessAuth()
 
 ErrorCodeEnum GUITask::BeginInitialize()
 {
-	/*InitializerService_ClientBase *pClient = new InitializerService_ClientBase(m_pEntity);
-	auto rc = pClient->Connect();
-	if (rc == Error_Succeed)
-	{
-		InitializerService_Initialize_Info info = {};
-		rc = pClient->Initialize(info);
-		pClient->GetFunction()->CloseSession();
-	}
-	else
-	{
-		LogError(Severity_Low, rc, 0, "connect to entity [Initializer] fail");
-		pClient->SafeDelete();
-	}
-	
-	return rc;*/
-
-	return Error_Succeed;
+	return Error_NotImpl;
 }
 
 #include "mod_GuiConsole.h"
@@ -368,6 +417,61 @@ ErrorCodeEnum GUITask::AsyncTerminateEntity(const char *entity_name, void *pData
 	}
 }
 
+UINT CalcKeyCountUnderSection(const char* pszFile, const char* pszSection)
+{
+    UINT result(0);
+#if defined(_MSC_VER)
+	DWORD dwInitialCapacity = 16;
+	DWORD dwSize;
+	char* p = NULL;
+	const int tries = 70;
+	ErrorCodeEnum Error = Error_Succeed;
+	int i;
+	for (i = 0; i < tries; ++i) {
+		p = (char*)realloc(p, dwInitialCapacity);
+		dwSize = ::GetPrivateProfileStringA(pszSection, NULL, NULL, p, dwInitialCapacity, pszFile);
+		if (dwSize == dwInitialCapacity - 2) { // buffer is too small
+			dwInitialCapacity = dwInitialCapacity * 2;
+		} else {
+			break;
+		}
+	}
+	if (i < tries) {
+		int cnt = 0;
+		char* t = p;
+		size_t n;
+		while ((n = strlen(t)) > 0) {
+			cnt++;
+			t += n + 1;
+		}
+		result = cnt;
+	}
+
+	free(p);
+#endif //_MSC_VER
+
+	return result;
+}
+
+UINT GUITask::GetWillWorkEntityCountFromHealthmanager()
+{
+	UINT count(0);
+	CSystemStaticInfo sysInfo;
+	CSimpleStringA cfgPath = "", strCoreBoot("CoreBoot"), strSafeLoad("SafeLoad"), strOp("Operating");
+	m_pEntity->GetFunction()->GetPath("cfg", cfgPath);
+	m_pEntity->GetFunction()->GetSystemStaticInfo(sysInfo);
+	strCoreBoot = strCoreBoot + "." + sysInfo.strMachineType;
+	strSafeLoad = strSafeLoad + "." + sysInfo.strMachineType;
+	strOp = strOp + "." + sysInfo.strMachineType;
+	cfgPath = cfgPath + "\\HealthManager.ini";
+
+	count += CalcKeyCountUnderSection(cfgPath, strCoreBoot);
+	count += CalcKeyCountUnderSection(cfgPath, strSafeLoad);
+	count += CalcKeyCountUnderSection(cfgPath, strOp);
+
+	return count;
+}
+
 ErrorCodeEnum GUITask::GetAllEntity(CAutoArray<EntityEntry> &Entities)
 {
 	CSmartPointer<IEntityFunction> spFunc = m_pEntity->GetFunction();
@@ -468,6 +572,31 @@ void GUITask::OnEntityStateHook(const char *pszEntityName,const char *pszTrigger
 
         PostMessage(m_hWndMainFrame, WM_GUICONSOLE, dwProcessID, (LPARAM)entry);
     }
+	
+	
+	SYSTEMTIME st;
+	GetLocalTime(&st);
+
+	CSimpleStringA msg;
+	if(eState == EntityState_Starting)
+		msg = CSimpleString::Format("[%04d-%02d-%02d %02d:%02d:%02d] 正在启动实体%s...", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, pszEntityName);
+	if(eState == EntityState_Idle)
+	{
+		msg = CSimpleString::Format("[%04d-%02d-%02d %02d:%02d:%02d] %s实体启动成功", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, pszEntityName);
+		
+		m_idleNum++;
+	}
+
+	if(eLastState == EntityState_Idle && eState != EntityState_Idle )
+	{
+		msg = CSimpleString::Format("[%04d-%02d-%02d %02d:%02d:%02d] %s实体异常,重新启动...", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, pszEntityName);
+
+		m_idleNum--;
+	}
+
+	PostMessage(m_hWndStartPage, WM_NUMCHANGE, 0, 0);
+	PostMessage(m_hWndStartPage, WM_SHOW_MSG,  (WPARAM)strdup(msg), (LPARAM)RGB(171, 171, 171));
+	
 #endif //_MSC_VER
 }
 
@@ -477,7 +606,45 @@ void GUITask::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const Lo
 {
 	// 忽略GPIO事件
 	if (dwUserCode == 0x2090000A || dwUserCode == 0x20900009)
-			return;
+		return;
+	else if (dwUserCode == EVENT_MOD_CENTERSETTING_UPDATE_CENTER)
+	{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("检测到集中配置更新了");
+		auto generateCenterSettingPath = []() ->std::string {
+			char pathbuf[1024] = "";
+			int  pathlen = ::GetModuleFileNameA(NULL, pathbuf, 1024);//获得GuiConsole路径
+
+			// 替换掉单杠
+			int times = 0;
+			while (pathlen > 0)
+			{
+				if (pathbuf[pathlen--] == SPLIT_SLASH)
+					times++;
+				if (2 == times)
+					break;
+			}
+			pathbuf[++pathlen] = '\0';
+			std::string dstPath = pathbuf;
+#if defined(_MSC_VER)
+            dstPath.append("\\cfg\\CenterSetting.ini");
+#else
+            dstPath.append("/cfg/CenterSetting.LAN.ini");
+#endif //_MSC_VER
+			return dstPath;
+		};
+		//实时更新实体打印的日志等级,这个功能在信创下需要调整,实现方式不一样 gifur@20230816
+
+		auto centersettingPath = generateCenterSettingPath();
+		load_debugLevelInCentersetting(centersettingPath.c_str());
+
+		//此时实体的idx已经存在,更新一下实体的logDebugLevel
+		CAutoArray<CSimpleStringA> strEntityNames;
+		CAutoArray<WORD> wEntityDevelopID;
+		GetAllEntityIdx(strEntityNames, wEntityDevelopID);
+		update_debugLevel(strEntityNames, wEntityDevelopID);
+
+	}
+		
 
 	if (pszMessage!=NULL && strlen(pszMessage)>2)
 	{
@@ -486,13 +653,28 @@ void GUITask::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const Lo
 			str[str.GetLength()-2] = 0;
 						
 		if (eLogType == Log_Error)
+		{
 			str = CSimpleStringA::Format("[%s] Error:{%s}(sc:0x%X, uc:0x%X)\r\n", pszEntityName, (const char*)str, dwSysError, dwUserCode);
+#if defined(_MSC_VER)
+            PostMessage(m_hWndStartPage, WM_SHOW_MSG, (WPARAM)strdup(str), (LPARAM)RGB(255, 132, 32));
+#endif //_MSC_VER
+		}
 		else if(eLogType == Log_Warning)
+		{
 			str = CSimpleStringA::Format("[%s] Warn:{%s}(sc:0x%X, uc:0x%X)\r\n", pszEntityName, (const char*)str, dwSysError, dwUserCode);
+			if(eLevel == Severity_High)
+			{
+#if defined(_MSC_VER)
+                PostMessage(m_hWndStartPage, WM_SHOW_MSG, (WPARAM)strdup(str), (LPARAM)RGB(255, 132, 32));
+#endif //_MSC_VER
+			}
+		}
 		else if(eLogType == Log_Event)
 			str = CSimpleStringA::Format("[%s] Event:{%s}(uc:0x%X)\r\n", pszEntityName, (const char*)str, dwUserCode);
 		else if (eLogType == Log_Debug)
 			str = CSimpleStringA::Format("[%s] Debug:{%s}\r\n", pszEntityName, (const char*)str);
+		else
+			return;
 
 		OutputMsg(str);
 	}
@@ -523,7 +705,7 @@ ErrorCodeEnum GUITask::SetWindowPosition(bool bTop)
         if (bTop) {
             ShowWindow(m_hWndMainFrame, SW_NORMAL);
             SetWindowPos(m_hWndMainFrame, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
-            SetWindowPos(m_hWndMainFrame, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+            SetWindowPos(m_hWndMainFrame, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
         } else {
             SetWindowPos(m_hWndMainFrame, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
             SetWindowPos(m_hWndMainFrame, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
@@ -615,3 +797,28 @@ ErrorCodeEnum GUITask::CloseOutputConsole()
 	return pFunc->CloseOuputConsole();
 }
 
+void GUITask::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)
+		{
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("close start page");
+#if defined(_MSC_VER)
+            if (m_hWndStartPage) {
+                PostMessageA(m_hWndStartPage, WM_CLOSE, -1, -1);
+            }
+#endif //_MSC_VER
+			m_pEntity->GetFunction()->UnregistSysVarEvent("UIState");
+		}
+	}
+}
+
+ErrorCodeEnum GUITask::HideGuiConsole()
+{
+#if defined(_MSC_VER)
+    ShowWindow(m_hWndMainFrame, SW_HIDE);
+#endif //_MSC_VER
+	return Error_Succeed;
+}

+ 20 - 6
Module/mod_guiconsole/guitask.h

@@ -6,10 +6,6 @@
 #include "SpBase.h"
 #include "SpFSM.h"
 
-#if defined(RVC_OS_LINUX)
-#include <pthread.h>
-#endif //RVC_OS_LINUX
-
 struct EntityEntry
 {
 	CSimpleStringA Name;
@@ -58,7 +54,7 @@ struct StartMenuEntry
 	CSimpleStringA strCmdLine;
 };
 
-class GUITask : public ICallbackListener, public IEntityStateListener, public ILogListener
+class GUITask : public ICallbackListener, public IEntityStateListener, public ILogListener, public ISysVarListener
 {
 public:
 	GUITask();
@@ -66,6 +62,7 @@ public:
 
 	ErrorCodeEnum Kickoff(CEntityBase *pEntity);
 	ErrorCodeEnum Close();
+	ErrorCodeEnum EnterHighLevelMode();
 	ErrorCodeEnum AsyncStartEntity(const char *entity_name, const char *cmdline, void *pData);
 	ErrorCodeEnum AsyncStopEntity(const char *entity_name, void *pData);
 	ErrorCodeEnum AsyncPauseEntity(const char *entity_name, void *pData);
@@ -98,6 +95,8 @@ public:
 	ErrorCodeEnum ShowOutputConsole();
 	ErrorCodeEnum CloseOutputConsole();
 
+	ErrorCodeEnum HideGuiConsole();
+
 	// IEntityStateListener
 	virtual void OnEntityStateHook(const char *pszEntityName,const char *pszTriggerEntity,EntityStateEnum eState,EntityStateEnum eLastState);
 	virtual void OnCeateConnection(const char *pszCallerEntity,const char *pszServiceEntity) {}
@@ -112,7 +111,12 @@ public:
 	// ILogListener
 	virtual void OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
 		const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID, 
-		const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext& pLinkInfo);
+		const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext &pLinkInfo);
+
+	virtual void OnSysVarEvent(const char *pszKey,
+		const char *pszValue, const char *pszOldValue, const char *pszEntityName);
+
+	void GetIdleEntityNum(int &idleNum, int &totalNum){idleNum = m_idleNum; totalNum = m_totalNum;}
 
 private:
 	ErrorCodeEnum OutputMsg(const char *pMsg);
@@ -133,15 +137,25 @@ private:
 		return 0;
 	}
 
+	UINT GetWillWorkEntityCountFromHealthmanager();
+
 private:
 	HANDLE m_hEventStartReady;
 	HANDLE m_hEventStopReady;
 	HANDLE m_hThread;
+	HANDLE m_hThread2;
+
 	HWND m_hWndMainFrame;
+	HWND m_hWndStartPage;
 	CEntityBase *m_pEntity;
 
 	CUUID m_logSubID;
 	bool m_bHighLevel;
+
+	int m_newStartPage;
+
+	int m_idleNum;
+	int m_totalNum;
 };
 
 #endif // __GUI_TASK_H

+ 1 - 1
Module/mod_guiconsole/import_libSysInit.h

@@ -107,7 +107,7 @@ typedef BOOL(*RVCINIT_ENDINIT)();
 #define RVCINITENDINIT "RVCInit_endInit"
 extern RVCINIT_ENDINIT RVCInit_endInit;
 
-typedef BOOL(*RVCINIT_INITRESTORE)();
+typedef BOOL(*RVCINIT_INITRESTORE)(bool);
 #define RVCINITINITRESTORE "RVCInit_InitRestore"
 extern RVCINIT_INITRESTORE RVCInit_InitRestore;
 

+ 334 - 76
Module/mod_guiconsole/mainfrm.cpp

@@ -4,8 +4,9 @@
 #include "fileutil.h"
 #include "array.h"
 #include "iniutil.h"
-#include "EventCode.h"
+#include "GUIConsole_UserCode.h"
 #include "import_libSysInit.h"
+#include "EventCode.h"
 
 #include "AccessAuthorization_client_g.h"
 using namespace AccessAuthorization;
@@ -46,9 +47,6 @@ void CAboutDlg::OnOK(UINT uNotifyCode, int nID, CWindow wndCtl)
 	GetDlgItem(IDC_EDIT2).SetWindowTextA(dtSysTime.ToTimeString());	
 }
 
-#include "MaintainWatcher_client_g.h"
-using namespace MaintainWatcher;
-
 void CAboutDlg::OnOK2(UINT uNotifyCode, int nID, CWindow wndCtl)
 {
 	GetDlgItem(IDC_EDIT3).SetWindowTextA("");
@@ -78,59 +76,6 @@ void CAboutDlg::OnOK2(UINT uNotifyCode, int nID, CWindow wndCtl)
 		(const char*)info.tmStart.ToTimeString(), (const char*)info.tmReboot.ToTimeString(), (const char*)info.InstallVersion.ToString(),
 		info.eTriggerReason, info.wSameReasonTime, info.eWay, info.wSameWayTime);
 	GetDlgItem(IDC_EDIT3).SetWindowTextA(str);
-
-	//auto pEntity = m_pGUITask->GetEntity();
-	MaintainCertificate_ClientBase *pClient = new MaintainCertificate_ClientBase(pEntity);
-	auto rc = pClient->Connect();
-	if (rc != Error_Succeed)
-	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect to MaintainWatcher entity fail: %d", rc);
-	}
-	else
-	{
-		MaintainCertificate_GetUserInfo_Req req = {};
-		MaintainCertificate_GetUserInfo_Ans ans = {};
-		rc = pClient->GetUserInfo(req, ans, 10000);
-		if (rc != Error_Succeed)
-		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get userinfo fail from MaintainWatcher: %d", rc);
-			pClient->SafeDelete();
-		}
-		else
-		{
-			// UserID=SP00000004;UserName=RVC0001;AuthorierID=SP00000001;AuthorizeTime=2014/8/13 18:46:29;RecommenderSAP=80274390;RecommenderOfficeID=274390;
-			CSimpleStringA &str = ans.UserInfo;
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get maintainer info: %s", (const char*)str);
-
-			CSimpleStringA m_strUserID, m_strUserName, m_strAuthorizer, m_strAuthTime;
-			auto arr = str.Split(';');
-			for (int i = 0; i < arr.GetCount(); i++)
-			{
-				auto arr2 = arr[i].Split('=');
-				if (arr2.GetCount() != 2)
-					continue;
-
-				if (arr2[0] == "UserID")
-					m_strUserID = arr2[1];
-				else if (arr2[0] == "UserName")
-					m_strUserName = arr2[1];
-				else if (arr2[0] == "AuthorierID")
-					m_strAuthorizer = arr2[1];
-				else if (arr2[0] == "AuthorizeTime")
-					m_strAuthTime = arr2[1];
-			}
-
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("UserID=%s;UserName=%s;Authorizer=%s;AuthTime=%s",
-				(const char*)m_strUserID,
-				(const char*)m_strUserName,
-				(const char*)m_strAuthorizer,
-				(const char*)m_strAuthTime);
-
-			pClient->GetFunction()->CloseSession();
-		}
-		
-		pClient = NULL;
-	}
 }
 
 void CAboutDlg::OnOK3(UINT uNotifyCode, int nID, CWindow wndCtl)
@@ -1332,10 +1277,21 @@ void CSysInitView::CleanListView()
 
 void CSysInitView::CheckSystemInit()
 {
+	auto pFunc = m_pGUITask->GetEntity()->GetFunction();
+	CSmartPointer<IConfigInfo> spConfig;
+	auto rc = pFunc->OpenConfig(Config_CenterSetting, spConfig);
+	if (rc != Error_Succeed)
+		return;
+
 	int checkSysInit = 0; 
-	if (1 == checkSysInit) {
-        CloseHandle((HANDLE)_beginthreadex(NULL, 0, (unsigned int(__stdcall*)(void*))SysInitCheck, this, 0, NULL));
-	}
+	rc = spConfig->ReadConfigValueInt(m_pGUITask->GetEntity()->GetEntityName(), "CheckSysInit", checkSysInit);
+	if (rc != Error_Succeed)
+		return;
+
+	CSystemStaticInfo stStaticinfo;
+	pFunc->GetSystemStaticInfo(stStaticinfo);
+	if (1 == checkSysInit)
+		CloseHandle((HANDLE)_beginthreadex(NULL, 0, (unsigned int(__stdcall *)(void *))SysInitCheck, this, 0, NULL));
 }
 
 void CSysInitView::modifyCheckStatus(DWORD status)
@@ -1489,8 +1445,7 @@ BOOL CSysInitView::CheckThreadRunning()
 	return TRUE;
 }
 
-void CSysInitView::TestHighLevelDbg(
-	BOOL isShow, BOOL isHighLevel)
+void CSysInitView::TestHighLevelDbg(BOOL isShow, BOOL isHighLevel)
 {
 	::PostMessage(this->GetParent(), WM_SHOW_MAINTAIN_VIEW, isShow ? 1 : 0, isHighLevel ? 1 : 0);
 }
@@ -1687,7 +1642,7 @@ DWORD SysRestoreBegin(LPVOID lpv)
 	showMsg.Format(_T("取消系统定制功能初始化"));
 	if (1 == initDlg->m_systemMainRestoreCheck.GetCheck())
 	{
-		if (!RVCInit_InitRestore())
+		if (!RVCInit_InitRestore(true))
 			initDlg->EasyAddMsgToListView(showMsg, FALSE);
 		else
 		{
@@ -2067,7 +2022,7 @@ void CControlView::OnCommitResult(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*w
 	if (rc != Error_Succeed)
 	{
 		MessageBoxA(CSimpleStringA::Format("重置终端计数失败(0x%X)", rc));
-		LogError(Severity_Middle, rc, 0, CSimpleStringA::Format("重置终端计数失败(0x%X)", rc));
+		LogWarn(Severity_Middle, rc, 0, CSimpleStringA::Format("重置终端计数失败(0x%X)", rc));
 		return;
 	}
 
@@ -2091,7 +2046,7 @@ void CControlView::OnCommitResult(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*w
 	else
 	{
 		MessageBoxA(CSimpleStringA::Format("重置后端计数失败(0x%X)", rc));
-		LogError(Severity_Middle, rc, 0, CSimpleStringA::Format("重置后端计数失败(0x%X)", rc));
+		LogWarn(Severity_Middle, rc, 0, CSimpleStringA::Format("重置后端计数失败(0x%X)", rc));
 	}
 }
 
@@ -2670,11 +2625,6 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 
 	CenterWindow();
 
-#ifdef ALL_FUNCTION_SHOW
-	OnShowMaintainView(1, 1, 1);
-	OnShowMaintainView(1, 1, 1);
-#endif
-		
 	return 0;
 }
 
@@ -2801,6 +2751,7 @@ void CMainFrame::OnStartEntityFinished(ErrorCodeEnum ErrorResult, const char *en
 {
 	if (ErrorResult == Error_Succeed) {
 		output_printf("start %s entity ok!\r\n", entity_name);
+		
 	} else {
 		output_printf("start %s entity failed! Error = 0x%08X \r\n", entity_name, ErrorResult);
 	}
@@ -3248,12 +3199,6 @@ void CMainFrame::OnInitialize(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/
 	m_pConsole->BeginInitialize();	
 }
 
-void CMainFrame::OnMobileDial(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/)
-{
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("begin show mobiledial dialog...");
-	m_pConsole->ShowMobileDialog();	
-}
-
 void CMainFrame::OnDeleteKeySet(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/)
 {
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("delete keyset...");
@@ -3517,6 +3462,15 @@ void CMainFrame::OnStartMenuRange(UINT uNotifyCode, int nID, CWindow wndCtl)
 	}
 }
 
+LRESULT CMainFrame::OnChangeStartState(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	LOG_FUNCTION();
+	ShowWindow(SW_SHOW);
+	m_bStarted = true;
+	return 0;
+}
+
+
 void CCommandEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags )
 {
 	if (nChar == VK_RETURN) {
@@ -3560,3 +3514,307 @@ void CCommandEdit::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags )
 	}
 }
 
+LRESULT StartPageDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	LOG_FUNCTION();
+
+	MoveWindow(0, 0, 960, 610);
+
+	CRect rc;
+	GetWindowRect(&rc);
+
+
+	GetDlgItem(IDC_STATIC1).MoveWindow(rc.left + 40, rc.top + 38, 187, 24);
+	GetDlgItem(IDC_STATIC2).MoveWindow(rc.left + 385, rc.top + 97, 108, 39);
+	GetDlgItem(IDC_EXITVTM).MoveWindow(rc.left + 67, rc.top + 550, 38, 30);
+	GetDlgItem(IDC_PROGRESS).MoveWindow(rc.left + 493, rc.top + 97, 80, 39);
+	GetDlgItem(IDC_STATIC_BASICINFO).MoveWindow(rc.left +800, rc.top + 540, 140, 60);
+
+	m_pOutput = new COutputList();
+	RECT rect;
+	SetRect(&rect, rc.left + 70, rc.top + 168, rc.left + 70 + 820, rc.top + 168 + 367);
+	m_pOutput->Create(m_hWnd, rect, "", WS_VISIBLE | WS_CHILD | LBS_OWNERDRAWVARIABLE | LVS_REPORT 
+				| LBS_HASSTRINGS);
+	m_pOutput->ModifyStyle(NULL, WS_HSCROLL | WS_VSCROLL);
+
+	CSimpleStringA basicInoShowText(CSimpleStringA("v") + m_baseInfo.strSoftwareVersion + "\r\n" + m_baseInfo.strTerminalNo + "\r\n" + m_baseInfo.strMachineType);
+	GetDlgItem(IDC_STATIC_BASICINFO).SetWindowTextA(basicInoShowText.GetData());
+	CenterWindow();
+	return 0;
+}
+
+
+LRESULT StartPageDlg::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	CRect rc;
+	POINT pt;
+
+	pt.x = GET_X_LPARAM(lParam);
+	pt.y = GET_Y_LPARAM(lParam);
+	GetClientRect(&rc);
+	ClientToScreen(&rc);
+
+	return rc.PtInRect(pt) ? HTCAPTION : 0;
+}
+
+LRESULT StartPageDlg::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	LOG_FUNCTION();
+	DestroyWindow();
+	return 0;
+}
+
+
+HBRUSH StartPageDlg::OnCtlColorDlg(CDCHandle dc, CWindow wnd)
+{
+	if (m_hWnd == wnd.m_hWnd) 
+	{
+		dc.SetBkColor(RGB(0,0,0));
+		return (HBRUSH)GetStockObject(WHITE_BRUSH);
+	} else {
+		SetMsgHandled(FALSE);
+		return 0;
+	}
+}
+
+
+HBRUSH StartPageDlg::OnCtlColorStatic( CDCHandle dc, CStatic wndStatic)
+{
+	if (GetDlgItem(IDC_STATIC2).m_hWnd == wndStatic.m_hWnd) {
+		dc.SetTextColor(RGB(51, 51, 51));
+		dc.SetBkColor(RGB(255, 255, 255));
+		CFont font;
+		font.CreateFontA(30, 0, 0, 0, FW_HEAVY, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS, 
+			CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, FF_SWISS, "微软雅黑");
+		dc.SelectFont(font);
+
+		return (HBRUSH)GetStockObject(WHITE_BRUSH);
+	} else if (GetDlgItem(IDC_EXITVTM).m_hWnd == wndStatic.m_hWnd) {
+		dc.SetTextColor(RGB(77, 123, 254));
+		dc.SetBkColor(RGB(255, 255, 255));
+		CFont font;
+		font.CreateFontA(22, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS,
+			CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, FF_SWISS, "微软雅黑");
+		dc.SelectFont(font);
+		return (HBRUSH)GetStockObject(WHITE_BRUSH);
+	} else if (GetDlgItem(IDC_STATIC_BASICINFO).m_hWnd == wndStatic.m_hWnd) {
+		dc.SetTextColor(RGB(169, 169, 169));
+		dc.SetBkColor(RGB(255, 255, 255));
+		CFont font;
+		font.CreateFontA(20, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS,
+			CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, FF_SWISS, "微软雅黑");
+		dc.SelectFont(font);
+		return (HBRUSH)GetStockObject(WHITE_BRUSH);
+	}
+	SetMsgHandled(FALSE);
+	return 0;
+}
+
+LRESULT StartPageDlg::OnStnClickedStatic3(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+	m_pStartTask->ReqFrameworkQuit(false);
+
+	return 0;
+}
+
+void StartPageDlg::OutPut(const char* msg, COLORREF rgb)
+{
+	CString str(msg);
+
+	//m_pOutput->SetItemHeight(m_pOutput->GetCount() - 1, 21);
+	
+	CRect rc;
+	m_pOutput->GetClientRect(&rc);
+	int maxWidth = rc.Width();
+	int len = str.GetLength();
+
+	CClientDC dc(m_pOutput->m_hWnd);
+
+	SIZE strsz = {0};
+	GetTextExtentPoint32((HDC)dc.m_hDC, str, len, &strsz);
+
+	if(strsz.cx == 0)
+		return;
+
+	if(strsz.cx < maxWidth - 50)
+	{
+		m_pOutput->AddString(str, rgb);
+		m_pOutput->SetItemHeight(m_pOutput->GetCount() - 1, 21);
+		m_pOutput->SetCurSel(m_pOutput->GetCount() - 1);
+		return;
+	}
+
+	while(strsz.cx >= maxWidth - 50)
+	{
+		len--;
+		GetTextExtentPoint32((HDC)dc.m_hDC, str, len, &strsz);
+	}
+
+	m_pOutput->AddString(str.Left(len), rgb);
+	m_pOutput->SetItemHeight(m_pOutput->GetCount() - 1, 21);
+	m_pOutput->AddString(str.Right(str.GetLength() - len), rgb);
+	m_pOutput->SetItemHeight(m_pOutput->GetCount() - 1, 21);
+	m_pOutput->SetCurSel(m_pOutput->GetCount() - 1);
+}
+
+LRESULT StartPageDlg::OnShowMsg( UINT uMsg, WPARAM wParam, LPARAM lParam )
+{
+	char *pMsg = (char*)wParam;
+	COLORREF rgb = (COLORREF)lParam;
+
+	OutPut(pMsg, rgb);
+
+	delete pMsg;
+	return 0;
+}
+
+LRESULT StartPageDlg::OnShowProgress(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	int idleNum, totalNum;
+	m_pStartTask->GetIdleEntityNum(idleNum, totalNum);
+	CSimpleStringA csProgress = CSimpleString::Format("(%d/%d)", idleNum, totalNum);
+	GetDlgItem(IDC_PROGRESS).SetWindowTextA(csProgress.GetData());
+	return 0;
+}
+
+HBRUSH StartPageDlg::OnCtlColorProgress( CDCHandle dc, CStatic wndStatic)
+{
+	if (GetDlgItem(IDC_PROGRESS).m_hWnd == wndStatic.m_hWnd) {
+		dc.SetTextColor(RGB(51, 51, 51));
+		dc.SetBkColor(RGB(255, 255, 255));
+		CFont font;
+		font.CreateFontA(30, 0, 0, 0, FW_HEAVY, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS, 
+			CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, FF_SWISS, "微软雅黑");
+		dc.SelectFont(font);
+
+		return (HBRUSH)GetStockObject(WHITE_BRUSH);
+	}else {
+		SetMsgHandled(FALSE);
+		return 0;
+	}
+}
+
+void COutputList::DrawItem(LPDRAWITEMSTRUCT lpDIS) 
+{
+	if ((int)lpDIS->itemID < 0)
+		return; 
+
+	CDCHandle pDC(lpDIS->hDC);
+
+	COLORREF crText;
+	CString sText;
+	COLORREF crNorm = (COLORREF)lpDIS->itemData;		// Color information is in item data.
+	COLORREF crHilite = RGB(255-GetRValue(crNorm), 255-GetGValue(crNorm), 255-GetBValue(crNorm));
+
+	// If item has been selected, draw the highlight rectangle using the item's color.
+	if ((lpDIS->itemState & ODS_SELECTED) &&
+		(lpDIS->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
+	{
+		pDC.FillSolidRect(&lpDIS->rcItem, crNorm);
+	}
+
+	// If item has been deselected, draw the rectangle using the window color.
+	if (!(lpDIS->itemState & ODS_SELECTED) &&	(lpDIS->itemAction & ODA_SELECT))
+	{
+		pDC.FillSolidRect(&lpDIS->rcItem, ::GetSysColor(COLOR_WINDOW));
+	}	 	
+
+	// If item has focus, draw the focus rect.
+	if ((lpDIS->itemAction & ODA_FOCUS) && (lpDIS->itemState & ODS_FOCUS))
+		pDC.DrawFocusRect(&lpDIS->rcItem); 
+
+	// If item does not have focus, redraw (erase) the focus rect.
+	if ((lpDIS->itemAction & ODA_FOCUS) &&	!(lpDIS->itemState & ODS_FOCUS))
+		pDC.DrawFocusRect(&lpDIS->rcItem); 
+
+
+	// Set the background mode to TRANSPARENT to draw the text.
+	int nBkMode = pDC.SetBkMode(TRANSPARENT);
+
+	// If the item's color information is set, use the highlight color
+	// gray text color, or normal color for the text.
+	if (lpDIS->itemData)		
+	{
+		if (lpDIS->itemState & ODS_SELECTED)
+			crText = pDC.SetTextColor(crHilite);
+		else if (lpDIS->itemState & ODS_DISABLED)
+			crText = pDC.SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
+		else
+			crText = pDC.SetTextColor(crNorm);
+	}
+	// Else the item's color information is not set, so use the
+	// system colors for the text.
+	else
+	{
+		if (lpDIS->itemState & ODS_SELECTED)
+			crText = pDC.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
+		else if (lpDIS->itemState & ODS_DISABLED)
+			crText = pDC.SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
+		else
+			crText = pDC.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
+	}
+
+
+	// Get and display item text.
+	GetText(lpDIS->itemID, sText);
+	CRect rect = lpDIS->rcItem;
+
+	// Setup the text format.
+	UINT nFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER;
+	if (GetStyle() & LBS_USETABSTOPS)
+		nFormat |= DT_EXPANDTABS;
+
+	// Calculate the rectangle size before drawing the text.
+	CFont font;
+	font.CreateFontA(20, 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS, 
+		CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, FF_SWISS, "微软雅黑");
+
+	pDC.SelectFont(font);
+
+	pDC.DrawText(sText, -1, &rect, nFormat | DT_CALCRECT);
+	pDC.DrawText(sText, -1, &rect, nFormat);
+
+	pDC.SetTextColor(crText); 
+	pDC.SetBkMode(nBkMode);
+}	
+
+void COutputList::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
+{
+	lpMIS->itemHeight = ::GetSystemMetrics(SM_CXMENUCHECK);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("lpMIS->itemHeight=%d", lpMIS->itemHeight);
+}	
+
+int COutputList::AddString(LPCTSTR lpszItem)
+{
+	return ((CListBox*)this)->AddString(lpszItem);
+
+}	
+
+int COutputList::AddString(LPCTSTR lpszItem, COLORREF rgb)
+{
+	int nItem = AddString(lpszItem);
+	if (nItem >= 0)
+		SetItemData(nItem, rgb);
+	return nItem;
+}
+
+int COutputList::InsertString(int nIndex, LPCTSTR lpszItem)
+{
+	return ((CListBox*)this)->InsertString(nIndex, lpszItem);
+}	
+
+int COutputList::InsertString(int nIndex, LPCTSTR lpszItem, COLORREF rgb)
+{
+	int nItem = ((CListBox*)this)->InsertString(nIndex,lpszItem);
+	if (nItem >= 0)
+		SetItemData(nItem, rgb);
+	return nItem;
+}	
+
+void COutputList::SetItemColor(int nIndex, COLORREF rgb)
+{
+
+	SetItemData(nIndex, rgb);
+
+	RedrawWindow();
+}

+ 105 - 8
Module/mod_guiconsole/mainfrm.h

@@ -3,11 +3,10 @@
 
 #pragma once
 
-#define ALL_FUNCTION_SHOW
-
 #include "resource.h"
 #include "guitask.h"
 
+
 #define WM_GUICONSOLE	(WM_APP + 1)
 #define WM_SHOW_MSG (WM_APP + 2)
 #define WM_SHOW_MAINTAIN_VIEW  (WM_APP + 3)
@@ -15,6 +14,11 @@
 #define WM_CHECK_SYSINIT_SUCCESS (WM_APP + 5)
 #define WM_SHOW_BEGININIT_VIEW (WM_APP + 6)
 #define WM_SHOW_MOBILEDIAL_VIEW (WM_APP + 7)
+#define WM_SHOW_STARTPAGE  (WM_APP + 8)
+#define WM_STARTED (WM_APP + 9)
+#define WM_PRINTMSG (WM_APP + 10)
+#define WM_HIDEGUICONSOLE (WM_APP + 11)
+#define WM_NUMCHANGE (WM_APP + 12)
 
 #define OP_START_ENTITY		1
 #define OP_STOP_ENTITY		0
@@ -39,6 +43,22 @@ struct callback_entry : public IReleasable
 
 #if defined(_MSC_VER)
 
+struct TerminalBaseInfo 
+{
+	CSimpleStringA strTerminalNo;
+	CSimpleStringA strMachineType;
+	CSimpleStringA strSoftwareVersion;
+
+	TerminalBaseInfo() 
+		:strTerminalNo(true), strMachineType(true), strSoftwareVersion(true) {}
+	TerminalBaseInfo(TerminalBaseInfo& rhs) 
+		:strTerminalNo(rhs.strTerminalNo), strMachineType(rhs.strMachineType), strSoftwareVersion(rhs.strSoftwareVersion) {}
+	TerminalBaseInfo(const TerminalBaseInfo& rhs)
+		:strTerminalNo(rhs.strTerminalNo), strMachineType(rhs.strMachineType), strSoftwareVersion(rhs.strSoftwareVersion)
+	{
+	}
+};
+
 
 class CMainFrame;
 
@@ -252,6 +272,7 @@ private:
 	BOOL CheckThreadRunning();
 public:
 	void TestHighLevelDbg(BOOL isShow, BOOL isHighLevel);
+	//检查设备是否有做操作系统定制初始化
 	void CheckSystemInit();
 protected:
 	HINSTANCE m_dllWrc;
@@ -351,6 +372,73 @@ private:
 	GUITask *m_pGUITask;
 };
 
+class COutputList: public ATL::CWindowImpl<COutputList, CListBox>, public COwnerDraw<COutputList>
+{
+public:
+	DECLARE_WND_SUPERCLASS(NULL, CListBox::GetWndClassName())
+
+	int AddString(LPCTSTR lpszItem);											// Adds a string to the list box
+	int AddString(LPCTSTR lpszItem, COLORREF rgb);						// Adds a colored string to the list box
+	int InsertString(int nIndex, LPCTSTR lpszItem);						// Inserts a string to the list box
+	int InsertString(int nIndex, LPCTSTR lpszItem, COLORREF rgb);	// Inserts a colored string to the list box
+	void SetItemColor(int nIndex, COLORREF rgb);							// Sets the color of an item in the list box
+
+	BEGIN_MSG_MAP_EX(COutputList)
+		CHAIN_MSG_MAP_ALT(COwnerDraw<COutputList>, 1)
+		DEFAULT_REFLECTION_HANDLER()
+	END_MSG_MAP()
+
+public:
+	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
+	virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
+
+};
+
+class StartPageDlg : public ATL::CDialogImpl<StartPageDlg>
+{
+public:
+	StartPageDlg(GUITask* pStartTask) : m_pStartTask(pStartTask)
+	{
+	}
+	enum{ IDD = IDD_STARTPAGE };
+
+	BEGIN_MSG_MAP_EX(StartPageDlg)
+		MESSAGE_HANDLER_EX(WM_INITDIALOG, OnInitDialog)
+		MESSAGE_HANDLER_EX(WM_NCHITTEST, OnNcHitTest)
+		COMMAND_HANDLER(IDC_EXITVTM, STN_CLICKED, OnStnClickedStatic3)
+		MESSAGE_HANDLER_EX(WM_CLOSE, OnClose)
+		MESSAGE_HANDLER_EX(WM_SHOW_MSG, OnShowMsg)
+		MESSAGE_HANDLER_EX(WM_NUMCHANGE, OnShowProgress)
+		MSG_WM_CTLCOLORDLG(OnCtlColorDlg)
+		MSG_WM_CTLCOLORSTATIC(OnCtlColorStatic)
+		MSG_WM_CTLCOLORSTATIC(OnCtlColorProgress)
+		REFLECT_NOTIFICATIONS_EX()
+	END_MSG_MAP()
+
+	COutputList* m_pOutput;
+
+	void SetTerminalBasicInfo(const TerminalBaseInfo& info) {
+		m_baseInfo = info;
+	}
+private:
+	GUITask* m_pStartTask;
+	CBitmap* m_pBitmap;
+	TerminalBaseInfo m_baseInfo;
+public:
+	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam);
+	LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam);
+	LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam);
+	HBRUSH OnCtlColorDlg(CDCHandle dc, CWindow wnd);
+	HBRUSH OnCtlColorStatic(CDCHandle dc, CStatic wndStatic);
+	LRESULT OnStnClickedStatic3(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+	void OutPut(const char* msg, COLORREF rgb = RGB(171, 171, 171));
+	LRESULT OnCtlColorStatic(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+	LRESULT OnShowMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);
+	LRESULT OnShowProgress(UINT uMsg, WPARAM wParam, LPARAM lParam);
+	HBRUSH OnCtlColorProgress(CDCHandle dc, CStatic wndStatic);
+};
+
+
 class CMainFrame : public WTL::CFrameWindowImpl<CMainFrame>,
 			       public WTL::CMessageFilter, 
 				   public WTL::CIdleHandler,
@@ -361,7 +449,8 @@ public:
 
 	CMainFrame(GUITask *pConsole) : m_pConsole(pConsole), m_bOperationPending(FALSE), m_iSelectIdx(-1), 
 		m_nLineCount(0),  m_wndOutput(this, 1), m_bVScrolling(false), m_sysInfoView(m_pConsole), 
-		m_controlView(m_pConsole), m_highLevelView(m_pConsole), m_sysInitView(m_pConsole), m_cansysInitRm(TRUE)
+		m_controlView(m_pConsole), m_highLevelView(m_pConsole), m_sysInitView(m_pConsole), m_cansysInitRm(TRUE),
+		m_bStarted(false)
 	{
 	}
 
@@ -384,7 +473,6 @@ public:
 		COMMAND_ID_HANDLER_EX(ID_FRESH, OnFresh)
 		COMMAND_ID_HANDLER_EX(ID_HELP_ABOUT, OnAbout)
 		COMMAND_ID_HANDLER_EX(ID_FILE_INITIALIZE, OnInitialize)
-		COMMAND_ID_HANDLER_EX(ID_SETTINGS_DIAL, OnMobileDial)
 		COMMAND_ID_HANDLER_EX(ID_FILE_DELKEYSET, OnDeleteKeySet)
 		COMMAND_ID_HANDLER_EX(ID_FILE_MAINTAIN, OnMaintain)
 		COMMAND_ID_HANDLER_EX(ID_FILE_HIGHLEVEL, OnHighLevel)		
@@ -396,11 +484,11 @@ public:
 		//MESSAGE_HANDLER_EX(WM_CLOSE, OnClose)
 		MESSAGE_HANDLER_EX(WM_GUICONSOLE, OnGuiConsole)
 		MESSAGE_HANDLER_EX(WM_SHOW_MSG, OnShowMsg)
-#ifndef ALL_FUNCTION_SHOW
 		MESSAGE_HANDLER_EX(WM_SHOW_MAINTAIN_VIEW, OnShowMaintainView)
-#endif
 		MESSAGE_HANDLER_EX(WM_SHOW_BEGININIT_VIEW, OnShowBeginInitView)
 		MESSAGE_HANDLER_EX(WM_SHOW_MOBILEDIAL_VIEW, OnShowMobileDialView)
+		MESSAGE_HANDLER_EX(WM_STARTED, OnChangeStartState)
+
 		NOTIFY_HANDLER_EX(IDC_LIST1, LVN_ITEMCHANGED, OnListLeftItemchanged)
 		NOTIFY_HANDLER_EX(IDC_LIST2, LVN_ITEMCHANGED, OnListRightItemchanged)
 		NOTIFY_HANDLER_EX(IDC_LIST1, NM_CLICK, OnListLeftItemclicked)
@@ -432,18 +520,18 @@ public:
 	void OnMaintain(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/);
 	void OnHighLevel(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/);
 	void OnInitialize(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/);
-	void OnMobileDial(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/);
 	void OnDeleteKeySet(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/);
 	//void OnReboot(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/);
 	void OnShellExit(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/);
 	void OnOSRestart(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/);
 	//LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam);	
-	
+
 	LRESULT OnShowMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);
 	LRESULT OnGuiConsole(UINT uMsg, WPARAM wParam, LPARAM lParam);
 	LRESULT OnShowMaintainView(UINT uMsg, WPARAM wParam, LPARAM lParam);
 	LRESULT OnShowBeginInitView(UINT uMsg, WPARAM wParam, LPARAM lParam);
 	LRESULT OnShowMobileDialView(UINT uMsg, WPARAM wParam, LPARAM lParam);
+	LRESULT OnChangeStartState(UINT uMsg, WPARAM wParam, LPARAM lParam);
 	LRESULT OnListLeftItemchanged(NMHDR* phdr);
 	LRESULT OnListRightItemchanged(NMHDR* phdr);
 	LRESULT OnListLeftItemclicked(NMHDR* phdr);
@@ -493,6 +581,7 @@ private:
 	WTL::CSplitterWindow m_verticalSplitter;
 	WTL::CHorSplitterWindow m_splitter;
 	WTL::CEdit m_output;
+
 	CCommandEdit m_cmd;
 	WTL::CFont m_output_font;
 	WTL::CStatusBarCtrl m_status;
@@ -510,6 +599,8 @@ private:
 	ATL::CContainedWindow m_wndOutput;
 
 	CTabView m_tabView;
+	CTabView m_tabView2;
+
 	CSysInfoView m_sysInfoView;
 	CControlView m_controlView;
 	CHighLevelView m_highLevelView;
@@ -517,6 +608,12 @@ private:
 	//System Init Page
 	CSysInitView m_sysInitView;
 	BOOL m_cansysInitRm;
+
+	HWND m_hStartPage;
+
+	bool m_bStarted;
+
+	//StartPageDlg m_startPageDlg;
 };
 
 #endif //_MSC_VER

+ 13 - 4
Module/mod_guiconsole/mod_GuiConsole.h

@@ -2,9 +2,8 @@
 
 #include "SpBase.h"
 #include "modVer.h"
-#include "SpTest.h"
 #include "GUIConsoleFSM.h"
-
+#include "IHttpFunc.h"
 #include "GUIConsole_server_g.h"
 using namespace GUIConsole;
 
@@ -16,7 +15,8 @@ class CGUIConsoleEntity : public CEntityBase, public ILogListener, public ITimer
 {
 public:
 	CGUIConsoleEntity() :m_SubLogID1(0), m_SubLogID2(0), m_dwBeginTime(0),
-		m_strUserID(""), m_strUserName(""), m_strAuthorizer(""), m_strCurRight(""), m_strAuthTime("")
+		m_strUserID(""), m_strUserName(""), m_strAuthorizer(""), m_strCurRight(""), m_strAuthTime(""), m_uploadLogInfo_waitSec(3600),
+		m_refreshWaitSec(1200), m_pHttpFunc(NULL), m_defaultSystemId("LR04.02_Terminal")
 	{
 	}
 
@@ -44,7 +44,7 @@ public:
 	ErrorCodeEnum SubscribeEntitysEvents();
 	ErrorCodeEnum UnsubscribeEntitysEvents();
 	CSimpleStringA GetCurMaintainer(){ return m_strUserID;}
-
+	bool refreshToken();
 	ErrorCodeEnum GetCurrentMaintainer(CSimpleStringA &strUserID,	CSimpleStringA &strUserName, CSimpleStringA &strCurRight,
 		CSimpleStringA &strAuthorizer, unsigned int &dwBeginTime);
 	ErrorCodeEnum Empower(const char *pszUserID);
@@ -82,6 +82,7 @@ protected:
 	CUUID m_SubLogID1;
 	CUUID m_SubLogID2;
 	CUUID m_SubLogID3;
+	CUUID m_SubLogID4;
 
 	// 当前维护用户信息
 	CSimpleStringA m_strUserID;
@@ -90,6 +91,14 @@ protected:
 	CSimpleStringA m_strAuthorizer;
 	CSimpleStringA m_strAuthTime;
 	DWORD m_dwBeginTime;
+public:
+	int m_uploadLogInfo_waitSec;
+	std::string m_channelId;
+	std::string m_tokenSecret;
+	std::string m_defaultSystemId;
+	static std::string m_httpToken;
+	int m_refreshWaitSec;
+	IHttpFunc* m_pHttpFunc;
 };
 
 class CGUIConsoleSession : public GUIConsoleService_ServerSessionBase

+ 1 - 47
Module/mod_guiconsole/mod_guiconsole.cpp

@@ -6,10 +6,9 @@
 #include "GUIConsole_UserCode.h"
 #include "CardIssuer_client_g.h"
 using namespace CardIssuer;
-#include "MaintainWatcher_client_g.h"
-using namespace MaintainWatcher;
 
 #include "fileutil.h"
+#include <sys/stat.h>
 
 void CGUIConsoleEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext) 
 {
@@ -88,51 +87,6 @@ void CGUIConsoleEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogI
 			m_strAuthorizer = "";
 			m_strAuthTime = "";
 
-			MaintainCertificate_ClientBase *pClient = new MaintainCertificate_ClientBase(this);
-			auto rc = pClient->Connect();
-			if (rc != Error_Succeed)
-			{
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect to MaintainWatcher entity fail: %d", rc);
-				pClient->SafeDelete();
-			}
-			else
-			{
-				MaintainCertificate_GetUserInfo_Req req = {};
-				MaintainCertificate_GetUserInfo_Ans ans = {};
-				rc = pClient->GetUserInfo(req, ans, 10000);
-				if (rc != Error_Succeed)
-				{
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get userinfo fail from MaintainWatcher: %s", SpStrError(rc));
-				}
-				else
-				{
-					// UserID=SP00000004;UserName=RVC0001;AuthorierID=SP00000001;AuthorizeTime=2014/8/13 18:46:29;RecommenderSAP=80274390;RecommenderOfficeID=274390;
-					CSimpleStringA &str = ans.UserInfo;
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get maintainer info: %s", (const char*)str);
-
-					auto arr = str.Split(';');
-					for (int i = 0; i < arr.GetCount(); i++)
-					{
-						auto arr2 = arr[i].Split('=');
-						if (arr2.GetCount() != 2)
-							continue;
-
-						if (arr2[0] == "UserID")
-							m_strUserID = arr2[1];
-						else if (arr2[0] == "UserName")
-							m_strUserName = arr2[1];
-						else if (arr2[0] == "AuthorierID")
-							m_strAuthorizer = arr2[1];
-						else if (arr2[0] == "AuthorizeTime")
-							m_strAuthTime = arr2[1];
-					}
-				}
-				
-                pClient->GetFunction()->CloseSession();
-
-			}
-            pClient = NULL;
-
 			m_strCurRight = bLowLevel ? "Low" : "High";
 			m_dwBeginTime = CSmallDateTime::GetNow();