//---------------------------------------------------------------------------

#include <vcl.h>
#include "WindowMsgF.h"

#include "CDSIncidentF.h"
#include "ITSLangTransF.h"

#pragma hdrstop

#include "FrmInitializeF.h"
#include "FrmCctvOprMainF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxContainer"
#pragma link "cxControls"
#pragma link "cxEdit"
#pragma link "cxGraphics"
#pragma link "cxLabel"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxProgressBar"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinCaramel"
#pragma link "dxSkinCoffee"
#pragma link "dxSkinDarkRoom"
#pragma link "dxSkinDarkSide"
#pragma link "dxSkinFoggy"
#pragma link "dxSkinGlassOceans"
#pragma link "dxSkiniMaginary"
#pragma link "dxSkinLilian"
#pragma link "dxSkinLiquidSky"
#pragma link "dxSkinLondonLiquidSky"
#pragma link "dxSkinMcSkin"
#pragma link "dxSkinMoneyTwins"
#pragma link "dxSkinOffice2007Black"
#pragma link "dxSkinOffice2007Blue"
#pragma link "dxSkinOffice2007Green"
#pragma link "dxSkinOffice2007Pink"
#pragma link "dxSkinOffice2007Silver"
#pragma link "dxSkinOffice2010Black"
#pragma link "dxSkinOffice2010Blue"
#pragma link "dxSkinsCore"
#pragma link "dxSkinSeven"
#pragma link "dxSkinSharp"
#pragma link "dxSkinSilver"
#pragma link "dxSkinStardust"
#pragma resource "*.dfm"

//TFrmInitialize *FrmInitialize = NULL;
//---------------------------------------------------------------------------
__fastcall TFrmInitialize::TFrmInitialize(TComponent* Owner)
    : TForm(Owner)
{
    //ADOQry->Connection = ITSDb_GetConnection();
    LangTrans->Translate(this, ITSDb_GetConnection());
}
//---------------------------------------------------------------------------

void __fastcall TFrmInitialize::FormShow(TObject *Sender)
{
    Refresh();
    TmrShow->Enabled = true;
}
//---------------------------------------------------------------------------

void __fastcall TFrmInitialize::TmrShowTimer(TObject *Sender)
{
    TmrShow->Enabled = false;

    Application->ProcessMessages();
    cxProgressBar1->Properties->Max = 150;

    try
    {
        cxProgressBar1->Position = 10;
        LblStatus->Caption = cxLabel1->Caption;;//"코드정보 로딩...";
        Application->ProcessMessages();
        if (!ItsCodeManager)
        {
            ItsCodeManager = new TItsCodeManager();
            ItsCodeManager->LoadFromDb();
        }

        cxProgressBar1->Position = 20;
        LblStatus->Caption = cxLabel2->Caption;//"프로세스정보 로딩...";
        Application->ProcessMessages();
        if (!ItsProcessManager)
        {
            ItsProcessManager = new TItsProcessManager();
            ItsProcessManager->LoadFromDb();
            //ItsProcessManager->LoadProcessStatusFromDb();
            FrmCctvOprMain->PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_00);
            FrmCctvOprMain->FPollPrcsState.Polling = GetTickCount();
        }

        cxProgressBar1->Position = 70;
        LblStatus->Caption = cxLabel3->Caption;//"CCTV정보 로딩...";
        Application->ProcessMessages();
        if (!CctvCtlrManager)
        {
            CctvCtlrManager = new TCctvCtlrManager();
            CctvCtlrManager->LoadFromDb();

            FrmCctvOprMain->PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_01);
            FrmCctvOprMain->FPollVmsState.Polling = GetTickCount();
        }

        cxProgressBar1->Position = 130;
        LblStatus->Caption = cxLabel6->Caption;//"돌발발생정보 로딩...";
        Application->ProcessMessages();
        if (!ItsIncidentManager)
        {
            ItsIncidentManager = new TItsIncidentManager();
            //ItsIncidentManager->LoadFromDb();
            FrmCctvOprMain->PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_05);
            FrmCctvOprMain->FPollIncident.Polling = GetTickCount();
        }
    }
    catch(...)
    {
    }

    Close();
}
//---------------------------------------------------------------------------

void __fastcall TFrmInitialize::FormClose(TObject *Sender, TCloseAction &Action)
{
    Action = caFree;    
}
//---------------------------------------------------------------------------

