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 recurs every 2 weeks, on Monday and Wednesday. It occurs 15 times.
AppointmentItem apt1 = CreateAppointmentPattern("2 weeks interval, on Monday and Wednesday, 15 occurrences.", 3);
apt1.SetRecurrenceInfo(RecurrenceBuilder.Weekly(apt1.Start, 15).ByDay(WeekDays.Monday | WeekDays.Wednesday).Interval(2).Build());
scheduler.AppointmentItems.Add(apt1);
// An appointment occurs every fourth week on weekends. Infinite (no end date).
AppointmentItem apt2 = CreateAppointmentPattern("Every fourth week on weekends. Infinite (no end date).", 3);
apt2.SetRecurrenceInfo(RecurrenceBuilder.Weekly(apt2.Start).ByDay(WeekDays.WeekendDays).Interval(3).Build());
scheduler.AppointmentItems.Add(apt2);
// An appointment occurs every Friday for 24 days.
AppointmentItem apt3 = CreateAppointmentPattern("Every Friday for 24 days.", 3);
apt3.SetRecurrenceInfo(RecurrenceBuilder.Weekly(apt3.Start, apt3.Start.AddDays(24)).ByDay(WeekDays.Friday).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 recurs every 2 weeks, on Monday and Wednesday. It occurs 15 times.
Private apt1 As AppointmentItem = CreateAppointmentPattern("2 weeks interval, on Monday and Wednesday, 15 occurrences.", 3)
apt1.SetRecurrenceInfo(RecurrenceBuilder.Weekly(apt1.Start, 15).ByDay(WeekDays.Monday Or WeekDays.Wednesday).Interval(2).Build())
scheduler.AppointmentItems.Add(apt1)
' An appointment occurs every fourth week on weekends. Infinite (no end date).
Dim apt2 As AppointmentItem = CreateAppointmentPattern("Every fourth week on weekends. Infinite (no end date).", 3)
apt2.SetRecurrenceInfo(RecurrenceBuilder.Weekly(apt2.Start).ByDay(WeekDays.WeekendDays).Interval(3).Build())
scheduler.AppointmentItems.Add(apt2)
' An appointment occurs every Friday for 24 days.
Dim apt3 As AppointmentItem = CreateAppointmentPattern("Every Friday for 24 days.", 3)
apt3.SetRecurrenceInfo(RecurrenceBuilder.Weekly(apt3.Start, apt3.Start.AddDays(24)).ByDay(WeekDays.Friday).Build())
scheduler.AppointmentItems.Add(apt3)