123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- // PutOutBinary.cpp : 定义应用程序的类行为。
- //
- #include "stdafx.h"
- #include "PutOutBinary.h"
- #include "PutOutBinaryDlg.h"
- #include "filehelp.h"
- // ----stat头文件;
- #include <sys/types.h>
- #include <sys/stat.h>
- // ----stat头文件;
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // CPutOutBinaryApp
- BEGIN_MESSAGE_MAP(CPutOutBinaryApp, CWinApp)
- ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
- END_MESSAGE_MAP()
- // CPutOutBinaryApp 构造
- CPutOutBinaryApp::CPutOutBinaryApp()
- {
- // 支持重新启动管理器
- m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
- // TODO: 在此处添加构造代码,
- // 将所有重要的初始化放置在 InitInstance 中
- }
- // 唯一的一个 CPutOutBinaryApp 对象
- CPutOutBinaryApp theApp;
- CTime StringToDateTime(IN CString strDateTime /* = _T("") */)
- {
- 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;
- }
- // CPutOutBinaryApp 初始化
- BOOL CPutOutBinaryApp::InitInstance()
- {
- // 如果一个运行在 Windows XP 上的应用程序清单指定要
- // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
- //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
- 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
- // 输出文本日志, 以生成xls文件;
- 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);
- //tms.GetLocalTm(&_tm);
- 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();
- // 创建 shell 管理器,以防对话框包含
- // 任何 shell 树视图控件或 shell 列表视图控件。
- CShellManager *pShellManager = new CShellManager;
- // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
- CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
- // 标准初始化
- // 如果未使用这些功能并希望减小
- // 最终可执行文件的大小,则应移除下列
- // 不需要的特定初始化例程
- // 更改用于存储设置的注册表项
- // TODO: 应适当修改该字符串,
- // 例如修改为公司或组织名
- SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
- CPutOutBinaryDlg dlg;
- m_pMainWnd = &dlg;
- INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
- // TODO: 在此放置处理何时用
- // “确定”来关闭对话框的代码
- }
- else if (nResponse == IDCANCEL)
- {
- // TODO: 在此放置处理何时用
- // “取消”来关闭对话框的代码
- }
- else if (nResponse == -1)
- {
- TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
- TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
- }
- // 删除上面创建的 shell 管理器。
- if (pShellManager != NULL)
- {
- delete pShellManager;
- }
- #if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS)
- ControlBarCleanUp();
- #endif
- // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
- // 而不是启动应用程序的消息泵。
- return FALSE;
- }
|