Example #1
0
        /// <summary>
        /// <see cref="ExchangeSyncProvider.EnumerateChanges"/>
        /// </summary>
        public override IEnumerable <IRemoteItem> EnumerateChanges(SyncContext context)
        {
            base.EnumerateChanges(context);
            var result = new List <IRemoteItem>();

            if (!UserSettings.ImportActivities)
            {
                return(result);
            }
            var folders = new List <Exchange.Folder>();

            Exchange.FolderId trashFolderId = Exchange.Folder.Bind(
                Service, Exchange.WellKnownFolderName.DeletedItems, Exchange.BasePropertySet.IdOnly).Id;
            if (UserSettings.ImportActivitiesAll)
            {
                Exchange.Folder rootFolder = Exchange.Folder.Bind(Service, Exchange.WellKnownFolderName.MsgFolderRoot);
                folders.GetAllFoldersByFilter(rootFolder);
                folders.Add(rootFolder);
            }
            else
            {
                folders = SafeBindFolders(Service, UserSettings.RemoteFolderUIds.Keys, context);
            }
            Exchange.SearchFilter itemsFilter = GetItemsSearchFilters();
            SyncItemSchema        schema      = FindSchemaBySyncValueName(typeof(ExchangeTask).Name);

            foreach (Exchange.Folder folder in folders)
            {
                if (folder.Id.Equals(trashFolderId))
                {
                    continue;
                }
                var itemView = new Exchange.ItemView(PageItemCount);
                Exchange.FindItemsResults <Exchange.Item> itemCollection;
                do
                {
                    itemCollection = folder.ReadItems(itemsFilter, itemView);
                    foreach (Exchange.Item item in itemCollection)
                    {
                        Exchange.Task task = ExchangeUtility.SafeBindItem <Exchange.Task>(Service, item.Id);
                        if (task != null)
                        {
                            var remoteItem = new ExchangeTask(schema, task, TimeZone);
                            result.Add(remoteItem);
                        }
                    }
                } while (itemCollection.MoreAvailable);
            }
            return(result);
        }
Example #2
0
        public override IRemoteItem LoadSyncItem(SyncItemSchema schema, string id)
        {
            ExchangeBase remoteItem;

            Exchange.Task task = ExchangeUtility.SafeBindItem <Exchange.Task>(Service, new Exchange.ItemId(id));
            if (task != null)
            {
                remoteItem = new ExchangeTask(schema, task, TimeZone)
                {
                    Action = SyncAction.Update
                };
            }
            else
            {
                task       = new Exchange.Task(Service);
                remoteItem = new ExchangeTask(schema, task, id, TimeZone)
                {
                    State = SyncState.Deleted
                };
            }
            return(remoteItem);
        }