Print Page | Close Window

Trying to load all records into calendar at once

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=16488
Printed Date: 16 May 2024 at 4:26am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Trying to load all records into calendar at once
Posted By: dennisV
Subject: Trying to load all records into calendar at once
Date Posted: 22 March 2010 at 5:45pm
Hello all,

I'm trying to load all calendar records into the control when the application starts, to speed up loading time, but I can't seem to get it to work properly.

Can someone spot what I'm doing wrong? Thanks in advance!

The idea is to create arrays of events for days and then add them to the cache, so that the control could use them. Maybe I need a different approach altogether?

Some code (not really working properly):


        CArray<CXTPCalendarEvent *> plannerEntries;
        // populate the array from the database here, entries are sorted based on start time

        COleDateTime dtCur;
        dtCur.m_dt = 0;
        CXTPCalendarEvents * ptrEvents = NULL;

        int count = plannerEntries.GetCount();
        for(int i=0; i<count; i++)
        {
            CXTPCalendarEvent * pEvent = plannerEntries.GetAt(i);
            if(pEvent)
            {
                COleDateTime dtEvent = pEvent->GetStartTime();
                COleDateTime dtToCompare = dtEvent;
                dtToCompare.SetDateTime(dtEvent.GetYear(), dtEvent.GetMonth(), dtEvent.GetDay(), 0, 0, 0);

                if(dtCur.m_dt == 0 ||
                    dtCur.m_dt != dtToCompare.m_dt)
                {
                    if(ptrEvents)
                    {
                        if(dtCur.m_dt != 0)
                        {
                            m_cache.AddToCache(ptrEvents, dtCur);
                        }
                    }

                    dtCur = dtToCompare;

                    if(ptrEvents)
                        delete ptrEvents;
                    ptrEvents = new CXTPCalendarEvents;
                }

                if(ptrEvents)
                {
                    ptrEvents->Add(pEvent, FALSE);
                }
            }
        }

        if(ptrEvents)
        {
            if(dtCur.m_dt != 0)
            {
                m_cache.AddToCache(ptrEvents, dtCur);
            }

            delete ptrEvents;
        }


This is in my custom data provider of course.


-------------
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net