Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Calendar
  New Posts New Posts RSS Feed - faster way to provide data
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

faster way to provide data

 Post Reply Post Reply
Author
Message
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Topic: faster way to provide data
    Posted: 15 August 2008 at 9:28am
I use a custom data provider and the event OnRetrieveDayEvents to supply Event Objects with Version 12.0.1

1) I do some queries in each call of  OnRetrieveDayEvents, but this is very slow if you are in a MonthView  ->  ist would be faster do provide all Events object of at least the current month in one bunch (one database query)

 Questions:
  Is there a better way to supply the data?
  or
  can I preload the data -> if yes which event should I use?

Regards

Alex
 
 
Back to Top
AndreiM View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 18 August 2007
Status: Offline
Points: 132
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndreiM Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2008 at 2:25pm
There is not built-in mechanizm to load all or some part of events in one batch.
As I understand you mean CXTPCalendarCustomDataProvider::DoRetrieveDayEvents.
 
Calendar data providers have internal cache.
After DoRetrieveDayEvents call - returned events will be stored in cache and DoRetrieveDayEvents will not be fired for this day.
 
I see 2 ways to avoid this:
   1. Use internal cache (may be for loading time only). Load all events in some array and use data from this array in OnRetrieveDayEvents.
   2. Load all events and use DataProvider->AddEvent to put all events to cache. In this case Data Provider will fire DoCreate_Event. Just skip it when loading data.   
 
Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Posted: 18 August 2008 at 7:39am
Yes, OnRetrieveDayEvents is the handler of XTP_NC_CALENDAR_DoRetrieveDayEvents:


I would like to avoid caching, because my application works in a multiuser environment with a lot of event changes.
It would be a great help to know, when the view will be updated f.ex. the month view starts a series of calls to event XTP_NC_CALENDAR_DoRetrieveDayEvents. So when the first call to XTP_NC_CALENDAR_DoRetrieveDayEvents occurs i could prefetch records of the next 7 or 30 days.

Any idea how to achieve that?

Back to Top
AndreiM View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 18 August 2007
Status: Offline
Points: 132
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndreiM Quote  Post ReplyReply Direct Link To This Post Posted: 18 August 2008 at 12:07pm
I think you can use way 2 described above (I mean add all events on the loading to cache),
but as I understand you will need some mechanism for synchronize clients.
 
Can you describe a little more about your multiuser architecture?
Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Posted: 19 August 2008 at 3:26am
Well its not that complicated
Appointments and Tasks are saved in a central database (simple client -server). Each client can add own appointments but also set appointments for other persons (also delete and change). So each client must poll (query) for new appointments and events. We use some sophisticated mechanisms for that task and also some internal data structures for saving recurrences. We read simple appointments on demand directly from database to reduce memory consumption.

Our application has the ability to show calendars of multiple persons. So if we would add all visible events to cache  -> this would take too long and consume too much memory.

So we would like to use that calendar control only for display. We do not need the data management. So if we would have an event, when the user changes the view and when  the user changes the day within the day view, we could add all visible events to cache and remove them before a new update of the view occurs.


Regards

Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2008 at 8:24am
I finally found a solution by adding Events to my own Cache in OnRetrieveDayEvents.

Event OnRetrieveDayEvents:

int nDayCount = GetCalendarCtrl().GetActiveView()->GetViewDayCount();
COleDateTime dtCurrentViewStart = GetCalendarCtrl().GetActiveView()->GetViewDayDate(0);

...

if(dtStart == dtCurrentViewStart && nDayCount > 1)
        AssignEventsToTmpCache(dtCurrentViewStart, nDayCount);

i fill the cache on the first request and then use it for lookup

this is much faster in monthview ans also in weekview
Back to Top
Marco1 View Drop Down
Senior Member
Senior Member


Joined: 16 January 2004
Location: Germany
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote Marco1 Quote  Post ReplyReply Direct Link To This Post Posted: 11 May 2009 at 6:08am
Alex,
can you please give some further implemention details, cause we are having exactly the same problem.
Remote database, lot of entries, client/server model, changing data in background...

Regars, Marco

Back to Top
pitronot View Drop Down
Newbie
Newbie


Joined: 24 May 2009
Location: Israel
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote pitronot Quote  Post ReplyReply Direct Link To This Post Posted: 25 May 2009 at 6:14pm
I have worked on a multi user env a while back, what we did was as follows
 
every change in event would be added to a table called changes
 
we used design patter called visitor dispatch design
the idea is that each user has a mailbox with changes, and will poll the table for changes per userid, this way all users will be in sync when they wish it.
 
There is a thread that runs every 2 min (or by button) and gathers and spreads the info of the user's changes vs other users' changes.
 
 
the table looked as follows
[Changes]
eventid : int
userid : int
 
every change would fill up the eventid and add all the userid's in the system
 
in every poll the thread would
 +read all the changes to the Changes table filtered by userid - first connect, readonly optimistic
 +add all changes the user made to the events - second er, connect, pessimistic lock
 
the Events table had a trigger to update the Changes table with all userid's not belonging to the CreatorID.
 
that's it.
 
pretty simple system.
 
very fast and efficient.
 
 
Mickey Perlstein
Dev Manager, vb division
 
 
 
Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Posted: 26 May 2009 at 3:09am
Hi !

I have a single Datasource that queries all visible Appointments for all users (users determined by filter).
The only special thing we use is, that we do not query for only one day, which is  too slow in the month view. We have our own cache that feeds the normal OnRetrieveDayEvents.

So if OnRetrieveDayEvents occurs, we first  check whether our cache contains the events. If not, we do the query and feed our cache.

Hope that helps :-)
Back to Top
Marco1 View Drop Down
Senior Member
Senior Member


Joined: 16 January 2004
Location: Germany
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote Marco1 Quote  Post ReplyReply Direct Link To This Post Posted: 26 May 2009 at 3:49am
Hi Alex,

thank you. Meanwhile I did the same thing and developed a special cache for the custom data provider which provides all events. One database access fetches all events for one year. This is extremly fast.
The internal calendar cache is disabled.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.160 seconds.