Ver Fonte

完成上报测试数据功能。

JeffWang há 2 anos atrás
pai
commit
c848f9085e

+ 9 - 1
Source/OGCAssistTool/OGCAssistTool/OGCAssistTool.cpp

@@ -93,7 +93,7 @@ COGCAssistToolApp::COGCAssistToolApp()
 {
 	// TODO: 在此处添加构造代码,
 	// 将所有重要的初始化放置在 InitInstance 中
-#ifdef _DEBUG
+#ifndef _DEBUG
 	if ( CMESdb::GetInstance() )
 	{
 		TString strSN, strBom;
@@ -148,6 +148,14 @@ BOOL COGCAssistToolApp::InitInstance()
 	// 例如修改为公司或组织名
 	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
 
+	// 启动日志;
+	char szCfgPath[MAX_PATH] = {0};
+	GetCurrentDirectoryA(MAX_PATH, szCfgPath);
+	sprintf_s(szCfgPath, "%s\\log4z.cfg", szCfgPath);
+	ILog4zManager::getRef().config(szCfgPath);
+	ILog4zManager::getRef().start();
+	LOGI("OGC辅助程序启动 ");
+
 	MTVERIFY(GLOBAL::GetConfigInfo());
 
 	GLOBAL::g_db.Open();

+ 1 - 0
Source/OGCAssistTool/OGCAssistTool/OGCAssistTool.vcxproj

@@ -84,6 +84,7 @@
       <AssemblyDebug>true</AssemblyDebug>
       <SubSystem>Windows</SubSystem>
       <TargetMachine>MachineX86</TargetMachine>
+      <UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

+ 19 - 3
Source/OGCAssistTool/OGCAssistTool/PageDebug.cpp

@@ -211,6 +211,8 @@ BOOL CPageDebug::ConnectProc(DATAHEADER *pHeader, MSG_INFO *pMsg)
 	else if ( pHeader->byMsgType == C2S_DISCONNECT )
 		m_pDlg->SetDlgItemText(BTN_CONNECT, pMsg->byResult ? _T("连接设备") : _T("断开连接"));
 	*/
+
+	return TRUE;
 }
 
 BOOL CPageDebug::ReceiveProc(DATAHEADER *pHeader, MSG_INFO *pMsg)
@@ -444,9 +446,18 @@ DWORD CPageDebug::ThreadGoProc(LPVOID lpParam)
 										// 在线模式,上报结果;
 										if ( !GLOBAL::g_config.nOffline )
 										{
-											if ( m_pDlg->UpLoadTestData(strSN, bRet, _T("")) )
+											CString strMsg;
+											if ( !m_pDlg->UpLoadTestData(strSN, bRet, _T("")) )
+											{												
+												strMsg.Format(_T("%s;上传测试数据失败"), bRet ? _T("成功") : _T("失败"));
+												m_pDlg->m_lable_result.SetText(strMsg);
+												m_pDlg->m_lable_result.SetBkColor(COLOR_RED);
+											}
+											else
 											{
-
+												strMsg.Format(_T("%s;上传测试数据成功"), bRet ? _T("成功") : _T("失败"));
+												m_pDlg->m_lable_result.SetText(strMsg);
+												m_pDlg->m_lable_result.SetBkColor(COLOR_RED);
 											}
 										}	
 
@@ -1032,8 +1043,13 @@ bool CPageDebug::UpLoadTestData(CString strSN, BOOL bResult, CString strErrorMsg
 		{
 			return true;
 		}
+
+		LOGE("过站失败:" << GLOBAL::wcs2mbs(strSN).c_str());
+	}
+	else {
+		LOGE("上传测试数据失败" << GLOBAL::wcs2mbs(strSN).c_str());
 	}
-	
+
 	return false;
 }
 

+ 9 - 9
Source/OGCAssistTool/OGCAssistTool/Protocol.h

@@ -56,12 +56,12 @@ typedef struct _MSG_INFO_
 		byResult = 0;
 		dwClientId = 0;
 		memset(byData, 0, DATA_LEN);
-		memset(szClientName, 0, sizeof(TCHAR)*NAME_LEN);
+		memset(szClientName, 0, sizeof(TCHAR) * NAME_LEN);
 	}
 
-	_MSG_INFO_ &operator=(const _MSG_INFO_ &that)
+	_MSG_INFO_& operator=(const _MSG_INFO_& that)
 	{
-		if ( this == &that )
+		if (this == &that)
 			return *this;
 
 		dwClientId = that.dwClientId;
@@ -71,7 +71,7 @@ typedef struct _MSG_INFO_
 
 		return *this;
 	}
-}MSG_INFO,*LPMSG_INFO;
+}MSG_INFO, * LPMSG_INFO;
 
 typedef struct _HEADER_
 {
@@ -88,25 +88,25 @@ typedef struct _HEADER_
 		byMsgType = 0;
 	}
 
-	_HEADER_ &operator=(const _HEADER_ &that)
+	_HEADER_& operator=(const _HEADER_& that)
 	{
-		if ( this == &that )
+		if (this == &that)
 			return *this;
-	
+
 		byProtocol = that.byProtocol;
 		dwPackageLen = that.dwPackageLen;
 		byMsgType = that.byMsgType;
 
 		return *this;
 	}
-}DATAHEADER, *LPDATAHEADER;
+}DATAHEADER, * LPDATAHEADER;
 
 // 헝헹관
 typedef struct _PACKAGE_ {
 	DATAHEADER	header;
 	//BYTE		buf[4]; // 야竟코휭(寧濾뒈囹);
 	LPVOID		buf;
-}PACKAGE, *LPPACKAGE;
+}PACKAGE, * LPPACKAGE;
 
 #pragma pack(pop)
 #pragma endregion 숌데繫斤葵累

+ 3 - 0
Source/OGCAssistTool/OGCAssistTool/stdafx.h

@@ -56,6 +56,9 @@ typedef std::wstring TString;
 typedef std::string TString;
 #endif
 
+#include "log4z.h"
+using namespace zsummer::log4z;
+
 #ifdef _UNICODE
 #if defined _M_IX86
 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")