CrsTrafVolDir.cpp 4.6 KB

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