VmsLogStts.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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\FrmVmsLogSttsF.cpp", FrmVmsLogStts);
  12. USEFORM("MAIN\FrmVmsLogSttsSubF.cpp", FrmVmsLogSttsSub);
  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("VmsLogStts", 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. if (g_AppCfg.itsdb.sConnectStr == "")
  78. {
  79. ITSDb_SetInfo(g_AppCfg.itsdb.sProvider, g_AppCfg.itsdb.sServerName, g_AppCfg.itsdb.sUserName, g_AppCfg.itsdb.sPassword);
  80. }
  81. else
  82. {
  83. ITSDb_SetConnStr(g_AppCfg.itsdb.sConnectStr);
  84. }
  85. if (!ITSDb_Open())
  86. {
  87. if (g_AppCfg.sLang == "kr")
  88. {
  89. Application->MessageBox(L"데이터베이스 접속에 실패하였습니다.\r\n\r\n프로그램을 종료합니다.",
  90. L"프로그램 시작 오류!!!",
  91. MB_OK|MB_ICONERROR);
  92. }
  93. else
  94. {
  95. Application->MessageBox(L"Database connection failed.\r\n\r\nExit the program.",
  96. L"Program Start Error!!!",
  97. MB_OK|MB_ICONERROR);
  98. }
  99. goto prog_exit;
  100. }
  101. try
  102. {
  103. ReportMemoryLeaksOnShutdown = true;
  104. Application->Initialize();
  105. Application->MainFormOnTaskBar = true;
  106. Application->Title = g_AppCfg.sTitle;
  107. Application->Title = "VMS 상태이력 조회";
  108. Application->CreateForm(__classid(TFrmVmsLogStts), &FrmVmsLogStts);
  109. Application->Run();
  110. }
  111. catch (Exception &exception)
  112. {
  113. Application->ShowException(&exception);
  114. }
  115. catch (...)
  116. {
  117. try
  118. {
  119. throw Exception("");
  120. }
  121. catch (Exception &exception)
  122. {
  123. Application->ShowException(&exception);
  124. }
  125. }
  126. prog_exit:
  127. try
  128. {
  129. ITSDb_Finalize();
  130. }
  131. catch(...)
  132. {
  133. }
  134. return 0;
  135. }
  136. //---------------------------------------------------------------------------