Skip to main content

How to: Create Hourly Recurrence

  • 2 minutes to read
<dxsch:SchedulerControl.AppointmentItems>
    <!--Every 3 hours. Five occurrences.-->
    <dxsch:AppointmentItem 
        Type="Pattern"
        Start="1/1/2020 13:00:00"
        End="1/1/2020 14:00:00"
        Subject="Every 3 hours. Five occurrences."
        RecurrenceInfo="{dxsch:RecurrenceHourly Start='1/1/2020 13:00:00', Interval=3, OccurrenceCount=5}" />
    <!--Every 5 hours. Infinite (no end date).-->
    <dxsch:AppointmentItem 
        Type="Pattern"
        Start="1/1/2020 13:00:00"
        End="1/1/2020 14:00:00"
        Subject="Every 5 hours. Infinite (no end date)."
        RecurrenceInfo="{dxsch:RecurrenceHourly Start='1/1/2020 13:00:00', Interval=5}" />
    <!--Every hour. Series duration is 24 hours.-->
    <dxsch:AppointmentItem 
        Type="Pattern"
        Start="1/1/2020 13:00:00"
        End="1/1/2020 14:00:00"
        Subject="Every hour.  Series duration is 24 hours."
        RecurrenceInfo="{dxsch:RecurrenceHourly Start='1/1/2020 13:00:00', End='1/2/2020 13:00:00'}" />
</dxsch:SchedulerControl.AppointmentItems>
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 3 hours. Five occurrences.
    AppointmentItem apt1 = CreateAppointmentPattern("Every 3 hours. Five occurrences.", 1);
    apt1.SetRecurrenceInfo(RecurrenceBuilder.Hourly(apt1.Start, 5).Interval(3).Build());
    scheduler.AppointmentItems.Add(apt1);

    // An appointment is set every 5 hours. Infinite (no end date).
    AppointmentItem apt2 = CreateAppointmentPattern("Every 5 hours. Infinite (no end date).", 1);
    apt3.SetRecurrenceInfo(RecurrenceBuilder.Hourly(apt2.Start).Interval(5).Build());
    scheduler.AppointmentItems.Add(apt2);

    // An appointment is set every hour. Appointment series duration is 24 hours.
    AppointmentItem apt3 = CreateAppointmentPattern("Every hour.  Series duration is 24 hours.", 1);
    apt3.SetRecurrenceInfo(RecurrenceBuilder.Hourly(apt3.Start, apt3.Start.AddHours(24)).Build());
    scheduler.AppointmentItems.Add(apt3);