//---------------------------------------------------------------------------
#pragma hdrstop

#include "CDSParkF.h"
#include "AppGlobalF.h"

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

#pragma package(smart_init)

/////////////////////////////////////////////////////////////////////////////
TCDSParkManager *CDSParkManager = NULL;
//---------------------------------------------------------------------------
int TCDSParkManager::Load()
{
    FLists.RemoveAll();

    String apiUri = g_AppCfg.sRestApiUri + "/api/vms/common/vms-type";
    TMcJsonItem *ObjList = NULL;
    try {
        ObjList = TRestObjectManager::RequestGet(apiUri);
        if (ObjList == NULL) {
            return 0;
        }

        for (int ii = 0; ii < ObjList->Count; ii++) {
            String sDelYn = TRestObjectManager::GetValue(ObjList->Items[ii], "del_yn");
            if (sDelYn == "Y") {
                continue;
            }

            TCDSPark *pObj = new TCDSPark();
            pObj->PRLT_CTLR_NMBR = TRestObjectManager::GetValue(ObjList->Items[ii], "aa");
            pObj->PRLT_CTLR_ID   = TRestObjectManager::GetValue(ObjList->Items[ii], "aa");
            pObj->PRLT_NM        = TRestObjectManager::GetValue(ObjList->Items[ii], "aa");
            pObj->REAL_DATA_YN   = TRestObjectManager::GetValue(ObjList->Items[ii], "aa");
            pObj->DEL_YN = sDelYn;

            FLists.Push(pObj->PRLT_CTLR_NMBR, pObj);
        }
    } __finally {
        if (ObjList) delete ObjList;
    }
    return FLists.Size();
}
//---------------------------------------------------------------------------
