Print Page | Close Window

faster way to provide data

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=11836
Printed Date: 29 April 2024 at 1:28am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: faster way to provide data
Posted By: Alex H.
Subject: faster way to provide data
Date 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
 
 



Replies:
Posted By: AndreiM
Date 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.   
 


-------------
Regards,
Andrei Melnik


Posted By: Alex H.
Date 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?



Posted By: AndreiM
Date 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?


-------------
Regards,
Andrei Melnik


Posted By: Alex H.
Date 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



Posted By: Alex H.
Date 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


Posted By: Marco1
Date 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



Posted By: pitronot
Date 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
 
 
 


Posted By: Alex H.
Date 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 :-)


Posted By: Marco1
Date 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.




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