faster way to provide data |
Post Reply |
Author | |
Alex H.
Senior Member Joined: 12 February 2004 Status: Offline Points: 266 |
Post Options
Thanks(0)
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 |
|
AndreiM
Moderator Group Joined: 18 August 2007 Status: Offline Points: 132 |
Post Options
Thanks(0)
|
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.
|
|
Alex H.
Senior Member Joined: 12 February 2004 Status: Offline Points: 266 |
Post Options
Thanks(0)
|
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? |
|
AndreiM
Moderator Group Joined: 18 August 2007 Status: Offline Points: 132 |
Post Options
Thanks(0)
|
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?
|
|
Alex H.
Senior Member Joined: 12 February 2004 Status: Offline Points: 266 |
Post Options
Thanks(0)
|
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 |
|
Alex H.
Senior Member Joined: 12 February 2004 Status: Offline Points: 266 |
Post Options
Thanks(0)
|
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 |
|
Marco1
Senior Member Joined: 16 January 2004 Location: Germany Status: Offline Points: 251 |
Post Options
Thanks(0)
|
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 |
|
pitronot
Newbie Joined: 24 May 2009 Location: Israel Status: Offline Points: 6 |
Post Options
Thanks(0)
|
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 |
|
Alex H.
Senior Member Joined: 12 February 2004 Status: Offline Points: 266 |
Post Options
Thanks(0)
|
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 :-) |
|
Marco1
Senior Member Joined: 16 January 2004 Location: Germany Status: Offline Points: 251 |
Post Options
Thanks(0)
|
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. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |