FrmInitializeF.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "CDSMonitoringObjF.h"
  5. #include "DMDbF.h"
  6. #pragma hdrstop
  7. #include "FrmInitializeF.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma link "cxContainer"
  11. #pragma link "cxControls"
  12. #pragma link "cxEdit"
  13. #pragma link "cxGraphics"
  14. #pragma link "cxLabel"
  15. #pragma link "cxLookAndFeelPainters"
  16. #pragma link "cxLookAndFeels"
  17. #pragma link "cxProgressBar"
  18. #pragma link "dxSkinBlack"
  19. #pragma link "dxSkinBlue"
  20. #pragma link "dxSkinsCore"
  21. #pragma resource "*.dfm"
  22. TFrmInitialize *FrmInitialize = NULL;
  23. //---------------------------------------------------------------------------
  24. __fastcall TFrmInitialize::TFrmInitialize(TComponent* Owner)
  25. : TForm(Owner)
  26. {
  27. if (g_AppCfg.sLang != "kr")
  28. {
  29. Caption = "Program initialize";
  30. LblStatus->Caption = "Initialize...";
  31. }
  32. }
  33. //---------------------------------------------------------------------------
  34. void __fastcall TFrmInitialize::FormShow(TObject *Sender)
  35. {
  36. Refresh();
  37. TmrShow->Enabled = true;
  38. }
  39. //---------------------------------------------------------------------------
  40. void __fastcall TFrmInitialize::TmrShowTimer(TObject *Sender)
  41. {
  42. TmrShow->Enabled = false;
  43. Refresh();
  44. Application->ProcessMessages();
  45. cxProgressBar1->Properties->Max = 100;
  46. try
  47. {
  48. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Connect database...";
  49. else LblStatus->Caption = "데이터베이스 연결 중...";
  50. Application->ProcessMessages();
  51. cxProgressBar1->Position = 10;
  52. DMDb->SetConnectString(g_AppCfg.itsdb.sProvider, g_AppCfg.itsdb.sServerName, g_AppCfg.itsdb.sUserName, g_AppCfg.itsdb.sPassword);
  53. if (!DMDb->Connect())
  54. {
  55. if (g_AppCfg.sLang != "kr")
  56. {
  57. Application->MessageBox(L"Database connection failed.\r\n\r\nPlease restart the program.",
  58. L"Database connection error !!!",
  59. MB_OK|MB_ICONERROR);
  60. }
  61. else
  62. {
  63. Application->MessageBox(L"데이터베이스 연결에 실패하였습니다.\r\n\r\n프로그램을 다시 시작하십시요.",
  64. L"데이터베이스 연결 오류!!!",
  65. MB_OK|MB_ICONERROR);
  66. }
  67. return;
  68. }
  69. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Loading basic informations...";
  70. else LblStatus->Caption = "기본 정보 로딩 중...";
  71. Application->ProcessMessages();
  72. cxProgressBar1->Position = 20;
  73. ObjCtlrManager->LoadCtlrFromDb(DMDb->GetConnection());
  74. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Initialize default monitoring screen...";
  75. else LblStatus->Caption = "기본 모니터링 화면 초기화...";
  76. Application->ProcessMessages();
  77. cxProgressBar1->Position = 40;
  78. ObjCtlrManager->InitMonitoringFormFromDb(DMDb->GetConnection());
  79. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Displaying monitoring screen...";
  80. else LblStatus->Caption = "모니터링 화면 조회중...";
  81. Application->ProcessMessages();
  82. Application->ProcessMessages();
  83. cxProgressBar1->Position = 60;
  84. ObjCtlrManager->LoadMonitoringFormFromDb(DMDb->GetConnection());
  85. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Configuring monitoring screen...";
  86. else LblStatus->Caption = "모니터링 화면 구성중...";
  87. Application->ProcessMessages();
  88. cxProgressBar1->Position = 100;
  89. Application->ProcessMessages();
  90. DMDb->Close();;
  91. }
  92. catch(...)
  93. {
  94. }
  95. Close();
  96. }
  97. //---------------------------------------------------------------------------
  98. void __fastcall TFrmInitialize::FormClose(TObject *Sender, TCloseAction &Action)
  99. {
  100. Action = caFree;
  101. }
  102. //---------------------------------------------------------------------------