How to: Create Minutely Recurrence
- 2 minutes to read
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-create-appointments-with-various-recurrence-types-in-code-t574486.
public AppointmentItem CreateAppointmentPattern(string subj, int categoryId) {
AppointmentItem apt = new AppointmentItem(AppointmentType.Pattern);
apt.Start = DateTime.Today.AddHours(9);
apt.End = apt.Start.AddMinutes(5);
apt.Subject = subj;
apt.LabelId = categoryId;
return apt;
}
// An appointment is set every 10 minutes. Five occurrences.
AppointmentItem apt1 = CreateAppointmentPattern("Every 10 minutes. Five occurrences.", 0);
apt1.RecurrenceInfo.Type = RecurrenceType.Minutely;
apt1.RecurrenceInfo.Start = apt1.Start;
apt1.RecurrenceInfo.Periodicity = 10;
apt1.RecurrenceInfo.Range = RecurrenceRange.OccurrenceCount;
apt1.RecurrenceInfo.OccurrenceCount = 5;
scheduler.AppointmentItems.Add(apt1);
// An appointment is set every 45 minutes. Infinite (no end time).
AppointmentItem apt2 = CreateAppointmentPattern("Every 45 minutes. Infinite", 0);
apt2.RecurrenceInfo.Type = RecurrenceType.Minutely;
apt2.RecurrenceInfo.Start = apt1.Start;
apt2.RecurrenceInfo.Periodicity = 45;
apt2.RecurrenceInfo.Range = RecurrenceRange.NoEndDate;
scheduler.AppointmentItems.Add(apt2);
// An appointment is set every 20 minutes. The appointment chain duration is 10 hours.
AppointmentItem apt3 = CreateAppointmentPattern("Every 20 minutes. Series duration is 10 hours.", 0);
apt3.RecurrenceInfo.Type = RecurrenceType.Minutely;
apt3.RecurrenceInfo.Start = apt1.Start;
apt3.RecurrenceInfo.Periodicity = 20;
apt3.RecurrenceInfo.Range = RecurrenceRange.EndByDate;
apt3.RecurrenceInfo.End = apt1.RecurrenceInfo.Start.AddHours(10);
scheduler.AppointmentItems.Add(apt3);