VmsCmraViewer.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 "FrmVmsCmraViewerF.h"
  10. //---------------------------------------------------------------------------
  11. USEFORM("SRC\FrmVmsCmraViewerF.cpp", FrmVmsCmraViewer);
  12. USEFORM("SRC\FrmCameraScreenF.cpp", FrmCameraScreen);
  13. USEFORM("SRC\FrmCameraPlayerF.cpp", FrmCameraPlayer);
  14. USEFORM("SRC\FrmCameraFullScreenF.cpp", FrmCameraFullScreen);
  15. USEFORM("SRC\FrmCameraInfoF.cpp", FrmCameraInfo);
  16. USEFORM("SRC\DMDbF.cpp", DMDb); /* TDataModule: File Type */
  17. //---------------------------------------------------------------------------
  18. WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
  19. {
  20. if (!CheckApplicationParam()) {
  21. return 0;
  22. }
  23. if (!ApplicationSingleRun("TFrmVmsCmraViewer", "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 0
  50. if (!ITSDb_Initialize())
  51. {
  52. if (g_AppCfg.sLang == "kr")
  53. {
  54. Application->MessageBox(L"Database 자원을 시스템으로부터 얻지 못했습니다.\r\n\r\n프로그램을 종료합니다.",
  55. L"프로그램 시작 오류!!!",
  56. MB_OK|MB_ICONERROR);
  57. }
  58. else
  59. {
  60. Application->MessageBox(L"Database resource could not be obtained from the system.\r\n\r\nExit the program.",
  61. L"Program Start Error!!!",
  62. MB_OK|MB_ICONERROR);
  63. }
  64. goto prog_exit;
  65. }
  66. if (g_AppCfg.itsdb.sConnectStr == "")
  67. {
  68. ITSDb_SetInfo(g_AppCfg.itsdb.sProvider, g_AppCfg.itsdb.sServerName, g_AppCfg.itsdb.sUserName, g_AppCfg.itsdb.sPassword);
  69. }
  70. else
  71. {
  72. ITSDb_SetConnStr(g_AppCfg.itsdb.sConnectStr);
  73. }
  74. if (!ITSDb_Open())
  75. {
  76. if (g_AppCfg.sLang == "kr")
  77. {
  78. Application->MessageBox(L"데이터베이스 접속에 실패하였습니다.\r\n\r\n프로그램을 종료합니다.",
  79. L"프로그램 시작 오류!!!",
  80. MB_OK|MB_ICONERROR);
  81. }
  82. else
  83. {
  84. Application->MessageBox(L"Database connection failed.\r\n\r\nExit the program.",
  85. L"Program Start Error!!!",
  86. MB_OK|MB_ICONERROR);
  87. }
  88. goto prog_exit;
  89. }
  90. #endif
  91. try
  92. {
  93. ReportMemoryLeaksOnShutdown = true;
  94. Application->Initialize();
  95. Application->MainFormOnTaskBar = true;
  96. Application->Title = g_AppCfg.sTitle;
  97. Application->Title = "VMS 영상 모니터링";
  98. Application->CreateForm(__classid(TFrmVmsCmraViewer), &FrmVmsCmraViewer);
  99. Application->CreateForm(__classid(TDMDb), &DMDb);
  100. Application->Run();
  101. }
  102. catch (Exception &exception)
  103. {
  104. Application->ShowException(&exception);
  105. }
  106. catch (...)
  107. {
  108. try
  109. {
  110. throw Exception("");
  111. }
  112. catch (Exception &exception)
  113. {
  114. Application->ShowException(&exception);
  115. }
  116. }
  117. prog_exit:
  118. try
  119. {
  120. #if 0
  121. ITSDb_Finalize();
  122. #endif
  123. }
  124. catch(...)
  125. {
  126. }
  127. return 0;
  128. }
  129. //---------------------------------------------------------------------------