From b4a18bfef6cb9f5d48a12b455dfa78f9ef67e348 Mon Sep 17 00:00:00 2001
From: kojingeun <diteam.co.kr>
Date: 수, 07 6월 2023 10:29:07 +0900
Subject: [PATCH] Revert "Ongoing50 #4517 CF AOI Review 결과 파일 찾기 실패 개선"

---
 ReviewSystem/ReviewSystem/DisplayMessage.cpp |  133 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 110 insertions(+), 23 deletions(-)

diff --git a/ReviewSystem/ReviewSystem/DisplayMessage.cpp b/ReviewSystem/ReviewSystem/DisplayMessage.cpp
index 8d7f0e2..a223f03 100644
--- a/ReviewSystem/ReviewSystem/DisplayMessage.cpp
+++ b/ReviewSystem/ReviewSystem/DisplayMessage.cpp
@@ -8,6 +8,12 @@
 
 	SetPath(strPath);
 
+	// #3417 LYWCF AOI Review �쟾�꽕鍮� Log Process媛쒖꽑 ADD START
+	DWORD  dwThreadId = 0;
+	HANDLE hThread = CreateThread(NULL, 0, RunThreadDisplayLog, NULL, 0, &dwThreadId);
+	m_ThreadId = dwThreadId;
+	// #3417 LYWCF AOI Review �쟾�꽕鍮� Log Process媛쒖꽑 ADD END
+
 	InitializeCriticalSection(&m_csLog);
 }
 
@@ -19,13 +25,17 @@
 		m_pFileLog = NULL;
 	}
 
+	PostThreadMessage(m_ThreadId, WM_QUIT, 0, 0);
+
 	DeleteCriticalSection(&m_csLog);
 }
 
 void CDisplayMessage::SetPath(const CString& strPath)
 {
 	m_strLogPath = strPath;
-
+	CString m_GlobalLogPath;
+	m_strLogFile.Format(_T("D:\\DIT_LogData\\%04d%02d%02d"), m_strLogPath, m_TimeLogFile.GetYear(), m_TimeLogFile.GetMonth(), m_TimeLogFile.GetDay());
+	CreateDirectory(m_strLogFile, NULL);
 	CreateDirectory(m_strLogPath, NULL);
 
 	MakeLogFile();
@@ -34,6 +44,10 @@
 BOOL CDisplayMessage::MakeLogFile()
 {
 	// Log 泥섎━
+	CString m_GlobalLogPath;
+	m_strLogFile.Format(_T("D:\\DIT_LogData\\%04d%02d%02d"), m_TimeLogFile.GetYear(), m_TimeLogFile.GetMonth(), m_TimeLogFile.GetDay());
+	CreateDirectory(m_strLogFile, NULL);
+
 	if (m_strLogPath.IsEmpty())
 		return FALSE;
 
@@ -50,41 +64,85 @@
 
 	return TRUE;
 }
-
+// #3417 LYWCF AOI Review �쟾�꽕鍮� Log Process媛쒖꽑 ADD START
 void CDisplayMessage::DisplayMessage(const CString& strMessage)
 {
-	WriteToFile(strMessage);
+// 	WriteToFile(strMessage);
+// 
+// 	if(m_pDM2P)
+// 	{
+// 		m_pDM2P->DM2P_DisplayMessage(strMessage);
+// 	}
+	/*< SWK 20221226 - #4403 MOD Start >*/
+// 	CString* pstrLog = new CString(strMessage);
+// 	PostThreadMessage(m_ThreadId, WM_DIPLAY_LOG, reinterpret_cast<WPARAM>(pstrLog), 0);
+	pLogData plogdata = new LogData;
+	::GetLocalTime(&plogdata->currentTime);
+	plogdata->strLog = strMessage;
+	PostThreadMessage(m_ThreadId, WM_DIPLAY_LOG, reinterpret_cast<WPARAM>(plogdata), 0);
+	/*< SWK 20221226 - #4403 MOD End >*/
 
-	if(m_pDM2P)
-	{
-		m_pDM2P->DM2P_DisplayMessage(strMessage);
-	}
 }
+// #3417 LYWCF AOI Review �쟾�꽕鍮� Log Process媛쒖꽑 ADD END
 
+// #3417 LYWCF AOI Review �쟾�꽕鍮� Log Process媛쒖꽑 ADD START
 void CDisplayMessage::DisplayMessage(const TCHAR* lpstrFormat, ...)
 {
 	va_list list;
 	TCHAR strText[2000] = {0};
-
-	va_start(list, lpstrFormat);
-	_vstprintf_s(strText, lpstrFormat, list);
-	va_end(list);
-
-	WriteToFile(strText);
-
-	if(m_pDM2P)
+	try
 	{
-		m_pDM2P->DM2P_DisplayMessage(strText);
+		va_start(list, lpstrFormat);
+		_vstprintf_s(strText, lpstrFormat, list);
+		va_end(list);
+
+		/*< SWK 20221226 - #4403 MOD Start >*/
+// 		CString* pstrLog = new CString(strText);
+// 		PostThreadMessage(m_ThreadId, WM_DIPLAY_LOG, reinterpret_cast<WPARAM>(pstrLog), 0);
+		pLogData plogdata = new LogData;
+		::GetLocalTime(&plogdata->currentTime);
+		plogdata->strLog = strText;
+		PostThreadMessage(m_ThreadId, WM_DIPLAY_LOG, reinterpret_cast<WPARAM>(plogdata), 0);
+		/*< SWK 20221226 - #4403 MOD End >*/
+	}
+	catch (...)
+	{
+		return;
+	}
+
+
+// 	WriteToFile(strText);
+// 
+// 	if(m_pDM2P)
+// 	{
+// 		m_pDM2P->DM2P_DisplayMessage(strText);
+// 	}
+}
+// #3417 LYWCF AOI Review �쟾�꽕鍮� Log Process媛쒖꽑 ADD END
+
+// #3417 LYWCF AOI Review �쟾�꽕鍮� Log Process媛쒖꽑 ADD START
+//< SWK 20221226 - #4403 MOD >
+//void CDisplayMessage::ThreadDisplayMessage(const CString& strMessage)
+void CDisplayMessage::ThreadDisplayMessage(const LogData& logdata)
+{
+	WriteToFile(logdata.currentTime, logdata.strLog);
+
+	if (m_pDM2P)
+	{
+		m_pDM2P->DM2P_DisplayMessage(logdata.strLog);
 	}
 }
-
-BOOL CDisplayMessage::WriteToFile(const CString& strMessage)
+//< SWK 20221226 - #4403 MOD >
+//BOOL CDisplayMessage::WriteToFile(const CString& strMessage)
+BOOL CDisplayMessage::WriteToFile(const SYSTEMTIME& t, const CString& strMessage)
 {
 	if(m_pFileLog == NULL)	return FALSE;
 
-	EnterCriticalSection(&m_csLog);
+	//EnterCriticalSection(&m_csLog);
 
-	CTime	time = CTime::GetCurrentTime();
+	//< SWK 20221226 - #4403 MOD >
+//	CTime	time = CTime::GetCurrentTime();
+	CTime	time(t);
 	CString	strTimeStamp = _T("");
 	// �궇吏쒓� 諛붾�뚮㈃ �뙆�씪紐낆쓣 媛깆떊�빐�꽌 �벖�떎.
 	if ((time.GetMonth() != m_TimeLogFile.GetMonth()) || (time.GetDay() != m_TimeLogFile.GetDay()) || !m_pFileLog)
@@ -95,7 +153,11 @@
 		// �쑀�땲肄붾뱶 �뙆�씪�쓽 �떆�옉�� BOM(0xFEFF) �씠�뼱�빞 �븳�떎.
 		TCHAR strCommand = 0xFEFF;
 		CString strLog = _T("");
-		strTimeStamp.Format(_T("[%02d:%02d:%02d]"), time.GetHour(), time.GetMinute(), time.GetSecond());
+		//strTimeStamp.Format(_T("[%02d:%02d:%02d]"), time.GetHour(), time.GetMinute(), time.GetSecond());
+		/*< SWK 20221221 - #4403 MOD Start >*/
+//		strTimeStamp.Format(_T("[%02d:%02d:%02d_%02d:%02d:%02d]"), time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond());
+		strTimeStamp.Format(_T("[%02d:%02d:%02d_%02d:%02d:%02d.%03d]"), time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond(), t.wMilliseconds);
+		/*< SWK 20221221 - #4403 MOD End >*/
 #ifdef UNICODE
 		strLog.Format(_T("%c%s %s\r\n"), strCommand, strTimeStamp, strMessage);
 #else
@@ -107,10 +169,35 @@
 		m_pFileLog->Close();
 	}
 
-	LeaveCriticalSection(&m_csLog);
+	//LeaveCriticalSection(&m_csLog);
 
 	return TRUE;
 }
 
+DWORD CDisplayMessage::RunThreadDisplayLog(LPVOID param)
+{
+	MSG msg;
+	while (GetMessage(&msg, NULL, 0, 0))
+	{
+		//< SWK 20221226 - #4403 MOD >
+//		CString* pstrLog = reinterpret_cast<CString*>(msg.wParam);
+		CDisplayMessage::pLogData plogdata = reinterpret_cast<CDisplayMessage::pLogData>(msg.wParam);
+		switch (msg.message)
+		{
+		case WM_DIPLAY_LOG:
+			
+			/*< SWK 20221226 - #4403 MOD Start >*/
+// 			g_pLog->ThreadDisplayMessage(*pstrLog);
+// 			delete pstrLog;
+			g_pLog->ThreadDisplayMessage(*plogdata);
+			delete plogdata;
+			/*< SWK 20221226 - #4403 MOD End >*/
+			break;
 
-
+		default:
+			break;
+		}
+	}
+	return 0;
+}
+// #3417 LYWCF AOI Review �쟾�꽕鍮� Log Process媛쒖꽑 ADD END

--
Gitblit v1.9.3