Skip to main content

OutlookImport.SetCalendarProvider(IOutlookCalendarProvider) Method

Specifies a custom provider to process a collection of Outlook objects, before they are loaded into the Scheduler storage.

Namespace: DevExpress.XtraScheduler.Outlook

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

Declaration

public void SetCalendarProvider(
    IOutlookCalendarProvider provider
)

Parameters

Name Type Description
provider IOutlookCalendarProvider

An object implementing the IOutlookCalendarProvider interface.

Remarks

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