FrmInitializeF.cpp 4.1 KB

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