private static object GetMapiValueFromValue(StoreSession session, ExTimeZone timeZone, object value) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(timeZone, "timeZone"); if (value is PropertyError) { throw new ArgumentException(string.Format("We should never need to translate a PropertyError into mapi.net, because it makes no sense to set an error. PropertyError found = {0}.", value)); } QueryFilter queryFilter = value as QueryFilter; if (queryFilter != null) { return(FilterRestrictionConverter.CreateRestriction(session, timeZone, session.Mailbox.MapiStore, queryFilter)); } RuleAction[] array = value as RuleAction[]; if (array != null) { RuleAction[] array2 = new RuleAction[array.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = RuleActionConverter.ConvertRuleAction(session, timeZone, array[i]); } return(array2); } return(ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(timeZone, value)); }
internal static void SetTableFilter(StoreSession session, MapiProp propertyReference, MapiTable mapiTable, QueryFilter queryFilter) { if (queryFilter != null) { Restriction restriction = FilterRestrictionConverter.CreateRestriction(session, session.ExTimeZone, propertyReference, queryFilter); object thisObject = null; bool flag = false; try { if (session != null) { session.BeginMapiCall(); session.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } mapiTable.Restrict(restriction); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateRestriction, ex, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("Folder::SetTableFilter. Failed to set a restriction.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateRestriction, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("Folder::SetTableFilter. Failed to set a restriction.", new object[0]), ex2 }); } finally { try { if (session != null) { session.EndMapiCall(); if (flag) { session.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } } }
protected SynchronizerProviderBase(CoreFolder folder, SynchronizerConfigFlags flags, QueryFilter filter, StorageIcsState initialState, PropertyDefinition[] includeProperties, PropertyDefinition[] excludeProperties, short[] unspecifiedIncludeProperties, short[] unspecifiedExcludeProperties, int fastTransferBlockSize) { this.folder = folder; 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 = null; if (includeProperties != null && includeProperties.Length > 0) { includePropertyTags = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiFolder, this.folder.Session, true, includeProperties); } ICollection <PropTag> excludePropertyTags = null; if (excludeProperties != null && excludeProperties.Length > 0) { excludePropertyTags = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiFolder, this.folder.Session, true, excludeProperties); } SynchronizerProviderBase.ReconstituteProperties(unspecifiedIncludeProperties, ref includePropertyTags); SynchronizerProviderBase.ReconstituteProperties(unspecifiedExcludeProperties, ref excludePropertyTags); StoreSession session = this.folder.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.MapiCreateSynchronizer(flags, restriction, initialState, includePropertyTags, excludePropertyTags, fastTransferBlockSize); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.CannotCreateSynchronizerEx(base.GetType()), ex, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("SynchronizerProviderBase..ctor. Failed to create/configure MapiSynchronizerEx.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.CannotCreateSynchronizerEx(base.GetType()), ex2, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("SynchronizerProviderBase..ctor. Failed to create/configure MapiSynchronizerEx.", 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(); } } }
private void WriteOutlookSearchFolderDefinitionBlob(MessageItem message, SearchFolderCriteria criteria) { Restriction restriction = FilterRestrictionConverter.CreateRestriction(base.Session, base.PropertyBag.ExTimeZone, base.MapiProp, criteria.SearchQuery); OutlookSearchFolder.WriteOutlookSearchFolderDefinitionBlob(message, restriction, criteria.DeepTraversal, criteria.FolderScope); }
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); }
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(); } } }