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) { } } } }); } } }
private byte[] CatchUpIcsState(MailboxSyncWatermark currentWatermark) { byte[] result = null; MapiFolder mapiFolder = this.folder.MapiFolder; MemoryStream memoryStream = null; MemoryStream memoryStream2 = null; try { if (currentWatermark.IcsState == null) { memoryStream = new MemoryStream(); } else { memoryStream = new MemoryStream(currentWatermark.IcsState); } StoreSession session = this.folder.Session; bool flag = false; try { if (session != null) { session.BeginMapiCall(); session.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } try { using (MapiManifest mapiManifest = mapiFolder.CreateExportManifest()) { IcsCallback iMapiManifestCallback = new IcsCallback(this, null, 0, null); mapiManifest.Configure(this.GetConfigFlags() | ManifestConfigFlags.Catchup, null, memoryStream, iMapiManifestCallback, IcsCallback.PropTags); mapiManifest.Synchronize(); memoryStream2 = new MemoryStream(); mapiManifest.GetState(memoryStream2); result = memoryStream2.ToArray(); } } catch (MapiExceptionCorruptData innerException) { throw new CorruptSyncStateException(ServerStrings.ExSyncStateCorrupted("ICS"), innerException); } catch (CorruptDataException innerException2) { throw new CorruptSyncStateException(ServerStrings.ExSyncStateCorrupted("ICS"), innerException2); } } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.ICSSynchronizationFailed, ex, session, this, "{0}. MapiException = {1}.", new object[] { string.Format("MailboxSyncProvider::CatchUpIcsState()", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.ICSSynchronizationFailed, ex2, session, this, "{0}. MapiException = {1}.", new object[] { string.Format("MailboxSyncProvider::CatchUpIcsState()", new object[0]), ex2 }); } finally { try { if (session != null) { session.EndMapiCall(); if (flag) { session.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } } finally { Util.DisposeIfPresent(memoryStream); Util.DisposeIfPresent(memoryStream2); } return(result); }