protected override MailboxChangesManifest RunManualHierarchySync(bool catchup, SyncHierarchyManifestState hierState) { MrsTracer.Provider.Function("EasSourceMailbox.RunManualHierarchySync", new object[0]); base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None); EasHierarchySyncState easHierarchySyncState = EasHierarchySyncState.Deserialize(hierState.ProviderSyncState); hierState.ProviderSyncState = null; EasHierarchySyncState easHierarchySyncState2 = base.RefreshFolderCache(); EntryIdMap <EasHierarchySyncState.EasFolderData> entryIdMap = new EntryIdMap <EasHierarchySyncState.EasFolderData>(); foreach (EasHierarchySyncState.EasFolderData easFolderData in easHierarchySyncState.FolderData) { entryIdMap[EasMailbox.GetEntryId(easFolderData.ServerId)] = easFolderData; } EntryIdMap <EasHierarchySyncState.EasFolderData> entryIdMap2 = new EntryIdMap <EasHierarchySyncState.EasFolderData>(); foreach (EasHierarchySyncState.EasFolderData easFolderData2 in easHierarchySyncState2.FolderData) { entryIdMap2[EasMailbox.GetEntryId(easFolderData2.ServerId)] = easFolderData2; } MailboxChangesManifest mailboxChangesManifest = new MailboxChangesManifest(); mailboxChangesManifest.DeletedFolders = new List <byte[]>(); foreach (byte[] array in entryIdMap.Keys) { if (!entryIdMap2.ContainsKey(array)) { mailboxChangesManifest.DeletedFolders.Add(array); } } mailboxChangesManifest.ChangedFolders = new List <byte[]>(); foreach (KeyValuePair <byte[], EasHierarchySyncState.EasFolderData> keyValuePair in entryIdMap2) { byte[] key = keyValuePair.Key; EasHierarchySyncState.EasFolderData value = keyValuePair.Value; EasHierarchySyncState.EasFolderData easFolderData3; if (entryIdMap.TryGetValue(key, out easFolderData3)) { if (easFolderData3.ParentId != value.ParentId || easFolderData3.DisplayName != value.DisplayName) { mailboxChangesManifest.ChangedFolders.Add(key); } } else { mailboxChangesManifest.ChangedFolders.Add(key); } } return(mailboxChangesManifest); }
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); }
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); }