search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

problems with the new recurrence mechanism

Asked by Gabriel
12 years ago.

Hi there,

We have built schedule software based on DayPilot. When DayPilot deployed the new version with 1-record based recurrence things began to go bad.
The main problem is that base events and their exceptions should ALWAYS be available in the set of events that you get from the database and pass on to the control to expand. The control needs these two records to correctly determine which event to show.

This might work well in simple calenders, but in our case we have several departments with their own employees. Some of these employees work on multiple departments. So this happens:

Department A has

  • Employee I
  • Employee II

Department B has

  • Employee I
  • Employee III

If I create a recurrent event for Employee I in department A it shows correctly for that Employee in department B. So far so good.

If I move an instance of that event from Employee I to Employee II (creating an exception-record in the process) and the scheduler refreshes then in Department A I see the the event in Employee's II schedule and not in Employee's I anymore. So far so good.

Now, when I show the schedule for department B where Employee II doesn't work, I only get the original base event from the database and feed that to the control. So what happens now, the control does not know anything about an exceptionrecord and shows the event in the schedule of Employee I! Offcourse this event should not show here as it has been moved to another department.

This also happens when I want to doubleclick on an employee and only wants to show the weeklyschedule for that employee. Any exceptions moved to other employees in that department won't load so the original event is shown in this weekly schedule, and we don't want that.

To make things worse, it also happens the other way around:

Department A has

  • Employee I
  • Employee II

Department B has

  • Employee I
  • Employee III

If I create a recurrent event for Employee II in department and move it as an exception to Employee I it shows correctly for that Employee in department A. So far so good.

But when I go to department B there is no base appointment in the resultset for that department because Employee II doesn't work there. So the control doesn't show the exception-event for Employee either!

This last problem can be 'solved' by looping through the resultset and identify all exception-records that have no matching base-record. For these records I remove the recurrenceinfo so the control won't try to match it to a base record. This way it will show in the calender as a 'regular' one time only event. It's not ideal though and makes it very prone to bugs because all of the different combinations.

If I would want to solve the first problem (base events showing up unwanted) I would have to search the database for matching exceptions in the database FOR EACH non-exception event in that schedule (which might be 100+ easily). This will drag down performance. Also it's very hard to find a matching exception for all of these 'virtual' events as these don't exist in the database.

Is there anything I can do to prevent these problems without having to go back to the old way?

TIA

Gabriel

Answer posted by Dan Letecky [DayPilot]
12 years ago.

Scheduling applications might get complex easily and I won't pretend DayPilot has a prebuilt solution for all the cases. One of the first things you may need to do is to switch from a simple one-table db schema (where the events, planned dates and resource links are all kept in the events table) to a more complex one (with one-to-many resource links).

In this case, this would help as well. In order to be able to load all recurring events correctly, you will need to add a table with event-resource links. This table will keep a record of all resources that might need this recurring event definition. You may use this just for the recurring events but probably it will be more elegant to keep the resource links for regular links as well.

For all standard events and recurring events with no exceptions, there will be just one link in this table. If you create an exception that will specify a different resource, you will need to add a link to that resource (if it doesn't exist already). You should do this for the master event and for all exceptions.

This way you will not have to load all recurring events in order to show recurring events for a single user but you will use this link table.

If you just need to find all exceptions related to a master event, you can use the recurrence field. All the recurrence field values (produced by RecurrenceException.Encode, RecurrenceException.EncodeExceptionModified, and RecurrenceException.EncodeExceptionDeleted) start with the master event id encoded using Base64, followed by a hash character ('#').

You should be able to do something like this (schematically):

var search = Base64.Encode(recurrentMasterId) + "#";
SELECT * FROM [event] WHERE [recurrent] LIKE @search + '%' 

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.