public void OnAttachmentDisconnected(AttachmentPropertyBag attachmentBag, PersistablePropertyBag dataPropertyBag) { this.CheckDisposed(null); PersistablePropertyBag persistablePropertyBag = null; int attachmentNumber = attachmentBag.AttachmentNumber; if (this.newAttachmentList.TryGetValue(attachmentNumber, out persistablePropertyBag)) { this.newAttachmentList.Remove(attachmentNumber); attachmentBag.Dispose(); } }
internal AcrPropertyBag(PersistablePropertyBag propertyBag, AcrProfile profile, StoreObjectId itemId, IPropertyBagFactory propertyBagFactory, byte[] openChangeKey) { this.propertyBag = propertyBag; base.PrefetchPropertyArray = this.propertyBag.PrefetchPropertyArray; this.profile = profile; this.itemId = itemId; this.propertyBagFactory = propertyBagFactory; this.openChangeKey = openChangeKey; if (propertyBag.DisposeTracker != null) { propertyBag.DisposeTracker.AddExtraDataWithStackTrace("AcrPropertyBag owns PersistablePropertyBag propertyBag at"); } }
private void WritePropertyIfMissing(NativeStorePropertyDefinition property, PersistablePropertyBag propertyBag, OutboundMsgConverter.ComputeValueDelegate computeValue) { PropertyError propertyError = ((IDirectPropertyBag)propertyBag).GetValue(property) as PropertyError; if (propertyError != null && !PropertyError.IsPropertyValueTooBig(propertyError)) { object obj = computeValue(); if (!(obj is PropertyError)) { this.WriteProperty(property, obj); } } }
public PersistablePropertyBag OpenAttachment(ICollection <PropertyDefinition> prefetchProperties, AttachmentPropertyBag attachmentBag) { this.CheckDisposed(null); int attachmentNumber = attachmentBag.AttachmentNumber; PersistablePropertyBag persistablePropertyBag = null; if (!this.savedAttachmentList.TryGetValue(attachmentNumber, out persistablePropertyBag)) { throw new InvalidOperationException("InMemoryAttachmentProvider::OpenAttachment - Invalid attachment number"); } persistablePropertyBag.Load(prefetchProperties); return(persistablePropertyBag); }
public void Flush() { this.CheckDisposed(null); this.CoreObjectUpdate(); PersistablePropertyBag persistablePropertyBag = CoreObject.GetPersistablePropertyBag(this.ParentCollection.ContainerItem); if (!persistablePropertyBag.Context.IsValidationDisabled) { ValidationContext context = new ValidationContext(this.Session); Validation.Validate(this, context); } this.PropertyBag.FlushChanges(); }
private void WriteProperty(NativeStorePropertyDefinition property, PersistablePropertyBag propertyBag) { object obj = propertyBag.TryGetProperty(property); PropertyError propertyError = obj as PropertyError; if (propertyError == null) { this.WriteProperty(property, obj); return; } if (PropertyError.IsPropertyValueTooBig(propertyError)) { this.StreamProperty(property, propertyBag); } }
internal ConflictResolutionResult SaveChangesWithAcr(SaveMode saveMode) { base.CheckDisposed("AcrPropertyBag::SaveChangesWithAcr"); ConflictResolutionResult conflictResolutionResult = null; if (this.CanSaveBeNoOp() && !this.uncommitted) { return(ConflictResolutionResult.Success); } try { this.propertyBag.SaveChanges(false); this.uncommitted = false; } catch (SaveConflictException) { PersistablePropertyBag persistablePropertyBag = this.propertyBagFactory.CreateStorePropertyBag(this.propertyBag, this.PrefetchPropertyArray); persistablePropertyBag.Context.Copy(this.propertyBag.Context); try { conflictResolutionResult = this.ApplyAcr(persistablePropertyBag, saveMode); if (conflictResolutionResult.SaveStatus == SaveResult.Success || conflictResolutionResult.SaveStatus == SaveResult.SuccessWithConflictResolution) { persistablePropertyBag.FlushChanges(); persistablePropertyBag.SaveChanges(false); this.PropertyBag = persistablePropertyBag; persistablePropertyBag = null; this.uncommitted = false; } } finally { if (persistablePropertyBag != null) { persistablePropertyBag.Dispose(); } } } if (conflictResolutionResult == null) { conflictResolutionResult = ConflictResolutionResult.Success; } if (conflictResolutionResult.SaveStatus != SaveResult.IrresolvableConflict) { this.RefreshCacheAfterSave(conflictResolutionResult); } return(conflictResolutionResult); }
public void OnAfterAttachmentSave(AttachmentPropertyBag attachmentBag) { this.CheckDisposed(null); int attachmentNumber = attachmentBag.AttachmentNumber; this.AttachmentCollection.OnAfterAttachmentSave(attachmentNumber); PersistablePropertyBag persistablePropertyBag = null; if (this.newAttachmentList.TryGetValue(attachmentNumber, out persistablePropertyBag)) { this.newAttachmentList.Remove(attachmentNumber); this.savedAttachmentList.Add(attachmentNumber, attachmentBag.PersistablePropertyBag); byte[] bytes = BitConverter.GetBytes(attachmentNumber); persistablePropertyBag[InternalSchema.RecordKey] = bytes; this.AttachmentCollection.UpdateAttachmentId(attachmentBag.AttachmentId, attachmentNumber); } }
private static CoreAttachment CopyAttachment(CoreAttachment sourceAttachment, ICollection <NativeStorePropertyDefinition> excludeProperties) { CoreAttachment coreAttachment = null; if (sourceAttachment != null) { coreAttachment = sourceAttachment.ParentCollection.Create(AttachmentType.Stream); sourceAttachment.PropertyBag.Load(InternalSchema.ContentConversionProperties); foreach (NativeStorePropertyDefinition nativeStorePropertyDefinition in sourceAttachment.PropertyBag.AllNativeProperties) { if (excludeProperties == null || !excludeProperties.Contains(nativeStorePropertyDefinition)) { PersistablePropertyBag.CopyProperty(sourceAttachment.PropertyBag, nativeStorePropertyDefinition, coreAttachment.PropertyBag); } } } return(coreAttachment); }
private bool WritePropertyStreamData(PersistablePropertyBag propertyBag, NativeStorePropertyDefinition property, out long totalBytesRead) { totalBytesRead = 0L; try { using (Stream stream = propertyBag.OpenPropertyStream(property, PropertyOpenMode.ReadOnly)) { using (Stream stream2 = this.tnefWriter.StartStreamProperty(property)) { totalBytesRead = Util.StreamHandler.CopyStreamData(stream, stream2); } } } catch (ObjectNotFoundException) { } return(false); }
private AttachmentPropertyBag InternalCreateAttachmentPropertyBag(AttachmentType?type, CoreAttachment attachmentToClone, IItem itemToAttach) { this.InitCollection("InternalCreateAttachmentPropertyBag", true); bool flag = false; int attachmentNumber = -1; PersistablePropertyBag persistablePropertyBag = null; AttachmentPropertyBag attachmentPropertyBag = null; try { Schema attachmentSchema = CoreAttachmentCollection.GetAttachmentSchema(type); ICollection <PropertyDefinition> prefetchProperties = InternalSchema.Combine <PropertyDefinition>(attachmentSchema.AutoloadProperties, (ICollection <PropertyDefinition>) this.fetchProperties); persistablePropertyBag = this.attachmentProvider.CreateAttachment(prefetchProperties, attachmentToClone, itemToAttach, out attachmentNumber); attachmentPropertyBag = new AttachmentPropertyBag(this.attachmentProvider, attachmentNumber, persistablePropertyBag, true); attachmentPropertyBag.ExTimeZone = this.ExTimeZone; if (type != null) { int num = CoreAttachment.AttachmentTypeToAttachMethod(type.Value); ((IDirectPropertyBag)attachmentPropertyBag).SetValue(InternalSchema.AttachMethod, num); } this.isDirty = true; this.IsClonedFromAnExistingAttachmentCollection = false; flag = true; } finally { if (!flag) { if (attachmentPropertyBag != null) { attachmentPropertyBag.Dispose(); attachmentPropertyBag = null; } if (persistablePropertyBag != null) { persistablePropertyBag.Dispose(); persistablePropertyBag = null; } } } return(attachmentPropertyBag); }
internal void UndoTnef() { this.CheckDisposed("UndoTnef"); this.ClearRecipientTable(); this.ClearAttachmentTable(); foreach (PropertyDefinition propertyDefinition in InboundMessageWriter.UndoPropertyList) { this.coreItem.PropertyBag.Delete(propertyDefinition); } PersistablePropertyBag persistablePropertyBag = CoreObject.GetPersistablePropertyBag(this.CoreItem); IDirectPropertyBag directPropertyBag = persistablePropertyBag; directPropertyBag.SetValue(InternalSchema.ItemClass, "IPM.Note"); MessageItem messageItem = this.coreItem as MessageItem; if (messageItem != null) { messageItem.ReplyTo.Clear(); } }
public PersistablePropertyBag CreateStorePropertyBag(PropertyBag propertyBag, ICollection <PropertyDefinition> prefetchProperties) { byte[] entryId = propertyBag.TryGetProperty(InternalSchema.EntryId) as byte[]; StoreObjectId id = StoreObjectId.FromProviderSpecificId(entryId, StoreObjectType.Unknown); StoreObjectPropertyBag storeObjectPropertyBag = propertyBag as StoreObjectPropertyBag; ICollection <PropertyDefinition> prefetchPropertyArray; if (storeObjectPropertyBag != null) { prefetchPropertyArray = ((prefetchProperties != null) ? prefetchProperties.Union(storeObjectPropertyBag.PrefetchPropertyArray) : storeObjectPropertyBag.PrefetchPropertyArray); } else { prefetchPropertyArray = prefetchProperties; } PersistablePropertyBag persistablePropertyBag = ItemBagFactory.CreatePropertyBag(this.storeSession, id, prefetchPropertyArray); persistablePropertyBag.ExTimeZone = this.exTimeZone; return(persistablePropertyBag); }
private void StreamProperty(NativeStorePropertyDefinition property, PersistablePropertyBag propertyBag) { Stream stream = null; try { stream = propertyBag.OpenPropertyStream(property, PropertyOpenMode.ReadOnly); this.StreamProperty(property, stream); } catch (ObjectNotFoundException) { } finally { if (stream != null) { stream.Dispose(); } } }
internal static void CopyProperty(PersistablePropertyBag source, PropertyDefinition property, PersistablePropertyBag destination) { object obj = source.TryGetProperty(property); PropertyError propertyError = obj as PropertyError; if (propertyError == null) { destination[property] = obj; return; } if (PropertyError.IsPropertyValueTooBig(propertyError)) { Stream stream; Stream readStream = stream = source.OpenPropertyStream(property, PropertyOpenMode.ReadOnly); try { Stream stream2; Stream writeStream = stream2 = destination.OpenPropertyStream(property, PropertyOpenMode.Create); try { Util.StreamHandler.CopyStreamData(readStream, writeStream); } finally { if (stream2 != null) { ((IDisposable)stream2).Dispose(); } } } finally { if (stream != null) { ((IDisposable)stream).Dispose(); } } } }
internal static CoreItem CreateNewCoreItem(StoreSession session, ItemCreateInfo itemCreateInfo, VersionedId itemId, bool useAcr, ItemBuilder.MapiMessageCreator mapiMessageCreator) { PersistablePropertyBag persistablePropertyBag = null; CoreItem coreItem = null; bool flag = false; StoreObjectId storeObjectId = null; byte[] changeKey = null; Origin origin = Origin.New; CoreItem result; try { persistablePropertyBag = ItemBuilder.ConstructItemPersistablePropertyBag(session, itemCreateInfo.Schema.AutoloadProperties, useAcr, itemCreateInfo.AcrProfile, mapiMessageCreator); if (itemId != null) { object obj = persistablePropertyBag.TryGetProperty(CoreItemSchema.ReadCnNew); if (obj is byte[] && ((byte[])obj).Length > 0) { changeKey = itemId.ChangeKeyAsByteArray(); storeObjectId = itemId.ObjectId; origin = Origin.Existing; } } coreItem = new CoreItem(session, persistablePropertyBag, storeObjectId, changeKey, origin, ItemLevel.TopLevel, itemCreateInfo.Schema.AutoloadProperties, ItemBindOption.None); flag = true; result = coreItem; } finally { if (!flag) { Util.DisposeIfPresent(coreItem); Util.DisposeIfPresent(persistablePropertyBag); } } return(result); }
private void ConvertToItem(TnefReader reader, bool isSummaryTnef) { if (this.IsReplicationMessage) { PersistablePropertyBag persistablePropertyBag = CoreObject.GetPersistablePropertyBag(base.MessageWriter.CoreItem); if (persistablePropertyBag != null) { persistablePropertyBag.Context.IsValidationDisabled = true; } } this.reader = reader; this.isSummaryTnef = isSummaryTnef; this.isRecipientTablePromoted = false; while (this.reader.ReadNextAttribute()) { this.CheckTnefComplianceStatus(); this.ReadAttribute(); } this.ProcessEndTnef(); PropertyBagSaveFlags propertyBagSaveFlags = PropertyBagSaveFlags.IgnoreMapiComputedErrors | base.ConversionOptions.GetSaveFlags(base.IsTopLevelMessage); CoreObject.GetPersistablePropertyBag(base.CoreItem).SaveFlags |= propertyBagSaveFlags; }
internal static PersistablePropertyBag ConstructItemPersistablePropertyBag(StoreSession session, ICollection <PropertyDefinition> propertiesToLoad, bool createAcrPropertyBag, AcrProfile acrProfile, ItemBuilder.MapiMessageCreator mapiMessageCreator) { MapiMessage mapiMessage = null; PersistablePropertyBag persistablePropertyBag = null; PersistablePropertyBag persistablePropertyBag2 = null; bool flag = false; PersistablePropertyBag result; try { mapiMessage = mapiMessageCreator(); persistablePropertyBag = new StoreObjectPropertyBag(session, mapiMessage, propertiesToLoad); PersistablePropertyBag persistablePropertyBag3; if (createAcrPropertyBag) { persistablePropertyBag2 = new AcrPropertyBag(persistablePropertyBag, acrProfile, null, new RetryBagFactory(session), null); persistablePropertyBag3 = persistablePropertyBag2; } else { persistablePropertyBag3 = persistablePropertyBag; } flag = true; result = persistablePropertyBag3; } finally { if (!flag) { Util.DisposeIfPresent(persistablePropertyBag2); Util.DisposeIfPresent(persistablePropertyBag); Util.DisposeIfPresent(mapiMessage); } } return(result); }
private bool WritePropertyStreamData(PersistablePropertyBag propertyBag, NativeStorePropertyDefinition property) { long num; return(this.WritePropertyStreamData(propertyBag, property, out num)); }
internal static MailboxStoreObject Bind(StoreSession session, MapiStore mapiStore, ICollection <PropertyDefinition> requestedProperties, bool getMappingSignature, bool overridePropertyList) { ICollection <PropertyDefinition> collection = InternalSchema.Combine <PropertyDefinition>(overridePropertyList ? new PropertyTagPropertyDefinition[] { MailboxSchema.MailboxType, MailboxSchema.MailboxTypeDetail } : MailboxSchema.Instance.AutoloadProperties, requestedProperties); PersistablePropertyBag persistablePropertyBag = null; CoreMailboxObject coreMailboxObject = null; MailboxStoreObject mailboxStoreObject = null; bool flag = false; MailboxStoreObject result; try { byte[] array = null; if (getMappingSignature) { object thisObject = null; bool flag2 = false; try { if (session != null) { session.BeginMapiCall(); session.BeginServerHealthCall(); flag2 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } using (MapiFolder rootFolder = mapiStore.GetRootFolder()) { array = (rootFolder.GetProp(PropTag.MappingSignature).Value as byte[]); } } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.StoreOperationFailed, ex, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("Failed to get mapping signature.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.StoreOperationFailed, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("Failed to get mapping signature.", new object[0]), ex2 }); } finally { try { if (session != null) { session.EndMapiCall(); if (flag2) { session.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } } if (array != null) { session.MappingSignature = Convert.ToBase64String(array); } persistablePropertyBag = new StoreObjectPropertyBag(session, mapiStore, collection); coreMailboxObject = new CoreMailboxObject(session, persistablePropertyBag, null, null, collection); mailboxStoreObject = new MailboxStoreObject(coreMailboxObject); flag = true; result = mailboxStoreObject; } finally { if (!flag) { if (mailboxStoreObject != null) { mailboxStoreObject.Dispose(); mailboxStoreObject = null; } if (coreMailboxObject != null) { coreMailboxObject.Dispose(); coreMailboxObject = null; } if (persistablePropertyBag != null) { persistablePropertyBag.Dispose(); persistablePropertyBag = null; } } } return(result); }
private void DecryptMsg(MessageItem rightsProtectedMessage, string useLicense, SafeRightsManagementHandle decryptorHandle) { if (decryptorHandle == null) { throw new ArgumentNullException("decryptorHandle"); } if (decryptorHandle.IsInvalid) { throw new ArgumentException("decryptorHandle"); } this.originalItem = rightsProtectedMessage; DrmEmailMessage drmEmailMessage = null; bool flag = false; try { ExTraceGlobals.RightsManagementTracer.TraceDebug((long)this.GetHashCode(), "Found a use license for server. Decrypting message"); DrmEmailMessageBinding messageBinding = new DrmEmailMessageBinding(this.drmMsgContainer.PublishLicense, decryptorHandle); this.drmMsgContainer.Bind(messageBinding, new CreateStreamCallbackDelegate(this.BodyStreamCallback), new CreateStreamCallbackDelegate(this.AttachmentsStreamCallback)); drmEmailMessage = this.drmMsgContainer.EmailMessage; this.SaveAndCloseCurrentAttachment(); this.decryptedItem.SafeSetProperty(InternalSchema.DRMServerLicense, useLicense); this.decryptedItem.SafeSetProperty(InternalSchema.DrmPublishLicense, this.drmMsgContainer.PublishLicense); if (drmEmailMessage.Attachments.Count > 0) { ExTraceGlobals.RightsManagementTracer.TraceDebug <int>((long)this.GetHashCode(), "Number of attachments in the rights protected message : {0}", drmEmailMessage.Attachments.Count); int num = 0; foreach (DrmEmailAttachment drmEmailAttachment in drmEmailMessage.Attachments) { using (Attachment attachment = this.decryptedItem.AttachmentCollection.Open(this.messageAttachmentIds[num++], null)) { attachment.FileName = drmEmailAttachment.FileName; attachment[InternalSchema.DisplayName] = drmEmailAttachment.DisplayName; attachment.ContentId = drmEmailAttachment.ContentId; attachment[InternalSchema.AttachContentLocation] = drmEmailAttachment.ContentLocation; attachment[InternalSchema.AttachMhtmlFlags] = drmEmailAttachment.AttachFlags; attachment[InternalSchema.AttachCalendarHidden] = drmEmailAttachment.AttachHidden; if (drmEmailAttachment.AttachHidden) { attachment.IsInline = true; } if (drmEmailMessage.BodyFormat == BodyFormat.Rtf) { attachment.RenderingPosition = (int)drmEmailAttachment.CharacterPosition; if (attachment.AttachmentType == AttachmentType.EmbeddedMessage || attachment.AttachmentType == AttachmentType.Stream) { attachment[InternalSchema.AttachRendering] = drmEmailAttachment.AttachRendering; } } if (this.decryptAttachments) { Stream stream = null; StreamAttachment streamAttachment = attachment as StreamAttachment; if (streamAttachment != null && StreamAttachment.TryOpenRestrictedContent(streamAttachment, this.orgId, out stream)) { using (stream) { using (Stream contentStream = streamAttachment.GetContentStream(PropertyOpenMode.Create)) { Util.StreamHandler.CopyStreamData(stream, contentStream); } } } } attachment.Save(); } } } drmEmailMessage.Close(); drmEmailMessage = null; if (this.originalItem != null) { PersistablePropertyBag.CopyProperty(this.originalItem.PropertyBag, InternalSchema.TransportMessageHeaders, this.decryptedItem.PropertyBag); this.decryptedItem.Recipients.CopyRecipientsFrom(this.originalItem.Recipients); } this.decryptedItem.Save(SaveMode.NoConflictResolution); this.decryptedItem.Load(InternalSchema.ContentConversionProperties); flag = true; } finally { if (drmEmailMessage != null) { drmEmailMessage.Close(); drmEmailMessage = null; } if (!flag && this.decryptedItem != null) { this.decryptedItem.Dispose(); this.decryptedItem = null; } } }
private bool TryGetPropertyDefinitionsFromPropertyTags(StoreSession session, ICorePropertyBag corePropertyBag, uint[] propertyTags, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, out NativeStorePropertyDefinition[] propertyDefinitions, out uint unresolvablePropTag) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(corePropertyBag, "corePropertyBag"); Util.ThrowOnNullArgument(propertyTags, "propertyTags"); EnumValidator.ThrowIfInvalid <NativeStorePropertyDefinition.TypeCheckingFlag>(typeCheckingFlag, PropertyTagCache.validOptionSet); unresolvablePropTag = 0U; PropTag[] array = new PropTag[propertyTags.Length]; for (int i = 0; i < propertyTags.Length; i++) { array[i] = (PropTag)propertyTags[i]; } propertyDefinitions = this.PropertyDefinitionsFromPropTags(typeCheckingFlag, PersistablePropertyBag.GetPersistablePropertyBag(corePropertyBag).MapiProp, session, array); for (int j = 0; j < propertyDefinitions.Length; j++) { if (propertyDefinitions[j] == null) { unresolvablePropTag = (uint)array[j]; return(false); } } return(true); }
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(); } } }
private ContactLinkingProcessingState InspectNotification(COWTriggerAction operation, StoreSession session, CoreItem item, bool onBeforeNotification, bool onDumpster) { if (onDumpster) { return(ContactLinkingProcessingState.DoNotProcess); } if (!onBeforeNotification) { return(ContactLinkingProcessingState.DoNotProcess); } if (item == null) { return(ContactLinkingProcessingState.Unknown); } if (!(session is MailboxSession)) { COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: not a mailbox session."); return(ContactLinkingProcessingState.DoNotProcess); } if (operation != COWTriggerAction.Create && operation != COWTriggerAction.Update) { COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: not an Create or Update operation."); return(ContactLinkingProcessingState.DoNotProcess); } PersistablePropertyBag persistablePropertyBag = CoreObject.GetPersistablePropertyBag(item); switch (persistablePropertyBag.Context.AutomaticContactLinkingAction) { case AutomaticContactLinkingAction.ClientBased: if (!this.IsClientAllowed(session.ClientInfoString)) { COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: not allowed client session."); return(ContactLinkingProcessingState.DoNotProcess); } break; case AutomaticContactLinkingAction.Ignore: COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: IgnoreAutomaticContactLinking=true."); return(ContactLinkingProcessingState.DoNotProcess); } if (session.LogonType != LogonType.Owner && session.LogonType != LogonType.Delegated) { COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: logon session is not user or delegated."); return(ContactLinkingProcessingState.DoNotProcess); } string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty); if (string.IsNullOrEmpty(valueOrDefault)) { return(ContactLinkingProcessingState.Unknown); } if (ObjectClass.IsPlace(valueOrDefault)) { COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: place item class are not processed."); return(ContactLinkingProcessingState.DoNotProcess); } if (!ObjectClass.IsContact(valueOrDefault)) { COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: item class is not contact."); return(ContactLinkingProcessingState.DoNotProcess); } if (operation == COWTriggerAction.Update && !Array.Exists <StorePropertyDefinition>(COWContactLinking.NotificationProperties, (StorePropertyDefinition property) => item.PropertyBag.IsPropertyDirty(property))) { COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: no relevant properties changed"); return(ContactLinkingProcessingState.Unknown); } if (ClientInfo.MOMT.IsMatch(session.ClientInfoString)) { return(ContactLinkingProcessingState.ProcessAfterSave); } return(ContactLinkingProcessingState.ProcessBeforeSave); }
public PersistablePropertyBag CreateAttachment(ICollection <PropertyDefinition> propertiesToLoad, CoreAttachment attachmentToClone, IItem itemToAttach, out int attachmentNumber) { MapiAttach mapiAttach = null; PersistablePropertyBag persistablePropertyBag = null; bool flag = false; int num = 0; try { StoreSession session = this.AttachmentCollection.ContainerItem.Session; bool flag2 = false; try { if (session != null) { session.BeginMapiCall(); session.BeginServerHealthCall(); flag2 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } mapiAttach = this.AttachmentCollection.ContainerItem.MapiMessage.CreateAttach(out num); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenAttachment, ex, session, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenAttachment, ex2, session, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex2 }); } finally { try { if (session != null) { session.EndMapiCall(); if (flag2) { session.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } attachmentNumber = num; if (attachmentToClone != null) { MapiAttachmentProvider.CopySavedMapiAttachment(true, this, this.AttachmentCollection.ContainerItem.Session, (MapiAttach)attachmentToClone.PropertyBag.MapiProp, mapiAttach); } else if (itemToAttach != null) { MapiMessage mapiMessage = itemToAttach.MapiMessage; MapiMessage mapiMessage2 = null; StoreSession session2 = this.AttachmentCollection.ContainerItem.Session; bool flag3 = false; try { if (session2 != null) { session2.BeginMapiCall(); session2.BeginServerHealthCall(); flag3 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } mapiMessage2 = mapiAttach.OpenEmbeddedMessage(OpenPropertyFlags.Create); } catch (MapiPermanentException ex3) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenEmbeddedMessage, ex3, session2, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex3 }); } catch (MapiRetryableException ex4) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenEmbeddedMessage, ex4, session2, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex4 }); } finally { try { if (session2 != null) { session2.EndMapiCall(); if (flag3) { session2.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } using (mapiMessage2) { PropProblem[] array = null; StoreSession session3 = this.AttachmentCollection.ContainerItem.Session; bool flag4 = false; try { if (session3 != null) { session3.BeginMapiCall(); session3.BeginServerHealthCall(); flag4 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } array = mapiMessage.CopyTo(mapiMessage2, new PropTag[] { (PropTag)InternalSchema.UrlCompName.PropertyTag }); } catch (MapiPermanentException ex5) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCopyFailedProperties, ex5, session3, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex5 }); } catch (MapiRetryableException ex6) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCopyFailedProperties, ex6, session3, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex6 }); } finally { try { if (session3 != null) { session3.EndMapiCall(); if (flag4) { session3.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } if (array != null) { int num2 = -1; for (int i = 0; i < array.Length; i++) { int scode = array[i].Scode; if (scode == -2147221233 || scode == -2147221222) { ExTraceGlobals.StorageTracer.TraceDebug <int>((long)this.GetHashCode(), "Storage.MapiAttachmentProvider.AddExisting Item: CopyTo returned ignorable scode = {0}", scode); } else { ExTraceGlobals.StorageTracer.TraceError <int>((long)this.GetHashCode(), "Storage.MapiAttachmentProvider.AddExisting Item: CopyTo returned fatal scode = {0}", scode); num2 = i; } if (num2 != -1) { throw PropertyError.ToException(ServerStrings.ExUnableToCopyAttachments, StoreObjectPropertyBag.MapiPropProblemsToPropertyErrors(null, mapiMessage, array)); } } } StoreSession session4 = this.AttachmentCollection.ContainerItem.Session; bool flag5 = false; try { if (session4 != null) { session4.BeginMapiCall(); session4.BeginServerHealthCall(); flag5 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } mapiMessage2.SaveChanges(); } catch (MapiPermanentException ex7) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSaveChanges, ex7, session4, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex7 }); } catch (MapiRetryableException ex8) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSaveChanges, ex8, session4, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::CreateMapiAttachment", new object[0]), ex8 }); } finally { try { if (session4 != null) { session4.EndMapiCall(); if (flag5) { session4.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } } } persistablePropertyBag = this.CreateStorePropertyBag(mapiAttach, propertiesToLoad); persistablePropertyBag.ExTimeZone = this.ExTimeZone; flag = true; } finally { if (!flag) { if (persistablePropertyBag != null) { persistablePropertyBag.Dispose(); } if (mapiAttach != null) { mapiAttach.Dispose(); } } } return(persistablePropertyBag); }
internal CoreMailboxObject(StoreSession session, PersistablePropertyBag propertyBag, StoreObjectId storeObjectId, byte[] changeKey, ICollection <PropertyDefinition> prefetchProperties) : base(session, propertyBag, storeObjectId, changeKey, Origin.Existing, ItemLevel.TopLevel, prefetchProperties) { }
public ICoreItem OpenAttachedItem(ICollection <PropertyDefinition> propertiesToLoad, AttachmentPropertyBag attachmentBag, bool isNew) { MapiMessage mapiMessage = null; PersistablePropertyBag persistablePropertyBag = null; CoreItem coreItem = null; bool flag = false; StoreObjectId storeObjectId = null; byte[] array = null; ICoreItem result; try { StoreObjectPropertyBag storeObjectPropertyBag = (StoreObjectPropertyBag)attachmentBag.PersistablePropertyBag; MapiAttach mapiAttach = (MapiAttach)storeObjectPropertyBag.MapiProp; StoreSession session = this.AttachmentCollection.ContainerItem.Session; OpenPropertyFlags openPropertyFlags = isNew ? OpenPropertyFlags.Create : (this.AttachmentCollection.IsReadOnly ? OpenPropertyFlags.BestAccess : OpenPropertyFlags.BestAccess); openPropertyFlags |= OpenPropertyFlags.DeferredErrors; string text = storeObjectPropertyBag.TryGetProperty(InternalSchema.ItemClass) as string; Schema schema = (text != null) ? ObjectClass.GetSchema(text) : MessageItemSchema.Instance; propertiesToLoad = InternalSchema.Combine <PropertyDefinition>(schema.AutoloadProperties, propertiesToLoad); StoreSession session2 = this.AttachmentCollection.ContainerItem.Session; bool flag2 = false; try { if (session2 != null) { session2.BeginMapiCall(); session2.BeginServerHealthCall(); flag2 = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } mapiMessage = mapiAttach.OpenEmbeddedMessage(openPropertyFlags); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenEmbeddedMessage, ex, session2, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::OpenAttachedItem", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenEmbeddedMessage, ex2, session2, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiAttachmentProvider::OpenAttachedItem", new object[0]), ex2 }); } finally { try { if (session2 != null) { session2.EndMapiCall(); if (flag2) { session2.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } persistablePropertyBag = new StoreObjectPropertyBag(session, mapiMessage, propertiesToLoad); if (!isNew) { StoreObjectType storeObjectType = ItemBuilder.ReadStoreObjectTypeFromPropertyBag(persistablePropertyBag); ItemCreateInfo itemCreateInfo = ItemCreateInfo.GetItemCreateInfo(storeObjectType); propertiesToLoad = InternalSchema.Combine <PropertyDefinition>(itemCreateInfo.Schema.AutoloadProperties, propertiesToLoad); if (this.AttachmentCollection.IsReadOnly) { StoreId.SplitStoreObjectIdAndChangeKey(StoreObjectId.DummyId, out storeObjectId, out array); } persistablePropertyBag = new AcrPropertyBag(persistablePropertyBag, itemCreateInfo.AcrProfile, storeObjectId, new RetryBagFactory(session), array); } coreItem = new CoreItem(session, persistablePropertyBag, storeObjectId, array, isNew ? Origin.New : Origin.Existing, ItemLevel.Attached, propertiesToLoad, ItemBindOption.None); if (text != null && isNew) { coreItem.PropertyBag[InternalSchema.ItemClass] = text; } flag = true; result = coreItem; } finally { if (!flag) { if (coreItem != null) { coreItem.Dispose(); coreItem = null; } if (persistablePropertyBag != null) { persistablePropertyBag.Dispose(); persistablePropertyBag = null; } if (mapiMessage != null) { mapiMessage.Dispose(); mapiMessage = null; } } } return(result); }
private static MapiModifyTable GetMapiModifyTable(CoreFolder coreFolder, NativeStorePropertyDefinition property) { PersistablePropertyBag persistablePropertyBag = CoreObject.GetPersistablePropertyBag(coreFolder); PropTag propTag = PropertyTagCache.Cache.PropTagFromPropertyDefinition(persistablePropertyBag.MapiProp, coreFolder.Session, property); StoreSession storeSession = coreFolder.Session; object thisObject = null; bool flag = false; MapiModifyTable result; try { if (storeSession != null) { storeSession.BeginMapiCall(); storeSession.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } result = (MapiModifyTable)persistablePropertyBag.MapiProp.OpenProperty(propTag, PropertyTable.IExchangeModifyTableInterfaceId, 0, OpenPropertyFlags.DeferredErrors); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetMapiTable, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("PropertyTable.GetMapiModifyTable. Unable to get MapiModifyTable.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetMapiTable, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("PropertyTable.GetMapiModifyTable. Unable to get MapiModifyTable.", new object[0]), ex2 }); } finally { try { if (storeSession != null) { storeSession.EndMapiCall(); if (flag) { storeSession.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } return(result); }
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(); } } }
internal static PersistablePropertyBag GetPersistablePropertyBag(ICoreObject coreObject) { return(PersistablePropertyBag.GetPersistablePropertyBag(coreObject.PropertyBag)); }