CString CXTPCalendarResourcesManager::GetDataProvider_ConnStr(int nIndex) const
{
    CXTPCalendarData* pData = GetDataProvider(nIndex);

    if (pData)
    {
        return pData->GetConnectionString();
    }
    return _T("");
}
void CXTPCalendarResourcesManager::_Save(CXTPPropExchange* pPX)
{
    if (!pPX || !pPX->IsStoring())
    {
        ASSERT(FALSE);
        return;

    }
    pPX->ExchangeLocale();

    CXTPPropExchangeSection secDPs(pPX->GetSection(_T("DataProviders")));

    int nDPCount = GetDataProvidersCount();
    CXTPPropExchangeEnumeratorPtr ptrEnumDPs(secDPs->GetEnumerator(_T("DataProvider")));
    POSITION posStorage = ptrEnumDPs->GetPosition(nDPCount);

    for (int nDRNr = 0; nDRNr < nDPCount; nDRNr++)
    {
        CXTPCalendarData* pDP = GetDataProvider(nDRNr);
        ASSERT(pDP);
        if (!pDP)
        {
            continue;
        }

        CString strConnStr = pDP->GetConnectionString();

        CXTPPropExchangeSection secDP(ptrEnumDPs->GetNext(posStorage));
        PX_String(&secDP, _T("ConnectionString"), strConnStr);
    }

    //---------------------
    CXTPPropExchangeSection secResources(pPX->GetSection(_T("Resources")));

    int nRCCount = GetResourcesCount();
    CXTPPropExchangeEnumeratorPtr ptrEnumRCs(secResources->GetEnumerator(_T("Resource")));
    posStorage = ptrEnumRCs->GetPosition(nRCCount);

    for (int nRCNr = 0; nRCNr < nRCCount; nRCNr++)
    {
        CXTPCalendarResourceDescription* pRCdesc = GetResource(nRCNr);
        if (!pRCdesc || !pRCdesc->m_ptrResource)
        {
            ASSERT(FALSE);
            continue;
        }

        CXTPPropExchangeSection secRC(ptrEnumRCs->GetNext(posStorage));

        CString strRCName = pRCdesc->m_ptrResource->GetName();
        PX_String(&secRC, _T("Name"), strRCName);
        PX_Bool(&secRC, _T("Enabled"), pRCdesc->m_bEnabled);
        PX_Bool(&secRC, _T("GenerateName"), pRCdesc->m_bGenerateName);

        CXTPCalendarData* pRCdp = pRCdesc->m_ptrResource->GetDataProvider();
        if (pRCdp)
        {
            CString strConnStr = pRCdp->GetConnectionString();
            PX_String(&secRC, _T("ConnectionString"), strConnStr);

            int nSchIdsCount = 0;
            if (pRCdesc->m_ptrResource->GetSchedules())
            {
                nSchIdsCount = (int)pRCdesc->m_ptrResource->GetSchedules()->GetSize();
            }
            PX_Int(&secRC, _T("SchedulesCount"), nSchIdsCount);

            CXTPPropExchangeEnumeratorPtr ptrEnumSchIDs(secRC->GetEnumerator(_T("Schedules")));
            POSITION posSchID = ptrEnumSchIDs->GetPosition(nSchIdsCount);

            for (int k = 0; k < nSchIdsCount; k++)
            {
                CXTPPropExchangeSection secSchID(ptrEnumSchIDs->GetNext(posSchID));
                ULONG ulSchID = pRCdesc->m_ptrResource->GetSchedules()->GetAt(k);
                PX_ULong(&secSchID, _T("ScheduleID"), ulSchID);
            }
        }
    }
}