private void RemoveItemFromDeletionList(StoreId itemId) { OccurrenceStoreObjectId occurrenceStoreObjectId = itemId as OccurrenceStoreObjectId; if (occurrenceStoreObjectId != null) { itemId = occurrenceStoreObjectId.GetMasterStoreObjectId(); } if (this.itemsToDelete.Contains(itemId)) { this.itemsToDelete.Remove(itemId); } }
internal VersionedId GetCorrelatedId(GlobalObjectId globalObjectId) { VersionedId result; if (this.isMasterMatchingTheOccurrence) { OccurrenceStoreObjectId itemId = new OccurrenceStoreObjectId(this.Id.ObjectId.ProviderLevelItemId, globalObjectId.Date); result = new VersionedId(itemId, this.Id.ChangeKeyAsByteArray()); } else { result = this.Id; } return(result); }
private CalendarItemBase ConvertToCalendarItem(GlobalObjectId goid, Item promotedItem, object[] matchedItem) { CalendarItemBase calendarItemBase = null; bool itemCreated = true; bool flag = false; promotedItem[InternalSchema.BodyTag] = promotedItem.Body.CalculateBodyTag(); try { if (matchedItem == null) { ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId, object, object>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. No matched existing object found, then create a new one. GOID:{0}; Subject:{1}; StartTime:{2}.", goid, promotedItem.TryGetProperty(ItemSchema.Subject), promotedItem.TryGetProperty(CalendarItemInstanceSchema.StartTime)); calendarItemBase = CalendarItem.Create(this.session, this.folder.Id); } else if (this.IsMeetingChanged(goid, promotedItem, matchedItem)) { StoreObjectId storeObjectId = ((VersionedId)matchedItem[this.QueryIndexId]).ObjectId; if (!goid.IsCleanGlobalObjectId && true.Equals(matchedItem[this.QueryIndexRecurring])) { storeObjectId = new OccurrenceStoreObjectId(storeObjectId.ProviderLevelItemId, goid.Date); } try { calendarItemBase = CalendarItemBase.Bind(this.session, storeObjectId); calendarItemBase.OpenAsReadWrite(); itemCreated = false; } catch (OccurrenceNotFoundException) { ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Tried to bind to an occurrence not existing", storeObjectId.ToString()); calendarItemBase = CalendarItem.Create(this.session, this.folder.Id); } } if (calendarItemBase != null) { try { this.CopyToCalendarItem(promotedItem, calendarItemBase, itemCreated); flag = true; goto IL_154; } catch (RecurrenceException arg) { ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId, RecurrenceException>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Failed to copy the iCal to a calendarItem for ID:{0}, Exception = {1}", goid, arg); flag = false; goto IL_154; } catch (AttachmentExceededException arg2) { ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId, AttachmentExceededException>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Failed to copy the iCal to a calendarItem for ID:{0}, Exception = {1}", goid, arg2); flag = false; goto IL_154; } } flag = true; IL_154 :; } finally { if (!flag) { ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Failed to convert to XSO calendar item. GOID:{0}.", goid); this.results.RawErrors.Add(ServerStrings.SyncFailedToCreateNewItemOrBindToExistingOne); Util.DisposeIfPresent(calendarItemBase); calendarItemBase = null; } } return(calendarItemBase); }
internal OccurrenceBagFactory(StoreSession storeSession, OccurrenceStoreObjectId occurrenceUniqueItemId) { this.storeSession = storeSession; this.exTimeZone = storeSession.ExTimeZone; this.occurrenceUniqueItemId = occurrenceUniqueItemId; }
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); }