SDC C-Project CF Review 프로그램
kojingeun
2023-07-14 f77e8008cac062596058fca2aeddda62b80bedbf
ReviewSystem/ReviewSystem/DisplayMessage.cpp
@@ -73,8 +73,14 @@
//    {
//       m_pDM2P->DM2P_DisplayMessage(strMessage);
//    }
   CString* pstrLog = new CString(strMessage);
   PostThreadMessage(m_ThreadId, WM_DIPLAY_LOG, reinterpret_cast<WPARAM>(pstrLog), 0);
   /*< 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 >*/
}
// #3417 LYWCF AOI Review 전설비 Log Process개선 ADD END
@@ -90,8 +96,14 @@
      _vstprintf_s(strText, lpstrFormat, list);
      va_end(list);
      CString* pstrLog = new CString(strText);
      PostThreadMessage(m_ThreadId, WM_DIPLAY_LOG, reinterpret_cast<WPARAM>(pstrLog), 0);
      /*< 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 (...)
   {
@@ -109,23 +121,28 @@
// #3417 LYWCF AOI Review 전설비 Log Process개선 ADD END
// #3417 LYWCF AOI Review 전설비 Log Process개선 ADD START
void CDisplayMessage::ThreadDisplayMessage(const CString& strMessage)
//< SWK 20221226 - #4403 MOD >
//void CDisplayMessage::ThreadDisplayMessage(const CString& strMessage)
void CDisplayMessage::ThreadDisplayMessage(const LogData& logdata)
{
   WriteToFile(strMessage);
   WriteToFile(logdata.currentTime, logdata.strLog);
   if (m_pDM2P)
   {
      m_pDM2P->DM2P_DisplayMessage(strMessage);
      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);
   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)
@@ -139,9 +156,7 @@
      //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());
      SYSTEMTIME   currentTime;
      ::GetLocalTime(&currentTime);
      strTimeStamp.Format(_T("[%02d:%02d:%02d_%02d:%02d:%02d.%03d]"), time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond(), currentTime.wMilliseconds);
      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);
@@ -159,18 +174,24 @@
   return TRUE;
}
DWORD RunThreadDisplayLog(LPVOID param)
DWORD CDisplayMessage::RunThreadDisplayLog(LPVOID param)
{
   MSG msg;
   while (GetMessage(&msg, NULL, 0, 0))
   {
      CString* pstrLog = reinterpret_cast<CString*>(msg.wParam);
      //< 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:
         
         g_pLog->ThreadDisplayMessage(*pstrLog);
         delete pstrLog;
         /*< SWK 20221226 - #4403 MOD Start >*/
//          g_pLog->ThreadDisplayMessage(*pstrLog);
//          delete pstrLog;
         g_pLog->ThreadDisplayMessage(*plogdata);
         delete plogdata;
         /*< SWK 20221226 - #4403 MOD End >*/
         break;
      default: