KB Article T866681
Visible to All Users

Scheduler - How to save and restore information about reminders, resources, and recurring patterns in XML format

All information about an appointment is saved as a single record in an underlying data source. Correspondingly, all appointment properties can be saved to the data source as scalar values (string, integer, boolean, DateTime).

Complex properties and collections (like reminders, resources, recurrence settings) are saved to the data source as XML strings in a corresponding format.
We use corresponding helpers to generate the mentioned XML strings while saving data and restore the mentioned properties/collections while loading appointments.

In some scenarios, it may be required to manually create such strings or parse XML strings obtained from a data source into corresponding objects.
This article describes how to use corresponding XML helpers for this task.

Reminders for Appointments

To generate an XML string containing information about an appointment's reminders, use the ReminderInfoCollectionXmlPersistenceHelper.ToXml method:

C#
ReminderInfoCollection someReminders = new ReminderInfoCollection(); someReminders.Add(new ReminderInfo() { AlertTime = DateTime.Now, TimeBeforeStart = TimeSpan.FromMinutes(10) }); ReminderInfoCollectionXmlPersistenceHelper helper = new ReminderInfoCollectionXmlPersistenceHelper(someReminders); string reminderXML = helper.ToXml();
Visual Basic
Dim someReminders As New ReminderInfoCollection() someReminders.Add(New ReminderInfo() With {.AlertTime = DateTime.Now, .TimeBeforeStart = TimeSpan.FromMinutes(10)}) Dim helper As New ReminderInfoCollectionXmlPersistenceHelper(someReminders) Dim reminderXML As String = helper.ToXml()

The ReminderInfoCollectionXmlPersistenceHelper.ObjectFromXml method can be used to restore a reminder collection from a given XML string:

C#
ReminderInfoCollection parsedReminders = new ReminderInfoCollection(); ReminderInfoCollectionXmlPersistenceHelper.ObjectFromXml(parsedReminders, reminderXML);
Visual Basic
Dim parsedReminders As New ReminderInfoCollection() ReminderInfoCollectionXmlPersistenceHelper.ObjectFromXml(parsedReminders, reminderXML)

Shared Resources for Appointments

When the Storage.Appointments.ResourceSharing option is enabled, each appointment can be assigned to several resources.
To create an XML string with information about a shared resource collection, use the AppointmentResourceIdCollectionXmlPersistenceHelper.ToXml method:

C#
ResourceIdCollection resources = new ResourceIdCollection(); resources.Add(2); resources.Add(5); AppointmentResourceIdCollectionXmlPersistenceHelper resourceHelper = new AppointmentResourceIdCollectionXmlPersistenceHelper(resources); string resourcesInXML = resourceHelper.ToXml();
Visual Basic
Dim resources As New ResourceIdCollection() resources.Add(2) resources.Add(5) Dim resourceHelper As New AppointmentResourceIdCollectionXmlPersistenceHelper(resources) Dim resourcesInXML As String = resourceHelper.ToXml()

The AppointmentResourceIdCollectionXmlPersistenceHelper.ObjectFromXml method can be used to restore the resource collection from an XML string:

C#
ResourceIdCollection parsedResources = new ResourceIdCollection(); AppointmentResourceIdCollectionXmlPersistenceHelper.ObjectFromXml(parsedResources, resourcesInXML);
Visual Basic
Dim parsedResources As New ResourceIdCollection() AppointmentResourceIdCollectionXmlPersistenceHelper.ObjectFromXml(parsedResources, resourcesInXML)

Take special note that starting from v15.2, resource IDs are saved in XML format using Base64 encoding:
Example of an XML string containing information about resources in old versions

XML
<ResourceIds> <ResourceId Type="System.Int32" Value="2" /> <ResourceId Type="System.Int32" Value="5" /> </ResourceIds>

Starting from version 15.2, the same string is encoded:

XML
<ResourceIds> <ResourceId Value="~Xtra#Base64AAEAAAD/////AQAAAAAAAAAEAQAAAAxTeXN0ZW0uSW50MzIBAAAAB21fdmFsdWUACAIAAAAL" /> <ResourceId Value="~Xtra#Base64AAEAAAD/////AQAAAAAAAAAEAQAAAAxTeXN0ZW0uSW50MzIBAAAAB21fdmFsdWUACAUAAAAL" /> </ResourceIds>

To switch back to the previous serialization mechanism, set the static Base64XmlObjectSerialization property to false:

C#
protected void Application_Start(object sender, EventArgs e) { DevExpress.XtraScheduler.SchedulerCompatibility.Base64XmlObjectSerialization = false; }
Visual Basic
Protected Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) DevExpress.XtraScheduler.SchedulerCompatibility.Base64XmlObjectSerialization = False End Sub

Recurrence Information for Appointments

To generate an XML string with recurrence information for a specific pattern, use the RecurrenceInfo.ToXml method:

C#
RecurrenceInfo recInfo = new RecurrenceInfo(); //ASPxScheduler1.SelectedAppointments[0].RecurrenceInfo; recInfo.Start = DateTime.Now; recInfo.Type = RecurrenceType.Weekly; recInfo.Periodicity = 2; recInfo.WeekDays = WeekDays.Monday | WeekDays.Wednesday; recInfo.Range = RecurrenceRange.OccurrenceCount; recInfo.OccurrenceCount = 15; string recurrenceXML = recInfo.ToXml();
Visual Basic
Dim recInfo As New RecurrenceInfo() 'ASPxScheduler1.SelectedAppointments[0].RecurrenceInfo; recInfo.Start = DateTime.Now recInfo.Type = RecurrenceType.Weekly recInfo.Periodicity = 2 recInfo.WeekDays = WeekDays.Monday Or WeekDays.Wednesday recInfo.Range = RecurrenceRange.OccurrenceCount recInfo.OccurrenceCount = 15 Dim recurrenceXML As String = recInfo.ToXml()

The RecurrenceInfo.FromXml method can be used to restore this information from an XML string:

C#
RecurrenceInfo parsedInfo = new RecurrenceInfo(); parsedInfo.FromXml(recurrenceXML);
Visual Basic
Dim parsedInfo As New RecurrenceInfo() parsedInfo.FromXml(recurrenceXML)

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.