void GenerateEvents(CustomEventList eventList) { int count = schedulerStorage1.Resources.Count; for (int i = 0; i < 100; i++) { Resource resource = schedulerStorage1.Resources[i % count]; string subjPrefix = resource.Caption + "'s "; eventList.Add(CreateEvent(eventList, subjPrefix + "meeting", resource.Id, 2, 5)); eventList.Add(CreateEvent(eventList, subjPrefix + "travel", resource.Id, 3, 6)); eventList.Add(CreateEvent(eventList, subjPrefix + "phone call", resource.Id, 0, 10)); } }
private void schedulerStorage1_FetchAppointments(object sender, FetchAppointmentsEventArgs e) { DateTime start = e.Interval.Start; DateTime end = e.Interval.End; CustomEventList actualDataSource = this.schedulerStorage1.Appointments.DataSource as CustomEventList; if (actualDataSource == null) { return; } // Check if the requested interval is outside lastFetchedInterval if (start <= lastFetchedInterval.Start || end >= lastFetchedInterval.End) { // You can vary margin value to find the most appropriate balance between performance and detalization TimeSpan margin = TimeSpan.FromDays(0); // TimeSpan.FromDays(1) lastFetchedInterval = new TimeInterval(start - margin, end + margin); // Poplate the actualDataSource using the lastFetchedInterval actualDataSource.Clear(); for (int i = 0; i < fullDataSource.Count; i++) { CustomAppointment customAppointment = fullDataSource[i]; if (customAppointment.StartTime >= lastFetchedInterval.Start.Date && customAppointment.EndTime <= lastFetchedInterval.End.Date) { actualDataSource.Add(customAppointment); } } } lblInfo.Text = string.Format("Interval: {0}, Appointments: {1}", lastFetchedInterval, actualDataSource.Count.ToString()); }