|
// FTPUploaderDlg.cpp : implementation file
|
//
|
|
#include "stdafx.h"
|
#include "FTPUploader.h"
|
#include "FTPUploaderDlg.h"
|
|
#ifdef _DEBUG
|
#define new DEBUG_NEW
|
#endif
|
|
#define WIN_POS_X 100
|
#define WIN_POS_Y 100
|
#define MAX_STACK_COUNT 50000
|
#define MAX_STEP_DEFECT 2000
|
// CAboutDlg dialog used for App About
|
|
class CAboutDlg : public CDialog
|
{
|
public:
|
CAboutDlg();
|
|
// Dialog Data
|
enum { IDD = IDD_ABOUTBOX };
|
|
protected:
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
// Implementation
|
protected:
|
DECLARE_MESSAGE_MAP()
|
};
|
|
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
{
|
}
|
|
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialog::DoDataExchange(pDX);
|
}
|
|
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
END_MESSAGE_MAP()
|
|
|
// CFTPUploaderDlg dialog
|
CFTPUploaderDlg::CFTPUploaderDlg(CWnd* pParent /*=NULL*/)
|
: CDialog(CFTPUploaderDlg::IDD, pParent)
|
, m_strID(_T("admin"))
|
, m_strPW(_T("1"))
|
, m_nTimeOut(1000)
|
, m_strHomePath(_T("/"))
|
, m_nPort(21)
|
, m_bCheckAutoUpload(TRUE)
|
, m_nAutoUploadDelay(100)
|
, m_rtOgrWindow(0,0,0,0)
|
, m_rtAddWindow(0,0,0,0)
|
, m_strID2(_T("admin"))
|
, m_strPW2(_T("1"))
|
, m_nTimeOut2(1000)
|
, m_strHomePath2(_T("/"))
|
, m_nPort2(21)
|
, m_bPassiveMode(FALSE)
|
{
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
m_pFTPThreadPool_Down = NULL;
|
m_pFTPThreadPool_Up = NULL;
|
m_pDlgUploadList_Down = NULL;
|
m_pDlgUploadList_Up = NULL;
|
|
m_nConfigMode = CM_File; //ÆÄÀÏ ÀúÀå ¸ðµå
|
}
|
|
|
CFTPUploaderDlg::~CFTPUploaderDlg()
|
{
|
m_TrayIcon.RemoveIcon();
|
}
|
|
void CFTPUploaderDlg::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialog::DoDataExchange(pDX);
|
DDX_Control(pDX, IDC_LIST_LOG, m_ctlLogList);
|
DDX_Control(pDX, IDC_LIST_LOG_UP, m_ctlLogList_Up);
|
DDX_Control(pDX, IDC_IPADDRESS_HOST, m_ctlIPAddress);
|
DDX_Text(pDX, IDC_EDIT_ID, m_strID);
|
DDX_Text(pDX, IDC_EDIT_PW, m_strPW);
|
DDX_Text(pDX, IDC_EDIT_TIMEOUT, m_nTimeOut);
|
DDX_Text(pDX, IDC_EDIT_HOMEPATH, m_strHomePath);
|
DDX_Text(pDX, IDC_EDIT_PORT, m_nPort);
|
DDX_Check(pDX, IDC_CHECK_AUTO_UPLOAD, m_bCheckAutoUpload);
|
DDX_Text(pDX, IDC_EDIT_ID2, m_nAutoUploadDelay);
|
DDX_Control(pDX, IDC_IPADDRESS_HOST2, m_ctlIPAddress2);
|
DDX_Text(pDX, IDC_EDIT_ID3, m_strID2);
|
DDX_Text(pDX, IDC_EDIT_PW2, m_strPW2);
|
DDX_Text(pDX, IDC_EDIT_PORT2, m_nPort2);
|
DDX_Text(pDX, IDC_EDIT_TIMEOUT2, m_nTimeOut2);
|
DDX_Text(pDX, IDC_EDIT_HOMEPATH2, m_strHomePath2);
|
DDX_Control(pDX, IDC_CHECK_PASSIVE_MODE, m_ctrlPassiveMode);
|
DDX_Control(pDX, IDC_IPADDRESS_HOST3, m_ctlIPAddress3);
|
DDX_Text(pDX, IDC_EDIT_ID4, m_strID3);
|
DDX_Text(pDX, IDC_EDIT_PW3, m_strPW3);
|
DDX_Text(pDX, IDC_EDIT_PORT3, m_nPort3);
|
DDX_Text(pDX, IDC_EDIT_TIMEOUT3, m_nTimeOut3);
|
DDX_Text(pDX, IDC_EDIT_HOMEPATH3, m_strHomePath3);
|
DDX_Control(pDX, IDC_CHECK_WSI, m_chkWSI);
|
}
|
|
BEGIN_MESSAGE_MAP(CFTPUploaderDlg, CDialog)
|
ON_WM_SYSCOMMAND()
|
ON_WM_PAINT()
|
ON_WM_QUERYDRAGICON()
|
//}}AFX_MSG_MAP
|
ON_WM_DESTROY()
|
ON_MESSAGE(UM_FTP_LOG, &CFTPUploaderDlg::OnFTPLog)
|
ON_MESSAGE(UM_FTP_LOG_UP, &CFTPUploaderDlg::OnFTPLog_Up)
|
ON_MESSAGE(UM_FTP_NOTIFY_LOG, &CFTPUploaderDlg::OnFTPNotifyLog)
|
ON_MESSAGE(UM_FTP_NOTIFY_LOG_UP, &CFTPUploaderDlg::OnFTPNotifyLog_Up)
|
ON_MESSAGE(WM_ICON_NOTIFY, &CFTPUploaderDlg::OnTrayNotification)
|
ON_BN_CLICKED(IDC_BUTTON_TEST, &CFTPUploaderDlg::OnBnClickedButtonTest)
|
ON_WM_TIMER()
|
ON_BN_CLICKED(IDC_BUTTON_CONFIG_SAVE, &CFTPUploaderDlg::OnBnClickedButtonConfigSave)
|
ON_WM_COPYDATA()
|
ON_BN_CLICKED(IDC_CHECK_AUTO_UPLOAD, &CFTPUploaderDlg::OnBnClickedCheckAutoUpload)
|
ON_WM_CLOSE()
|
ON_WM_CREATE()
|
ON_COMMAND(ID_FILE_OPEN, &CFTPUploaderDlg::OnFileOpen)
|
ON_COMMAND(ID_FILE_CLOSE, &CFTPUploaderDlg::OnFileClose)
|
ON_BN_CLICKED(IDC_BUTTON_DOWNLOAD_LIST, &CFTPUploaderDlg::OnBnClickedButtonDownloadList)
|
ON_BN_CLICKED(IDC_BUTTON_UPLOAD_LIST, &CFTPUploaderDlg::OnBnClickedButtonUploadList)
|
END_MESSAGE_MAP()
|
|
|
// CFTPUploaderDlg message handlers
|
|
BOOL CFTPUploaderDlg::OnInitDialog()
|
{
|
CDialog::OnInitDialog();
|
|
// Add "About..." menu item to system menu.
|
|
// IDM_ABOUTBOX must be in the system command range.
|
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
ASSERT(IDM_ABOUTBOX < 0xF000);
|
|
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
if (pSysMenu != NULL)
|
{
|
BOOL bNameValid;
|
CString strAboutMenu;
|
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
|
ASSERT(bNameValid);
|
if (!strAboutMenu.IsEmpty())
|
{
|
pSysMenu->AppendMenu(MF_SEPARATOR);
|
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
}
|
}
|
|
// Set the icon for this dialog. The framework does this automatically
|
// when the application's main window is not a dialog
|
SetIcon(m_hIcon, TRUE); // Set big icon
|
SetIcon(m_hIcon, FALSE); // Set small icon
|
|
// ¼¼ÆÃ °ª ·ÎµùÇϱâ
|
LoadConfig();
|
|
// ¼¼ÆÃ °ªÀ¸·Î ÄÁÆ®·Ñ ¾÷µ¥ÀÌÆ®
|
BYTE chIP[4] = {0,};
|
m_ctlIPAddress.GetAddress(chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
CString strIP = _T("");
|
strIP.Format(_T("%d.%d.%d.%d"),chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
m_ctlIPAddress2.GetAddress(chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
CString strIP2 = _T("");
|
strIP2.Format(_T("%d.%d.%d.%d"),chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
//201218 CJH - Download¿ë IP Ãß°¡
|
m_ctlIPAddress3.GetAddress(chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
CString strIP3 = _T("");
|
strIP3.Format(_T("%d.%d.%d.%d"),chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
m_ctrlPassiveMode.SetCheck(m_bPassiveMode);
|
|
m_chkWSI.SetCheck(m_bWSIChk);
|
|
// FTP ¾²·¹µåÇ® ¸¸µé±â
|
m_pFTPThreadPool_Down = new CFTPThreadPool(FTPThreadType_Download, 50);
|
if (m_pFTPThreadPool_Down)
|
{
|
m_pFTPThreadPool_Down->SetIFTP2P(this);
|
m_pFTPThreadPool_Down->SetConnectionInfo(strIP,m_strID,m_strPW,m_nPort,m_nTimeOut,m_strHomePath,strIP2,m_strID2,m_strPW2,m_nPort2,m_nTimeOut2,m_strHomePath2, strIP3,m_strID3,m_strPW3,m_nPort3,m_nTimeOut3,m_strHomePath3, m_bPassiveMode, m_bWSIChk);
|
m_pFTPThreadPool_Down->StartThread();
|
}
|
|
// FTP ¾²·¹µåÇ® ¸¸µé±â
|
m_pFTPThreadPool_Up = new CFTPThreadPool(FTPThreadType_Upload, 50);
|
if (m_pFTPThreadPool_Up)
|
{
|
m_pFTPThreadPool_Up->SetIFTP2P(this);
|
m_pFTPThreadPool_Up->SetConnectionInfo(strIP,m_strID,m_strPW,m_nPort,m_nTimeOut,m_strHomePath,strIP2,m_strID2,m_strPW2,m_nPort2,m_nTimeOut2,m_strHomePath2, strIP3,m_strID3,m_strPW3,m_nPort3,m_nTimeOut3,m_strHomePath3, m_bPassiveMode, m_bWSIChk);
|
m_pFTPThreadPool_Up->StartThread();
|
}
|
|
m_pDlgUploadList_Down = new CDlgUploadList(FTPThreadType_Download, this);
|
if(m_pDlgUploadList_Down)
|
{
|
m_pDlgUploadList_Down->SetIDUL2P(this);
|
m_pDlgUploadList_Down->Create(IDD_DLG_UPLOAD_LIST, this);
|
}
|
|
m_pDlgUploadList_Up = new CDlgUploadList(FTPThreadType_Upload, this);
|
if(m_pDlgUploadList_Up)
|
{
|
m_pDlgUploadList_Up->SetIDUL2P(this);
|
m_pDlgUploadList_Up->Create(IDD_DLG_UPLOAD_LIST, this);
|
}
|
|
// °ü·Ã Æú´õ »ý¼º
|
CreatePathDir(FTP_LOG_FILE_PATH);
|
CreatePathDir(BLANK_UPDOWNLOAD_PATH);
|
{
|
int nIndex = 0;
|
SYSTEMTIME st;
|
GetLocalTime(&st);
|
TCHAR strFileName[MAX_PATH];
|
|
_stprintf_s(strFileName, _T("%s\\%02d%02d%02d\\"),
|
FTP_LOG_FILE_PATH,
|
st.wYear, st.wMonth, st.wDay);
|
if( GetFileAttributes( strFileName ) == INVALID_FILE_ATTRIBUTES ) CreateDirectory(strFileName, NULL);
|
}
|
|
// LOG ÆÄÀÏ ¾²±â ŸÀÌ¸Ó È£Ãâ
|
SetTimer(TIMER_SAVE_LOG_FILE, 1000, NULL);
|
|
// Blank Timer set
|
if (m_bCheckAutoUpload)
|
{
|
Process_BlankFileCreate();
|
SetTimer(TIMER_BLANK_UPDOWNLOAD, m_nAutoUploadDelay*1000, NULL);
|
}
|
|
// FTP ¾÷·Î´õ È£Ãâ
|
SetTimer(TIMER_FTP_UPLOAD_INFO, 200, NULL);
|
|
// Æ®·¡ÀÌ ¾ÆÀÌÄÜ »èÁ¦
|
m_TrayIcon.HideIcon();
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
}
|
|
BOOL CFTPUploaderDlg::CreatePathDir(const CString& strFilename)
|
{
|
CString csPrefix(_T("")), csToken(_T(""));
|
int nStart = 0, nEnd;
|
CFileFind filefinder;
|
CString strDirPath = strFilename;
|
BOOL bResult = FALSE;
|
while( (nEnd = strFilename.Find('\\', nStart)) >= 0)
|
{
|
csToken = strFilename.Mid(nStart, nEnd-nStart);
|
CreateDirectory(csPrefix + csToken, NULL);
|
|
csPrefix += csToken;
|
csPrefix += _T("\\");
|
nStart = nEnd+1;
|
}
|
strDirPath = strDirPath.Left(strDirPath.ReverseFind('\\'));
|
bResult = filefinder.FindFile(strDirPath,NULL);
|
|
return bResult;
|
}
|
|
|
void CFTPUploaderDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
{
|
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
{
|
CAboutDlg dlgAbout;
|
dlgAbout.DoModal();
|
}
|
else
|
{
|
CDialog::OnSysCommand(nID, lParam);
|
}
|
}
|
|
// If you add a minimize button to your dialog, you will need the code below
|
// to draw the icon. For MFC applications using the document/view model,
|
// this is automatically done for you by the framework.
|
|
void CFTPUploaderDlg::OnPaint()
|
{
|
if (IsIconic())
|
{
|
CPaintDC dc(this); // device context for painting
|
|
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
|
// Center icon in client rectangle
|
int cxIcon = GetSystemMetrics(SM_CXICON);
|
int cyIcon = GetSystemMetrics(SM_CYICON);
|
CRect rect;
|
GetClientRect(&rect);
|
int x = (rect.Width() - cxIcon + 1) / 2;
|
int y = (rect.Height() - cyIcon + 1) / 2;
|
|
// Draw the icon
|
dc.DrawIcon(x, y, m_hIcon);
|
}
|
else
|
{
|
CDialog::OnPaint();
|
}
|
}
|
|
// The system calls this function to obtain the cursor to display while the user drags
|
// the minimized window.
|
HCURSOR CFTPUploaderDlg::OnQueryDragIcon()
|
{
|
return static_cast<HCURSOR>(m_hIcon);
|
}
|
|
|
int CFTPUploaderDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
{
|
if (__super::OnCreate(lpCreateStruct) == -1)
|
return -1;
|
|
// Æ®·¹ÀÌ ¾ÆÀÌÄÜ µî·Ï
|
if (!m_TrayIcon.Create(this, WM_ICON_NOTIFY, _T("FTPUploader"), NULL, IDR_MENU_TRAY))
|
return -1;
|
|
// ¾ÆÀÌÄÜ ¼³Á¤ : ¾ÆÀÌÄܾÆÀ̵𿡠ÀÚ½ÅÀÇ ¾ÆÀÌÄÜÀ» ³ÖÀ¸¼¼¿ä...
|
m_TrayIcon.SetIcon(IDR_MAINFRAME);
|
|
return 0;
|
}
|
|
void CFTPUploaderDlg::OnDestroy()
|
{
|
CDialog::OnDestroy();
|
|
// TODO: Add your message handler code here
|
KillTimer(TIMER_FTP_UPLOAD_INFO);
|
|
|
KillTimer(TIMER_SAVE_LOG_FILE);
|
|
|
KillTimer(TIMER_BLANK_UPDOWNLOAD);
|
|
|
if(m_pFTPThreadPool_Down)
|
{
|
m_pFTPThreadPool_Down->StopThread();
|
delete m_pFTPThreadPool_Down;
|
m_pFTPThreadPool_Down = NULL;
|
}
|
|
if(m_pFTPThreadPool_Up)
|
{
|
m_pFTPThreadPool_Up->StopThread();
|
delete m_pFTPThreadPool_Up;
|
m_pFTPThreadPool_Up = NULL;
|
}
|
|
if (m_pDlgUploadList_Down)
|
{
|
m_pDlgUploadList_Down->DestroyWindow();
|
delete m_pDlgUploadList_Down;
|
m_pDlgUploadList_Down = NULL;
|
}
|
|
if (m_pDlgUploadList_Up)
|
{
|
m_pDlgUploadList_Up->DestroyWindow();
|
delete m_pDlgUploadList_Up;
|
m_pDlgUploadList_Up = NULL;
|
}
|
}
|
|
LRESULT CFTPUploaderDlg::OnFTPLog( WPARAM wParam, LPARAM lParam )
|
{
|
CSingleLock localLock(&m_csFTPLog);
|
localLock.Lock();
|
|
CString *pStrLogMessage = (CString*)(wParam);
|
|
int nCount;
|
CTime time;
|
CString strStamp, strLog;
|
|
nCount = m_ctlLogList.GetCount();
|
if (nCount % 500 == 0)
|
{
|
m_ctlLogList.ResetContent();
|
}
|
|
time = CTime::GetCurrentTime();
|
strStamp.Format(_T("[%02d:%02d:%02d]"), time.GetHour(), time.GetMinute(), time.GetSecond());
|
strLog.Format(_T("%s %s"), strStamp, pStrLogMessage->GetBuffer());
|
m_ctlLogList.AddString(strLog);
|
m_ctlLogList.SetCurSel(m_ctlLogList.GetCount()-1);
|
|
// add log vector
|
strLog += _T("\n");
|
m_vecFTPLog.push_back(strLog);
|
|
return 0;
|
}
|
|
|
LRESULT CFTPUploaderDlg::OnFTPLog_Up( WPARAM wParam, LPARAM lParam )
|
{
|
CSingleLock localLock(&m_csFTPLog);
|
localLock.Lock();
|
|
CString *pStrLogMessage = (CString*)(wParam);
|
|
int nCount;
|
CTime time;
|
CString strStamp, strLog;
|
|
nCount = m_ctlLogList_Up.GetCount();
|
if (nCount % 500 == 0)
|
{
|
m_ctlLogList_Up.ResetContent();
|
}
|
|
time = CTime::GetCurrentTime();
|
strStamp.Format(_T("[%02d:%02d:%02d]"), time.GetHour(), time.GetMinute(), time.GetSecond());
|
strLog.Format(_T("%s %s"), strStamp, pStrLogMessage->GetBuffer());
|
m_ctlLogList_Up.AddString(strLog);
|
m_ctlLogList_Up.SetCurSel(m_ctlLogList_Up.GetCount()-1);
|
|
// add log vector
|
strLog += _T("\n");
|
m_vecFTPLog.push_back(strLog);
|
|
return 0;
|
}
|
|
LRESULT CFTPUploaderDlg::OnFTPNotifyLog( WPARAM wParam, LPARAM lParam )
|
{
|
CSingleLock localLock(&m_csFTPLog);
|
localLock.Lock();
|
|
CString *pStrLogMessage = (CString*)(wParam);
|
|
int nCount;
|
CTime time;
|
CString strStamp, strLog;
|
|
nCount = m_ctlLogList.GetCount();
|
if (nCount % 500 == 0)
|
{
|
m_ctlLogList.ResetContent();
|
}
|
|
time = CTime::GetCurrentTime();
|
strStamp.Format(_T("[%02d:%02d:%02d]"), time.GetHour(), time.GetMinute(), time.GetSecond());
|
strLog.Format(_T("%s %s"), strStamp, pStrLogMessage->GetBuffer());
|
m_ctlLogList.AddString(strLog);
|
m_ctlLogList.SetCurSel(m_ctlLogList.GetCount()-1);
|
|
// add log vector
|
strLog += _T("\n");
|
m_vecFTPFailLog.push_back(strLog);
|
|
return 0;
|
}
|
|
LRESULT CFTPUploaderDlg::OnFTPNotifyLog_Up( WPARAM wParam, LPARAM lParam )
|
{
|
CSingleLock localLock(&m_csFTPLog);
|
localLock.Lock();
|
|
CString *pStrLogMessage = (CString*)(wParam);
|
|
int nCount;
|
CTime time;
|
CString strStamp, strLog;
|
|
nCount = m_ctlLogList_Up.GetCount();
|
if (nCount % 500 == 0)
|
{
|
m_ctlLogList_Up.ResetContent();
|
}
|
|
time = CTime::GetCurrentTime();
|
strStamp.Format(_T("[%02d:%02d:%02d]"), time.GetHour(), time.GetMinute(), time.GetSecond());
|
strLog.Format(_T("%s %s"), strStamp, pStrLogMessage->GetBuffer());
|
m_ctlLogList_Up.AddString(strLog);
|
m_ctlLogList_Up.SetCurSel(m_ctlLogList_Up.GetCount()-1);
|
|
// add log vector
|
strLog += _T("\n");
|
m_vecFTPFailLog.push_back(strLog);
|
|
return 0;
|
}
|
|
|
LRESULT CFTPUploaderDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
|
{
|
// Delegate all the work back to the default implementation in CTrayIcon.
|
|
return m_TrayIcon.OnTrayNotification(wParam, lParam);
|
}
|
|
void CFTPUploaderDlg::Process_BlankFileCreate()
|
{
|
CString strTestFile = _T("");
|
CString strSubFolder = _T("LotHistory");
|
|
FILE *fp = NULL;
|
|
strTestFile = BLANK_DOWNLOAD_FILE;
|
strTestFile = _T("\\") + strTestFile;
|
strTestFile = BLANK_UPDOWNLOAD_PATH + strTestFile;
|
|
_tfopen_s(&fp, strTestFile, _T("w"));
|
if (fp)
|
{
|
_ftprintf_s(fp, _T("DOWN TEST FILE"));
|
fclose(fp);
|
fp = NULL;
|
}
|
|
// download
|
CFTPCopyDataParam downParam;
|
_stprintf_s(downParam.m_strServer_FolderName, strSubFolder);
|
_stprintf_s(downParam.m_strServer_FileName, BLANK_DOWNLOAD_FILE);
|
_stprintf_s(downParam.m_strLocal_FolderName, BLANK_UPDOWNLOAD_PATH);
|
_stprintf_s(downParam.m_strLocal_FileName, BLANK_DOWNLOAD_FILE);
|
downParam.m_nProcessType = FTPProcessType_UpFile;
|
AddUpload(&downParam);
|
|
|
strTestFile = BLANK_UPLOAD_FILE;
|
strTestFile = _T("\\") + strTestFile;
|
strTestFile = BLANK_UPDOWNLOAD_PATH + strTestFile;
|
_tfopen_s(&fp, strTestFile, _T("w"));
|
if (fp)
|
{
|
_ftprintf_s(fp, _T("UPLOAD TEST FILE"));
|
fclose(fp);
|
fp = NULL;
|
}
|
|
// upload
|
CFTPCopyDataParam upParam;
|
_stprintf_s(upParam.m_strServer_FolderName, strSubFolder);
|
_stprintf_s(upParam.m_strServer_FileName, BLANK_UPLOAD_FILE);
|
_stprintf_s(upParam.m_strLocal_FolderName, BLANK_UPDOWNLOAD_PATH);
|
_stprintf_s(upParam.m_strLocal_FileName, BLANK_UPLOAD_FILE);
|
upParam.m_nProcessType = FTPProcessType_UpFile;
|
AddUpload(&upParam);
|
|
}
|
|
void CFTPUploaderDlg::Process_BlankUpDownload()
|
{
|
CString strTestFile = _T("");
|
CString strSubFolder = _T("LotHistory");
|
|
// down
|
if (m_pFTPThreadPool_Down->GetUploadListCount()<1)
|
{
|
strTestFile = BLANK_DOWNLOAD_FILE;
|
strTestFile = BLANK_UPDOWNLOAD_PATH + strTestFile;
|
|
CFTPCopyDataParam downParam;
|
_stprintf_s(downParam.m_strServer_FolderName, strSubFolder);
|
_stprintf_s(downParam.m_strServer_FileName, BLANK_DOWNLOAD_FILE);
|
_stprintf_s(downParam.m_strLocal_FolderName, BLANK_UPDOWNLOAD_PATH);
|
_stprintf_s(downParam.m_strLocal_FileName, BLANK_DOWNLOAD_FILE);
|
downParam.m_nProcessType = FTPProcessType_DownFile;
|
|
AddDownload(&downParam);
|
}
|
|
// up
|
if (m_pFTPThreadPool_Up->GetUploadListCount()<1)
|
{
|
strTestFile = BLANK_UPLOAD_FILE;
|
strTestFile = BLANK_UPDOWNLOAD_PATH + strTestFile;
|
|
CFTPCopyDataParam upParam;
|
_stprintf_s(upParam.m_strServer_FolderName, strSubFolder);
|
_stprintf_s(upParam.m_strServer_FileName, BLANK_UPLOAD_FILE);
|
_stprintf_s(upParam.m_strLocal_FolderName, BLANK_UPDOWNLOAD_PATH);
|
_stprintf_s(upParam.m_strLocal_FileName, BLANK_UPLOAD_FILE);
|
upParam.m_nProcessType = FTPProcessType_UpFile;
|
|
AddUpload(&upParam);
|
}
|
|
}
|
|
void CFTPUploaderDlg::OnBnClickedButtonTest()
|
{
|
// TODO: Add your control notification handler code here
|
UpdateData(TRUE);
|
|
BYTE chIP[4] = {0,};
|
m_ctlIPAddress.GetAddress(chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
CString strIP = _T("");
|
strIP.Format(_T("%d.%d.%d.%d"),chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
m_ctlIPAddress2.GetAddress(chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
CString strIP2 = _T("");
|
strIP2.Format(_T("%d.%d.%d.%d"),chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
m_ctlIPAddress3.GetAddress(chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
CString strIP3 = _T("");
|
strIP3.Format(_T("%d.%d.%d.%d"),chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
m_bWSIChk = m_chkWSI.GetCheck();
|
|
m_pFTPThreadPool_Down->SetConnectionInfo(strIP,m_strID,m_strPW,m_nPort,m_nTimeOut,m_strHomePath,strIP2,m_strID2,m_strPW2,m_nPort2,m_nTimeOut2,m_strHomePath2, strIP3, m_strID3, m_strPW3, m_nPort3, m_nTimeOut3, m_strHomePath3, m_bPassiveMode, m_bWSIChk);
|
m_pFTPThreadPool_Up->SetConnectionInfo(strIP,m_strID,m_strPW,m_nPort,m_nTimeOut,m_strHomePath,strIP2,m_strID2,m_strPW2,m_nPort2,m_nTimeOut2,m_strHomePath2,strIP3, m_strID3, m_strPW3, m_nPort3, m_nTimeOut3, m_strHomePath3, m_bPassiveMode, m_bWSIChk);
|
|
CString strTestFile = _T("");
|
CString strSubFolder = _T("LotHistory");
|
|
// down
|
strTestFile = BLANK_DOWNLOAD_FILE;
|
strTestFile = BLANK_UPDOWNLOAD_PATH + strTestFile;
|
CFTPCopyDataParam downParam;
|
_stprintf_s(downParam.m_strServer_FolderName, strSubFolder);
|
_stprintf_s(downParam.m_strServer_FileName, BLANK_DOWNLOAD_FILE);
|
_stprintf_s(downParam.m_strLocal_FolderName, BLANK_UPDOWNLOAD_PATH);
|
_stprintf_s(downParam.m_strLocal_FileName, BLANK_DOWNLOAD_FILE);
|
downParam.m_nProcessType = FTPProcessType_DownFile;
|
|
// up
|
strTestFile = BLANK_UPLOAD_FILE;
|
strTestFile = BLANK_UPDOWNLOAD_PATH + strTestFile;
|
CFTPCopyDataParam upParam;
|
_stprintf_s(upParam.m_strServer_FolderName, strSubFolder);
|
_stprintf_s(upParam.m_strServer_FileName, BLANK_UPLOAD_FILE);
|
_stprintf_s(upParam.m_strLocal_FolderName, BLANK_UPDOWNLOAD_PATH);
|
_stprintf_s(upParam.m_strLocal_FileName, BLANK_UPLOAD_FILE);
|
upParam.m_nProcessType = FTPProcessType_UpFile;
|
|
for (int nIdx=0; nIdx<m_nAutoUploadDelay; nIdx++)
|
{
|
// down
|
AddDownload(&downParam);
|
|
// up
|
AddUpload(&upParam);
|
|
::Sleep(50);
|
}
|
|
}
|
|
void CFTPUploaderDlg::OnTimer(UINT_PTR nIDEvent)
|
{
|
// TODO: Add your message handler code here and/or call default
|
switch(nIDEvent)
|
{
|
case TIMER_BLANK_UPDOWNLOAD:
|
Process_BlankUpDownload();
|
break;
|
|
case TIMER_SAVE_LOG_FILE:
|
Process_SaveFTPLog();
|
break;
|
|
case TIMER_FTP_UPLOAD_INFO:
|
Process_FtpUploaderInfo();
|
break;
|
}
|
|
CDialog::OnTimer(nIDEvent);
|
}
|
|
void CFTPUploaderDlg::AddUpload( const CFTPCopyDataParam* pParam )
|
{
|
if (m_pFTPThreadPool_Up)
|
{
|
CFTPUploadParam uploadParam;
|
CFTPCopyDataParam *pUploadParam = &uploadParam;
|
*pUploadParam = *pParam;
|
m_pFTPThreadPool_Up->AddUploadParam(uploadParam);
|
}
|
}
|
|
void CFTPUploaderDlg::AddDownload( const CFTPCopyDataParam* pParam )
|
{
|
if (m_pFTPThreadPool_Down)
|
{
|
CFTPUploadParam uploadParam;
|
CFTPCopyDataParam *pUploadParam = &uploadParam;
|
*pUploadParam = *pParam;
|
m_pFTPThreadPool_Down->AddUploadParam(uploadParam);
|
}
|
}
|
|
BOOL CFTPUploaderDlg::LoadConfig()
|
{
|
char strRegBuf[255] = {0,};
|
|
|
if(m_nConfigMode == CM_File)
|
{
|
m_fileConfig.clear();
|
m_fileConfig.openfile(CONFIGFILENAME);
|
}
|
|
|
// ID
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("ID"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"admin");
|
}
|
|
m_strID = (CString)(CStringA)strRegBuf;
|
|
|
// PW
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("PW"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"1234");
|
}
|
|
m_strPW = (CString)(CStringA)strRegBuf;
|
|
// HOME Path
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("HOME"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"/");
|
}
|
|
m_strHomePath = (CString)(CStringA)strRegBuf;
|
|
// Port
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("PORT"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"21");
|
}
|
|
m_nPort = _tstoi( (CString)(CStringA)strRegBuf );
|
|
// TimeOut
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("TIMEOUT"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"5000");
|
}
|
|
m_nTimeOut = _tstoi( (CString)(CStringA)strRegBuf );
|
|
// IP
|
BYTE chIP[4] = {0,};
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP_0"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP[0] = _tstoi( (CString)(CStringA)strRegBuf );
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP_1"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP[1] = _tstoi( (CString)(CStringA)strRegBuf );
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP_2"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP[2] = _tstoi( (CString)(CStringA)strRegBuf );
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP_3"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP[3] = _tstoi( (CString)(CStringA)strRegBuf );
|
|
m_ctlIPAddress.SetAddress(chIP[0], chIP[1], chIP[2], chIP[3]);
|
|
//////////////////////////////////////////////////////////////////////////
|
// ID2
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("ID2"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"admin");
|
}
|
|
m_strID2 = (CString)(CStringA)strRegBuf;
|
|
|
// PW2
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("PW2"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"1234");
|
}
|
|
m_strPW2 = (CString)(CStringA)strRegBuf;
|
|
// HOME Path2
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("HOME2"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"/");
|
}
|
|
m_strHomePath2 = (CString)(CStringA)strRegBuf;
|
|
// Port2
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("PORT2"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"21");
|
}
|
|
m_nPort2 = _tstoi( (CString)(CStringA)strRegBuf );
|
|
// TimeOut2
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("TIMEOUT2"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"5000");
|
}
|
|
m_nTimeOut2 = _tstoi( (CString)(CStringA)strRegBuf );
|
|
// IP2
|
BYTE chIP2[4] = {0,};
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP2_0"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP2[0] = _tstoi( (CString)(CStringA)strRegBuf );
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP2_1"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP2[1] = _tstoi( (CString)(CStringA)strRegBuf );
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP2_2"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP2[2] = _tstoi( (CString)(CStringA)strRegBuf );
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP2_3"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP2[3] = _tstoi( (CString)(CStringA)strRegBuf );
|
m_ctlIPAddress2.SetAddress(chIP2[0], chIP2[1], chIP2[2], chIP2[3]);
|
|
//201218 CJH - IP Ãß°¡
|
//////////////////////////////////////////////////////////////////////////
|
// ID3
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("ID3"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"admin");
|
}
|
|
m_strID3 = (CString)(CStringA)strRegBuf;
|
|
|
// PW3
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("PW3"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"1234");
|
}
|
|
m_strPW3 = (CString)(CStringA)strRegBuf;
|
|
// HOME Path3
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("HOME3"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"/");
|
}
|
|
m_strHomePath3 = (CString)(CStringA)strRegBuf;
|
|
// Port3
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("PORT3"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"21");
|
}
|
|
m_nPort3 = _tstoi( (CString)(CStringA)strRegBuf );
|
|
// TimeOut3
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("TIMEOUT3"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"5000");
|
}
|
|
m_nTimeOut3 = _tstoi( (CString)(CStringA)strRegBuf );
|
|
// IP3
|
BYTE chIP3[4] = {0,};
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP3_0"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP3[0] = _tstoi( (CString)(CStringA)strRegBuf );
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP3_1"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP3[1] = _tstoi( (CString)(CStringA)strRegBuf );
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP3_2"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP3[2] = _tstoi( (CString)(CStringA)strRegBuf );
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("IP3_3"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"0");
|
}
|
chIP3[3] = _tstoi( (CString)(CStringA)strRegBuf );
|
m_ctlIPAddress3.SetAddress(chIP3[0], chIP3[1], chIP3[2], chIP3[3]);
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Auto Upload
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("AUTO_UPLOAD"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"1");
|
}
|
|
m_bCheckAutoUpload = (BOOL)_tstoi( (CString)(CStringA)strRegBuf );
|
|
// Auto Upload Delay
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("AUTO_UPLOAD_DELAY"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"5");
|
}
|
|
m_nAutoUploadDelay = _tstol( (CString)(CStringA)strRegBuf );
|
|
// Passive mode
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("PASSIVE_MODE"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"5");
|
}
|
|
m_bPassiveMode = _tstoi( (CString)(CStringA)strRegBuf );
|
|
// WSI USE
|
memset(strRegBuf,0,sizeof(char)*255);
|
if(ReadString(SHCU,KEY_FTP,_T("WSI_USE"),(LPBYTE)strRegBuf,255) == FALSE)
|
{
|
strcpy_s(strRegBuf,sizeof(char)*255,"5");
|
}
|
|
m_bWSIChk = _tstoi( (CString)(CStringA)strRegBuf );
|
|
UpdateData(FALSE);
|
return TRUE;
|
}
|
|
|
void CFTPUploaderDlg::OnBnClickedButtonConfigSave()
|
{
|
// TODO: Add your control notification handler code here
|
UpdateData(TRUE);
|
|
if(m_nConfigMode == CM_File)
|
{
|
m_fileConfig.clear();
|
}
|
|
char strRegBuf[255] = {0,};
|
|
// ID
|
sprintf_s(strRegBuf, sizeof(char)*255, "%s",(CStringA)m_strID);
|
WriteString(SHCU,KEY_FTP,_T("ID"),strRegBuf);
|
|
// PW
|
sprintf_s(strRegBuf, sizeof(char)*255, "%s",(CStringA)m_strPW);
|
WriteString(SHCU,KEY_FTP,_T("PW"),strRegBuf);
|
|
// HOME Path
|
sprintf_s(strRegBuf, sizeof(char)*255, "%s",(CStringA)m_strHomePath);
|
WriteString(SHCU,KEY_FTP,_T("HOME"),strRegBuf);
|
|
// Port
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d",m_nPort);
|
WriteString(SHCU,KEY_FTP,_T("PORT"),strRegBuf);
|
|
// TimeOut
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d",m_nTimeOut);
|
WriteString(SHCU,KEY_FTP,_T("TIMEOUT"),strRegBuf);
|
|
// IP
|
BYTE chIP[4] = {0,};
|
m_ctlIPAddress.GetAddress(chIP[0],chIP[1],chIP[2],chIP[3]);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP[0]);
|
WriteString(SHCU,KEY_FTP,_T("IP_0"),strRegBuf);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP[1]);
|
WriteString(SHCU,KEY_FTP,_T("IP_1"),strRegBuf);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP[2]);
|
WriteString(SHCU,KEY_FTP,_T("IP_2"),strRegBuf);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP[3]);
|
WriteString(SHCU,KEY_FTP,_T("IP_3"),strRegBuf);
|
|
//////////////////////////////////////////////////////////////////////////
|
// ID2
|
sprintf_s(strRegBuf, sizeof(char)*255, "%s",(CStringA)m_strID2);
|
WriteString(SHCU,KEY_FTP,_T("ID2"),strRegBuf);
|
|
// PW2
|
sprintf_s(strRegBuf, sizeof(char)*255, "%s",(CStringA)m_strPW2);
|
WriteString(SHCU,KEY_FTP,_T("PW2"),strRegBuf);
|
|
// HOME Path2
|
sprintf_s(strRegBuf, sizeof(char)*255, "%s",(CStringA)m_strHomePath2);
|
WriteString(SHCU,KEY_FTP,_T("HOME2"),strRegBuf);
|
|
// Port2
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d",m_nPort2);
|
WriteString(SHCU,KEY_FTP,_T("PORT2"),strRegBuf);
|
|
// TimeOut2
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d",m_nTimeOut2);
|
WriteString(SHCU,KEY_FTP,_T("TIMEOUT2"),strRegBuf);
|
|
// IP2
|
BYTE chIP2[4] = {0,};
|
m_ctlIPAddress2.GetAddress(chIP2[0],chIP2[1],chIP2[2],chIP2[3]);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP2[0]);
|
WriteString(SHCU,KEY_FTP,_T("IP2_0"),strRegBuf);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP2[1]);
|
WriteString(SHCU,KEY_FTP,_T("IP2_1"),strRegBuf);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP2[2]);
|
WriteString(SHCU,KEY_FTP,_T("IP2_2"),strRegBuf);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP2[3]);
|
WriteString(SHCU,KEY_FTP,_T("IP2_3"),strRegBuf);
|
|
//201218 CJH - Download¿ë IP Ãß°¡
|
//////////////////////////////////////////////////////////////////////////
|
// ID3
|
sprintf_s(strRegBuf, sizeof(char)*255, "%s",(CStringA)m_strID3);
|
WriteString(SHCU,KEY_FTP,_T("ID3"),strRegBuf);
|
|
// PW3
|
sprintf_s(strRegBuf, sizeof(char)*255, "%s",(CStringA)m_strPW3);
|
WriteString(SHCU,KEY_FTP,_T("PW3"),strRegBuf);
|
|
// HOME Path3
|
sprintf_s(strRegBuf, sizeof(char)*255, "%s",(CStringA)m_strHomePath3);
|
WriteString(SHCU,KEY_FTP,_T("HOME3"),strRegBuf);
|
|
// Port3
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d",m_nPort3);
|
WriteString(SHCU,KEY_FTP,_T("PORT3"),strRegBuf);
|
|
// TimeOut3
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d",m_nTimeOut3);
|
WriteString(SHCU,KEY_FTP,_T("TIMEOUT3"),strRegBuf);
|
|
// IP3
|
BYTE chIP3[4] = {0,};
|
m_ctlIPAddress3.GetAddress(chIP3[0],chIP3[1],chIP3[2],chIP3[3]);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP3[0]);
|
WriteString(SHCU,KEY_FTP,_T("IP3_0"),strRegBuf);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP3[1]);
|
WriteString(SHCU,KEY_FTP,_T("IP3_1"),strRegBuf);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP3[2]);
|
WriteString(SHCU,KEY_FTP,_T("IP3_2"),strRegBuf);
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d", chIP3[3]);
|
WriteString(SHCU,KEY_FTP,_T("IP3_3"),strRegBuf);
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Auto Upload
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d",(int)m_bCheckAutoUpload);
|
WriteString(SHCU,KEY_FTP,_T("AUTO_UPLOAD"),strRegBuf);
|
|
// Auto Upload Delay
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d",m_nAutoUploadDelay);
|
WriteString(SHCU,KEY_FTP,_T("AUTO_UPLOAD_DELAY"),strRegBuf);
|
|
// Passive Mode
|
m_bPassiveMode = m_ctrlPassiveMode.GetCheck();
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d",m_bPassiveMode);
|
WriteString(SHCU,KEY_FTP,_T("PASSIVE_MODE"),strRegBuf);
|
|
// WSI USE
|
m_bWSIChk = m_chkWSI.GetCheck();
|
sprintf_s(strRegBuf, sizeof(char)*255, "%d",m_bWSIChk);
|
WriteString(SHCU,KEY_FTP,_T("WSI_USE"),strRegBuf);
|
|
m_ctlIPAddress.GetAddress(chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
CString strIP = _T("");
|
strIP.Format(_T("%d.%d.%d.%d"),chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
m_ctlIPAddress2.GetAddress(chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
CString strIP2 = _T("");
|
strIP2.Format(_T("%d.%d.%d.%d"),chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
m_ctlIPAddress3.GetAddress(chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
CString strIP3 = _T("");
|
strIP3.Format(_T("%d.%d.%d.%d"),chIP[0],chIP[1],chIP[2],chIP[3]);
|
|
m_pFTPThreadPool_Down->SetConnectionInfo(strIP,m_strID,m_strPW,m_nPort,m_nTimeOut,m_strHomePath,strIP2,m_strID2,m_strPW2,m_nPort2,m_nTimeOut2,m_strHomePath2,strIP3,m_strID3,m_strPW3,m_nPort3,m_nTimeOut3,m_strHomePath3, m_bPassiveMode, m_bWSIChk);
|
m_pFTPThreadPool_Up->SetConnectionInfo(strIP,m_strID,m_strPW,m_nPort,m_nTimeOut,m_strHomePath,strIP2,m_strID2,m_strPW2,m_nPort2,m_nTimeOut2,m_strHomePath2,strIP3,m_strID3,m_strPW3,m_nPort3,m_nTimeOut3,m_strHomePath3, m_bPassiveMode, m_bWSIChk);
|
|
if(m_nConfigMode == CM_File)
|
{
|
m_fileConfig.savefile(CONFIGFILENAME);
|
}
|
}
|
|
BOOL CFTPUploaderDlg::ReadString( HKEY hKey, LPCTSTR lpKey, LPCTSTR lpValue, LPBYTE lpRet, DWORD nSize )
|
{
|
if(m_nConfigMode == CM_File && m_fileConfig.isFileOpen())
|
{
|
m_fileConfig.getItem((char*)lpValue, (char*)lpRet, "");
|
return TRUE;
|
}
|
HKEY key;
|
DWORD dwDisp;
|
DWORD Size;
|
|
if (RegCreateKeyEx(hKey, lpKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &key, &dwDisp) != ERROR_SUCCESS)
|
return FALSE;
|
|
Size = nSize;
|
|
if (RegQueryValueEx(key, lpValue, 0, NULL, (LPBYTE)lpRet, &Size) != ERROR_SUCCESS)
|
{
|
return FALSE;
|
}
|
|
RegCloseKey(key);
|
|
return TRUE;
|
}
|
|
BOOL CFTPUploaderDlg::WriteString( HKEY hKey, LPCTSTR lpKey, LPCTSTR lpValue, LPSTR lpData )
|
{
|
if(m_nConfigMode == CM_File)
|
{
|
m_fileConfig.setItem((char*)lpValue, (char*)lpData);
|
return TRUE;
|
}
|
HKEY key;
|
DWORD dwDisp;
|
|
if (RegCreateKeyEx(hKey, lpKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &key, &dwDisp) != ERROR_SUCCESS)
|
return FALSE;
|
|
if (RegSetValueEx(key, lpValue, 0, REG_SZ, (LPBYTE)lpData, (DWORD)(strlen(lpData) + 1) ) != ERROR_SUCCESS)
|
return FALSE;
|
|
RegCloseKey(key);
|
|
return TRUE;
|
}
|
|
|
BOOL CFTPUploaderDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
|
{
|
// TODO: Add your message handler code here and/or call default
|
switch( pCopyDataStruct->dwData )
|
{
|
case COPYDATA_RAW_DOWNLOAD:
|
{
|
CFTPCopyDataParam* pParam = static_cast<CFTPCopyDataParam*>(pCopyDataStruct->lpData);
|
ASSERT(pParam);
|
AddDownload(pParam);
|
}
|
break;
|
|
case COPYDATA_RAW_UPLOAD:
|
{
|
CFTPCopyDataParam* pParam = static_cast<CFTPCopyDataParam*>(pCopyDataStruct->lpData);
|
ASSERT(pParam);
|
AddUpload(pParam);
|
}
|
break;
|
|
// [C-PRJ] Image Upload Define - KHT (2020/11/19)
|
case COPYDATA_IMAGE_UPLOAD:
|
{
|
CFTPCopyDataParam* pParam = static_cast<CFTPCopyDataParam*>(pCopyDataStruct->lpData);
|
ASSERT(pParam);
|
AddUpload(pParam);
|
}
|
break;
|
|
case COPYDATA_RAW_DOWNLOAD_ACK:
|
{
|
CFTPCopyDataParam* pParam = static_cast<CFTPCopyDataParam*>(pCopyDataStruct->lpData);
|
ASSERT(pParam);
|
|
}
|
break;
|
|
case COPYDATA_RAW_UPLOAD_ACK:
|
{
|
CFTPCopyDataParam* pParam = static_cast<CFTPCopyDataParam*>(pCopyDataStruct->lpData);
|
ASSERT(pParam);
|
|
}
|
break;
|
|
// [C-PRJ] Image Upload Define - KHT (2020/11/19)
|
case COPYDATA_IMAGE_UPLOAD_ACK:
|
{
|
CFTPCopyDataParam* pParam = static_cast<CFTPCopyDataParam*>(pCopyDataStruct->lpData);
|
ASSERT(pParam);
|
}
|
break;
|
|
}
|
return CDialog::OnCopyData(pWnd, pCopyDataStruct);
|
}
|
|
void CFTPUploaderDlg::Process_SaveFTPLog()
|
{
|
CSingleLock localLock(&m_csFTPLog);
|
localLock.Lock();
|
|
USES_CONVERSION;
|
|
// ·Î±×¸¦ ÆÄÀÏ·Î ¸¸µé±â
|
CTime cuTime = CTime::GetCurrentTime();
|
|
//////////////////////////////////////////////////////////////////////////
|
CString strFileName = _T("");
|
{
|
int nIndex = 0;
|
SYSTEMTIME st;
|
GetLocalTime(&st);
|
strFileName.Format("%s\\%02d%02d%02d\\%s_%02d%02d%02d.log",
|
FTP_LOG_FILE_PATH,st.wYear, st.wMonth, st.wDay,
|
FTP_LOG_FILE_NAME,st.wYear, st.wMonth, st.wDay);
|
}
|
|
CStdioFile* pFileLog = new CStdioFile();
|
CFileException fileException;
|
if ( pFileLog->Open(strFileName, CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate | CFile::shareDenyNone, &fileException) )
|
{
|
pFileLog->SeekToEnd();
|
for (VecStringIt it=m_vecFTPLog.begin(); it!=m_vecFTPLog.end(); it++)
|
{
|
pFileLog->WriteString((*it));
|
}
|
m_vecFTPLog.clear();
|
pFileLog->Close();
|
}
|
delete pFileLog;
|
|
|
//////////////////////////////////////////////////////////////////////////
|
CString strFileName2 = _T("");
|
{
|
int nIndex = 0;
|
SYSTEMTIME st;
|
GetLocalTime(&st);
|
strFileName2.Format("%s\\%02d%02d%02d\\%s_%02d%02d%02d.log",
|
FTP_LOG_FILE_PATH,st.wYear, st.wMonth, st.wDay,
|
"logFTPFail",st.wYear, st.wMonth, st.wDay);
|
}
|
|
CStdioFile* pFileLog2 = new CStdioFile();
|
CFileException fileException2;
|
if ( pFileLog2->Open(strFileName2, CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate | CFile::shareDenyNone, &fileException2) )
|
{
|
pFileLog2->SeekToEnd();
|
for (VecStringIt it=m_vecFTPFailLog.begin(); it!=m_vecFTPFailLog.end(); it++)
|
{
|
pFileLog2->WriteString((*it));
|
}
|
m_vecFTPFailLog.clear();
|
pFileLog2->Close();
|
}
|
delete pFileLog2;
|
}
|
|
void CFTPUploaderDlg::OnBnClickedCheckAutoUpload()
|
{
|
UpdateData(TRUE);
|
|
// Blank Timer set
|
if (m_bCheckAutoUpload)
|
{
|
SetTimer(TIMER_BLANK_UPDOWNLOAD, m_nAutoUploadDelay*1000, NULL);
|
}
|
else
|
{
|
KillTimer(TIMER_BLANK_UPDOWNLOAD);
|
}
|
}
|
|
|
void CFTPUploaderDlg::IFTP2P_DisplayLogMessage( int nType, int nLogIndex )
|
{
|
if (nType==FTPThreadType_Download) // download
|
{
|
const CString *pStrPtr = m_pFTPThreadPool_Down->GetLogBuffer(nLogIndex);
|
if (pStrPtr)
|
{
|
CString strMessage = *pStrPtr;
|
this->SendMessage(UM_FTP_LOG, (WPARAM)(&strMessage), NULL);
|
}
|
|
}
|
else if (nType==FTPThreadType_Upload) // upload
|
{
|
const CString *pStrPtr = m_pFTPThreadPool_Up->GetLogBuffer(nLogIndex);
|
if (pStrPtr)
|
{
|
CString strMessage = *pStrPtr;
|
this->SendMessage(UM_FTP_LOG_UP, (WPARAM)(&strMessage), NULL);
|
}
|
}
|
}
|
|
void CFTPUploaderDlg::IFTP2P_DisplayNotifyMessage( int nType, int nNotifyType, int nLogIndex )
|
{
|
if (nType==FTPThreadType_Download) // download
|
{
|
const CString *pStrPtr = m_pFTPThreadPool_Down->GetLogBuffer(nLogIndex);
|
if (pStrPtr)
|
{
|
CString strMessage = *pStrPtr;
|
this->SendMessage(UM_FTP_NOTIFY_LOG, (WPARAM)(&strMessage), (LPARAM)nNotifyType);
|
}
|
|
}
|
else if (nType==FTPThreadType_Upload) // upload
|
{
|
const CString *pStrPtr = m_pFTPThreadPool_Up->GetLogBuffer(nLogIndex);
|
if (pStrPtr)
|
{
|
CString strMessage = *pStrPtr;
|
this->SendMessage(UM_FTP_NOTIFY_LOG_UP, (WPARAM)(&strMessage), (LPARAM)nNotifyType);
|
}
|
}
|
}
|
|
void CFTPUploaderDlg::OnClose()
|
{
|
m_TrayIcon.ShowIcon();
|
|
ShowWindow(SW_HIDE);
|
}
|
|
|
|
void CFTPUploaderDlg::OnFileOpen()
|
{
|
m_TrayIcon.HideIcon();
|
|
ShowWindow(TRUE);
|
}
|
|
|
void CFTPUploaderDlg::OnFileClose()
|
{
|
int nRet = AfxMessageBox(_T("Exit FTPUploader?"), MB_YESNO);
|
if(IDNO == nRet) return;
|
|
if (m_pFTPThreadPool_Down)
|
{
|
m_pFTPThreadPool_Down->StopThread();
|
}
|
|
if (m_pFTPThreadPool_Up)
|
{
|
m_pFTPThreadPool_Up->StopThread();
|
}
|
|
m_TrayIcon.HideIcon();
|
|
CWnd *pWnd = GetParent();
|
if (pWnd)
|
{
|
pWnd->SendMessage(WM_CLOSE);
|
}
|
|
DestroyWindow();
|
|
}
|
|
void CFTPUploaderDlg::Process_FtpUploaderInfo()
|
{
|
if (m_pFTPThreadPool_Down)
|
{
|
UINT nReadyCount, nProcessCount, nCompletCount, nTotalCount;
|
|
m_pFTPThreadPool_Down->GetUploadListCountInfo(nReadyCount, nProcessCount, nCompletCount, nTotalCount);
|
|
SetDlgItemInt(IDC_EDIT_READY_DOWNLOAD, nReadyCount);
|
SetDlgItemInt(IDC_EDIT_DOWNLOADING, nProcessCount);
|
SetDlgItemInt(IDC_EDIT_COMP_DOWNLOAD, nCompletCount);
|
SetDlgItemInt(IDC_EDIT_TOTAL_DOWNLOAD, nTotalCount);
|
}
|
|
if (m_pFTPThreadPool_Up)
|
{
|
UINT nReadyCount, nProcessCount, nCompletCount, nTotalCount;
|
|
m_pFTPThreadPool_Up->GetUploadListCountInfo(nReadyCount, nProcessCount, nCompletCount, nTotalCount);
|
|
SetDlgItemInt(IDC_EDIT_READY_UPLOAD, nReadyCount);
|
SetDlgItemInt(IDC_EDIT_UPLOADING, nProcessCount);
|
SetDlgItemInt(IDC_EDIT_COMP_UPLOAD, nCompletCount);
|
SetDlgItemInt(IDC_EDIT_TOTAL_UPLOAD, nTotalCount);
|
}
|
}
|
|
void CFTPUploaderDlg::OnBnClickedButtonDownloadList()
|
{
|
if(m_pDlgUploadList_Down)
|
{
|
m_pDlgUploadList_Down->ShowWindow(SW_SHOW);
|
}
|
}
|
|
|
void CFTPUploaderDlg::OnBnClickedButtonUploadList()
|
{
|
if(m_pDlgUploadList_Up)
|
{
|
m_pDlgUploadList_Up->ShowWindow(SW_SHOW);
|
}
|
}
|
|
BOOL CFTPUploaderDlg::IDUL2P_GetReadyUploadParam( int nType, DeqFTPUploadParam& deqUploadParam )
|
{
|
if (nType==FTPThreadType_Download) // down
|
{
|
m_pFTPThreadPool_Down->GetUploadList(deqUploadParam);
|
return TRUE;
|
}
|
else if (nType==FTPThreadType_Upload) // up
|
{
|
m_pFTPThreadPool_Up->GetUploadList(deqUploadParam);
|
return TRUE;
|
}
|
|
return FALSE;
|
}
|
|
|
|
|
BOOL CFTPUploaderDlg::DestroyWindow()
|
{
|
// TODO: ¿©±â¿¡ Ư¼öÈµÈ Äڵ带 Ãß°¡ ¹×/¶Ç´Â ±âº» Ŭ·¡½º¸¦ È£ÃâÇÕ´Ï´Ù.
|
|
return __super::DestroyWindow();
|
}
|