Appointment.CreateException(AppointmentType, Int32) Method
Creates an exceptional appointment within a chain of recurring appointments.
Appointment CreateException( AppointmentType type, int recurrenceIndex )
Function CreateException( type As AppointmentType, recurrenceIndex As Integer ) As Appointment
An AppointmentType value that specifies the type of the exceptional appointment.
A zero-based integer which identifies the index in the chain of recurring appointments at which the new exceptional appointment will be created.
An Appointment object which is the newly created exceptional appointment.
To create a recurring appointment you should create a pattern appointment (its Appointment.Type property should be set to AppointmentType.Pattern) and specify the recurrence rule using the Appointment.RecurrenceInfo property. At run time, each pattern appointment generates a series of appointments, which is called a "recurrence chain". A recurrence chain is a series of regular occurrences (individual appointments) which will occur one after another at specified time intervals. An individual appointment (regular occurrence) in the chain has its Appointment.Type property set to AppointmentType.Occurrence. Each occurrence in the chain is identified by a zero-based recurrence index specified by the Appointment.RecurrenceIndex property.
The CreateException method allows you to modify an appointment (individual occurrence) in the chain when you have to change its location or start time. Also, you can delete an individual occurrence so it is excluded from the recurrence chain.
To modify a regular occurrence, call the CreateException method with the type parameter set to AppointmentType.ChangedOccurrence. As a result, a new appointment will be created based upon the pattern, and it will replace the specified regular occurrence. You can then change the settings of the new appointment as required.
To delete a regular occurrence, call the CreateException method with the type parameter set to AppointmentType.DeletedOccurrence. A new hidden appointment will be created so it replaces the regular occurrence at the specified recurrence index.
Use the Appointment.RestoreOccurrence method to restore the default state and settings of the individual occurrence.
The code below illustrates how to fix a different time for the recurring "Dinner" appointment that occurs on December 24.
TimeInterval interval = new TimeInterval(new DateTime(2018, 12, 24), TimeSpan.FromDays(1)); //retrieve the Appointment Appointment target = schedulerControl.DataStorage.GetAppointments(interval) .Find(x => x.Subject.Contains("Dinner")); //indentify the current Appointment index within a series int index = target.RecurrenceIndex; //replace the source Appointment with its Changed Occurrence copy Appointment changedTarget = target.RecurrencePattern.CreateException(AppointmentType.ChangedOccurrence, index); //modify the new appointment changedTarget.Start = changedTarget.Start.AddHours(2);