Recurring Events
- 5 minutes to read
This topic introduces the concept of the Recurring Events feature supported by the Scheduler Module, describes how to create and use recurring events in your schedule, and details how recurrence settings can be edited.
Non-Recurring and Recurring Events
The Scheduler module supports the following event types:
- Simple
- Occur only once in the specified time interval.
- Recurring
- Occur many times with the same time interval.
The Scheduler module works with business classes that implement the DevExpress.Persistent.Base.General.IEvent
interface. To support recurring events, these classes must implement an additional IRecurrentEvent
interface. If you already have a custom class that implements the IEvent
interface, you can implement the IRecurrentEvent
interface yourself. Alternatively, you can use the DevExpress.Persistent.BaseImpl.EF.Event
(Entity Framework Core) or DevExpress.Persistent.BaseImpl.Event
(XPO) class from the Business Class Library that implements the IEvent
and IRecurrentEvent
interfaces.
To see how these classes are implemented, refer to the following resources:
- %PROGRAMFILES%\DevExpress 24.1\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl.Xpo
- %PROGRAMFILES%\DevExpress 24.1\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl.EFCore)
To extend the class with custom properties, inherit from it.
Creating a Recurring Event
To create a recurring event, create an Event and specify its recurrence via the Recurrence
property. XAF uses SchedulerRecurrenceInfoPropertyEditor
to display this property in the Event Detail View.
- ASP.NET Core Blazor
- Windows Forms
- ASP.NET Web Forms
Click the Recurrence editor’s ellipsis button (Windows Forms and ASP.NET Web Forms) or select a combo box value (ASP.NET Core Blazor) to invoke the Recurrence dialog and specify the required settings.
- ASP.NET Core Blazor
- Windows Forms
- ASP.NET Web Forms
The recurrence settings specified in this dialog comprise the Recurrence Pattern.
Recurrence Pattern
A recurring event’s recurrence settings are stored in the Recurrence Pattern. When the Scheduler module needs to visualize the recurring event’s occurrences on a time line, it reads the recurrence settings from the Recurrence Pattern. However, a recurring event is not really useful in real-life applications if you cannot customize its individual occurrences. For instance, if you have a recurring event that represents a weekly meeting, you may want to specify that the next week’s meeting starts an hour later than usual. You cannot do this in the event’s Recurrence dialog. Instead, you can edit the required occurrence on the Scheduler’s time line. The Scheduler module handles such customizations automatically with the help of a special collection associated with the event. This collection stores all the occurrences of the event that were changed or deleted. So, a recurring event is defined by its Recurrence Pattern and the collection of changes.
ASP.NET Core Blazor
To edit a single occurrence of a recurring event, double-click the event or click the event and click Edit in the tooltip. In the displayed dialog select Edit appointment.
To edit the series, click the event and click Edit in the tooltip. In the displayed dialog select either Edit series or Edit appointment.
If an occurrence has been modified, you can restore its settings to the ones used in the series it belongs to. To do this, use the Restore Occurrence command.
Windows Forms
To edit a single occurrence of a recurring event, invoke the context menu and click Open. To change the settings of all the occurrences, except those that have been changed or deleted, click Edit Series:
If an occurrence has been modified, you can restore its settings to the ones used in the series it belongs to. To do this, use the Restore Default State command.
ASP.NET Web Forms
To edit a single occurrence of a Recurring Event, invoke the context menu and click Edit. To change the settings of all the occurrences, except those that have been changed or deleted, click Edit Series.
To open the occurrence’s Detail View in a view mode, click Open. In the Detail View, click Edit to change the settings of the current occurrence.
To view an occurrence as an instance of the entire series, click Open Series. In the invoked Detail View, you can modify the Resources collection of all occurrences in the series and click Edit to changes the settings of the series.
If an occurrence has been modified, you can restore its settings to the ones used in the series it belongs to. To do this, use the Restore Occurrence Action.
Alternatively, you can use the Edit, EditSeries, OpenSeries and RestoreOccurrence Actions on the toolbar in ASP.NET Web Forms applications:
Create and Edit Recurrent Events in Code
The code sample below shows how to create recurrent events programmatically. You can reuse this code in the Updater
class of your XAF application to populate your database with data.
- Add the DevExpress.Scheduler.Core NuGet package to the project and rebuild the solution.
Create a new class and replace the auto-generated code with the following code:
using DevExpress.ExpressApp.Actions; using DevExpress.ExpressApp; using DevExpress.Persistent.Base; using DevExpress.Persistent.BaseImpl.EF; using DevExpress.XtraScheduler; using DevExpress.XtraScheduler.Xml; namespace YourApplicationName.Module.Controllers { public class RecurrenceController : ObjectViewController<ListView, Event> { public RecurrenceController() { var makeRecurrentEventAction = new SimpleAction(this, "MakeRecurrent", PredefinedCategory.ObjectsCreation); makeRecurrentEventAction.SelectionDependencyType = SelectionDependencyType.RequireSingleObject; makeRecurrentEventAction.Execute += (s, e) => { Event schedulerEvent = (Event)View.CurrentObject; if (schedulerEvent.Type == (int)AppointmentType.Normal) { schedulerEvent.Type = (int)AppointmentType.Pattern; RecurrenceInfo recurrenceInfo = new RecurrenceInfo(schedulerEvent.StartOn.Value); // You can specify other options of the RecurrenceInfo class here. RecurrenceInfoXmlPersistenceHelper helper = new RecurrenceInfoXmlPersistenceHelper(recurrenceInfo); schedulerEvent.RecurrenceInfoXml = helper.ToXml(); ObjectSpace.CommitChanges(); View.Refresh(); } }; } } }