public override CalendarItemBase GetEmbeddedItem() { this.CheckDisposed("GetEmbeddedItem"); ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.GetEmbeddedItem: GOID={0}", this.GlobalObjectId); CalendarItemBase calendarItemBase = null; bool flag = false; CalendarItemBase result; try { ItemCreateInfo calendarItemInfo = ItemCreateInfo.CalendarItemInfo; calendarItemBase = ItemBuilder.ConstructItem <CalendarItem>(base.Session, base.StoreObjectId, (base.StoreObjectId != null) ? base.Id.ChangeKeyAsByteArray() : null, calendarItemInfo.Schema.AutoloadProperties, delegate { AcrPropertyBag acrPropertyBag = null; PersistablePropertyBag persistablePropertyBag = null; bool flag2 = false; StoreObjectId storeObjectId = base.StoreObjectId; PersistablePropertyBag result2; try { if (storeObjectId != null && !storeObjectId.IsFakeId) { persistablePropertyBag = StoreObjectPropertyBag.CreatePropertyBag(base.Session, storeObjectId, InternalSchema.ContentConversionProperties); acrPropertyBag = new AcrPropertyBag(persistablePropertyBag, AcrProfile.AppointmentProfile, storeObjectId, new ItemBagFactory(base.Session, base.StoreObjectId), null); flag2 = true; result2 = acrPropertyBag; } else { persistablePropertyBag = new StoreObjectPropertyBag(base.Session, base.MapiProp, InternalSchema.ContentConversionProperties, false); flag2 = true; result2 = persistablePropertyBag; } } finally { if (!flag2) { Util.DisposeIfPresent(persistablePropertyBag); Util.DisposeIfPresent(acrPropertyBag); } } return(result2); }, calendarItemInfo.Creator, base.CoreObject.Origin, base.CoreObject.ItemLevel); flag = true; result = calendarItemBase; } finally { if (!flag && calendarItemBase != null) { calendarItemBase.Dispose(); calendarItemBase = null; } } return(result); }
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); }
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); }
internal static CoreItem CoreItemBind(StoreSession session, StoreId storeId, ItemBuilder.MapiMessageCreator mapiMessageCreator, ItemBindOption itemBindOption, ICollection <PropertyDefinition> propertiesToLoad, ref StoreObjectType storeObjectType) { Util.ThrowOnNullArgument(session, "session"); EnumValidator.ThrowIfInvalid <ItemBindOption>(itemBindOption); Util.ThrowOnNullArgument(propertiesToLoad, "propertiesToLoad"); bool flag = false; MapiProp mapiProp = null; PersistablePropertyBag persistablePropertyBag = null; AcrPropertyBag acrPropertyBag = null; CoreItem coreItem = null; CoreItem result2; using (CallbackContext callbackContext = new CallbackContext(session)) { try { session.OnBeforeItemChange(ItemChangeOperation.ItemBind, session, storeId, coreItem, callbackContext); StoreObjectId storeObjectId; byte[] array; StoreId.SplitStoreObjectIdAndChangeKey(storeId, out storeObjectId, out array); session.CheckSystemFolderAccess(storeObjectId); if (storeObjectId != null && !IdConverter.IsMessageId(storeObjectId)) { throw new ArgumentException(ServerStrings.ExInvalidItemId); } bool flag2 = false; OccurrenceStoreObjectId occurrenceStoreObjectId = storeObjectId as OccurrenceStoreObjectId; IPropertyBagFactory propertyBagFactory; if (occurrenceStoreObjectId != null) { persistablePropertyBag = Item.CreateOccurrencePropertyBag(session, occurrenceStoreObjectId, propertiesToLoad); storeObjectType = StoreObjectType.CalendarItemOccurrence; flag2 = true; propertyBagFactory = new OccurrenceBagFactory(session, occurrenceStoreObjectId); } else { if (mapiMessageCreator != null) { mapiProp = mapiMessageCreator(); } else if ((itemBindOption & ItemBindOption.SoftDeletedItem) == ItemBindOption.SoftDeletedItem) { mapiProp = session.GetMapiProp(storeObjectId, OpenEntryFlags.BestAccess | OpenEntryFlags.DeferredErrors | OpenEntryFlags.ShowSoftDeletes); } else { mapiProp = session.GetMapiProp(storeObjectId); } persistablePropertyBag = new StoreObjectPropertyBag(session, mapiProp, propertiesToLoad); StoreObjectType storeObjectType2 = ItemBuilder.ReadStoreObjectTypeFromPropertyBag(persistablePropertyBag); if (storeObjectType2 == storeObjectType) { flag2 = true; } else { storeObjectType = storeObjectType2; } propertyBagFactory = new RetryBagFactory(session); if (storeObjectId != null && storeObjectId.ObjectType != storeObjectType) { storeObjectId = StoreObjectId.FromProviderSpecificId(storeObjectId.ProviderLevelItemId, storeObjectType); } } ItemBuilder.CheckPrivateItem(session, persistablePropertyBag); ItemCreateInfo itemCreateInfo = ItemCreateInfo.GetItemCreateInfo(storeObjectType); if (flag2) { propertiesToLoad = null; } else { propertiesToLoad = ItemBuilder.GetPropertiesToLoad(itemBindOption, itemCreateInfo.Schema, propertiesToLoad); } acrPropertyBag = new AcrPropertyBag(persistablePropertyBag, itemCreateInfo.AcrProfile, storeObjectId, propertyBagFactory, array); coreItem = new CoreItem(session, acrPropertyBag, storeObjectId, array, Origin.Existing, ItemLevel.TopLevel, propertiesToLoad, itemBindOption); flag = true; ConflictResolutionResult result = flag ? ConflictResolutionResult.Success : ConflictResolutionResult.Failure; session.OnAfterItemChange(ItemChangeOperation.ItemBind, session, storeId, coreItem, result, callbackContext); result2 = coreItem; } finally { if (!flag) { Util.DisposeIfPresent(coreItem); Util.DisposeIfPresent(acrPropertyBag); Util.DisposeIfPresent(persistablePropertyBag); Util.DisposeIfPresent(mapiProp); } } } return(result2); }