Пример #1
0
        protected EasHierarchySyncState RefreshFolderCache()
        {
            EasHierarchySyncState hierarchySyncState = this.GetHierarchySyncState();

            this.RefreshFolderCache(hierarchySyncState);
            return(hierarchySyncState);
        }
Пример #2
0
        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);
        }
Пример #3
0
        protected void RefreshFolderCache(EasHierarchySyncState state)
        {
            IReadOnlyCollection <Add> folders    = state.Folders;
            EntryIdMap <Add>          entryIdMap = new EntryIdMap <Add>(folders.Count);

            this.defaultCalendarId = null;
            foreach (Add add in folders)
            {
                EasFolderType easFolderType = add.GetEasFolderType();
                if (easFolderType == EasFolderType.Calendar)
                {
                    this.defaultCalendarId = EasMailbox.GetEntryId(add.ServerId);
                }
                EasFolderType easFolderType2 = easFolderType;
                if (easFolderType2 == EasFolderType.UserGeneric)
                {
                    goto IL_8B;
                }
                bool flag;
                switch (easFolderType2)
                {
                case EasFolderType.Contacts:
                case EasFolderType.UserContacts:
                    flag = !ConfigBase <MRSConfigSchema> .GetConfig <bool>("DisableContactSync");

                    goto IL_9D;

                case EasFolderType.UserMail:
                case EasFolderType.UserCalendar:
                    goto IL_8B;
                }
                flag = EasMailbox.folderTypeMap.ContainsKey(easFolderType);
IL_9D:
                if (flag)
                {
                    entryIdMap.Add(EasMailbox.GetEntryId(add.ServerId), add);
                    continue;
                }
                MrsTracer.Provider.Debug("EasMailbox.RefreshFolderCache: ignore {0} folder '{1}' since it is not supported yet", new object[]
                {
                    easFolderType,
                    add.DisplayName
                });
                continue;
IL_8B:
                flag = true;
                goto IL_9D;
            }
            this.EasFolderCache = entryIdMap;
        }
Пример #4
0
        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);
        }
Пример #5
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);
        }