private bool CheckRoomAvailability(string roomName, string email, Slot slot, ExchangeService service, DateTime startDate, DateTime endtDate, Dictionary <string, FindItemsResults <Appointment> > fapts) { bool blnReturn = true; string key = email + startDate.ToString("ddMMyyyy") + endtDate.ToString("ddMMyyyy"); FindItemsResults <Appointment> fapt = fapts[key]; if (fapt == null) { return(false); } if (fapt.Count() > 0) { var starts = fapt.Select(t => t.Start).ToList(); var ends = fapt.Select(t => t.End).ToList(); if (fapt.Where(t => ((t.Start < slot.StartDateTime && t.End > slot.StartDateTime) || (t.Start < slot.EndDateTime && t.End > slot.EndDateTime) || (slot.StartDateTime < t.Start && slot.EndDateTime > t.Start) || (slot.StartDateTime < t.End && slot.EndDateTime > t.End) || (slot.StartDateTime == t.Start && slot.EndDateTime == t.End) )).Count() > 0) { return(false); } } return(blnReturn); }
/// <summary> /// Loads the upcoming calendar entries: Anything from now until the end of today, at most <paramref name="maxAppointments"/> items. /// </summary> /// <param name="maxAppointments">Max number of items to load</param> /// <seealso cref="FetchStickyEntries"/> /// <seealso cref="IsSticky"/> private void FetchUpcomingEvents(int maxAppointments = 10) { CalendarFolder calendar = CalendarFolder.Bind(_exchange, WellKnownFolderName.Calendar); CalendarView view = new CalendarView(DateTime.Now.AddMinutes(-5), DateTime.Today.AddDays(1).AddSeconds(-1), maxAppointments) { PropertySet = new PropertySet(ItemSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Location, AppointmentSchema.MyResponseType, AppointmentSchema.IsAllDayEvent) }; FindItemsResults <Appointment> appointments = calendar.FindAppointments(view); UpcomingEvents = appointments .Where(x => !IsSticky(x)) .Select(ConvertToEvent) .OrderBy(x => x.Start) .ThenBy(x => x.MeetingResponseOrder) .ThenBy(x => x.End) .ThenBy(x => x.Subject) .ToList() .AsReadOnly(); }
/// <summary> /// Loads all of today's sticky entries. /// </summary> /// <seealso cref="FetchUpcomingEvents"/> /// <seealso cref="IsSticky"/> private void FetchStickyEntries() { CalendarFolder calendar = CalendarFolder.Bind(_exchange, WellKnownFolderName.Calendar); CalendarView view = new CalendarView(DateTime.Today, DateTime.Today.Add(_latestEndForStickyEvents)) { PropertySet = new PropertySet(ItemSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Location, AppointmentSchema.MyResponseType, AppointmentSchema.IsAllDayEvent) }; FindItemsResults <Appointment> appointments = calendar.FindAppointments(view); StickyEvents = appointments .Where(IsSticky) .Select(ConvertToEvent) .Where(x => x.ZoomId != default) .OrderBy(x => x.Subject) .ThenBy(x => x.MeetingResponseOrder) .ThenBy(x => x.Start) .ThenBy(x => x.End) .ToList() .AsReadOnly(); }