#include "StdAfx.h"
|
#include "FTPThreadPool.h"
|
|
|
CFTPThreadPool::CFTPThreadPool(int nType, DWORD dwPeriod) : CTimerThreadPools(dwPeriod, 1), m_nType(nType)
|
{
|
m_pConnection = NULL;
|
m_pFileFind = NULL;
|
m_pSession = NULL;
|
m_bConnect = FALSE;
|
m_nCurLogIndex = 0;
|
|
m_strIP = _T("127.0.0.1");
|
m_strID = _T("ID_Invalid");
|
m_strPassword = _T("PW_Invalid");
|
m_nPort = 21;
|
m_bPassive = TRUE;
|
m_nConnectionTimeout = 5000;
|
|
m_strDefaultFolderPath = _T("/Test/");
|
m_strLastErrorMessage = _T("");
|
|
// [C-PRJ] Image Upload Define - KHT (2020/11/19)
|
m_strIP2 = _T("127.0.0.1");
|
m_strID2 = _T("ID_Invalid");
|
m_strPassword2 = _T("PW_Invalid");
|
m_nPort2 = 21;
|
m_nConnectionTimeout2 = 5000;
|
m_strDefaultFolderPath2 = _T("/Test/");
|
|
//201218 CJH - Download¿ë IP Ãß°¡
|
m_strIP3 = _T("127.0.0.1");
|
m_strID3 = _T("ID_Invalid");
|
m_strPassword3 = _T("PW_Invalid");
|
m_nPort3 = 21;
|
m_nConnectionTimeout3 = 5000;
|
m_strDefaultFolderPath3 = _T("/Test/");
|
|
m_nCompletCount = 0;
|
m_nProcessCount = 0;
|
m_nTotalCount = 0;
|
|
m_bSharedFolder = TRUE;
|
|
m_bWSIChk = FALSE;
|
|
CreatePathDir(LOCAL_SIGNAL_FILE_PATH);
|
}
|
|
CFTPThreadPool::~CFTPThreadPool(void)
|
{
|
Disconnect();
|
}
|
|
BOOL CFTPThreadPool::StartThread()
|
{
|
return CTimerThreadPools::StartThread();
|
}
|
|
void CFTPThreadPool::StopThread()
|
{
|
CTimerThreadPools::StopThread();
|
}
|
|
BOOL CFTPThreadPool::AddUploadParam( const CFTPUploadParam& uploadParam )
|
{
|
CSingleLock localLock(&m_csUploadList);
|
localLock.Lock();
|
if(uploadParam.m_bFirstPriority==1)
|
{
|
m_deqUploadList.push_front(uploadParam);
|
}
|
else
|
{
|
m_deqUploadList.push_back(uploadParam);
|
}
|
m_nTotalCount = (++m_nTotalCount) % INT_MAX;
|
localLock.Unlock();
|
|
return TRUE;
|
}
|
|
void CFTPThreadPool::TimerThreadProcess( PVOID pParameter )
|
{
|
CSingleLock localLock(&m_csUploadList);
|
localLock.Lock();
|
|
// size check
|
if (m_deqUploadList.size()<1)
|
{
|
localLock.Unlock();
|
return;
|
}
|
|
// get front
|
DeqFTPUploadParamIt it=m_deqUploadList.begin();
|
CFTPUploadParam param = *it;
|
|
// delete front
|
m_deqUploadList.pop_front();
|
localLock.Unlock();
|
|
// ftp process
|
m_nProcessCount++;
|
if (param.m_nProcessType==FTPProcessType_UpFile)
|
{
|
Process_Upload(param);
|
}
|
else
|
{
|
Process_Download(param);
|
}
|
m_nProcessCount--;
|
m_nCompletCount = (++m_nCompletCount) % INT_MAX;
|
|
return;
|
}
|
|
BOOL CFTPThreadPool::Process_UploadAck(int nResultCode, const CFTPUploadParam& uploadParam)
|
{
|
if (uploadParam.m_nSendResultCode==0)
|
{
|
return TRUE;
|
}
|
|
HWND hWnd = uploadParam.GetSenderWnd();
|
if (hWnd==NULL)
|
{
|
return FALSE;
|
}
|
|
CFTPCopyDataParam ackParam = uploadParam;
|
ackParam.m_nSendResultCode = nResultCode;
|
|
USES_CONVERSION;
|
COPYDATASTRUCT cds;
|
cds.dwData = COPYDATA_RAW_UPLOAD_ACK;
|
cds.cbData = sizeof(CFTPCopyDataParam);
|
cds.lpData = &ackParam;
|
|
DWORD dwReturn = 0;
|
if(SendMessageTimeout(hWnd, WM_COPYDATA, NULL, (LPARAM)&cds, SMTO_NORMAL, 20000, (PDWORD_PTR)(dwReturn)) == FALSE)
|
{
|
return FALSE;
|
}
|
|
return TRUE;
|
}
|
|
BOOL CFTPThreadPool::Process_DownloadAck(int nResultCode, const CFTPUploadParam& uploadParam)
|
{
|
if (uploadParam.m_nSendResultCode==0)
|
{
|
return TRUE;
|
}
|
|
HWND hWnd = uploadParam.GetSenderWnd();
|
if (hWnd==NULL)
|
{
|
return FALSE;
|
}
|
|
CFTPCopyDataParam ackParam = uploadParam;
|
ackParam.m_nSendResultCode = nResultCode;
|
|
USES_CONVERSION;
|
COPYDATASTRUCT cds;
|
cds.dwData = COPYDATA_RAW_DOWNLOAD_ACK;
|
cds.cbData = sizeof(CFTPCopyDataParam);
|
cds.lpData = &ackParam;
|
|
DWORD dwReturn = 0;
|
if(SendMessageTimeout(hWnd, WM_COPYDATA, NULL, (LPARAM)&cds, SMTO_NORMAL, 20000, (PDWORD_PTR)(dwReturn)) == FALSE)
|
{
|
return FALSE;
|
}
|
|
return TRUE;
|
}
|
|
BOOL CFTPThreadPool::Process_Upload( CFTPUploadParam& uploadParam )
|
{
|
CSingleLock localLock(&m_csFtpProcess);
|
m_csFtpProcess.Lock();
|
|
CString strHomePath = _T("");
|
|
// 1. connect
|
CString strMessage = _T("");
|
|
DWORD dwTick = GetTickCount();
|
BOOL bConnect = ConnectMain();
|
dwTick = GetTickCount() - dwTick;
|
strMessage.Format(_T("Connection Time: %d msec"), dwTick);
|
DisplayLogMessage(strMessage);
|
|
int nUploadResult = FALSE;
|
|
if(bConnect)
|
{
|
// 2. upload
|
dwTick = GetTickCount();
|
if( nUploadResult = Upload(uploadParam) )
|
{
|
dwTick = GetTickCount() - dwTick;
|
strMessage.Format(_T("Upload Time: %d msec"), dwTick);
|
DisplayLogMessage(strMessage);
|
}
|
|
// 3. disconnect
|
dwTick = GetTickCount();
|
Disconnect();
|
dwTick = GetTickCount() - dwTick;
|
strMessage.Format(_T("Disconnect Time: %d msec"), dwTick);
|
DisplayLogMessage(strMessage);
|
}
|
|
// ACK¸¦ ÇØ¾ßÇϳª?
|
Process_UploadAck(nUploadResult, uploadParam);
|
|
return TRUE;
|
}
|
|
BOOL CFTPThreadPool::Process_Download( CFTPUploadParam& downloadParam )
|
{
|
CSingleLock localLock(&m_csFtpProcess);
|
m_csFtpProcess.Lock();
|
|
CString strMessage = _T("");
|
|
// 1. connect
|
DWORD dwTick = GetTickCount();
|
BOOL bConnect = ConnectMain();
|
dwTick = GetTickCount() - dwTick;
|
strMessage.Format(_T("Connection Time: %d msec"), dwTick);
|
DisplayLogMessage(strMessage);
|
|
BOOL bResult = TRUE;
|
if(bConnect)
|
{
|
// 2. download
|
dwTick = GetTickCount();
|
if( bResult=Download( downloadParam ) )
|
{
|
dwTick = GetTickCount() - dwTick;
|
strMessage.Format(_T("Download Time: %d msec"), dwTick);
|
DisplayLogMessage(strMessage);
|
}
|
|
// 3. disconnect
|
dwTick = GetTickCount();
|
Disconnect();
|
dwTick = GetTickCount() - dwTick;
|
strMessage.Format(_T("Disconnect Time: %d msec"), dwTick);
|
DisplayLogMessage(strMessage);
|
}
|
|
// ACK¸¦ ÇØ¾ßÇϳª?
|
Process_DownloadAck(TRUE, downloadParam);
|
|
return TRUE;
|
}
|
|
|
void CFTPThreadPool::SetConnectionTimeout( int nTimeout )
|
{
|
m_nConnectionTimeout = nTimeout;
|
}
|
|
void CFTPThreadPool::SetConnectionInfo( CString strIP, CString strUserID, CString strPassword, int nPort, int nTimeout, CString strHomePath, CString strIP2, CString strUserID2, CString strPassword2, int nPort2, int nTimeout2, CString strHomePath2, CString strIP3, CString strUserID3, CString strPassword3, int nPort3, int nTimeout3, CString strHomePath3, BOOL bPassive ,BOOL bWSIChk)
|
{
|
m_strIP = strIP;
|
m_strID = strUserID;
|
m_strPassword = strPassword;
|
m_nPort = nPort;
|
m_nConnectionTimeout = nTimeout;
|
m_strDefaultFolderPath = strHomePath;
|
m_bPassive = bPassive;
|
|
// [C-PRJ] Image Upload Define - KHT (2020/11/19)
|
m_strIP2 = strIP2;
|
m_strID2 = strUserID2;
|
m_strPassword2 = strPassword2;
|
m_nPort2 = nPort2;
|
m_nConnectionTimeout2 = nTimeout2;
|
m_strDefaultFolderPath2 = strHomePath2;
|
|
//201218 CJH - Download¿ë IP Ãß°¡
|
m_strIP3 = strIP3;
|
m_strID3 = strUserID3;
|
m_strPassword3 = strPassword3;
|
m_nPort3 = nPort3;
|
m_nConnectionTimeout3 = nTimeout3;
|
m_strDefaultFolderPath3 = strHomePath3;
|
|
m_bWSIChk = bWSIChk;
|
|
if(m_strDefaultFolderPath.Right(1) != _T("\\"))
|
{
|
m_strDefaultFolderPath += _T("\\");
|
}
|
|
// if(m_strDefaultFolderPath3.Right(1) != _T("\\"))
|
// {
|
// m_strDefaultFolderPath3 += _T("\\");
|
// }
|
}
|
|
BOOL CFTPThreadPool::ConnectMain()
|
{
|
Sleep(10);
|
|
// Main ¼¹ö Á¢¼Ó
|
if(m_bConnect = Connect())
|
{
|
//NotifyMessageToParent(eFTPConnection,m_strIP,m_strDefaultFolderPath);
|
// ±âº» Æú´õ À̵¿
|
if(m_bSharedFolder == FALSE && ChangeDirectory(m_strDefaultFolderPath) == FALSE)
|
{
|
CString strError = _T("CFTPThread::OnStartUploadProcess ChangeDirectory Process Error");
|
CString strErrorProcess = _T("FTP Chnage Home Path Fail!");
|
//NotifyMessageToParent(eFTPError,strErrorProcess,strError, TRUE);
|
|
if(m_bConnect == TRUE)
|
{
|
Disconnect();
|
}
|
|
return FALSE;
|
}
|
}
|
else
|
{
|
//NotifyMessageToParent(eFTPConnectionFail,m_strIP,m_strDefaultFolderPath, TRUE);
|
}
|
|
return TRUE;
|
}
|
|
|
BOOL CFTPThreadPool::Connect()
|
{
|
if(m_bSharedFolder)
|
{
|
return TRUE;
|
}
|
Disconnect();
|
|
if(m_pSession == NULL)
|
{
|
m_pSession = new CInternetSession();
|
}
|
|
m_pSession->SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,m_nConnectionTimeout);
|
m_pSession->SetOption(INTERNET_OPTION_SEND_TIMEOUT,m_nConnectionTimeout); // GetLastError ½Ã¿¡ ERROR_INTERNET_TIMEOUT ¿¡·¯¸¦ ¸®ÅÏÇÑ´Ù.
|
|
try
|
{
|
TRACE(_T("FTP Connection Try ! \n"));
|
m_pConnection = m_pSession->GetFtpConnection(m_strIP,m_strID,m_strPassword,m_nPort,m_bPassive);
|
//NotifyMessageToParent(eFTPConnection,m_strIP,m_strDefaultFolderPath);
|
TRACE(_T("FTP Connection OK ! \n"));
|
}
|
catch (CInternetException* pEx)
|
{
|
TCHAR szCause[255]={0};
|
if (pEx->GetErrorMessage(szCause, 255))
|
{
|
TRACE(_T("FTP Connection Fail Cause[%s]\n"), szCause);
|
|
m_strLastErrorMessage = szCause;
|
}
|
pEx->Delete();
|
|
if (m_pConnection)
|
delete m_pConnection;
|
m_pConnection = NULL;
|
|
m_pSession->Close();
|
if (m_pSession)
|
delete m_pSession;
|
m_pSession = NULL;
|
|
return 0;
|
}
|
|
if(m_pConnection == NULL)
|
{
|
m_pSession->Close();
|
if (m_pSession)
|
delete m_pSession;
|
m_pSession = NULL;
|
|
m_pConnection = NULL;
|
|
return FALSE;
|
}
|
|
CString strCurrentPath = _T("");
|
m_pConnection->GetCurrentDirectory(strCurrentPath);
|
TRACE("FTP Connection Success Dir[%s] \n",strCurrentPath);
|
|
if (m_pFileFind==NULL)
|
{
|
m_pFileFind = new CFtpFileFind(m_pConnection);
|
}
|
|
return TRUE;
|
}
|
|
BOOL CFTPThreadPool::Disconnect()
|
{
|
if (m_pConnection != NULL)
|
{
|
m_pConnection->Close();
|
delete m_pConnection;
|
m_pConnection = NULL;
|
}
|
|
if(m_pSession != NULL)
|
{
|
m_pSession->Close();
|
delete m_pSession;
|
m_pSession = NULL;
|
}
|
|
if(m_pFileFind != NULL)
|
{
|
m_pFileFind->Close();
|
delete m_pFileFind;
|
m_pFileFind = NULL;
|
}
|
|
m_bConnect = FALSE;
|
|
return TRUE;
|
}
|
|
BOOL CFTPThreadPool::ChangeDirectory( const CString& strPath, BOOL bCreate )
|
{
|
if(m_bSharedFolder) return TRUE;
|
|
if(m_pConnection == NULL)
|
return FALSE;
|
|
BOOL bReturn = m_pConnection->SetCurrentDirectory(strPath);
|
|
if (bCreate==FALSE)
|
{
|
return bReturn;
|
}
|
|
// ¸¶Áö¸· Æú´õ·Î À̵¿ÀÌ ½ÇÆÐ ÇÑ´Ù¸é For¹® µ¹¸é¼ Æú´õ¸¦ »ý¼ºÇÑ´Ù.
|
CString strFinalPath = strPath;
|
int nStartIdx = 1;
|
while(TRUE)
|
{
|
int nFindIdx = strFinalPath.Find(_T("/"),nStartIdx);
|
if(nFindIdx == -1)
|
break;
|
|
CString strSubPath = strFinalPath.Left(nFindIdx);
|
if(m_pConnection->SetCurrentDirectory(strSubPath) == FALSE)
|
{
|
if(m_pConnection->CreateDirectory(strSubPath) == FALSE)
|
{
|
return FALSE;
|
}
|
else
|
{
|
nStartIdx = nFindIdx + 1;
|
}
|
}
|
else
|
{
|
nStartIdx = nFindIdx + 1;
|
}
|
Sleep(10);
|
}
|
|
return TRUE;
|
}
|
|
BOOL CFTPThreadPool::Upload_Signal( const CFTPUploadParam& Param )
|
{
|
CString strMessage = _T("");
|
BOOL bUploadResult = FALSE;
|
|
// ÃÖÁ¾ ¼¹ö °æ·Î ¸¸µé±â
|
CString strServer_FinalPath = m_strDefaultFolderPath + Param.m_strServer_SignalFolderName;
|
strServer_FinalPath += _T("/");
|
|
// ¼¹ö °æ·Î º¯°æ ¾øÀ¸¸é ¸¸µé¾î¼ º¯°æ
|
if(m_bSharedFolder)
|
{
|
CString strCreatePath;
|
strCreatePath = "\\\\"+m_strIP+strServer_FinalPath;
|
CreatePathDir(strCreatePath);
|
}
|
else
|
{
|
ChangeDirectory(strServer_FinalPath, TRUE);
|
}
|
|
// ·ÎÄà ½Ã±×³Î ÆÄÀÏ °æ·Î
|
CString strLocalSignalPath = LOCAL_SIGNAL_FILE_PATH;
|
strLocalSignalPath += _T("\\");
|
strLocalSignalPath += Param.m_strServer_SignalFileName;
|
|
// ·ÎÄÿ¡ ½Ã±×³Î ÆÄÀÏ ¸¸µé±â
|
CFile SignalFile;
|
if (SignalFile.Open((LPCTSTR)strLocalSignalPath, CFile::modeCreate))
|
{
|
SignalFile.Close();
|
|
// ¸®¸ðÆ® ½ÃÅ©³Î ÆÄÀÏ °æ·Î
|
strServer_FinalPath = strServer_FinalPath + Param.m_strServer_SignalFileName;
|
|
// ½Ã±×³Î ÆÄÀÏ ¾÷·Îµå
|
if(m_bSharedFolder)
|
{
|
bUploadResult = CopyFile(strLocalSignalPath, strServer_FinalPath, FALSE);
|
}
|
else
|
{
|
bUploadResult = m_pConnection->PutFile(strLocalSignalPath, strServer_FinalPath);
|
}
|
|
// ·ÎÄà ½Ã±×³Î ÆÄÀÏ »èÁ¦
|
DeleteFile(strLocalSignalPath);
|
|
// °á°ú ·Î±× Ãâ·Â
|
DisplayResultMessage(bUploadResult, strServer_FinalPath, strLocalSignalPath);
|
|
}
|
|
return bUploadResult;
|
}
|
|
BOOL CFTPThreadPool::Upload( const CFTPUploadParam& Param )
|
{
|
if(m_bSharedFolder == FALSE && m_pConnection == NULL)
|
{
|
return FALSE;
|
}
|
|
CString strMessage = _T("");
|
BOOL bUploadResult = TRUE;
|
CString strConfigBackUpIp = _T("12.96.66.96"); // RTMS PC IP [ 21-03-03 KJG ] // RTMS PC ID/PW : administrator / dit1234!@
|
CString strConfigBackUpPath =_T("DIT_AutoConfigBackUp\\"); // RTMS PC·Î Config ÆÄÀÏ ¾÷·Îµå °æ·Î [ 21-03-03 KJG ]
|
// [C-PRJ] Image Upload Define - KHT (2020/11/19)
|
// ÃÖÁ¾ ¼¹ö °æ·Î ¸¸µé±â
|
CString strServer_FinalPath, strServer_WSIFinalPath = _T("");
|
|
if(Param.m_nDataType == FTPDataType_Image)
|
{
|
strServer_FinalPath = m_strDefaultFolderPath2 + Param.m_strServer_FolderName;
|
|
if(m_bWSIChk)
|
{
|
strServer_WSIFinalPath = m_strDefaultFolderPath2 + Param.m_strServer_FolderName + _T("\WSI\\");
|
}
|
}
|
else
|
{
|
strServer_FinalPath = m_strDefaultFolderPath + Param.m_strServer_FolderName;
|
}
|
if(Param.m_nDataType == FTPDataType_AutoBackUp) // RTMS PC·Î Config ÆÄÀÏ ¾÷·Îµå °æ·Î [ 21-03-03 KJG ]
|
{
|
strServer_FinalPath.Format("%s%s", strConfigBackUpPath, Param.m_strServer_FolderName);
|
}
|
|
//strServer_FinalPath += _T("\\");
|
|
// ¼¹ö °æ·Î º¯°æ ¾øÀ¸¸é ¸¸µé¾î¼ º¯°æ
|
if(m_bSharedFolder)
|
{
|
CString strCreatePath;
|
CString strWSICreatePath =_T("");
|
|
// [C-PRJ] Image Upload Define - KHT (2020/11/19)
|
if(Param.m_nDataType == FTPDataType_Image)
|
{
|
strCreatePath = "\\\\" + m_strIP2+ "\\" + strServer_FinalPath;
|
|
if(m_bWSIChk)
|
{
|
strWSICreatePath = "\\\\" + m_strIP2+ "\\" + strServer_FinalPath + _T("\WSI\\");
|
CreatePathDir(strWSICreatePath);
|
}
|
}
|
else
|
{
|
strCreatePath = "\\\\"+m_strIP+ "\\" + strServer_FinalPath;
|
}
|
if(Param.m_nDataType == FTPDataType_AutoBackUp) // RTMS PC·Î Config ÆÄÀÏ ¾÷·Îµå °æ·Î [ 21-03-03 KJG ]
|
{
|
strCreatePath.Format("\\\\%s\\%s", strConfigBackUpIp, strServer_FinalPath);
|
}
|
|
CreatePathDir(strCreatePath);
|
}
|
else
|
{
|
ChangeDirectory(strServer_FinalPath, TRUE);
|
}
|
|
|
//Raw ÆÄÀÏ °æ·Î Ãß°¡
|
CString strServerSubRawFileFullPathName=NULL;
|
if(Param.m_nDataType == FTPDataType_Raw)
|
{
|
CreatePathDir(Param.m_strServer_SubFilePath);
|
strServerSubRawFileFullPathName = Param.m_strServer_SubFilePath;
|
strServerSubRawFileFullPathName += Param.m_strServer_SubFileName;
|
}
|
|
|
|
// ·ÎÄà Ǯ °æ·Î¸í ¸¸µé±â
|
CString strLocal_FullPathName = Param.m_strLocal_FolderName;
|
strLocal_FullPathName += _T("\\");
|
strLocal_FullPathName += Param.m_strLocal_FileName;
|
|
// ·ÎÄà °æ·Î¿¡¼ ¿Ã¸± ÆÄÀÏ Ã£±â
|
CFileFind finder;
|
CString strServer_FullPathName =_T("");
|
BOOL bFind = finder.FindFile(strLocal_FullPathName);
|
while(bFind)
|
{
|
Sleep(10);
|
bFind = finder.FindNextFile();
|
|
if (finder.IsDots()) continue;
|
if (finder.IsDirectory()) continue;
|
|
// ¼¹ö Ç® °æ·Î¸í ¸¸µé±â
|
strServer_FullPathName = strServer_FinalPath + finder.GetFileName();
|
|
// ·ÎÄà Ǯ °æ·Î¸í ¸¸µé±â
|
strLocal_FullPathName = finder.GetFilePath();
|
|
// ¾÷·Îµå
|
if(m_bSharedFolder)
|
{
|
// [C-PRJ] Image Upload Define - KHT (2020/11/19)
|
if(Param.m_nDataType == FTPDataType_Image)
|
{
|
strServer_FullPathName = "\\\\"+m_strIP2+ "\\" + strServer_FinalPath + finder.GetFileName();
|
}
|
else
|
{
|
strServer_FullPathName = "\\\\"+m_strIP+ "\\" + strServer_FinalPath + finder.GetFileName();
|
}
|
if(Param.m_nDataType == FTPDataType_AutoBackUp) // RTMS PC·Î Config ÆÄÀÏ ¾÷·Îµå °æ·Î [ 21-03-03 KJG ]
|
{
|
strServer_FullPathName = "\\\\"+ strConfigBackUpIp + "\\" + strServer_FinalPath + finder.GetFileName();
|
}
|
strServer_FullPathName.MakeLower();
|
strServer_FullPathName.Replace("/", "\\");
|
|
bUploadResult = CopyFile(strLocal_FullPathName, strServer_FullPathName, FALSE);
|
CopyFile(strLocal_FullPathName,strServerSubRawFileFullPathName, FALSE);
|
}
|
else
|
{
|
bUploadResult = m_pConnection->PutFile(strLocal_FullPathName, strServer_FullPathName);
|
}
|
|
if(bUploadResult == FALSE)
|
{
|
DWORD dwResut = GetLastError();
|
int a = 0;
|
}
|
|
// °á°ú ·Î±× Ãâ·Â
|
DisplayResultMessage(bUploadResult, strServer_FullPathName, strLocal_FullPathName);
|
}
|
finder.Close();
|
|
if(Param.m_nDataType == FTPDataType_Image && m_bWSIChk)
|
{
|
// WSI ·ÎÄà Ǯ °æ·Î¸í ¸¸µé±â
|
CString strWSILocal_FullPathName = Param.m_strLocal_FolderName;
|
strWSILocal_FullPathName += _T("\\WSI\\");
|
strWSILocal_FullPathName += Param.m_strLocal_FileName;
|
|
// WSI ·ÎÄà °æ·Î¿¡¼ ¿Ã¸± ÆÄÀÏ Ã£±â
|
CFileFind finder;
|
CString strServer_WSIFullPathName =_T("");
|
BOOL bFind = finder.FindFile(strWSILocal_FullPathName);
|
while(bFind)
|
{
|
Sleep(10);
|
bFind = finder.FindNextFile();
|
|
if (finder.IsDots()) continue;
|
if (finder.IsDirectory()) continue;
|
|
// ¼¹ö Ç® °æ·Î¸í ¸¸µé±â
|
strServer_WSIFullPathName = strServer_WSIFinalPath + finder.GetFileName();
|
|
// ·ÎÄà Ǯ °æ·Î¸í ¸¸µé±â
|
strWSILocal_FullPathName = finder.GetFilePath();
|
|
// ¾÷·Îµå
|
if(m_bSharedFolder)
|
{
|
strServer_WSIFullPathName = "\\\\"+m_strIP2+ "\\" + strServer_WSIFinalPath + finder.GetFileName();
|
|
strServer_WSIFullPathName.MakeLower();
|
strServer_WSIFullPathName.Replace("/", "\\");
|
|
bUploadResult = CopyFile(strWSILocal_FullPathName, strServer_WSIFullPathName, FALSE);
|
}
|
else
|
{
|
bUploadResult = m_pConnection->PutFile(strWSILocal_FullPathName, strServer_WSIFullPathName);
|
}
|
|
if(bUploadResult == FALSE)
|
{
|
DWORD dwResut = GetLastError();
|
int a = 0;
|
}
|
|
// °á°ú ·Î±× Ãâ·Â
|
DisplayResultMessage(bUploadResult, strServer_WSIFullPathName, strWSILocal_FullPathName);
|
}
|
finder.Close();
|
}
|
|
if(Param.m_nDataType == FTPDataType_Image)
|
{
|
CString RTMSFile =NULL;
|
CString RTMSName = NULL;
|
CTime time;
|
BOOL bCopy;
|
time = CTime::GetCurrentTime();
|
|
RTMSFile = Param.m_strRTMS_FileName;
|
RTMSName = RTMSFile.Right( RTMSFile.GetLength() - RTMSFile.ReverseFind('\\')-1);;
|
|
RTMSName = RTMSName.Left(RTMSName.GetLength() - 21);
|
RTMSFile = "D:\\RTMS_Signal\\" + RTMSName;
|
|
RTMSFile.Format(RTMSFile + "%04d%02d%02d%02d%02d%02d.Signal",time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond());
|
|
//ÆÄÀÏ À̵¿
|
bCopy = ::CopyFile(Param.m_strRTMS_FileName, RTMSFile,FALSE);
|
|
DisplayResultMessage(bCopy,Param.m_strRTMS_FileName,RTMSFile);
|
|
}
|
|
// ½Ã±×³Î ÆÄÀÏÀ» ¾÷·ÎµåÇØ¾ßÇϸé.
|
if( Param.m_nCreateSignalFile == 1)
|
{
|
Upload_Signal(Param);
|
}
|
|
return bUploadResult;
|
}
|
|
BOOL CFTPThreadPool::Download( const CFTPUploadParam& Param)
|
{
|
if(m_bSharedFolder == FALSE && m_pConnection == NULL)
|
return FALSE;
|
|
// ¼¹ö ÃÖÁ¾ °æ·Î
|
CString strServer_FinalPath = m_strDefaultFolderPath3 + Param.m_strServer_FolderName + "/";
|
|
//201208 CJH - Stack ¿ë Ãß°¡
|
if(m_bSharedFolder)
|
{
|
CString strCreatePath;
|
strCreatePath = "\\\\"+m_strIP3+ "\\" + strServer_FinalPath;
|
//CreatePathDir(strCreatePath);
|
}
|
else
|
{
|
ChangeDirectory(strServer_FinalPath, TRUE);
|
}
|
|
// ·ÎÄà ÃÖÁ¾ °æ·Î
|
BOOL bDownResult = TRUE;
|
CString strLocal_FullPathName = Param.m_strLocal_FolderName;
|
strLocal_FullPathName += _T("\\");
|
|
try
|
{
|
// ¼¹ö ÃÖÁ¾ ÆÄÀÏ
|
if(m_bSharedFolder)
|
{
|
strServer_FinalPath = "\\\\"+m_strIP3+ m_strDefaultFolderPath3 + Param.m_strServer_FolderName + "/" ;
|
strServer_FinalPath.Replace("/", "\\");
|
}
|
else
|
{
|
strServer_FinalPath += Param.m_strServer_FileName;
|
}
|
|
if(m_bSharedFolder)
|
{
|
CFileFind finder;
|
|
// start looping
|
CString strLocal_FullFileName = _T("");
|
CString strServer_FindFormat = strServer_FinalPath + Param.m_strServer_FileName;
|
BOOL bWorking = finder.FindFile(strServer_FindFormat);
|
while (bWorking)
|
{
|
bWorking = finder.FindNextFile();
|
if (finder.IsDirectory()) continue;
|
if (finder.IsDots()) continue;
|
|
|
CString strValue = finder.GetFileName();
|
|
// ·ÎÄà Ǯ °æ·Î ¸¸µé±â
|
strLocal_FullFileName = strLocal_FullPathName + Param.m_strLocal_FileName;
|
|
CString strServerFileName = strServer_FinalPath + finder.GetFileName();
|
// ´Ù¿î·Îµå
|
bDownResult = bDownResult & CopyFile(strServerFileName, strLocal_FullFileName, FALSE);
|
|
// °á°ú ·Î±× Ãâ·Â
|
DisplayResultMessage(bDownResult, strServerFileName, strLocal_FullFileName);
|
|
}
|
finder.Close();
|
}
|
else
|
{
|
CFtpFileFind finder(m_pConnection);
|
|
// start looping
|
CString strLocal_FullFileName = _T("");
|
BOOL bWorking = finder.FindFile(strServer_FinalPath);
|
while (bWorking)
|
{
|
bWorking = finder.FindNextFile();
|
if (finder.IsDirectory()) continue;
|
if (finder.IsDots()) continue;
|
|
|
CString strValue = finder.GetFileName();
|
|
// ·ÎÄà Ǯ °æ·Î ¸¸µé±â
|
strLocal_FullFileName = strLocal_FullPathName + Param.m_strServer_FileName;//finder.GetFileName();
|
|
// ¼¹ö Ç® °æ·Î °¡Á®¿À±â
|
strServer_FinalPath = strServer_FinalPath;//finder.GetFilePath();
|
|
// ´Ù¿î·Îµå
|
bDownResult = bDownResult & m_pConnection->GetFile(strServer_FinalPath, strLocal_FullFileName, FALSE);
|
|
// °á°ú ·Î±× Ãâ·Â
|
DisplayResultMessage(bDownResult, strServer_FinalPath, strLocal_FullFileName);
|
}
|
finder.Close();
|
}
|
|
}
|
catch (CInternetException* pEx)
|
{
|
TCHAR sz[1024];
|
pEx->GetErrorMessage(sz, 1024);
|
_tprintf_s(_T("ERROR! %s\n"), sz);
|
pEx->Delete();
|
}
|
|
return bDownResult;
|
}
|
|
|
CString CFTPThreadPool::GetInternetErrorCodeToString( DWORD dwErrorCode )
|
{
|
CString strRet = _T("Invalid");
|
|
if( m_strLastErrorMessage != _T(""))
|
{
|
strRet = m_strLastErrorMessage;
|
m_strLastErrorMessage = _T("");
|
return strRet;
|
}
|
|
switch(dwErrorCode)
|
{
|
case ERROR_INTERNET_OUT_OF_HANDLES : strRet = _T("ERROR_INTERNET_OUT_OF_HANDLES ÇÒ´çÇÒ ¼ö ÀÖ´Â ÀÎÅÍ³Ý ÇÚµéÀÌ ¾ø½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_TIMEOUT : strRet = _T("ERROR_INTERNET_TIMEOUT ÀÛ¾÷ ½Ã°£À» ÃʰúÇß½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_EXTENDED_ERROR : strRet = _T("ERROR_INTERNET_EXTENDED_ERROR ¼¹ö¿¡¼ È®Àå Á¤º¸¸¦ ¹ÝȯÇß½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_INTERNAL_ERROR : strRet = _T("ERROR_INTERNET_INTERNAL_ERROR Microsoft ÀÎÅÍ³Ý È®Àå¿¡¼ ³»ºÎ ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_INVALID_URL : strRet = _T("ERROR_INTERNET_INVALID_URL À߸øµÈ URLÀÔ´Ï´Ù. "); break;
|
case ERROR_INTERNET_UNRECOGNIZED_SCHEME : strRet = _T("ERROR_INTERNET_UNRECOGNIZED_SCHEME URL¿¡¼ ÀÎ½ÄµÈ ÇÁ·ÎÅäÄÝÀ» »ç¿ëÇÏÁö ¾Ê½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_NAME_NOT_RESOLVED : strRet = _T("ERROR_INTERNET_NAME_NOT_RESOLVED ¼¹ö À̸§À̳ª ÁÖ¼Ò¸¦ È®ÀÎÇÒ ¼ö ¾ø½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_PROTOCOL_NOT_FOUND : strRet = _T("ERROR_INTERNET_PROTOCOL_NOT_FOUND ÇÊ¿äÇÑ ±â´ÉÀÌ Æ÷ÇÔµÈ ÇÁ·ÎÅäÄÝÀ» ãÀ» ¼ö ¾ø½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_INVALID_OPTION : strRet = _T("ERROR_INTERNET_INVALID_OPTION À߸øµÈ ¿É¼ÇÀÔ´Ï´Ù. "); break;
|
case ERROR_INTERNET_BAD_OPTION_LENGTH : strRet = _T("ERROR_INTERNET_BAD_OPTION_LENGTH ¿É¼Ç Á¾·ù¿¡ ´ëÇØ ±æÀ̰¡ ¸ÂÁö ¾Ê½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_OPTION_NOT_SETTABLE : strRet = _T("ERROR_INTERNET_OPTION_NOT_SETTABLE ¿É¼Ç °ªÀ» ¼³Á¤ÇÒ ¼ö ¾ø½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_SHUTDOWN : strRet = _T("ERROR_INTERNET_SHUTDOWN Microsoft ÀÎÅÍ³Ý È®Àå Áö¿øÀÌ Á¾·áµÇ¾ú½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_INCORRECT_USER_NAME : strRet = _T("ERROR_INTERNET_INCORRECT_USER_NAME »ç¿ëÇÒ ¼ö ¾ø´Â »ç¿ëÀÚ À̸§ÀÔ´Ï´Ù. "); break;
|
case ERROR_INTERNET_INCORRECT_PASSWORD : strRet = _T("ERROR_INTERNET_INCORRECT_PASSWORD »ç¿ëÇÒ ¼ö ¾ø´Â ¾ÏÈ£ÀÔ´Ï´Ù. "); break;
|
case ERROR_INTERNET_LOGIN_FAILURE : strRet = _T("ERROR_INTERNET_LOGIN_FAILURE ·Î±×ÀÎ ¿äûÀÌ °ÅºÎµÇ¾ú½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_INVALID_OPERATION : strRet = _T("ERROR_INTERNET_INVALID_OPERATION "); break;
|
case ERROR_INTERNET_OPERATION_CANCELLED : strRet = _T("ERROR_INTERNET_OPERATION_CANCELLED ÀÛ¾÷ÀÌ Ãë¼ÒµÇ¾ú½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_INCORRECT_HANDLE_TYPE : strRet = _T("ERROR_INTERNET_INCORRECT_HANDLE_TYPE Á¦°øµÈ ÇÚµéÀº ¿äûÇÑ ÀÛ¾÷¿¡ »ç¿ëÇÒ ¼ö ¾ø´Â Á¾·ùÀÔ´Ï´Ù. "); break;
|
case ERROR_INTERNET_INCORRECT_HANDLE_STATE : strRet = _T("ERROR_INTERNET_INCORRECT_HANDLE_STATE ¿äûÇÑ ÀÛ¾÷¿¡ »ç¿ëÇÒ ¼ö ¾ø´Â »óÅÂÀÇ ÇÚµéÀÔ´Ï´Ù. "); break;
|
case ERROR_INTERNET_NOT_PROXY_REQUEST : strRet = _T("ERROR_INTERNET_NOT_PROXY_REQUEST ÇÁ·Ï½Ã ¼¼¼Ç¿¡¼ ¿äûÇÒ ¼ö ¾ø½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND : strRet = _T("ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND ·¹Áö½ºÆ®¸® °ªÀ» ãÀ» ¼ö ¾ø½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_BAD_REGISTRY_PARAMETER : strRet = _T("ERROR_INTERNET_BAD_REGISTRY_PARAMETER ·¹Áö½ºÆ®¸® ¸Å°³ º¯¼ö°¡ ¸ÂÁö ¾Ê½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_NO_DIRECT_ACCESS : strRet = _T("ERROR_INTERNET_NO_DIRECT_ACCESS Á÷Á¢ ÀÎÅͳݿ¡ ¾×¼¼½ºÇÒ ¼ö ¾ø½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_NO_CONTEXT : strRet = _T("ERROR_INTERNET_NO_CONTEXT ÄÁÅØ½ºÆ® °ªÀ» Á¦°øÇÏÁö ¾Ê¾Ò½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_NO_CALLBACK : strRet = _T("ERROR_INTERNET_NO_CALLBACK »óÅ ÄݹéÀÌ Á¦°øµÇÁö ¾Ê¾Ò½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_REQUEST_PENDING : strRet = _T("ERROR_INTERNET_REQUEST_PENDING ¾ÆÁ÷ ÇØ°áµÇÁö ¾ÊÀº ¿äûÀÌ ÀÖ½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_INCORRECT_FORMAT : strRet = _T("ERROR_INTERNET_INCORRECT_FORMAT Á¤º¸ Çü½ÄÀÌ ¸ÂÁö ¾Ê½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_ITEM_NOT_FOUND : strRet = _T("ERROR_INTERNET_ITEM_NOT_FOUND ¿äûÇÑ Ç׸ñÀ» ãÀ» ¼ö ¾ø½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_CANNOT_CONNECT : strRet = _T("ERROR_INTERNET_CANNOT_CONNECT ¼¹ö¿¡ ¿¬°áÇÒ ¼ö ¾ø½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_CONNECTION_ABORTED : strRet = _T("ERROR_INTERNET_CONNECTION_ABORTED ¼¹ö¿ÍÀÇ ¿¬°áÀÌ ºñÁ¤»óÀûÀ¸·Î Á¾·áµÇ¾ú½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_CONNECTION_RESET : strRet = _T("ERROR_INTERNET_CONNECTION_RESET ¼¹ö¿ÍÀÇ ¿¬°áÀ» ´Ù½Ã ¼³Á¤Çß½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_FORCE_RETRY : strRet = _T("ERROR_INTERNET_FORCE_RETRY ÀÛ¾÷À» ´Ù½Ã ½ÃµµÇØ¾ß ÇÕ´Ï´Ù. "); break;
|
case ERROR_INTERNET_INVALID_PROXY_REQUEST : strRet = _T("ERROR_INTERNET_INVALID_PROXY_REQUEST À߸øµÈ ÇÁ·Ï½Ã ¿äûÀÔ´Ï´Ù. "); break;
|
case ERROR_INTERNET_NEED_UI : strRet = _T("ERROR_INTERNET_NEED_UI ÀÛ¾÷À» ¿Ï·áÇÏ·Á¸é »ç¿ëÀÚÀÇ Á¶ÀÛÀÌ ÇÊ¿äÇÕ´Ï´Ù. "); break;
|
case ERROR_INTERNET_HANDLE_EXISTS : strRet = _T("ERROR_INTERNET_HANDLE_EXISTS ÇÚµéÀÌ ÀÌ¹Ì ÀÖ½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_SEC_CERT_DATE_INVALID : strRet = _T("ERROR_INTERNET_SEC_CERT_DATE_INVALID ÀÎÁõ¼ ³¯Â¥°¡ À߸øµÇ¾ú°Å³ª ¸¸·áµÇ¾ú½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_SEC_CERT_CN_INVALID : strRet = _T("ERROR_INTERNET_SEC_CERT_CN_INVALID ÀÎÁõ¼ È£½ºÆ® À̸§ÀÌ À߸øµÇ¾ú°Å³ª ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR : strRet = _T("ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR ¸®µð·º¼Ç ¿äûÀ¸·Î ºñº¸¾È ¿¬°áÀ» º¸¾È ¿¬°á·Î º¯°æÇÕ´Ï´Ù. "); break;
|
case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR : strRet = _T("ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR ¸®µð·º¼Ç ¿äûÀ¸·Î º¸¾È ¿¬°áÀ» ºñº¸¾È ¿¬°á·Î º¯°æÇÕ´Ï´Ù. "); break;
|
case ERROR_INTERNET_MIXED_SECURITY : strRet = _T("ERROR_INTERNET_MIXED_SECURITY º¸¾È ¹× ºñº¸¾È ¿¬°áÀÌ È¥ÇյǾî ÀÖ½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_CHG_POST_IS_NON_SECURE : strRet = _T("ERROR_INTERNET_CHG_POST_IS_NON_SECURE ºñº¸¾È °Ô½Ã·Î º¯°æÇϰí ÀÖ½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_POST_IS_NON_SECURE : strRet = _T("ERROR_INTERNET_POST_IS_NON_SECURE ºñº¸¾È ¿¬°á »óÅ¿¡¼ µ¥ÀÌÅ͸¦ °Ô½ÃÇϰí ÀÖ½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED : strRet = _T("ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED Ŭ¶óÀÌ¾ðÆ® ÀÎÁõÀ» ¿Ï·áÇÏ·Á¸é ÀÎÁõ¼°¡ ÇÊ¿äÇÕ´Ï´Ù. "); break;
|
case ERROR_INTERNET_INVALID_CA : strRet = _T("ERROR_INTERNET_INVALID_CA ÀÎÁõ ±â°üÀÌ À߸øµÇ¾ú°Å³ª ¸ÂÁö ¾Ê½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP : strRet = _T("ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP Ŭ¶óÀÌ¾ðÆ® ÀÎÁõÀÌ ¿Ã¹Ù¸£°Ô ¼³Ä¡µÇÁö ¾Ê¾Ò½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_ASYNC_THREAD_FAILED : strRet = _T("ERROR_INTERNET_ASYNC_THREAD_FAILED Wininet ºñµ¿±â ½º·¹µå¿¡¼ ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù.´Ù½Ã ½ÃÀÛÇØ¾ß ÇÕ´Ï´Ù. "); break;
|
case ERROR_INTERNET_REDIRECT_SCHEME_CHANGE : strRet = _T("ERROR_INTERNET_REDIRECT_SCHEME_CHANGE ¸®µð·º¼Ç ÀÛ¾÷ Áß ÇÁ·ÎÅäÄÝ ½ºÅ°¸¶°¡ º¯°æµÇ¾ú½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_DIALOG_PENDING : strRet = _T("ERROR_INTERNET_DIALOG_PENDING ´Ù½Ã ½ÃµµÇÒ ¶§±îÁö ´ë±â ÁßÀÎ ÀÛ¾÷ÀÌ ÀÖ½À´Ï´Ù. "); break;
|
case ERROR_INTERNET_RETRY_DIALOG : strRet = _T("ERROR_INTERNET_RETRY_DIALOG ÀÛ¾÷À» ´Ù½Ã ½ÃµµÇØ¾ß ÇÕ´Ï´Ù. "); break;
|
case ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR : strRet = _T("ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR º¸¾È ¿µ¿ª Á¡°Ë¿¡ µû¶ó ÀÌ ÀÛ¾÷Àº ´Ù½Ã ½ÃµµÇØ¾ß ÇÕ´Ï´Ù. "); break;
|
case ERROR_INTERNET_INSERT_CDROM : strRet = _T("ERROR_INTERNET_INSERT_CDROM "); break;
|
case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED : strRet = _T("ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED "); break;
|
case ERROR_INTERNET_SEC_CERT_ERRORS : strRet = _T("ERROR_INTERNET_SEC_CERT_ERRORS "); break;
|
case ERROR_INTERNET_SEC_CERT_NO_REV : strRet = _T("ERROR_INTERNET_SEC_CERT_NO_REV "); break;
|
case ERROR_INTERNET_SEC_CERT_REV_FAILED : strRet = _T("ERROR_INTERNET_SEC_CERT_REV_FAILED "); break;
|
}
|
|
|
return strRet;
|
}
|
|
void CFTPThreadPool::DisplayLogMessage( const CString& strMessage )
|
{
|
if (m_pIFTP2P==NULL) return;
|
|
CSingleLock localLock(&m_csLogIndex);
|
localLock.Lock();
|
|
m_strLogBuffer[m_nCurLogIndex] = strMessage;
|
m_pIFTP2P->IFTP2P_DisplayLogMessage(m_nType, m_nCurLogIndex);
|
|
m_nCurLogIndex = (++m_nCurLogIndex) % MAX_BUFFER_COUNT;
|
}
|
|
void CFTPThreadPool::DisplayResultMessage( BOOL bResult, const CString& strServer, const CString& strLocal )
|
{
|
CString strTemp = _T("");
|
if (bResult)
|
{
|
strTemp = _T("Success! ");
|
}
|
else
|
{
|
strTemp = _T("FAIL! ");
|
}
|
|
CString strMesssage = strTemp+ _T("[Server] ") + strServer;
|
DisplayLogMessage(strMesssage);
|
|
strMesssage = strTemp+ _T("[Local] ") + strLocal;
|
DisplayLogMessage(strMesssage);
|
}
|
|
void CFTPThreadPool::DisplaynNotifyTypeMessage( int nNotifyType, const CString& strMessage )
|
{
|
if (m_pIFTP2P==NULL) return;
|
|
CSingleLock localLock(&m_csLogIndex);
|
localLock.Lock();
|
|
m_strLogBuffer[m_nCurLogIndex] = strMessage;
|
m_pIFTP2P->IFTP2P_DisplayNotifyMessage(m_nType, nNotifyType, m_nCurLogIndex);
|
|
m_nCurLogIndex = (++m_nCurLogIndex) % MAX_BUFFER_COUNT;
|
}
|
|
|
const CString* CFTPThreadPool::GetLogBuffer( int nIndex )
|
{
|
if (nIndex<0 || nIndex>=MAX_BUFFER_COUNT) return NULL;
|
return &m_strLogBuffer[nIndex];
|
}
|
|
const CFTPUploadParam* CFTPThreadPool::GetUploadList( int nIdx )
|
{
|
if (nIdx<0 || nIdx>=(int)m_deqUploadList.size()) return NULL;
|
|
return &(m_deqUploadList.at(nIdx));
|
}
|
|
void CFTPThreadPool::GetUploadList( DeqFTPUploadParam& deqUploadParam )
|
{
|
CSingleLock localLock(&m_csUploadList);
|
localLock.Lock();
|
|
deqUploadParam = m_deqUploadList;
|
}
|
|
void CFTPThreadPool::GetUploadListCountInfo( UINT& nReadyCount, UINT& nProcessCount, UINT& nCompletCount, UINT& nTotalCount )
|
{
|
nReadyCount = (UINT)m_deqUploadList.size();
|
nProcessCount = m_nProcessCount;
|
nCompletCount = m_nCompletCount;
|
nTotalCount = m_nTotalCount;
|
}
|
|
void CFTPThreadPool::NotifyMessage( int nNotifyType, const CString& strUploadPath, const CString& strLocalPath, BOOL bSendErrorCode )
|
{
|
CString strBuffer = _T("");
|
|
switch(nNotifyType)
|
{
|
case eFTPConnection:
|
{
|
strBuffer.Format(_T("FTP Connection - IP[%s] Home[%s]"), strUploadPath, strLocalPath);
|
}
|
break;
|
case eFTPDisConnection:
|
{
|
strBuffer.Format(_T("FTP DisConnection - IP[%s] Home[%s]"), strUploadPath, strLocalPath);
|
}
|
break;
|
case eFTPConnectionFail:
|
{
|
strBuffer.Format(_T("FTP Connection Fail - IP[%s] Home[%s] Error Code[%d - %s] "), strUploadPath, strLocalPath, GetLastError(), GetInternetErrorCodeToString( GetLastError() ) );
|
}
|
break;
|
case eFTPFileUploadSuccess:
|
{
|
strBuffer.Format(_T("!!!FTP Upload Success"));
|
}
|
break;
|
case eFTPFileUploadFail:
|
{
|
strBuffer.Format(_T("FTP Upload Fail Error Code[%d - %s] "), GetLastError(), GetInternetErrorCodeToString( GetLastError() ) );
|
}
|
break;
|
case eFTPFileDownloadSuccess:
|
{
|
strBuffer.Format(_T("!!!FTP Download Success"));
|
}
|
break;
|
case eFTPFileDownloadFail:
|
{
|
strBuffer.Format(_T("FTP Download Fail - Error Code[%d - %s] "), GetLastError(), GetInternetErrorCodeToString( GetLastError() ) );
|
}
|
break;
|
case eFTPError:
|
{
|
strBuffer.Format(_T("FTP Error - [%s] [%s] Error Code[%d - %s] "), strUploadPath, strLocalPath, GetLastError(), GetInternetErrorCodeToString( GetLastError() ) );
|
}
|
break;
|
|
}
|
|
DisplaynNotifyTypeMessage(nNotifyType, strBuffer);
|
}
|