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

#ifndef CDSUtisFH
#define CDSUtisFH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <ADODB.hpp>
#include <DB.hpp>
#include "cxCustomData.hpp"
#include "ITSLibF.h"
//---------------------------------------------------------------------------

/*
*  Utis class
*/
class TItsUtis
{
public:
    TItsUtis();
    virtual ~TItsUtis();
    void Clear();
private:
    bool    FModified;
    bool    FCompleted;

public:

	int    FGridIndex;	    // 메인폼에 뿌려지는 그리드 인덱스

    void SetValue(String &AOrgValue, String AValue);

protected:

public:
    __property bool   Modified  = {read = FModified};
    __property bool   Completed = {read = FCompleted, write = FCompleted};
	__property int    GridIndex  = {read = FGridIndex,  write = FGridIndex };
};
//---------------------------------------------------------------------------

#define MAX_UTIS_RUN    3
typedef struct
{
    String Status[MAX_UTIS_RUN];
    int    TotCnt[MAX_UTIS_RUN];
    int    RunCnt[MAX_UTIS_RUN];
    String LastTime[MAX_UTIS_RUN];
} UTIS_RUN;


/*
* Utis Manager
*/
class TItsUtisManager
{
public:
    TItsUtisManager();
    virtual ~TItsUtisManager();

public:
    String                      CenterId;
    UTIS_RUN                    UtisRun;
    int                         FTotCctvCnt;
    int                         RseRun[MAX_UTIS_RUN];
    TItsMap<String, TItsUtis*>  FLists;

public:
    void SetCenterId(String ACenterId);

    bool LoadFromDb(TADOConnection *ADbConn=NULL);
    bool LoadUtisMaster(TADOConnection *ADbConn=NULL);
    
    bool LoadUtisStatusFromDb(TADOConnection *ADbConn=NULL);
    bool LoadUtisStatusUtisRun(TADOConnection *ADbConn=NULL);
    bool LoadUtisStatusRseRun(TADOConnection *ADbConn=NULL);
};
//---------------------------------------------------------------------------
extern TItsUtisManager *ItsUtisManager;
//---------------------------------------------------------------------------

#endif

