private void ConfigureMapiManifest(SyncContentsManifestState syncState, FolderChangesManifest changes, EnumerateContentChangesFlags flags, int maxChanges)
        {
            if (this.isPagedEnumeration && !flags.HasFlag(EnumerateContentChangesFlags.FirstPage))
            {
                this.callback.InitializeNextPage(changes, maxChanges);
                return;
            }
            this.callback = new ManifestContentsCallback(this.folder.GetFolderId(), this.isPagedEnumeration);
            this.callback.InitializeNextPage(changes, maxChanges);
            ManifestConfigFlags manifestConfigFlags = ManifestConfigFlags.Associated | ManifestConfigFlags.Normal | ManifestConfigFlags.OrderByDeliveryTime;

            if (flags.HasFlag(EnumerateContentChangesFlags.Catchup))
            {
                manifestConfigFlags |= ManifestConfigFlags.Catchup;
            }
            Restriction restriction = ((this.mailbox.Options & MailboxOptions.IgnoreExtendedRuleFAIs) != MailboxOptions.None) ? ContentChangesFetcherUtils.ExcludeAllRulesRestriction : ContentChangesFetcherUtils.ExcludeV40RulesRestriction;

            using (this.mailbox.RHTracker.Start())
            {
                this.mapiManifest = this.mapiFolder.CreateExportManifest();
            }
            using (MemoryStream memoryStream = (syncState.Data != null) ? new MemoryStream(syncState.Data) : null)
            {
                using (this.mailbox.RHTracker.Start())
                {
                    this.mapiManifest.Configure(manifestConfigFlags, restriction, memoryStream, this.callback, new PropTag[0]);
                }
            }
        }
 protected static void TranslateFlag(ManifestConfigFlags sourceFlag, SyncConfigFlags destinationFlag, ManifestConfigFlags sourceFlags, ref SyncConfigFlags destinationFlags)
 {
     if ((sourceFlags & sourceFlag) == sourceFlag)
     {
         destinationFlags |= destinationFlag;
         return;
     }
     destinationFlags &= ~destinationFlag;
 }
Exemplo n.º 3
0
        private static SyncConfigFlags ConvertManifestConfigFlags(ManifestConfigFlags syncFlag)
        {
            EnumValidator.ThrowIfInvalid <ManifestConfigFlags>(syncFlag, HierarchyManifestProvider.validConvertOptions);
            SyncConfigFlags result = SyncConfigFlags.None;

            ManifestProviderBase <MapiHierarchyManifestEx, HierarchySyncPhase> .TranslateFlag(ManifestConfigFlags.NoDeletions, SyncConfigFlags.NoDeletions, syncFlag, ref result);

            ManifestProviderBase <MapiHierarchyManifestEx, HierarchySyncPhase> .TranslateFlag(ManifestConfigFlags.Catchup, SyncConfigFlags.Catchup, syncFlag, ref result);

            ManifestProviderBase <MapiHierarchyManifestEx, HierarchySyncPhase> .TranslateFlag(ManifestConfigFlags.NoChanges, SyncConfigFlags.NoChanges, syncFlag, ref result);

            return(result);
        }
Exemplo n.º 4
0
        private ManifestConfigFlags GetConfigFlags()
        {
            ManifestConfigFlags manifestConfigFlags = ManifestConfigFlags.Normal;

            if (this.returnNewestChangesFirst)
            {
                manifestConfigFlags |= ManifestConfigFlags.OrderByDeliveryTime;
            }
            if (!this.trackReadFlagChanges)
            {
                manifestConfigFlags |= ManifestConfigFlags.NoReadUnread;
            }
            if (this.trackAssociatedMessageChanges)
            {
                manifestConfigFlags |= ManifestConfigFlags.Associated;
            }
            if (this.trackConversations)
            {
                manifestConfigFlags |= ManifestConfigFlags.Conversations;
            }
            return(manifestConfigFlags);
        }
        private static SyncConfigFlags ConvertManifestConfigFlags(ManifestConfigFlags syncFlag)
        {
            SyncConfigFlags result = SyncConfigFlags.None;

            EnumValidator.ThrowIfInvalid <ManifestConfigFlags>(syncFlag);
            ManifestProviderBase <MapiManifestEx, ContentSyncPhase> .TranslateFlag(ManifestConfigFlags.NoDeletions, SyncConfigFlags.NoDeletions, syncFlag, ref result);

            ManifestProviderBase <MapiManifestEx, ContentSyncPhase> .TranslateFlag(ManifestConfigFlags.NoSoftDeletions, SyncConfigFlags.NoSoftDeletions, syncFlag, ref result);

            ManifestProviderBase <MapiManifestEx, ContentSyncPhase> .TranslateFlag(ManifestConfigFlags.ReadState, SyncConfigFlags.ReadState, syncFlag, ref result);

            ManifestProviderBase <MapiManifestEx, ContentSyncPhase> .TranslateFlag(ManifestConfigFlags.Associated, SyncConfigFlags.Associated, syncFlag, ref result);

            ManifestProviderBase <MapiManifestEx, ContentSyncPhase> .TranslateFlag(ManifestConfigFlags.Normal, SyncConfigFlags.Normal, syncFlag, ref result);

            ManifestProviderBase <MapiManifestEx, ContentSyncPhase> .TranslateFlag(ManifestConfigFlags.Catchup, SyncConfigFlags.Catchup, syncFlag, ref result);

            ManifestProviderBase <MapiManifestEx, ContentSyncPhase> .TranslateFlag(ManifestConfigFlags.NoChanges, SyncConfigFlags.NoChanges, syncFlag, ref result);

            ManifestProviderBase <MapiManifestEx, ContentSyncPhase> .TranslateFlag(ManifestConfigFlags.OrderByDeliveryTime, SyncConfigFlags.OrderByDeliveryTime, syncFlag, ref result);

            return(result);
        }
 public void SetExtendedProps(PropTag[] promotedProperties, RestrictionData[] restrictions, SortOrderData[] views, ICSViewData[] icsViews)
 {
     MrsTracer.Provider.Function("MapiDestinationFolder.SetExtendedProps", new object[0]);
     if (promotedProperties != null && promotedProperties.Length > 0)
     {
         ExecutionContext.Create(new DataContext[]
         {
             new OperationDataContext("MapiDestinationFolder.SetPromotedProps", OperationType.None),
             new PropTagsDataContext(promotedProperties)
         }).Execute(delegate
         {
             using (this.Mailbox.RHTracker.Start())
             {
                 using (MapiTable contentsTable = this.Folder.GetContentsTable(ContentsTableFlags.DeferredErrors))
                 {
                     contentsTable.SetColumns(promotedProperties);
                     contentsTable.QueryRows(1);
                 }
             }
         });
     }
     if (restrictions != null && restrictions.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying restrictions.", new object[0]);
         for (int i = 0; i < restrictions.Length; i++)
         {
             RestrictionData rd = restrictions[i];
             ExecutionContext.Create(new DataContext[]
             {
                 new OperationDataContext("MapiDestinationFolder.ApplyRestriction", OperationType.None),
                 new RestrictionDataContext(rd)
             }).Execute(delegate
             {
                 Restriction native = DataConverter <RestrictionConverter, Restriction, RestrictionData> .GetNative(rd);
                 using (this.Mailbox.RHTracker.Start())
                 {
                     using (MapiTable contentsTable = this.Folder.GetContentsTable(ContentsTableFlags.DeferredErrors))
                     {
                         using (new SortLCIDContext(this.Folder.MapiStore, rd.LCID))
                         {
                             contentsTable.Restrict(native);
                             contentsTable.QueryRows(1);
                         }
                     }
                 }
             });
         }
     }
     if (views != null && views.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying views.", new object[0]);
         for (int j = 0; j < views.Length; j++)
         {
             SortOrderData sod = views[j];
             ExecutionContext.Create(new DataContext[]
             {
                 new OperationDataContext("MapiDestinationFolder.ApplySortOrder", OperationType.None),
                 new SortOrderDataContext(sod)
             }).Execute(delegate
             {
                 SortOrder native = DataConverter <SortOrderConverter, SortOrder, SortOrderData> .GetNative(sod);
                 ContentsTableFlags contentsTableFlags = ContentsTableFlags.DeferredErrors;
                 if (sod.FAI)
                 {
                     contentsTableFlags |= ContentsTableFlags.Associated;
                 }
                 else if (sod.Conversation)
                 {
                     contentsTableFlags |= ContentsTableFlags.ShowConversations;
                 }
                 using (this.Mailbox.RHTracker.Start())
                 {
                     using (MapiTable contentsTable = this.Folder.GetContentsTable(contentsTableFlags))
                     {
                         using (new SortLCIDContext(this.Folder.MapiStore, sod.LCID))
                         {
                             contentsTable.SortTable(native, SortTableFlags.None);
                             contentsTable.QueryRows(1);
                         }
                     }
                 }
             });
         }
     }
     if (icsViews != null && icsViews.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying ICS views.", new object[0]);
         for (int k = 0; k < icsViews.Length; k++)
         {
             ICSViewData icsView = icsViews[k];
             ExecutionContext.Create(new DataContext[]
             {
                 new OperationDataContext("MapiDestinationFolder.ApplyICSView", OperationType.None),
                 new ICSViewDataContext(icsView)
             }).Execute(delegate
             {
                 ManifestConfigFlags flags = ManifestConfigFlags.Associated | ManifestConfigFlags.Normal;
                 if (icsView.Conversation)
                 {
                     flags = ManifestConfigFlags.Conversations;
                 }
                 using (this.Mailbox.RHTracker.Start())
                 {
                     using (MapiManifest mapiManifest = this.Folder.CreateExportManifest())
                     {
                         PropTag[] array = Array <PropTag> .Empty;
                         if (icsView.CoveringPropertyTags != null)
                         {
                             array = new PropTag[icsView.CoveringPropertyTags.Length];
                             for (int l = 0; l < icsView.CoveringPropertyTags.Length; l++)
                             {
                                 array[l] = (PropTag)icsView.CoveringPropertyTags[l];
                             }
                         }
                         mapiManifest.Configure(flags, null, null, MapiDestinationFolder.DummyManifestContentsCallback.Instance, array);
                         while (mapiManifest.Synchronize() != ManifestStatus.Done)
                         {
                         }
                     }
                 }
             });
         }
     }
 }
Exemplo n.º 7
0
 protected override MapiHierarchyManifestEx MapiCreateManifest(ManifestConfigFlags flags, Restriction restriction, StorageIcsState initialState, ICollection <PropTag> includePropertyTags, ICollection <PropTag> excludePropertyTags)
 {
     return(base.MapiFolder.CreateExportHierarchyManifestEx(HierarchyManifestProvider.ConvertManifestConfigFlags(flags), initialState.StateIdsetGiven, initialState.StateCnsetSeen, this, includePropertyTags, excludePropertyTags));
 }
Exemplo n.º 8
0
 internal HierarchyManifestProvider(CoreFolder folder, ManifestConfigFlags flags, StorageIcsState initialState, PropertyDefinition[] includeProperties, PropertyDefinition[] excludeProperties) : base(folder, flags, null, initialState, includeProperties, excludeProperties)
 {
 }
 internal ContentManifestProvider(CoreFolder folder, ManifestConfigFlags flags, QueryFilter filter, StorageIcsState initialState, PropertyDefinition[] includeProperties) : base(folder, flags, filter, initialState, includeProperties, Array <NativeStorePropertyDefinition> .Empty)
 {
 }
Exemplo n.º 10
0
 protected abstract TMapiManifest MapiCreateManifest(ManifestConfigFlags flags, Restriction restriction, StorageIcsState initialState, ICollection <PropTag> includePropertyTags, ICollection <PropTag> excludePropertyTags);
Exemplo n.º 11
0
        protected ManifestProviderBase(CoreFolder folder, ManifestConfigFlags flags, QueryFilter filter, StorageIcsState initialState, PropertyDefinition[] includeProperties, PropertyDefinition[] excludeProperties)
        {
            this.folder         = folder;
            this.disposeTracker = this.GetDisposeTracker();
            bool flag = false;

            try
            {
                PersistablePropertyBag persistablePropertyBag = CoreObject.GetPersistablePropertyBag(this.folder);
                Restriction            restriction            = null;
                if (filter != null)
                {
                    restriction = FilterRestrictionConverter.CreateRestriction(folder.Session, persistablePropertyBag.ExTimeZone, persistablePropertyBag.MapiProp, filter);
                }
                ICollection <PropTag> includePropertyTags = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiFolder, this.Session, true, includeProperties);
                ICollection <PropTag> excludePropertyTags = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiFolder, this.Session, true, excludeProperties);
                StoreSession          session             = this.Session;
                object thisObject = this.folder;
                bool   flag2      = false;
                try
                {
                    if (session != null)
                    {
                        session.BeginMapiCall();
                        session.BeginServerHealthCall();
                        flag2 = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    this.mapiManifest = this.MapiCreateManifest(flags, restriction, initialState, includePropertyTags, excludePropertyTags);
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.CannotCreateManifestEx(base.GetType()), ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("ManifestProviderBase..ctor. Failed to create/configure HierarchyManifestEx.", new object[0]),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.CannotCreateManifestEx(base.GetType()), ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("ManifestProviderBase..ctor. Failed to create/configure HierarchyManifestEx.", new object[0]),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (session != null)
                        {
                            session.EndMapiCall();
                            if (flag2)
                            {
                                session.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    base.Dispose();
                }
            }
        }