123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629 |
- #include "stdafx.h"
- #include "Test.h"
- #include "TestDlg.h"
- #include <WinNetWk.h>
- #include <vector>
- #include <string>
- #include <shlobj.h>
- using namespace std;
- #pragma comment(lib,"Mpr.lib")
- #pragma comment(lib,"lyfzExportImport.lib")
- extern "C" enum
- {
- IMPORT_ORIGIAL ,
- IMPORT_EARLY,
- IMPORT_FURTHER,
- IMPORT_DESIGN,
- EXPORT_ORIGIAL,
- EXPORT_EARLY,
- EXPORT_FURTHER,
- EXPORT_DESIGN,
- EXPORT_SELECTED,
- EXPORT_SELECTED_DESIGN
- };
- typedef struct _STGoodWithImages_
- {
- CString strGood;
- CString strPhotos;
- }STGoodWithImages, *pSTGoodWithImages;
- typedef BOOL(__stdcall *ExportWithProcess)(
- IN BOOL bWithSubFolders,
- IN LPCTSTR lpSourceDirectory,
- IN LPCTSTR lpBranchName,
- IN LPCTSTR lpOrderNumber,
- IN LPCTSTR lpSceneryName,
- IN LPCTSTR lpCustomerName,
- IN LPCTSTR lpSourceExt,
- IN LPCTSTR lpTargetExt,
- IN CONST INT &nOperation,
- IN BOOL bOverWrite,
- IN BOOL bCompress,
- IN CONST INT &nCompressWidth,
- IN CONST INT &nCompressHeight,
- IN BOOL bIncludeGoodName,
- IN vector<STGoodWithImages> *pvtSelectedGoodWithPhotos,
- IN LPCTSTR lpRequire
- );
- typedef BOOL(__stdcall *ImportWithProcess)(
- IN BOOL bAutoNaming,
- IN OUT INT &nNumIndex,
- IN BOOL bWithSubFolders,
- IN LPCTSTR lpTargetDirectory,
- IN LPCTSTR lpBranchName,
- IN LPCTSTR lpOrderNumber,
- IN LPCTSTR lpSceneryName,
- IN LPCTSTR lpSourceExt,
- IN LPCTSTR lpTargetExt,
- IN CONST INT &nOperation,
- IN BOOL bOverWrite,
- IN BOOL bCompress,
- IN CONST INT &nCompressWidth,
- IN CONST INT &nCompressHeight,
- IN BOOL bThumbnail,
- IN CONST INT &nThumbnailWidth,
- IN CONST INT &nThumbnailHeight,
- IN OUT std::vector<string>& vFile
- );
- extern ExportWithProcess g_ExportWithProcess;
- extern ImportWithProcess g_ImportWithProcess;
- static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
- {
- switch (uMsg)
- {
- case BFFM_INITIALIZED:
- {
-
-
- TCHAR szDir[MAX_PATH] = { 0 };
- GetCurrentDirectory(sizeof(szDir) / sizeof(TCHAR), szDir);
- SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szDir);
- }
- break;
- }
- return 0;
- }
- BOOL GetFilePath(TCHAR *FilePath, HWND hParentWnd, TCHAR* InstructionString, UINT ulFlags)
- {
- BROWSEINFO bInfo;
- LPITEMIDLIST pidl;
- ZeroMemory((PVOID)&bInfo, sizeof(BROWSEINFO));
- bInfo.hwndOwner = hParentWnd;
- bInfo.pszDisplayName = FilePath;
- bInfo.lpszTitle = InstructionString;
- bInfo.ulFlags = ulFlags;
- bInfo.lpfn = BrowseCallbackProc;
- bInfo.lParam = 0;
- if ((pidl = ::SHBrowseForFolder(&bInfo)) == NULL)
- return false;
- if (::SHGetPathFromIDList(pidl, FilePath) == FALSE)
- return false;
- return true;
- }
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- enum { IDD = IDD_ABOUTBOX };
- protected:
- virtual void DoDataExchange(CDataExchange* pDX);
- 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()
- CTestDlg::CTestDlg(CWnd* pParent )
- : CDialog(CTestDlg::IDD, pParent)
- , m_strImportPath(_T(""))
- , m_strExportPath(_T(""))
- , m_nImportType(0)
- , m_nExportType(0)
- , m_nImportCompressWidth(600)
- , m_nImportCompressHeight(300)
- , m_nImportThumbnailWidth(200)
- , m_nImportThumbnailHeight(100)
- , m_nExportCompressWidth(600)
- , m_nExportCompressHeight(300)
- , m_nImportStartNumber(1)
- {
- m_hMyDll = NULL;
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CTestDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, ST_ImportPath, m_strImportPath);
- DDX_Text(pDX, ST_ExportPath, m_strExportPath);
- DDX_Radio(pDX, Radio_Import_Original, m_nImportType);
- DDX_Radio(pDX, Radio_Export_Original, m_nExportType);
- DDX_Control(pDX, CHECK_ImportCompress, m_check_ImportCompress);
- DDX_Control(pDX, CHECK_ImportAutoNaming, m_check_ImportAutoNaming);
- DDX_Control(pDX, CHECK_ImportOverWrite, m_check_ImportOverWrite);
- DDX_Control(pDX, CHECK_ImportShowProcssing, m_check_ImportShowProcessing);
- DDX_Control(pDX, CHECK_ImportThumbnail, m_check_ImportThumbnial);
- DDX_Control(pDX, CHECK_ExportCompress, m_check_ExportCompress);
- DDX_Control(pDX, CHECK_ExportOverWrite, m_check_ExportOverWrite);
- DDX_Control(pDX, CHECK_ExportIncludGoods, m_check_ExportIncludeGoods);
- DDX_Text(pDX, Edit_ImportCompressWidth, m_nImportCompressWidth);
- DDX_Text(pDX, Edit_ImportCompressHeight, m_nImportCompressHeight);
- DDX_Text(pDX, Edit_ImportThumbnailWidth, m_nImportThumbnailWidth);
- DDX_Text(pDX, Edit_ImportThumbnailHeight, m_nImportThumbnailHeight);
- DDX_Text(pDX, Edit_ExportCompressWidth, m_nExportCompressWidth);
- DDX_Text(pDX, Edit_ExportCompressHeight, m_nExportCompressHeight);
- DDX_Text(pDX, Edit_StartNumber, m_nImportStartNumber);
- }
- BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
-
- ON_BN_CLICKED(Btn_ImportTest, &CTestDlg::OnBnClickedImporttest)
- ON_BN_CLICKED(Btn_ExportTest, &CTestDlg::OnBnClickedExporttest)
- ON_BN_CLICKED(Btn_SetImportPath, &CTestDlg::OnBnClickedSetimportpath)
- ON_BN_CLICKED(Btn_SetExportPath, &CTestDlg::OnBnClickedSetexportpath)
- ON_BN_CLICKED(CHECK_ImportCompress, &CTestDlg::OnBnClickedImportcompress)
- ON_BN_CLICKED(CHECK_ImportThumbnail, &CTestDlg::OnBnClickedImportthumbnail)
- ON_BN_CLICKED(CHECK_ExportCompress, &CTestDlg::OnBnClickedExportcompress)
- ON_BN_CLICKED(CHECK_ImportAutoNaming, &CTestDlg::OnBnClickedImportautonaming)
- ON_BN_CLICKED(Radio_Import_Original, &CTestDlg::OnBnClickedImportOriginal)
- ON_BN_CLICKED(Radio_Import_Early, &CTestDlg::OnBnClickedImportEarly)
- ON_BN_CLICKED(Radio_Import_Further, &CTestDlg::OnBnClickedImportFurther)
- ON_BN_CLICKED(Radio_Import_Design, &CTestDlg::OnBnClickedImportDesign)
- END_MESSAGE_MAP()
- BOOL CTestDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
-
- 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);
- }
- }
-
-
- SetIcon(m_hIcon, TRUE);
- SetIcon(m_hIcon, FALSE);
-
- if(m_check_ImportCompress.GetCheck())
- {
- ((CWnd*)GetDlgItem(Edit_ImportCompressWidth))->EnableWindow(TRUE);
- ((CWnd*)GetDlgItem(Edit_ImportCompressHeight))->EnableWindow(TRUE);
- }
- else
- {
- ((CWnd*)GetDlgItem(Edit_ImportCompressWidth))->EnableWindow(FALSE);
- ((CWnd*)GetDlgItem(Edit_ImportCompressHeight))->EnableWindow(FALSE);
- }
- if(m_check_ImportThumbnial.GetCheck())
- {
- ((CWnd*)GetDlgItem(Edit_ImportThumbnailWidth))->EnableWindow(TRUE);
- ((CWnd*)GetDlgItem(Edit_ImportThumbnailHeight))->EnableWindow(TRUE);
- }
- else
- {
- ((CWnd*)GetDlgItem(Edit_ImportThumbnailWidth))->EnableWindow(FALSE);
- ((CWnd*)GetDlgItem(Edit_ImportThumbnailHeight))->EnableWindow(FALSE);
- }
- if(m_check_ExportCompress.GetCheck())
- {
- ((CWnd*)GetDlgItem(Edit_ExportCompressWidth))->EnableWindow(TRUE);
- ((CWnd*)GetDlgItem(Edit_ExportCompressHeight))->EnableWindow(TRUE);
- }
- else
- {
- ((CWnd*)GetDlgItem(Edit_ExportCompressWidth))->EnableWindow(FALSE);
- ((CWnd*)GetDlgItem(Edit_ExportCompressHeight))->EnableWindow(FALSE);
- }
- if(m_check_ImportAutoNaming.GetCheck())
- {
- ((CWnd*)GetDlgItem(Edit_StartNumber))->EnableWindow(TRUE);
- }
- else
- {
- ((CWnd*)GetDlgItem(Edit_StartNumber))->EnableWindow(FALSE);
- }
- LPSHELLFOLDER lpsf=NULL;
- HRESULT hr = SHGetDesktopFolder(&lpsf);
- TCHAR path[255];
- SHGetSpecialFolderPath(0,path,CSIDL_DESKTOPDIRECTORY,0);
- TCHAR szExsitingFileName[MAX_PATH] = { _T("E:\\lyfzbin\\Services\\客户原片(管理软件)$\\20141224-001\\景点\\001.jpg") };
- (_tcsrchr(szExsitingFileName, _T('\\')))[0] = 0;
- LoadMyDllLibrary();
- m_strImportOldPath = _T("E:\\lyfzbin\\Services");
- m_strImportPath = _T("E:\\lyfzbin\\Services\\客户原片(管理软件)$");
- m_strExportPath = _T("E:\\lyfzbin\\Services\\客户原片(管理软件)$\\20141226-001");
- UpdateData(FALSE);
-
- return TRUE;
- }
- void CTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
- void CTestDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this);
- SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
-
- 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;
-
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- HCURSOR CTestDlg::OnQueryDragIcon()
- {
- return static_cast<HCURSOR>(m_hIcon);
- }
- void CTestDlg::LoadMyDllLibrary()
- {
- DWORD dwError = 0;
- if ( m_hMyDll == NULL)
- m_hMyDll = LoadLibrary(_T("lyfzExportImport.dll"));
- if ( m_hMyDll == NULL)
- {
- dwError = GetLastError();
- AfxMessageBox(_T("加载动态库失败"));
- return;
- }
- g_ExportWithProcess = (ExportWithProcess)::GetProcAddress(m_hMyDll,"ExportWithProcess");
- g_ImportWithProcess = (ImportWithProcess)::GetProcAddress(m_hMyDll, "ImportWithProcess");
-
- }
- void CTestDlg::FreeMyDllLibrary()
- {
- if ( m_hMyDll )
- {
- FreeLibrary(m_hMyDll);
- m_hMyDll = NULL;
- }
- }
- void CTestDlg::OnBnClickedImporttest()
- {
- UpdateData();
- std::vector<std::string> vFiles;
- if ( g_ImportWithProcess )
- {
- g_ImportWithProcess(
- m_check_ImportAutoNaming.GetCheck(),
- m_nImportStartNumber,
- FALSE,
- m_strImportPath,
- _T(""),
- _T("201412******||||||||||26-001"),
- _T("水华寨农家乐"),
- NULL,
- NULL,
- m_nImportType,
- m_check_ImportOverWrite.GetCheck(),
- m_check_ImportCompress.GetCheck(),
- m_nImportCompressWidth,
- m_nImportCompressHeight,
- m_check_ImportThumbnial.GetCheck(),
- m_nImportThumbnailWidth,
- m_nImportThumbnailHeight,
- vFiles);
- }
- UpdateData(FALSE);
- }
- void CTestDlg::OnBnClickedExporttest()
- {
- UpdateData(TRUE);
-
- vector<STGoodWithImages> vtGI;
- STGoodWithImages tagGI;
- tagGI.strGood = _T("商品0");
- tagGI.strPhotos = _T("*景点0:ABC0001|ABC0002|ABC0003|ABC0004|ABC0005|*景点1:ABC00011|ABC00012|ABC00013|ABC00014|ABC00015|*");
- vtGI.push_back(tagGI);
- STGoodWithImages tagGI1;
- tagGI1.strGood = _T("商品1");
- tagGI1.strPhotos = _T("*景点0:ABC0001|ABC0002|ABC0003|ABC0004|ABC0005|*景点1:ABC00011|ABC00012|ABC00013|ABC00014|ABC00015|*");
- vtGI.push_back(tagGI1);
- STGoodWithImages tagGI2;
- tagGI2.strGood = _T("商品2");
- tagGI2.strPhotos = _T("*景点0:ABC0001|ABC0002|ABC0003|ABC0004|ABC0005|*景点1:ABC00011|ABC00012|ABC00013|ABC00014|ABC00015|*");
- vtGI.push_back(tagGI2);
- STGoodWithImages tagGI3;
- tagGI3.strGood = _T("商品3");
- tagGI3.strPhotos = _T("*景点0:ABC0001|ABC0002|ABC0003|ABC0004|ABC0005|*景点1:ABC00011|ABC00012|ABC00013|ABC00014|ABC00015|*");
- vtGI.push_back(tagGI3);
- if (g_ExportWithProcess)
- {
- g_ExportWithProcess(
- FALSE,
- m_strExportPath,
- NULL,
- _T("20141225-001"),
- NULL,
- _T("Grans***** Bill"),
- NULL,
- NULL,
- m_nExportType + 4,
- m_check_ExportOverWrite.GetCheck(),
- m_check_ExportCompress.GetCheck(),
- m_nExportCompressWidth,
- m_nExportCompressHeight,
- FALSE,
- &vtGI,
- NULL
- );
-
- }
- UpdateData(FALSE);
- }
- void CTestDlg::OnBnClickedSetimportpath()
- {
-
- UpdateData();
- TCHAR szImport[MAX_PATH] = {0};
- if(GetFilePath(szImport, NULL, _T("请选择相片的源路径!"), BIF_USENEWUI | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS))
- {
- m_strImportPath = szImport;
- m_strImportOldPath = szImport;
- }
- UpdateData(FALSE);
- }
- void CTestDlg::OnBnClickedSetexportpath()
- {
-
- UpdateData();
- TCHAR szExport[MAX_PATH] = {0};
- if(GetFilePath(szExport, NULL, _T("请选择相片的源路径!"), BIF_USENEWUI | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS))
- m_strExportPath = szExport;
- UpdateData(FALSE);
- }
- void CTestDlg::OnBnClickedImportcompress()
- {
-
- if(m_check_ImportCompress.GetCheck())
- {
- ((CWnd*)GetDlgItem(Edit_ImportCompressWidth))->EnableWindow(TRUE);
- ((CWnd*)GetDlgItem(Edit_ImportCompressHeight))->EnableWindow(TRUE);
- }
- else
- {
- ((CWnd*)GetDlgItem(Edit_ImportCompressWidth))->EnableWindow(FALSE);
- ((CWnd*)GetDlgItem(Edit_ImportCompressHeight))->EnableWindow(FALSE);
- }
- }
- void CTestDlg::OnBnClickedImportthumbnail()
- {
-
- if(m_check_ImportThumbnial.GetCheck())
- {
- ((CWnd*)GetDlgItem(Edit_ImportThumbnailWidth))->EnableWindow(TRUE);
- ((CWnd*)GetDlgItem(Edit_ImportThumbnailHeight))->EnableWindow(TRUE);
- }
- else
- {
- ((CWnd*)GetDlgItem(Edit_ImportThumbnailWidth))->EnableWindow(FALSE);
- ((CWnd*)GetDlgItem(Edit_ImportThumbnailHeight))->EnableWindow(FALSE);
- }
- }
- void CTestDlg::OnBnClickedExportcompress()
- {
-
- if(m_check_ExportCompress.GetCheck())
- {
- ((CWnd*)GetDlgItem(Edit_ExportCompressWidth))->EnableWindow(TRUE);
- ((CWnd*)GetDlgItem(Edit_ExportCompressHeight))->EnableWindow(TRUE);
- }
- else
- {
- ((CWnd*)GetDlgItem(Edit_ExportCompressWidth))->EnableWindow(FALSE);
- ((CWnd*)GetDlgItem(Edit_ExportCompressHeight))->EnableWindow(FALSE);
- }
- }
- void CTestDlg::OnBnClickedImportautonaming()
- {
-
- if(m_check_ImportAutoNaming.GetCheck())
- {
- ((CWnd*)GetDlgItem(Edit_StartNumber))->EnableWindow(TRUE);
- }
- else
- {
- ((CWnd*)GetDlgItem(Edit_StartNumber))->EnableWindow(FALSE);
- }
- }
- void CTestDlg::OnBnClickedImportOriginal()
- {
-
- UpdateData(TRUE);
- m_strImportPath = m_strImportOldPath;
- if(m_strImportPath[m_strImportPath.GetLength() - 1] != _T('\\'))
- m_strImportPath += _T("\\");
- m_strImportPath += _T("客户原片(管理软件)$");
- UpdateData(FALSE);
- }
- void CTestDlg::OnBnClickedImportEarly()
- {
-
- UpdateData(TRUE);
- m_strImportPath = m_strImportOldPath;
- if(m_strImportPath[m_strImportPath.GetLength() - 1] != _T('\\'))
- m_strImportPath += _T("\\");
- m_strImportPath += _T("修好的片(管理软件)$");
- UpdateData(FALSE);
- }
- void CTestDlg::OnBnClickedImportFurther()
- {
-
- UpdateData(TRUE);
- m_strImportPath = m_strImportOldPath;
- if(m_strImportPath[m_strImportPath.GetLength() - 1] != _T('\\'))
- m_strImportPath += _T("\\");
- m_strImportPath += _T("精修好的片(管理软件)$");
- UpdateData(FALSE);
- }
- void CTestDlg::OnBnClickedImportDesign()
- {
-
- UpdateData(TRUE);
- m_strImportPath = m_strImportOldPath;
- if(m_strImportPath[m_strImportPath.GetLength() - 1] != _T('\\'))
- m_strImportPath += _T("\\");
- m_strImportPath += _T("设计好的片(管理软件)$");
- UpdateData(FALSE);
- }
|