CPhotoFTPReceiveApp.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /****************************************************************/
  2. /* */
  3. /* CPhotoFTPReceiveApp.cpp */
  4. /* */
  5. /* Defines the class behaviors for the application. */
  6. /* */
  7. /* Programmed by LYFZ van der Meer */
  8. /* Copyright LYFZ Software Solutions 2002 */
  9. /* http://www.LYFZvandermeer.nl */
  10. /* */
  11. /* Last updated: 10 july 2002 */
  12. /* */
  13. /****************************************************************/
  14. #include "stdafx.h"
  15. #include "CPhotoFTPReceiveApp.h"
  16. #include "ApplicationDlg.h"
  17. #include "CPhotoFTPReceive.h"
  18. #include "BranchInfo.h"
  19. #include "Global.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. BEGIN_MESSAGE_MAP(CCPhotoFTPReceiveApp, CWinApp)
  26. //{{AFX_MSG_MAP(CCPhotoFTPReceiveApp)
  27. ON_COMMAND(ID_APP_SHOW, OnAppShow)
  28. ON_COMMAND(ID_APP_EXIT, OnAppExit)
  29. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  30. ON_COMMAND(ID_HELP_INDEX, OnHelpIndex)
  31. //}}AFX_MSG_MAP
  32. ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CCPhotoFTPReceiveApp construction
  36. CCPhotoFTPReceiveApp::CCPhotoFTPReceiveApp()
  37. {
  38. // TODO: add construction code here,
  39. // Place all significant initialization in InitInstance
  40. }
  41. /////////////////////////////////////////////////////////////////////////////
  42. // The one and only CCPhotoFTPReceiveApp object
  43. CCPhotoFTPReceiveApp theApp;
  44. CCPhotoFTPReceive theServer;
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CCPhotoFTPReceiveApp initialization
  47. BOOL CCPhotoFTPReceiveApp::InitInstance()
  48. {
  49. HANDLE hObject = CreateMutex(NULL,FALSE,_T("CCPhotoFTPReceiveApp"));
  50. if(GetLastError() == ERROR_ALREADY_EXISTS)
  51. {
  52. return false;
  53. }
  54. SetRegistryKey(_T("LYFZ Software Solutions"));
  55. if (!AfxSocketInit())
  56. {
  57. AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
  58. return FALSE;
  59. }
  60. // Standard initialization
  61. // If you are not using these features and wish to reduce the size
  62. // of your final executable, you should remove from the following
  63. // the specific initialization routines you do not need.
  64. #ifdef _AFXDLL
  65. Enable3dControls(); // Call this when using MFC in a shared DLL
  66. #else
  67. Enable3dControlsStatic(); // Call this when linking to MFC statically
  68. #endif
  69. InitCommonControls();
  70. #if 1
  71. CString strArguments(_T("/20150511123051556633.ly.com/20131017-001250"));
  72. strArguments = _T("/20131017-001250");
  73. CString strBranchId = _T("");
  74. CString strOrderNum = _T("");
  75. int nIndex = -1;
  76. nIndex = strArguments.Find(_T(".ly.com"));
  77. if ( nIndex == -1 )
  78. {
  79. if(-1 != strArguments.Find(_T("."))) // test.dat之类的文件;
  80. {
  81. strOrderNum = strArguments.Mid(1);
  82. }
  83. }
  84. else
  85. {
  86. strBranchId = strArguments.Mid(1,nIndex+6);
  87. strOrderNum = strArguments.Mid(nIndex+8);
  88. }
  89. #endif
  90. #if 1
  91. // 打开数据库;
  92. GetSysIniInfo();
  93. CBranchInfo::GetInstance()->InitCatalog(g_dwDBServerPort,g_szDBSource,g_szDBAccount,g_szDBPassWord,g_szDBName);
  94. CBranchInfo::GetInstance()->GetTblBranchId();
  95. CBranchInfo::GetInstance()->GetTblNetShareInfo();
  96. #endif
  97. // Create the tray icon
  98. if (!m_TrayIcon.Create(WM_ICON_NOTIFY, // Icon notify message to use
  99. _T("客照接收FTP服务器"), // tooltip
  100. LoadIcon(IDI_CPhotoFTPReceive), // Icon
  101. IDR_POPUP_MENU)) // ID of tray icon
  102. return -1;
  103. int nLogLevel = GetProfileInt("Settings", "LogLevel" , 1);
  104. if (0)//nLogLevel)
  105. {
  106. // create configuration filename
  107. CString strFileName;
  108. GetAppDir(strFileName);
  109. strFileName += "ftptrace.txt";
  110. m_LogFile.SetLogLevel(nLogLevel);
  111. // open log file
  112. m_LogFile.Open((LPCTSTR)strFileName);
  113. }
  114. CApplicationDlg dlg;
  115. m_pMainWnd = &dlg;
  116. int nResponse = dlg.DoModal();
  117. if (nResponse == IDOK)
  118. {
  119. // TODO: Place code here to handle when the dialog is
  120. // dismissed with OK
  121. }
  122. else if (nResponse == IDCANCEL)
  123. {
  124. // TODO: Place code here to handle when the dialog is
  125. // dismissed with Cancel
  126. }
  127. // Since the dialog has been closed, return FALSE so that we exit the
  128. // application, rather than start the application's message pump.
  129. return FALSE;
  130. }
  131. void CCPhotoFTPReceiveApp::OnAppShow()
  132. {
  133. if (m_pMainWnd)
  134. m_pMainWnd->ShowWindow(SW_SHOW);
  135. }
  136. void CCPhotoFTPReceiveApp::OnAppExit()
  137. {
  138. m_pMainWnd->DestroyWindow();
  139. }
  140. void CCPhotoFTPReceiveApp::OnAppAbout()
  141. {
  142. // CSettingsSheet propsheet("Settings", AfxGetApp()->m_pMainWnd, 2);
  143. // remove Help button
  144. // propsheet.m_psh.dwFlags &= ~(PSH_HASHELP);
  145. // display Settings dialogbox
  146. // propsheet.DoModal();
  147. }
  148. /********************************************************************/
  149. /* */
  150. /* Function name : OnHelpIndex */
  151. /* Description : Command to show help file. */
  152. /* */
  153. /********************************************************************/
  154. void CCPhotoFTPReceiveApp::OnHelpIndex()
  155. {
  156. // launch help
  157. // ::WinHelp(AfxGetMainWnd()->m_hWnd, AfxGetApp()->m_pszHelpFilePath, HELP_CONTENTS, 0L);
  158. }