VmsMsgPubrMngr.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <tchar.h>
  5. #include <cxFormats.hpp>
  6. //---------------------------------------------------------------------------
  7. #include "AppGlobalF.h"
  8. #include "ITSDbF.h"
  9. #include "FrmVmsMsgPubrMngrF.h"
  10. //---------------------------------------------------------------------------
  11. USEFORM("SRC\FrmVmsPubrSelTermF.cpp", FrmVmsPubrSelTerm);
  12. USEFORM("SRC\FrmVmsMsgPubrMngrF.cpp", FrmVmsMsgPubrMngr);
  13. //---------------------------------------------------------------------------
  14. WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
  15. {
  16. if (!CheckApplicationParam()) {
  17. return 0;
  18. }
  19. if (!ApplicationSingleRun("TFrmVmsMsgPubrMngr", "VMS 홍보 메시지 관리")) {
  20. return 0;
  21. }
  22. DateSeparator = '-';
  23. TimeSeparator = ':';
  24. ShortDateFormat ="yyyy-MM-dd";
  25. ShortTimeFormat = "hh:nn:ss";
  26. LongTimeFormat = "hh:nn:ss";
  27. cxFormatController()->BeginUpdate();
  28. cxFormatController()->UseDelphiDateTimeFormats = true;
  29. cxFormatController()->EndUpdate();
  30. cxFormatController()->GetFormats();
  31. cxFormatController()->NotifyListeners();
  32. g_nPid = (int)GetCurrentProcessId();
  33. g_sAppDir = ExtractFilePath(Application->ExeName);
  34. g_sAppName = ChangeFileExt(ExtractFileName(Application->ExeName), "");
  35. g_sCfgDir = g_sAppDir + g_IniFileDir + "\\";
  36. g_sLogDir = g_sAppDir + "Log\\";
  37. ForceDirectories(g_sLogDir.c_str());
  38. ChDir(g_sAppDir);
  39. /*
  40. * 시스템 운영환경을 ini 파일에서 읽어 온다.
  41. */
  42. LoadDefaultConfigInfo(g_IniFileName);
  43. ITSLog = new TITSLog(g_sLogDir, g_sAppName, g_AppCfg.sLogDay);
  44. ITSLog->FLogCfg = g_LogCfg;
  45. if (!ITSDb_Initialize())
  46. {
  47. if (g_AppCfg.sLang == "kr")
  48. {
  49. Application->MessageBox(L"Database 자원을 시스템으로부터 얻지 못했습니다.\r\n\r\n프로그램을 종료합니다.",
  50. L"프로그램 시작 오류!!!",
  51. MB_OK|MB_ICONERROR);
  52. }
  53. else
  54. {
  55. Application->MessageBox(L"Database resource could not be obtained from the system.\r\n\r\nExit the program.",
  56. L"Program Start Error!!!",
  57. MB_OK|MB_ICONERROR);
  58. }
  59. goto prog_exit;
  60. }
  61. if (g_AppCfg.itsdb.sConnectStr == "")
  62. {
  63. ITSDb_SetInfo(g_AppCfg.itsdb.sProvider, g_AppCfg.itsdb.sServerName, g_AppCfg.itsdb.sUserName, g_AppCfg.itsdb.sPassword);
  64. }
  65. else
  66. {
  67. ITSDb_SetConnStr(g_AppCfg.itsdb.sConnectStr);
  68. }
  69. if (!ITSDb_Open())
  70. {
  71. if (g_AppCfg.sLang == "kr")
  72. {
  73. Application->MessageBox(L"데이터베이스 접속에 실패하였습니다.\r\n\r\n프로그램을 종료합니다.",
  74. L"프로그램 시작 오류!!!",
  75. MB_OK|MB_ICONERROR);
  76. }
  77. else
  78. {
  79. Application->MessageBox(L"Database connection failed.\r\n\r\nExit the program.",
  80. L"Program Start Error!!!",
  81. MB_OK|MB_ICONERROR);
  82. }
  83. goto prog_exit;
  84. }
  85. try
  86. {
  87. ReportMemoryLeaksOnShutdown = true;
  88. Application->Initialize();
  89. Application->MainFormOnTaskBar = true;
  90. Application->Title = g_AppCfg.sTitle;
  91. Application->Title = "VMS 홍보 메시지 관리";
  92. Application->CreateForm(__classid(TFrmVmsMsgPubrMngr), &FrmVmsMsgPubrMngr);
  93. Application->Run();
  94. }
  95. catch (Exception &exception)
  96. {
  97. Application->ShowException(&exception);
  98. }
  99. catch (...)
  100. {
  101. try
  102. {
  103. throw Exception("");
  104. }
  105. catch (Exception &exception)
  106. {
  107. Application->ShowException(&exception);
  108. }
  109. }
  110. prog_exit:
  111. try
  112. {
  113. ITSDb_Finalize();
  114. }
  115. catch(...)
  116. {
  117. }
  118. return 0;
  119. }
  120. //---------------------------------------------------------------------------