VmsLogDspl.cpp 4.4 KB

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