VmsMsgUserDisp.cpp 4.1 KB

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