예제 #1
0
 internal EasFolderSyncState GetPersistedSyncState(SyncContentsManifestState syncBlob)
 {
     if (syncBlob.Data != null)
     {
         return(EasFolderSyncState.Deserialize(syncBlob.Data));
     }
     return(new EasFolderSyncState
     {
         SyncKey = "0",
         CrawlerSyncKey = "0"
     });
 }
예제 #2
0
        List <MessageRec> ISourceFolder.EnumerateMessagesPaged(int maxPageSize)
        {
            SyncContentsManifestState syncContentsManifestState = base.Mailbox.SyncState[base.EntryId];
            EasFolderSyncState        persistedSyncState        = base.Mailbox.GetPersistedSyncState(syncContentsManifestState);

            if (string.IsNullOrEmpty(this.nextEnumerateKey))
            {
                this.nextEnumerateKey = persistedSyncState.CrawlerSyncKey;
            }
            else
            {
                persistedSyncState.CrawlerSyncKey = this.nextEnumerateKey;
                persistedSyncState.CrawlerDeletions.AddRange(this.pendingDeletes);
                syncContentsManifestState.Data = persistedSyncState.Serialize();
            }
            EasSyncOptions options = new EasSyncOptions
            {
                SyncKey            = this.nextEnumerateKey,
                RecentOnly         = false,
                MaxNumberOfMessage = maxPageSize
            };
            EasSyncResult easSyncResult = base.SyncMessages(base.Mailbox.CrawlerConnectionWrapper, options);

            if (this.estimatedItemCount == 0)
            {
                options.SyncKey         = easSyncResult.SyncKeyRequested;
                this.estimatedItemCount = base.GetItemEstimate(base.Mailbox.CrawlerConnectionWrapper, options);
            }
            if (easSyncResult.MessageRecs.Count == 0)
            {
                return(null);
            }
            this.nextEnumerateKey = easSyncResult.NewSyncKey;
            List <MessageRec> list = new List <MessageRec>(easSyncResult.MessageRecs.Count);

            foreach (MessageRec messageRec in easSyncResult.MessageRecs)
            {
                if (persistedSyncState.ChangesSynced == null || !(messageRec.CreationTimestamp < persistedSyncState.ChangesSynced.Value) || !(messageRec.CreationTimestamp > persistedSyncState.ChangesSynced.Value - EasRequestGenerator.RecentSyncTimeSpan))
                {
                    if (EasSourceFolder.FindMessageCategory(messageRec) == EasMessageCategory.Delete)
                    {
                        this.pendingDeletes.Add(EasMailbox.GetStringId(messageRec.EntryId));
                    }
                    else
                    {
                        list.Add(messageRec);
                    }
                }
            }
            return(list);
        }
예제 #3
0
        private byte[] CreateCalendarEvent(byte[] calendarEventId, byte[] folderEntryId, Event theEvent, IList <Event> exceptionalEvents, IList <string> deletedOccurrences)
        {
            SyncContentsManifestState syncContentsManifestState = this.SyncState[folderEntryId];
            EasFolderSyncState        persistedSyncState        = base.GetPersistedSyncState(syncContentsManifestState);
            string newSyncKey = null;

            byte[] result = this.CreateItem(calendarEventId, folderEntryId, (string itemClientId, string syncKey, string serverId) => this.EasConnectionWrapper.CreateCalendarEvent(itemClientId, syncKey, out newSyncKey, serverId, theEvent, exceptionalEvents, deletedOccurrences, this.EasAuthenticationParameters.UserSmtpAddress));
            if (newSyncKey != null)
            {
                persistedSyncState.SyncKey     = newSyncKey;
                syncContentsManifestState.Data = persistedSyncState.Serialize();
            }
            return(result);
        }
예제 #4
0
        FolderChangesManifest ISourceFolder.EnumerateChanges(EnumerateContentChangesFlags flags, int maxChanges)
        {
            FolderChangesManifest     folderChangesManifest     = base.CreateInitializedChangesManifest();
            SyncContentsManifestState syncContentsManifestState = base.Mailbox.SyncState[base.EntryId];
            EasFolderSyncState        persistedSyncState        = base.Mailbox.GetPersistedSyncState(syncContentsManifestState);
            string         syncKey = persistedSyncState.SyncKey;
            EasSyncOptions options = new EasSyncOptions
            {
                SyncKey            = syncKey,
                RecentOnly         = true,
                MaxNumberOfMessage = 512
            };
            EasSyncResult     easSyncResult = base.SyncMessages(base.Mailbox.EasConnectionWrapper, options);
            List <MessageRec> messageRecs   = easSyncResult.MessageRecs;

            this.EnumerateIncrementalChanges(folderChangesManifest, messageRecs);
            this.MergePendingDeletes(folderChangesManifest, persistedSyncState.CrawlerDeletions);
            persistedSyncState.SyncKey       = easSyncResult.NewSyncKey;
            persistedSyncState.ChangesSynced = new DateTime?(DateTime.UtcNow);
            persistedSyncState.CrawlerDeletions.Clear();
            syncContentsManifestState.Data = persistedSyncState.Serialize();
            return(folderChangesManifest);
        }