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 every seventh day of February every year. Four occurrences.
AppointmentItem apt1 = CreateAppointmentPattern("Every seventh day of February every year. Four occurrences.", 5);
apt1.SetRecurrenceInfo(RecurrenceBuilder.Yearly(apt1.Start, 4).ByMonthDay(2, 7).Build());
scheduler.AppointmentItems.Add(apt1);
// An appointment occurs the second Monday in August for 2 years. Infinite (no end date).
AppointmentItem apt2 = CreateAppointmentPattern("The second Monday in August with a 2-year interval. Infinite (no end date).", 5);
apt2.SetRecurrenceInfo(RecurrenceBuilder.Yearly(apt2.Start).ByMonthDay(8, WeekDays.Monday, WeekOfMonth.Second)
.Interval(2).Build());
scheduler.AppointmentItems.Add(apt2);
// An appointment occurs on the last day of every year for 10 years.
AppointmentItem apt3 = CreateAppointmentPattern("The last day of every year for 10 years.", 5);
apt3.SetRecurrenceInfo(RecurrenceBuilder.Yearly(apt3.Start, apt3.Start.AddYears(10)).ByMonthDay(12, 31).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 every seventh day of February every year. Four occurrences.
Private apt1 As AppointmentItem = CreateAppointmentPattern("Every seventh day of February every year. Four occurrences.", 5)
apt1.SetRecurrenceInfo(RecurrenceBuilder.Yearly(apt1.Start, 4).ByMonthDay(2, 7).Build())
scheduler.AppointmentItems.Add(apt1)
' An appointment occurs the second Monday in August for 2 years. Infinite (no end date).
Dim apt2 As AppointmentItem = CreateAppointmentPattern("The second Monday in August with a 2-year interval. Infinite (no end date).", 5)
apt2.SetRecurrenceInfo(RecurrenceBuilder.Yearly(apt2.Start).ByMonthDay(8, WeekDays.Monday, WeekOfMonth.Second).Interval(2).Build())
scheduler.AppointmentItems.Add(apt2)
' An appointment occurs on the last day of every year for 10 years.
Dim apt3 As AppointmentItem = CreateAppointmentPattern("The last day of every year for 10 years.", 5)
apt3.SetRecurrenceInfo(RecurrenceBuilder.Yearly(apt3.Start, apt3.Start.AddYears(10)).ByMonthDay(12, 31).Build())
scheduler.AppointmentItems.Add(apt3)