protected override MailboxChangesManifest DoManifestSync(EnumerateHierarchyChangesFlags flags, int maxChanges, SyncHierarchyManifestState hierState, MapiStore mapiStore)
        {
            MrsTracer.Provider.Function("EasSourceMailbox.DoManifestSync", new object[0]);
            base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None);
            flags.HasFlag(EnumerateHierarchyChangesFlags.Catchup);
            EasHierarchySyncState easHierarchySyncState = EasHierarchySyncState.Deserialize(hierState.ProviderSyncState);
            string syncKey = easHierarchySyncState.SyncKey;
            string syncKey2;
            IReadOnlyCollection <Add> readOnlyCollection;
            MailboxChangesManifest    folderChangesOnServer = this.GetFolderChangesOnServer(syncKey, out syncKey2, out readOnlyCollection);
            bool flag = false;

            easHierarchySyncState.SyncKey = syncKey2;
            if (folderChangesOnServer.DeletedFolders != null)
            {
                List <Add> list = new List <Add>(folderChangesOnServer.DeletedFolders.Count);
                foreach (Add add in easHierarchySyncState.Folders)
                {
                    foreach (byte[] entryId in folderChangesOnServer.DeletedFolders)
                    {
                        if (StringComparer.Ordinal.Equals(add.ServerId, EasMailbox.GetStringId(entryId)))
                        {
                            list.Add(add);
                            break;
                        }
                    }
                }
                foreach (Add item in list)
                {
                    easHierarchySyncState.Folders.Remove(item);
                    flag = true;
                }
            }
            if (readOnlyCollection != null)
            {
                foreach (Add item2 in readOnlyCollection)
                {
                    easHierarchySyncState.Folders.Add(item2);
                    flag = true;
                }
            }
            hierState.ProviderSyncState = easHierarchySyncState.Serialize(false);
            if (flag)
            {
                base.RefreshFolderCache(easHierarchySyncState);
            }
            return(folderChangesOnServer);
        }
Example #2
0
        private EasHierarchySyncState GetHierarchySyncState()
        {
            SyncHierarchyManifestState hierarchyData = this.SyncState.HierarchyData;
            EasHierarchySyncState      easHierarchySyncState;

            if (hierarchyData != null && !string.IsNullOrEmpty(hierarchyData.ProviderSyncState) && hierarchyData.ManualSyncData == null)
            {
                MrsTracer.Provider.Debug("EasMailbox.GetHierarchySyncState: Deserialize folder state from hierState.ProviderSyncState", new object[0]);
                easHierarchySyncState = EasHierarchySyncState.Deserialize(hierarchyData.ProviderSyncState);
            }
            else
            {
                MrsTracer.Provider.Debug("EasMailbox.GetHierarchySyncState: Get all the folders from the EAS server", new object[0]);
                string syncKey;
                Add[]  allFoldersOnServer = this.GetAllFoldersOnServer(out syncKey);
                easHierarchySyncState           = new EasHierarchySyncState(allFoldersOnServer, syncKey);
                hierarchyData.ProviderSyncState = easHierarchySyncState.Serialize(false);
            }
            hierarchyData.ManualSyncData = null;
            return(easHierarchySyncState);
        }