Loading multiple recurrances into a calendar


I’m 99% sure I want to purchase your product… just want to run something by you first.

I want to populate an ASP.Net Calendar control with scheduled appointments. The calendar calls an event DayRender as it renders each day, and this is where you have the opportunity to load in the contents for each day.

If a user sets up 20 recurring appointments in our database, and we want to show them on the calendar, then the way I see it you’ve got to query each one of those recurrance objects for every day of the week to determine if an appointment occurs for that day. This doesn’t seem real efficient as it would result in more than 600 queries just to display the recurring appointments on the calendar.

Is there a more straightforward way to doing this?




Let’s say that a user has the an recurring task to make a bank deposit that recurs every Tuesday.

Two weeks from now, they want to change the occurrance to happen on Wednesday because of a holiday.

They want to attach a note to the following week reminding them that they need to deposit to a different account.

Can date changes and custom information be stored with each occurrance?




Hi Rob,

To answer questions in your first message:

1. Simple code solution. Aspose.Recurrence calculates dates of occurrences very fast and you can try and call every recurrence object for every day you want to display. You can try this first because it will result in the simplest code and most likely good enough performance. So for 20 occurrences and 30 days you would have 600 calls to GenerateOccurrences() function.

2. Optimized solution. If your calendar displays a range of dates, for example a week or a month, then you can optimize and call every recurrence object only once for the range you want to display. I don’t think the code is going to be more complex, maybe it will even be simpler. There will be only 20 calls to GenerateOccurrences(start, end, dates).

3. Even more optimized solution. Every calendar application normally displays only a range of dates to the user at a given time. If you want to minimize number of calls to GenerateOccurrences() even further, you can create a cache of occurrences for, say plus/minus several months from the current date. So you only call GenerateOccurrences(bigger range) when the program starts up and then you only call it if the user navigates behind the date range covered by the cache or if the user modifies one of the recurrence objects. This is the most complex solution to code because it requires creating a sort of precalculated occurrence cache manager, but it achieves smallest number of calls to GenerateOccurrences(). I don’t think Aspose.Recurrence will ever become such a calculation bottleneck as to require a complex cache like this.

If you want a little history, Aspose.Recurrence was initially developed just for a calendar application that displayed daily, weekly, monthly and yearly views of events. Solution 2 was used in that application successfully. I was calling each recurrence object once to calculate occurrences for the range the calendar was displaying.


Hi Rob,

Now to answer your question about changes of dates and reminders.

1. Aspose.Recurrence supports Change and Skip Exemptions. This means that every occurrences that is a part of the pattern can either be changed to another date or skipped altogether. You do this by using RecurrenceBase.Exemptions collection.
For example, next Tuesday is 28/10/2003 and this is the day when a normal occurrence happens, but you want to change that date to be Wednesday, 29/10/2003. All you do is:
recur.Exemptions.AddChange(new DateTime(2003, 10, 28), new DateTime(2003, 10, 29);

2. At the moment you cannot store custom information inside Aspose.Recurrence recurrence and exemption objects and this is a design feature I’ll try to explain.

Every use of Aspose.Recurrence is unique and poses different requirements so Aspose.Recurrence tries to achieve high reusability by implementing only one thing - calculating recurrence dates, but doing it well.

It is supposed that you don’t try to store something inside Aspose.Recurrence classes, but instead, use and store Aspose.Recurrence classes inside your domain specific classes.

For example, in a calendar application like yours, you would probably have Event class. Every event is likely to have fields: Name, Duration, IsAllDay, Attendees, Location, Category, Notes etc etc. Another attribute of Event could be presense or absense of recurrence. That recurrence pattern and also all occurrences can be represented using Aspose.Recurrence classes. So basically, it is your Event class that “has” or “uses” Aspose.Recurrence, not vice versa.

There is an example in Aspose.Recurrence.Demos.WinForms of just that. There is a class called Task that has Name and Recurrence. The program mostly operates using instances of the Task class (your domain object) and invokes Aspose.Recurrence only to manager recurrence pattern or calculate occurrence dates.

3. On reflection, for lightweight applications it might be worthwhile for RecurrenceBase and Exemption classes in Aspose.Recurrence to have “public object Tag” property so you actually can store some custom data within Aspose.Recurrence objects. Let me know if this feature will be useful to you and I might be able to add it relatively quickly. Otherwise, build your classes so they “own” and “know” about Aspose.Recurrence.