Skip to main content

IOutlookCalendarProvider.PrepareItemsForExchange(_Items) Method

Override this method to create a list of items representing appointments in export/import processes.

Namespace: DevExpress.XtraScheduler.Outlook

Assembly: DevExpress.XtraScheduler.v23.2.Core.Desktop.dll

NuGet Package: DevExpress.Scheduler.CoreDesktop

Declaration

List<_AppointmentItem> PrepareItemsForExchange(
    _Items items
)

Parameters

Name Type Description
items DevExpress.XtraScheduler.Outlook.Interop._Items

A list of objects implementing the DevExpress.XtraScheduler.Outlook.Interop._AppointmentItem interface.

Returns

Type Description
List<_AppointmentItem>

An object implementing the DevExpress.XtraScheduler.Outlook.Interop._Items interface.

Remarks

Override the PrepareItemsForExchange method to filter a collection of appointment items passed for import/export.

The following code illustrates the implementation of the custom outlook calendar provider, that enables you to filter outlook objects before they are imported to the Scheduler.

The filter is set to import appointments for the current week only. More specifically, the following appointments are imported:

  • all simple non-recurring appointments within a specified week interval;
  • all series of recurring appointments if any of these appointments occur during a specified week (note that series are imported in their entirety, including simple occurrences and exceptions).
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Native;
using DevExpress.XtraScheduler.Outlook;
using DevExpress.XtraScheduler.Outlook.Interop;
    public class ParameterizedCalendarProvider: OutlookCalendarProvider {
        TimeInterval interval;
        public ParameterizedCalendarProvider(TimeInterval interval) {
            this.interval = interval != null ? interval : TimeInterval.Empty;
        }
        public TimeInterval Interval { get { return interval; } }

        protected override List<_AppointmentItem> PrepareItemsForExchange(_Items items) {
             List<_AppointmentItem> result = new List<_AppointmentItem>();
             if (items == null)
                return result;

            string filter = FormatInterval(Interval);
            _AppointmentItem olApt = items.Find(filter) as _AppointmentItem;
            while (olApt != null) {
                result.Add(olApt);
                olApt = items.FindNext() as _AppointmentItem;
            }
            return result;
        }
        protected string FormatInterval(TimeInterval interval) {
            return String.Format("[Start] > '{0}' AND [End] < '{1}'",
                interval.Start.ToString("g"), interval.End.ToString("g"));
        }
    }
See Also