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

#include "CDSVmsIfscF.h"
#include "AppGlobalF.h"

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

#pragma package(smart_init)

/////////////////////////////////////////////////////////////////////////////
TVmsIfscManager *VmsIfscManager = NULL;
//---------------------------------------------------------------------------
int TVmsIfscManager::Load()
{
    FLists.RemoveAll();

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

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

            TVmsIfsc *pObj = new TVmsIfsc();
            pObj->VMS_IFSC_ID       = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_ifsc_id");
            pObj->VMS_IFSC_NM       = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_ifsc_nm");
            pObj->DSPL_STRT_NODE_NM = TRestObjectManager::GetValue(ObjList->Items[ii], "dspl_strt_node_nm");
            pObj->DSPL_END_NODE_NM  = TRestObjectManager::GetValue(ObjList->Items[ii], "dspl_end_node_nm");
            pObj->DETR_ID           = TRestObjectManager::GetValue(ObjList->Items[ii], "detr_id");
            pObj->ROAD_NM           = TRestObjectManager::GetValue(ObjList->Items[ii], "road_nm");
            pObj->SPOT_NM           = TRestObjectManager::GetValue(ObjList->Items[ii], "spot_nm");
            pObj->AXIS_YN           = TRestObjectManager::GetValue(ObjList->Items[ii], "axis_yn");
            pObj->USE_YN = sUseYn;

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