FrmInitializeF.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 (g_AppCfg.itsdb.sConnectStr == "")
  55. {
  56. DMDb->SetConnectString(g_AppCfg.itsdb.sProvider, g_AppCfg.itsdb.sServerName, g_AppCfg.itsdb.sUserName, g_AppCfg.itsdb.sPassword);
  57. }
  58. else
  59. {
  60. DMDb->SetConnectString(g_AppCfg.itsdb.sConnectStr);
  61. }
  62. if (!DMDb->Connect())
  63. {
  64. if (g_AppCfg.sLang != "kr")
  65. {
  66. Application->MessageBox(L"Database connection failed.\r\n\r\nPlease restart the program.",
  67. L"Database connection error !!!",
  68. MB_OK|MB_ICONERROR);
  69. }
  70. else
  71. {
  72. Application->MessageBox(L"데이터베이스 연결에 실패하였습니다.\r\n\r\n프로그램을 다시 시작하십시요.",
  73. L"데이터베이스 연결 오류!!!",
  74. MB_OK|MB_ICONERROR);
  75. }
  76. return;
  77. }
  78. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Loading basic informations...";
  79. else LblStatus->Caption = "기본 정보 로딩 중...";
  80. Application->ProcessMessages();
  81. cxProgressBar1->Position = 20;
  82. ObjCtlrManager->LoadCtlrFromDb(DMDb->GetConnection());
  83. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Initialize default monitoring screen...";
  84. else LblStatus->Caption = "기본 모니터링 화면 초기화...";
  85. Application->ProcessMessages();
  86. cxProgressBar1->Position = 40;
  87. ObjCtlrManager->InitMonitoringFormFromDb(DMDb->GetConnection());
  88. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Displaying monitoring screen...";
  89. else LblStatus->Caption = "모니터링 화면 조회중...";
  90. Application->ProcessMessages();
  91. Application->ProcessMessages();
  92. cxProgressBar1->Position = 60;
  93. ObjCtlrManager->LoadMonitoringFormFromDb(DMDb->GetConnection());
  94. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Configuring monitoring screen...";
  95. else LblStatus->Caption = "모니터링 화면 구성중...";
  96. Application->ProcessMessages();
  97. cxProgressBar1->Position = 100;
  98. Application->ProcessMessages();
  99. DMDb->Close();;
  100. }
  101. catch(...)
  102. {
  103. }
  104. Close();
  105. }
  106. //---------------------------------------------------------------------------
  107. void __fastcall TFrmInitialize::FormClose(TObject *Sender, TCloseAction &Action)
  108. {
  109. Action = caFree;
  110. }
  111. //---------------------------------------------------------------------------