void CXTPCalendarResourcesManager::ApplyToCalendar(CXTPCalendarControl* pCalendar) { CXTPCalendarResources arResources; int nRCCount = GetResourcesCount(); for (int i = 0; i < nRCCount; i++) { CXTPCalendarResourceDescription* pRCdesc = GetResource(i); if (!pRCdesc || !pRCdesc->m_ptrResource) { ASSERT(FALSE); continue; } if (!pRCdesc->m_bEnabled || !pRCdesc->m_ptrResource->GetDataProvider()) { continue; } arResources.Add(pRCdesc->m_ptrResource, TRUE); } if (arResources.GetCount()) { pCalendar->SetResources(&arResources); } }
void CXTPCalendarViewDay::SetResources(CXTPCalendarResources* pResources) { BOOL bChanged = TRUE; if (!pResources) { bChanged = m_pResources != NULL; CMDTARGET_RELEASE(m_pResources); } else { if (!m_pResources) m_pResources = new CXTPCalendarResources(); if (!m_pResources) return; // copy data to allow using self as input parameter CXTPCalendarResources arRes; arRes.Append(pResources); m_pResources->RemoveAll(); m_pResources->Append(&arRes); } if (bChanged && GetView_()) { GetView_()->SendNotification(XTP_NC_CALENDAR_RESOURCES_WHERE_CHANGED, 2, (LPARAM)this); } }
BOOL CXTPCalendarRemindersManager::GetUpcomingEventsAll(COleDateTime dtFrom, COleDateTimeSpan spPeriod, CXTPCalendarEventsPtr& rptrEvents) { rptrEvents = NULL; if (!m_pResourcesNf || !m_pResourcesNf->GetResourcesGroupedByDP()) { ASSERT(FALSE); return FALSE; } CXTPCalendarResources* pRCgroups = m_pResourcesNf->GetResourcesGroupedByDP(); int i; int nCount = pRCgroups->GetCount(); //-- check is all data providers opened ------------- for (i = 0; i < nCount; i++) { CXTPCalendarResource* pRC = pRCgroups->GetAt(i); ASSERT(pRC); CXTPCalendarData* pData = pRC ? pRC->GetDataProvider() : NULL; ASSERT(pData); if (!pData || !pData->IsOpen()) { return FALSE; } } //-- read data ---------------- for (i = 0; i < nCount; i++) { CXTPCalendarResource* pRC = pRCgroups->GetAt(i); ASSERT(pRC); CXTPCalendarData* pData = pRC ? pRC->GetDataProvider() : NULL; if (!pData || !pData->IsOpen()) { ASSERT(FALSE); continue; } CXTPCalendarEventsPtr ptrEv = pData->GetUpcomingEvents(dtFrom, spPeriod); if (rptrEvents) { rptrEvents->Append(ptrEv); } else { rptrEvents = ptrEv; } pRC->FilterEventsByScheduleID(rptrEvents); } return TRUE; }
BOOL CXTPCalendarController::_HasEvents(COleDateTime dtDay) { ASSERT(m_pResourcesNf); if (!m_pResourcesNf) { return FALSE; } CXTPCalendarResources* pRCx = m_pResourcesNf->GetResourcesGroupedByDP(); int nRCCount = pRCx ? pRCx->GetCount() : 0; for (int i = 0; i < nRCCount; i++) { CXTPCalendarResource* pRC = pRCx->GetAt(i); ASSERT(pRC); CXTPCalendarEventsPtr ptrEvents = pRC ? pRC->RetrieveDayEvents(dtDay) : NULL; if (ptrEvents && ptrEvents->GetCount() > 0) { return TRUE; } } return FALSE; }