我使用以下代码示例从 customMicrosoft Dynamics CRM 2011 实体生成定期约会。此约会仅用于显示目的,它不会存储在任何地方。它只是用来显示某个员工何时必须按照他的周安排工作。
string vmstartuur = weekkalender.GetAttributeValue<OptionSetValue>("acm_" + weekdag + "vmstartuur").Value.ToString(dutchCultureInfo);
string vmstartminuut = weekkalender.GetAttributeValue<OptionSetValue>("acm_" + weekdag + "vmstartminuut").Value.ToString(dutchCultureInfo);
string vmeinduur = weekkalender.GetAttributeValue<OptionSetValue>("acm_" + weekdag + "vmeinduur").Value.ToString(dutchCultureInfo);
string vmeindminuut = weekkalender.GetAttributeValue<OptionSetValue>("acm_" + weekdag + "vmeindminuut").Value.ToString(dutchCultureInfo);
DateTime vmstartDateTime = new DateTime(nextDateTime.Year, nextDateTime.Month, nextDateTime.Day, Convert.ToInt32(vmstartuur.Substring(Math.Max(0, vmstartuur.Length - 2))), Convert.ToInt32(vmstartminuut.Substring(Math.Max(0, vmstartminuut.Length - 2))), 0, DateTimeKind.Local);
DateTime vmendDateTime = new DateTime(nextDateTime.Year, nextDateTime.Month, nextDateTime.Day, Convert.ToInt32(vmeinduur.Substring(Math.Max(0, vmeinduur.Length - 2))), Convert.ToInt32(vmeindminuut.Substring(Math.Max(0, vmeindminuut.Length - 2))), 0, DateTimeKind.Local);
Telerik.Web.UI.Appointment vmrecurringAppointment = new Telerik.Web.UI.Appointment {Subject = weekdag + " voormiddag", ID= weekkalender.acm_werknemer.Name + weekdag + "_voormiddag", Start = vmstartDateTime, End = vmendDateTime};
RecurrenceRange vmrange = new RecurrenceRange {Start = vmrecurringAppointment.Start, EventDuration = vmrecurringAppointment.End - vmrecurringAppointment.Start, RecursUntil = contract.slfn_Eindeovereenkomst.GetValueOrDefault(DateTime.MaxValue), MaxOccurrences = Int32.MaxValue};
WeeklyRecurrenceRule vmWeeklyRecurrenceRule = new WeeklyRecurrenceRule(1, GetRecurrenceDay(dayOfWeek), vmrange);
vmrecurringAppointment.RecurrenceRule = vmWeeklyRecurrenceRule.ToString();
vmrecurringAppointment.RecurrenceState = RecurrenceState.Master;
appointmentList.Add(vmrecurringAppointment);
我生成 2 到 14 个定期约会,每天 2 个。然后我使用RadScheduler.DataSource
绑定appointmentList
到 RadScheduler。
创建了约会,但问题是它们不会再次发生。第一次约会确实会在需要时出现,即在他开始工作的那一天,但不会重复。我在http://www.telerik.com/help/aspnet-ajax/scheduler-working-with-recurring-appointments.html和http://dotnetslackers.com/articles/aspnet/上遵循 Telerik 的定期约会指南Using-Teleriks-Scheduler-Component.aspx,但我无法弄清楚为什么它不会再次发生。