Exemplo n.º 1
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);
        }