private float CalcCurrentWorkTimeLoad(AppointmentBaseCollection apts, TimeInterval interval, Resource resource) { AppointmentBaseCollection aptsByResource = new AppointmentBaseCollection(); var aptQuery = apts.Where(a => a.ResourceId.Equals(resource.Id)); aptsByResource.AddRange(aptQuery.ToList()); IntervalLoadRatioCalculator calc = new IntervalLoadRatioCalculator(interval, aptsByResource); return(calc.Calculate()); }
public static void scheduler_CustomDrawNavigationButton(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { NavigationButtonNext navButton = e.ObjectInfo as NavigationButtonNext; SchedulerControl scheduler = sender as SchedulerControl; SchedulerStorage storage = scheduler.Storage as SchedulerStorage; // Do not count by resources. if (scheduler.GroupType != SchedulerGroupType.None) { return; } if (navButton != null && scheduler != null && storage != null) { // Count appointments within the interval used by the Next navigation button. AppointmentBaseCollection apts = scheduler.Storage.Appointments.Items; TimeSpan aptSearchInterval = scheduler.OptionsView.NavigationButtons.AppointmentSearchInterval; DateTime lastVisibleTime = scheduler.ActiveView.GetVisibleIntervals().Last().End; int aptCount = apts.Where(a => (a.Start > lastVisibleTime) && (a.Start < lastVisibleTime.Add(aptSearchInterval))).Count(); navButton.DisplayTextItem.Text = String.Format("Next {0} appointments", aptCount); } }