VmsCamViewer.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 "FrmVmsCamViewerF.h"
  10. //---------------------------------------------------------------------------
  11. USEFORM("SRC\FrmVmsCamViewerF.cpp", FrmVmsCamViewer);
  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. USEFORM("SRC\FRAME_VmsListF.cpp", FRAMEVmsList); /* TFrame: File Type */
  18. USEFORM("SRC\VMSVIEWMF.cpp", VMSVIEWM);
  19. //---------------------------------------------------------------------------
  20. WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
  21. {
  22. if (!ApplicationSingleRun("TFrmVmsCamViewer", "VMS Web Camera Monitoring")) {
  23. return 0;
  24. }
  25. DateSeparator = '-';
  26. TimeSeparator = ':';
  27. ShortDateFormat ="yyyy-MM-dd";
  28. ShortTimeFormat = "hh:nn:ss";
  29. LongTimeFormat = "hh:nn:ss";
  30. cxFormatController()->BeginUpdate();
  31. cxFormatController()->UseDelphiDateTimeFormats = true;
  32. cxFormatController()->EndUpdate();
  33. cxFormatController()->GetFormats();
  34. cxFormatController()->NotifyListeners();
  35. g_nPid = (int)GetCurrentProcessId();
  36. g_sAppDir = ExtractFilePath(Application->ExeName);
  37. g_sAppName = ChangeFileExt(ExtractFileName(Application->ExeName), "");
  38. g_sCfgDir = g_sAppDir + g_IniFileDir + "\\";
  39. g_sLogDir = g_sAppDir + "Log\\";
  40. ForceDirectories(g_sLogDir.c_str());
  41. ChDir(g_sAppDir);
  42. /*
  43. * 시스템 운영환경을 ini 파일에서 읽어 온다.
  44. */
  45. LoadDefaultConfigInfo(g_IniFileName);
  46. ITSLog = new TITSLog(g_sLogDir, g_sAppName, g_AppCfg.sLogDay);
  47. ITSLog->FLogCfg = g_LogCfg;
  48. if (!ITSDb_Initialize())
  49. {
  50. Application->MessageBox(L"Database resource could not be obtained from the system.\r\n\r\nExit the program.",
  51. L"Program Start Error!!!",
  52. MB_OK|MB_ICONERROR);
  53. goto prog_exit;
  54. }
  55. if (g_AppCfg.itsdb.sConnectStr == "")
  56. {
  57. ITSDb_SetInfo(g_AppCfg.itsdb.sProvider, g_AppCfg.itsdb.sServerName, g_AppCfg.itsdb.sUserName, g_AppCfg.itsdb.sPassword);
  58. }
  59. else
  60. {
  61. ITSDb_SetConnStr(g_AppCfg.itsdb.sConnectStr);
  62. }
  63. if (!ITSDb_Open())
  64. {
  65. Application->MessageBox(L"Database connection failed.\r\n\r\nExit the program.",
  66. L"Program Start Error!!!",
  67. MB_OK|MB_ICONERROR);
  68. goto prog_exit;
  69. }
  70. try
  71. {
  72. ReportMemoryLeaksOnShutdown = true;
  73. Application->Initialize();
  74. Application->MainFormOnTaskBar = true;
  75. Application->Title = g_AppCfg.sTitle;
  76. Application->Title = "VMS Web Camera Monitoring";
  77. Application->CreateForm(__classid(TFrmVmsCamViewer), &FrmVmsCamViewer);
  78. Application->CreateForm(__classid(TDMDb), &DMDb);
  79. Application->Run();
  80. }
  81. catch (Exception &exception)
  82. {
  83. Application->ShowException(&exception);
  84. }
  85. catch (...)
  86. {
  87. try
  88. {
  89. throw Exception("");
  90. }
  91. catch (Exception &exception)
  92. {
  93. Application->ShowException(&exception);
  94. }
  95. }
  96. prog_exit:
  97. try
  98. {
  99. #if 0
  100. ITSDb_Finalize();
  101. #endif
  102. }
  103. catch(...)
  104. {
  105. }
  106. return 0;
  107. }
  108. //---------------------------------------------------------------------------