For those of you following this series, I'm going to take a slight detour to explain one of the little bits of magic that we have been using to make loading and saving appointments very easy: RecurrenceExceptionHelper. If you downloaded the sample application from part 3, you'll see this sitting in the Silverlight-RIA-Entity folder (aka the Silverlight portion of the solution).
The first thing you might be asking is where the need for such a class comes from. Well, handling Recurrence rules and Exceptions are two of the more complex things that you can do when working with appointments. When using a two table approach to saving appointments, exceptions are referenced by an AppointmentType variable and the references are handled via the relationship between the tables.
Well, relational databases are not my cup of tea, so storing exceptions with the appointment seemed like the next best step. When working with saving recurrence patterns, the RadScheduler team has provided us with the RecurrencePatternHelper (you'll see this referenced in the project we've been working on) which comes from the Telerik.Windows.Controls.Scheduler.ICalendar namespace. This helper provides two main functions- turning a recurrence pattern into a nicely serialized string for storage and producing a recurrence pattern when you provide that string back to it.
Exceptions, on the other hand, don't have a standard method for handling them, especially when you start creating custom appointment types. So came the need for RecurrenceExceptionHelper.
The purpose of the class is twofold, much like its friend RecurrencePatternHelper- to serialize a list of exceptions for storage and to turn that stored string into exceptions we can add back to our appointments when they are retrieved from the database. So we have two methods to use here:
I included comments in the class that sum up nicely how we save these items:
Make note of this section because it explains exactly how an ExceptionOccurence is broken down. Moving forward as we start working with a custom appointment class, you'll see how important it is to know how RecurrenceExceptionHelper works so you can add new fields into your saved exceptions.
I know this wasn't the most exciting installment of this series, but I wanted to take a few moments to explain this class because it will become very important to know how it works as you move forward with custom appointments and how RadScheduler works with them.
In the next episode, we'll be looking into how to customize the AppointmentEditTemplate to incorporate the Location, URL, Developer, and ProductLine variables from our database.
Evan Hutnick works as a Developer Evangelist for Telerik specializing in Silverlight and WPF in addition to being a Microsoft MVP for Silverlight. After years as a development enthusiast in .Net technologies, he has been able to excel in XAML development helping to provide samples and expertise in these cutting edge technologies. You can find him on Twitter @EvanHutnick.
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.