123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- #include "stdafx.h"
- #include "PutOutBinary.h"
- #include "PutOutBinaryDlg.h"
- #include "filehelp.h"
- #include <sys/types.h>
- #include <sys/stat.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- BEGIN_MESSAGE_MAP(CPutOutBinaryApp, CWinApp)
- ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
- END_MESSAGE_MAP()
- CPutOutBinaryApp::CPutOutBinaryApp()
- {
-
- m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
-
-
- }
- CPutOutBinaryApp theApp;
- CTime StringToDateTime(IN CString strDateTime )
- {
- if (strDateTime.IsEmpty())
- strDateTime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
- TCHAR cc = 0;
- INT nYear = 0, nMonth = 0, nDay = 0, nHour = 0, nMinute = 0, nSecond = 0;
- if (strDateTime.Find(_T("年")) != -1)
- {
- #ifdef UNICODE
- _stscanf_s(strDateTime.GetString(),
- _T("%4d%c%2d%c%2d%c%c%2d%c%2d%c%2d%c"),
- &nYear, &cc, sizeof(TCHAR),
- &nMonth, &cc, sizeof(TCHAR),
- &nDay, &cc, sizeof(TCHAR),
- &cc, sizeof(TCHAR),
- &nHour, &cc, sizeof(TCHAR),
- &nMinute, &cc, sizeof(TCHAR),
- &nSecond, &cc, sizeof(TCHAR));
- #else
- sscanf(strDateTime,
- _T("%4d%c%2d%c%2d%c%c%2d%c%2d%c%2d%c"),
- &nYear, &cc,
- &nMonth, &cc,
- &nDay, &cc, &cc,
- &nHour, &cc,
- &nMinute, &cc,
- &nSecond, &cc);
- #endif
- }
- else
- {
- #ifdef UNICODE
- _stscanf_s(strDateTime.GetString(),
- _T("%4d%c%2d%c%2d%c%2d%c%2d%c%2d"),
- &nYear, &cc, sizeof(TCHAR),
- &nMonth, &cc, sizeof(TCHAR),
- &nDay, &cc, sizeof(TCHAR),
- &nHour, &cc, sizeof(TCHAR),
- &nMinute, &cc, sizeof(TCHAR),
- &nSecond);
- #else
- sscanf(strDateTime,
- _T("%4d%c%2d%c%2d%c%2d%c%2d%c%2d"),
- &nYear, &cc,
- &nMonth, &cc,
- &nDay, &cc,
- &nHour, &cc,
- &nMinute, &cc,
- &nSecond);
- #endif
- }
-
- CTime tm(nYear, nMonth, nDay, nHour, nMinute, nSecond);
- return tm;
- }
- BOOL CPutOutBinaryApp::InitInstance()
- {
-
-
-
- INITCOMMONCONTROLSEX InitCtrls;
- InitCtrls.dwSize = sizeof(InitCtrls);
-
-
- InitCtrls.dwICC = ICC_WIN95_CLASSES;
- InitCommonControlsEx(&InitCtrls);
- CWinApp::InitInstance();
- GetSysIniInfo();
- AdoImpl ado;
- ado.SetConnectString(AdoDataSourceType::ADO_SQLSERVER, g_szDBSource, _T("0"), g_szDBAccount, g_szDBPassWord, g_szDBName);
- if (ado.Opendatabase())
- {
- #if 0
- ado.GetBinary(_T("renyuan"), _T("photo"), _T("421181199110166655"), NULL);
- #endif
- #if 0
- ado.GetOrderContractImage(_T("client"), _T("photo"), _T(""), NULL);
- #endif
- #if 0
- ado.GetOrderOtherContractImage(_T("clientcontract"), _T("photo"), _T(""), NULL);
- #endif
- #if 0
- ado.GetChargeAgainstRevenueImage(_T("gudingfeiyong"), _T("photo"), _T(""), NULL);
- #endif
- }
- #if 1
-
- filehelpImpl filehp;
- STR_VEC vtfiles;
- TCHAR szDirectory[MAX_PATH] = {0};
- _stprintf_s(szDirectory, _T("%sconstracts"), g_szModulePath);
- filehp.getfiles_findin_subfolder(szDirectory, _T("*.jpg"), &vtfiles);
- size_t fsize = 0;
- struct _stat64i32 statbuf;
- CString str;
- CString strOrder = _T("");
- CString strDateTime = _T("");
- CTime tms;
- SYSTEMTIME systime;
- struct tm _tm;
- for(auto file : vtfiles )
- {
- _tstat(file.c_str(), &statbuf);
- strOrder = file.substr(_tcslen(_T("E:\\lyfz-project.org\\Others\\导出数据库相片\\Debug\\constracts\\")), 12).c_str();
- if (file.find(_T("其他合同")) != TString::npos)
- {
- str = file.substr(file.find_last_of('\\') + _tcslen(_T("其他合同")) + 1, 14).c_str();
- strDateTime.Format(_T("%s-%s-%s %s:%s:%s"), str.Left(4), str.Mid(4, 2), str.Mid(6,2), str.Mid(8,2), str.Mid(10, 2), str.Mid(12, 2));
- }
- else
- {
- str = strOrder.Left(8);
- strDateTime.Format(_T("%s-%s-%s 00:00:00"), str.Left(4), str.Mid(4,2), str.Right(2));
- }
- tms = StringToDateTime(strDateTime);
-
- WriteTextLog(_T("%s %s %s %ld %ld"),
- file.substr(_tcslen(_T("E:\\lyfz-project.org\\Others\\导出数据库相片\\Debug\\constracts\\")), 12).c_str(),
- file.substr(file.find_last_of('\\') + 1).c_str(),
- file.substr(_tcslen(_T("E:\\lyfz-project.org\\Others\\导出数据库相片\\Debug\\constracts\\"))).c_str(),
- statbuf.st_size,
- tms
- );
- }
- #endif
- AfxMessageBox(_T("导出完成"));
- AfxEnableControlContainer();
-
-
- CShellManager *pShellManager = new CShellManager;
-
- CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
-
-
-
-
-
-
-
- SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
- CPutOutBinaryDlg dlg;
- m_pMainWnd = &dlg;
- INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
-
-
- }
- else if (nResponse == IDCANCEL)
- {
-
-
- }
- else if (nResponse == -1)
- {
- TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
- TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
- }
-
- if (pShellManager != NULL)
- {
- delete pShellManager;
- }
- #if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS)
- ControlBarCleanUp();
- #endif
-
-
- return FALSE;
- }
|