protected virtual ISyncProvider CreateSyncProvider(Folder folder, bool trackReadFlagChanges, bool trackAssociatedMessageChanges, bool returnNewestChangesFirst, bool trackConversations, bool allowTableRestrict, bool disposeFolder, ISyncLogger syncLogger = null)
        {
            MailboxSyncProvider mailboxSyncProvider = MailboxSyncProvider.Bind(folder, trackReadFlagChanges, trackAssociatedMessageChanges, returnNewestChangesFirst, trackConversations, allowTableRestrict, disposeFolder, syncLogger);

            mailboxSyncProvider.IcsPropertyGroupFilter = this.IcsPropertyGroupFilter;
            return(mailboxSyncProvider);
        }
예제 #2
0
 internal IcsCallback(MailboxSyncProvider mailboxSyncProvider, Dictionary <ISyncItemId, ServerManifestEntry> serverManifest, int numOperations, MailboxSyncWatermark syncWatermark)
 {
     this.mailboxSyncProvider     = mailboxSyncProvider;
     this.serverManifest          = serverManifest;
     this.numOperations           = numOperations;
     this.moreAvailable           = false;
     this.syncWatermark           = syncWatermark;
     this.lastServerManifestEntry = null;
 }
예제 #3
0
        private bool EnsureMapiManifest(MailboxSyncWatermark minWatermark, int numOperations, Dictionary <ISyncItemId, ServerManifestEntry> newServerManifest)
        {
            MemoryStream memoryStream = null;
            MapiFolder   mapiFolder   = this.folder.MapiFolder;

            if (this.manifest != null)
            {
                if (MailboxSyncProvider.IcsStateEquals(this.icsState, minWatermark.IcsState))
                {
                    if (this.extraServerManifestEntry != null)
                    {
                        if (numOperations == 0)
                        {
                            return(true);
                        }
                        newServerManifest.Add(this.extraServerManifestEntry.Id, this.extraServerManifestEntry);
                        if (this.extraServerManifestEntry.Watermark != null)
                        {
                            minWatermark.ChangeNumber = ((MailboxSyncWatermark)this.extraServerManifestEntry.Watermark).ChangeNumber;
                        }
                        this.SyncLogger.Information <ISyncItemId>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider::EnsureMapiManifest Adding cached change, id = {0}", this.extraServerManifestEntry.Id);
                        this.extraServerManifestEntry = null;
                    }
                    this.icsCallback.Bind(minWatermark, numOperations, newServerManifest);
                    this.SyncLogger.Information <int, int>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider::EnsureMapiManifest Reusing ICS manifest, numOperations = {0}, newServerManifest.Count = {1}", numOperations, newServerManifest.Count);
                    return(false);
                }
                this.manifest.Dispose();
                this.manifest = null;
                this.SyncLogger.Information <int, int>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider::EnsureMapiManifest Tossed old ICS manifest, numOperations = {0}, newServerManifest.Count = {1}", numOperations, newServerManifest.Count);
            }
            try
            {
                memoryStream     = ((minWatermark.IcsState == null) ? new MemoryStream() : new MemoryStream(minWatermark.IcsState));
                this.manifest    = mapiFolder.CreateExportManifest();
                this.icsCallback = new IcsCallback(this, newServerManifest, numOperations, minWatermark);
                Restriction restriction = (this.icsPropertyGroupFilter == null) ? null : FilterRestrictionConverter.CreateRestriction(this.folder.Session, this.folder.Session.ExTimeZone, this.folder.MapiFolder, this.icsPropertyGroupFilter);
                this.manifest.Configure(this.GetConfigFlags(), restriction, memoryStream, this.icsCallback, IcsCallback.PropTags);
                this.SyncLogger.Information <int, int>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider::EnsureMapiManifest Created new ICS manifest, numOperations = {0}, newServerManifest.Count = {1}", numOperations, newServerManifest.Count);
            }
            finally
            {
                Util.DisposeIfPresent(memoryStream);
            }
            return(false);
        }
예제 #4
0
        public ManifestCallbackStatus Delete(byte[] entryId, bool softDelete, bool expiry)
        {
            if (ExTraceGlobals.SyncTracer.IsTraceEnabled(TraceType.InfoTrace))
            {
                this.TraceDeleteCallbackProps(entryId, softDelete, expiry);
            }
            if (softDelete)
            {
                return(ManifestCallbackStatus.Continue);
            }
            StoreObjectId     id = StoreObjectId.FromProviderSpecificId(entryId, StoreObjectType.Unknown);
            MailboxSyncItemId mailboxSyncItemId = MailboxSyncItemId.CreateForExistingItem(this.mailboxSyncProvider.FolderSync, id);

            if (mailboxSyncItemId == null)
            {
                return(ManifestCallbackStatus.Continue);
            }
            this.lastServerManifestEntry = MailboxSyncProvider.CreateItemDeleteManifestEntry(mailboxSyncItemId);
            return(this.CheckYieldOrStop());
        }
예제 #5
0
        public ManifestCallbackStatus Change(byte[] entryId, byte[] sourceKey, byte[] changeKey, byte[] changeList, DateTime lastModifiedTime, ManifestChangeType changeType, bool associated, PropValue[] properties)
        {
            EnumValidator.ThrowIfInvalid <ManifestChangeType>(changeType, "changeType");
            if (ExTraceGlobals.SyncTracer.IsTraceEnabled(TraceType.InfoTrace))
            {
                this.TraceChangeChangeCallbackProps(entryId, sourceKey, changeKey, changeList, lastModifiedTime, changeType, associated, properties);
            }
            int?           num                        = null;
            string         text                       = null;
            bool           read                       = false;
            ConversationId conversationId             = null;
            bool           firstMessageInConversation = false;
            ExDateTime?    filterDate                 = null;

            foreach (PropValue propValue in properties)
            {
                if (!propValue.IsError())
                {
                    PropTag propTag = propValue.PropTag;
                    if (propTag <= PropTag.MessageDeliveryTime)
                    {
                        if (propTag != PropTag.MessageClass)
                        {
                            ConversationIndex index;
                            if (propTag != PropTag.ConversationIndex)
                            {
                                if (propTag == PropTag.MessageDeliveryTime)
                                {
                                    if (propValue.PropType == PropType.SysTime)
                                    {
                                        filterDate = new ExDateTime?((ExDateTime)propValue.GetDateTime());
                                    }
                                }
                            }
                            else if (propValue.PropType == PropType.Binary && ConversationIndex.TryCreate(propValue.GetBytes(), out index) && index != ConversationIndex.Empty && index.Components != null && index.Components.Count == 1)
                            {
                                firstMessageInConversation = true;
                            }
                        }
                        else if (propValue.PropType == PropType.String)
                        {
                            text = propValue.GetString();
                        }
                    }
                    else if (propTag != PropTag.MessageFlags)
                    {
                        if (propTag != PropTag.InternetArticleNumber)
                        {
                            if (propTag == PropTag.ConversationId)
                            {
                                if (propValue.PropType == PropType.Binary)
                                {
                                    conversationId = ConversationId.Create(propValue.GetBytes());
                                }
                            }
                        }
                        else
                        {
                            if (propValue.PropType != PropType.Int)
                            {
                                return(ManifestCallbackStatus.Continue);
                            }
                            num = new int?(propValue.GetInt());
                        }
                    }
                    else if (propValue.PropType == PropType.Int)
                    {
                        MessageFlags @int = (MessageFlags)propValue.GetInt();
                        read = ((@int & MessageFlags.IsRead) == MessageFlags.IsRead);
                    }
                }
            }
            if (changeType == ManifestChangeType.Add || changeType == ManifestChangeType.Change)
            {
                if (num == null)
                {
                    return(ManifestCallbackStatus.Continue);
                }
                StoreObjectId        id = StoreObjectId.FromProviderSpecificId(entryId, (text == null) ? StoreObjectType.Unknown : ObjectClass.GetObjectType(text));
                MailboxSyncItemId    mailboxSyncItemId    = MailboxSyncItemId.CreateForNewItem(id);
                MailboxSyncWatermark mailboxSyncWatermark = MailboxSyncWatermark.CreateForSingleItem();
                mailboxSyncWatermark.UpdateWithChangeNumber(num.Value, read);
                ServerManifestEntry serverManifestEntry = this.mailboxSyncProvider.CreateItemChangeManifestEntry(mailboxSyncItemId, mailboxSyncWatermark);
                serverManifestEntry.IsNew                      = (changeType == ManifestChangeType.Add);
                serverManifestEntry.MessageClass               = text;
                serverManifestEntry.ConversationId             = conversationId;
                serverManifestEntry.FirstMessageInConversation = firstMessageInConversation;
                serverManifestEntry.FilterDate                 = filterDate;
                mailboxSyncItemId.ChangeKey                    = changeKey;
                this.lastServerManifestEntry                   = serverManifestEntry;
            }
            else
            {
                StoreObjectId     id2 = StoreObjectId.FromProviderSpecificId(entryId, StoreObjectType.Unknown);
                MailboxSyncItemId mailboxSyncItemId2 = MailboxSyncItemId.CreateForExistingItem(this.mailboxSyncProvider.FolderSync, id2);
                if (mailboxSyncItemId2 == null)
                {
                    return(ManifestCallbackStatus.Continue);
                }
                this.lastServerManifestEntry = MailboxSyncProvider.CreateItemDeleteManifestEntry(mailboxSyncItemId2);
                this.lastServerManifestEntry.ConversationId = conversationId;
            }
            return(this.CheckYieldOrStop());
        }