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 occurs on the 11th day of each month. Four occurrences.
AppointmentItem apt1 = CreateAppointmentPattern("On 11th day of each month. Four occurrences.", 4);
apt1.SetRecurrenceInfo(RecurrenceBuilder.Monthly(apt1.Start, 4).ByDay(11).Build());
scheduler.AppointmentItems.Add(apt1);
// An appointment occurs on the last Wednesday of the month, for 2 months. Infinite (no end date).
AppointmentItem apt2 = CreateAppointmentPattern("Last Wednesday of the month, for 2 months. Infinite (no end date).", 4);
apt2.SetRecurrenceInfo(RecurrenceBuilder.Monthly(apt2.Start).ByDay(WeekDays.Wednesday, WeekOfMonth.Last)
.Interval(2).Build());
scheduler.AppointmentItems.Add(apt2);
// An appointment occurs on the first Monday of the month for 3 months. The series duration is one year.
AppointmentItem apt3 = CreateAppointmentPattern("First Monday of the month for 3 months. The series duration is one year.", 4);
apt3.SetRecurrenceInfo(RecurrenceBuilder.Monthly(apt3.Start, apt3.Start.AddYears(1))
.ByDay(WeekDays.Monday, WeekOfMonth.First).Interval(3).Build());
scheduler.AppointmentItems.Add(apt3);
Public Function CreateAppointmentPattern(ByVal subj As String, ByVal categoryId As Integer) As AppointmentItem
Dim apt As New AppointmentItem(AppointmentType.Pattern)
apt.Start = Date.Today.AddHours(9)
apt.End = apt.Start.AddMinutes(5)
apt.Subject = subj
apt.LabelId = categoryId
Return apt
End Function
' An appointment occurs on the 11th day of each month. Four occurrences.
Private apt1 As AppointmentItem = CreateAppointmentPattern("On 11th day of each month. Four occurrences.", 4)
apt1.SetRecurrenceInfo(RecurrenceBuilder.Monthly(apt1.Start, 4).ByDay(11).Build())
scheduler.AppointmentItems.Add(apt1)
' An appointment occurs on the last Wednesday of the month, for 2 months. Infinite (no end date).
Dim apt2 As AppointmentItem = CreateAppointmentPattern("Last Wednesday of the month, for 2 months. Infinite (no end date).", 4)
apt2.SetRecurrenceInfo(RecurrenceBuilder.Monthly(apt2.Start).ByDay(WeekDays.Wednesday, WeekOfMonth.Last).Interval(2).Build())
scheduler.AppointmentItems.Add(apt2)
' An appointment occurs on the first Monday of the month for 3 months. The series duration is one year.
Dim apt3 As AppointmentItem = CreateAppointmentPattern("First Monday of the month for 3 months. The series duration is one year.", 4)
apt3.SetRecurrenceInfo(RecurrenceBuilder.Monthly(apt3.Start, apt3.Start.AddYears(1)).ByDay(WeekDays.Monday, WeekOfMonth.First).Interval(3).Build())
scheduler.AppointmentItems.Add(apt3)