internal static StoreObjectPropertyBag CreatePropertyBag(StoreSession storeSession, StoreObjectId id, ICollection <PropertyDefinition> prefetchPropertyArray) { Util.ThrowOnNullArgument(id, "id"); MapiProp mapiProp = null; StoreObjectPropertyBag storeObjectPropertyBag = null; bool flag = false; StoreObjectPropertyBag result; try { mapiProp = storeSession.GetMapiProp(id); storeObjectPropertyBag = new StoreObjectPropertyBag(storeSession, mapiProp, prefetchPropertyArray); flag = true; result = storeObjectPropertyBag; } finally { if (!flag) { Util.DisposeIfPresent(storeObjectPropertyBag); Util.DisposeIfPresent(mapiProp); } } return(result); }
internal static MapiPropertyBag CreateMapiPropertyBag(StoreSession storeSession, StoreObjectId id) { Util.ThrowOnNullArgument(storeSession, "storeSession"); Util.ThrowOnNullArgument(id, "id"); MapiProp disposable = null; MapiPropertyBag mapiPropertyBag = null; bool flag = false; MapiPropertyBag result; try { disposable = storeSession.GetMapiProp(id); mapiPropertyBag = new MapiPropertyBag(storeSession, disposable); flag = true; result = mapiPropertyBag; } finally { if (!flag) { Util.DisposeIfPresent(mapiPropertyBag); Util.DisposeIfPresent(disposable); } } return(result); }
protected override SharingBindingData CreateDataObjectFromItem(object[] properties) { VersionedId versionedId = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <VersionedId>(properties, 1); if (versionedId == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Binding is missing ID", this.mailboxSession.MailboxOwner); return(null); } string text = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 12); if (text == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing sharingLocalType", this.mailboxSession.MailboxOwner, versionedId); return(null); } SharingDataType sharingDataType = SharingDataType.FromContainerClass(text); if (sharingDataType == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, string>((long)this.GetHashCode(), "{0}: Binding {1} has invalid sharingLocalType: {2}", this.mailboxSession.MailboxOwner, versionedId, text); return(null); } string text2 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 8); if (text2 == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing initiatorName", this.mailboxSession.MailboxOwner, versionedId); return(null); } string text3 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 9); if (text3 == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing initiatorSmtpAddress", this.mailboxSession.MailboxOwner, versionedId); return(null); } string text4 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 7); if (text4 == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing remoteFolderName", this.mailboxSession.MailboxOwner, versionedId); return(null); } string text5 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 18); if (text5 == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing remoteFolderId", this.mailboxSession.MailboxOwner, versionedId); return(null); } string text6 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 10); if (text6 == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing localFolderName", this.mailboxSession.MailboxOwner, versionedId); return(null); } string text7 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 11); if (text7 == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing localFolderUid", this.mailboxSession.MailboxOwner, versionedId); return(null); } StoreObjectId localFolderId; try { localFolderId = StoreObjectId.FromHexEntryId(text7, sharingDataType.StoreObjectType); } catch (CorruptDataException) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} has invalid localFolderUid", this.mailboxSession.MailboxOwner, versionedId); return(null); } int?num = SharingItemManagerBase <SharingBindingData> .TryGetPropertyVal <int>(properties, 3); if (num == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing flavor", this.mailboxSession.MailboxOwner, versionedId); return(null); } bool isDefaultFolderShared = 0 != (num.Value & 131072); DateTime? lastSyncTimeUtc = null; ExDateTime?exDateTime = SharingItemManagerBase <SharingBindingData> .TryGetPropertyVal <ExDateTime>(properties, 15); if (exDateTime == null) { ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing lastSyncTime", this.mailboxSession.MailboxOwner, versionedId); } else { lastSyncTimeUtc = new DateTime?((DateTime)exDateTime.Value.ToUtc()); } return(new SharingBindingData(versionedId, sharingDataType, text2, text3, text4, text5, text6, localFolderId, isDefaultFolderShared, lastSyncTimeUtc)); }
internal static ImportCalendarResults ImportCalendar(Stream inputStream, string charset, InboundConversionOptions options, StoreSession session, StoreObjectId folderId) { return(ICalSharingHelper.ImportCalendar(inputStream, charset, options, session, folderId, Deadline.NoDeadline)); }
public static void ExportCalendar(Stream outputStream, string charset, OutboundConversionOptions options, MailboxSession session, StoreObjectId folderId, ExDateTime windowStart, ExDateTime windowEnd, DetailLevelEnumType detailType) { EnumValidator.ThrowIfInvalid <DetailLevelEnumType>(detailType, "detailType"); PropertyDefinition[] array = InternetCalendarSchema.FromDetailLevel(detailType); Array.IndexOf <PropertyDefinition>(array, CalendarItemBaseSchema.FreeBusyStatus); int num = Array.IndexOf <PropertyDefinition>(array, InternalSchema.ItemId); using (CalendarFolder calendarFolder = CalendarFolder.Bind(session, folderId)) { object[][] array2 = calendarFolder.InternalGetCalendarView(windowStart, windowEnd, detailType == DetailLevelEnumType.AvailabilityOnly, true, true, RecurrenceExpansionOption.IncludeMaster | RecurrenceExpansionOption.TruncateMaster, array); Item[] items = new Item[array2.Length]; try { for (int i = 0; i < array2.Length; i++) { items[i] = MessageItem.CreateInMemory(StoreObjectSchema.ContentConversionProperties); for (int j = 0; j < array.Length; j++) { StorePropertyDefinition storePropertyDefinition = array[j] as StorePropertyDefinition; if (storePropertyDefinition != null && (storePropertyDefinition.PropertyFlags & PropertyFlags.ReadOnly) != PropertyFlags.ReadOnly) { object obj = array2[i][j]; if (!PropertyError.IsPropertyError(obj)) { items[i][storePropertyDefinition] = obj; } } } if (detailType == DetailLevelEnumType.FullDetails && array2[i][num] is VersionedId) { using (CoreItem coreItem = CoreItem.Bind(session, (VersionedId)array2[i][num], new PropertyDefinition[] { ItemSchema.TextBody, ItemSchema.HtmlBody, ItemSchema.RtfBody })) { using (TextReader textReader = coreItem.Body.OpenTextReader(BodyFormat.TextPlain)) { items[i][ItemSchema.TextBody] = textReader.ReadToEnd(); } } } } OutboundAddressCache addressCache = new OutboundAddressCache(options, new ConversionLimitsTracker(options.Limits)); List <LocalizedString> errorStream = new List <LocalizedString>(); ConvertUtils.CallCts(ExTraceGlobals.ICalTracer, "ICalSharingHelper::ExportCalendar", ServerStrings.ConversionCorruptContent, delegate { CalendarDocument.InternalItemsToICal(calendarFolder.DisplayName, items, null, addressCache, true, outputStream, errorStream, charset, options); }); if (errorStream.Count > 0) { ExTraceGlobals.ICalTracer.TraceError <int>(0L, "{0} errors found during outbound iCal content conversion.", errorStream.Count); AnonymousSharingLog.LogEntries(session, errorStream); } } finally { foreach (Item item in items) { if (item != null) { item.Dispose(); } } } } }
internal void Remove(UserConfigurationName configName, StoreObjectId folderId) { this.SharedCacheEntryManager.Remove(configName, folderId); }
protected internal override CalendarItemOccurrence RecoverDeletedOccurrence() { if (this.possibleDeletedOccurrenceId != null) { MailboxSession calendarMailboxSession = MeetingMessage.GetCalendarMailboxSession(this); for (int i = 0; i < 2; i++) { CalendarItem calendarItem = CalendarItem.Bind(calendarMailboxSession, StoreObjectId.FromProviderSpecificId(this.possibleDeletedOccurrenceId.ProviderLevelItemId, StoreObjectType.CalendarItem)); try { calendarItem.OpenAsReadWrite(); if (calendarItem.Recurrence != null) { InternalRecurrence internalRecurrence = (InternalRecurrence)calendarItem.Recurrence; ExDateTime occurrenceId = ((OccurrenceStoreObjectId)this.possibleDeletedOccurrenceId).OccurrenceId; if (internalRecurrence.IsValidOccurrenceId(occurrenceId)) { if (internalRecurrence.IsOccurrenceDeleted(occurrenceId)) { base.LocationIdentifierHelperInstance.SetLocationIdentifier(39541U, LastChangeAction.RecoverDeletedOccurance); calendarItem.RecoverDeletedOccurrence(this.possibleDeletedOccurrenceId); if (calendarItem.Save(SaveMode.ResolveConflicts).SaveStatus == SaveResult.IrresolvableConflict) { goto IL_136; } } CalendarItemOccurrence calendarItemOccurrence = CalendarItemOccurrence.Bind(calendarMailboxSession, this.possibleDeletedOccurrenceId, MeetingMessageSchema.Instance.AutoloadProperties); calendarItemOccurrence.OpenAsReadWrite(); ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence recovered.", this.GlobalObjectId); return(calendarItemOccurrence); } ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence id is invalid.", this.GlobalObjectId); return(null); } } catch (OccurrenceNotFoundException) { ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence not found.", this.GlobalObjectId); return(null); } finally { calendarItem.Dispose(); } IL_136 :; } } ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence not recovered.", this.GlobalObjectId); return(null); }
public bool SkipItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, bool onBeforeNotification, bool onDumpster, bool success, CallbackContext callbackContext) { Util.ThrowOnNullArgument(session, "session"); EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state"); Util.ThrowOnNullArgument(callbackContext, "callbackContext"); if (!WorkingSetPublisher.IsGroupWSPublishingEnabled()) { COWGroupMessageWSPublishing.Tracer.Information((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping group message working set publishing as the feature is disabled."); return(true); } switch (callbackContext.COWGroupMessageWSPublishingState) { case COWProcessorState.Unknown: callbackContext.COWGroupMessageWSPublishingState = this.InspectNotification(operation, session, item, onBeforeNotification, onDumpster); COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId, COWProcessorState>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: inspected item {0} and result is {1}.", itemId, callbackContext.COWGroupMessageWSPublishingState); return(true); case COWProcessorState.DoNotProcess: COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping notification for item {0} because it should not be processed.", itemId); return(true); case COWProcessorState.ProcessAfterSave: return(onBeforeNotification); case COWProcessorState.Processed: COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping notification for item {0} because it has already been processed.", itemId); return(true); default: return(true); } }
public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext) { Util.ThrowOnNullArgument(session, "session"); EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state"); EnumValidator.ThrowIfInvalid <OperationResult>(result, "result"); Util.ThrowOnNullArgument(item, "item"); Util.ThrowOnNullArgument(callbackContext, "callbackContext"); if (callbackContext.COWGroupMessageWSPublishingState != COWProcessorState.ProcessAfterSave) { COWGroupMessageWSPublishing.Tracer.TraceError <COWProcessorState>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing because the state doesn't indicate processing is needed: {0}", callbackContext.COWGroupMessageWSPublishingState); return; } if (onBeforeNotification) { COWGroupMessageWSPublishing.Tracer.TraceError((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing because we should only publish after saving"); return; } if (result != OperationResult.Succeeded) { COWGroupMessageWSPublishing.Tracer.TraceDebug <OperationResult>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing of message because the operation wasn't successful: {0}", result); return; } MailboxSession mailboxSession = session as MailboxSession; if (mailboxSession == null) { COWGroupMessageWSPublishing.Tracer.TraceError <OperationResult>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing the session is not a mailbox session", result); return; } if (mailboxSession.MailboxOwner == null || mailboxSession.MailboxOwner.MailboxInfo == null) { COWGroupMessageWSPublishing.Tracer.TraceError <OperationResult>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing, the session does not contain the mailbox info", result); return; } string displayName = mailboxSession.DisplayName; string groupId = mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(); Exception ex = this.groupWSPublisher.PublishGroupPost(item, displayName, groupId); if (ex == null) { COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: working set publishing of message {0} from group mailbox successful", itemId); } else { COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId, string>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: working set publishing of message {0} from group mailbox failed. Error: {1}", itemId, ex.ToString()); } callbackContext.COWGroupMessageWSPublishingState = COWProcessorState.Processed; }
public void GroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, bool onBeforeNotification, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); }
private COWProcessorState InspectNotification(COWTriggerAction operation, StoreSession session, CoreItem item, bool onBeforeNotification, bool onDumpster) { if (onDumpster) { return(COWProcessorState.DoNotProcess); } if (operation != COWTriggerAction.Create) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: not an Create operation."); return(COWProcessorState.DoNotProcess); } if (!onBeforeNotification) { return(COWProcessorState.DoNotProcess); } if (item == null) { return(COWProcessorState.Unknown); } if (item.Id != null) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: ItemId is non-null, so this is not a new item. Do not process."); return(COWProcessorState.DoNotProcess); } MailboxSession mailboxSession = session as MailboxSession; if (mailboxSession == null) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: not a mailbox session. Do not process."); return(COWProcessorState.DoNotProcess); } int?num = mailboxSession.Mailbox.TryGetProperty(MailboxSchema.MailboxTypeDetail) as int?; if (num == null) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: mailbox type not found. Try to inspect later."); return(COWProcessorState.Unknown); } if (!StoreSession.IsGroupMailbox(num.Value)) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: Mailbox isn't a GroupMailbox. Do not process."); return(COWProcessorState.DoNotProcess); } string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty); if (string.IsNullOrEmpty(valueOrDefault)) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class not found. Try to inspect later."); return(COWProcessorState.Unknown); } if (!ObjectClass.IsMessage(valueOrDefault, false)) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class is not a message. Do not process."); return(COWProcessorState.DoNotProcess); } if (ObjectClass.IsMeetingForwardNotification(valueOrDefault)) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class is meeting forward notification. Do not process."); return(COWProcessorState.DoNotProcess); } if (ObjectClass.IsMeetingResponse(valueOrDefault)) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class is meeting response. Do not process."); return(COWProcessorState.DoNotProcess); } bool flag = ClientInfo.OWA.IsMatch(mailboxSession.ClientInfoString); bool flag2 = ClientInfo.HubTransport.IsMatch(mailboxSession.ClientInfoString); if (!flag && !flag2) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: This isn't either a post or a delivery. Do not process."); return(COWProcessorState.DoNotProcess); } StoreObjectId storeObjectId = item.PropertyBag.TryGetProperty(StoreObjectSchema.ParentItemId) as StoreObjectId; if (storeObjectId == null) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: parent folder id not found. Try to inspect later."); return(COWProcessorState.Unknown); } StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox); if (defaultFolderId == null) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: inbox folder id not found. Try to inspect later."); return(COWProcessorState.Unknown); } if (!storeObjectId.Equals(defaultFolderId)) { COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: This message isn't located on the inbox folder. Do not process."); return(COWProcessorState.DoNotProcess); } return(COWProcessorState.ProcessAfterSave); }
public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); return(CowClientOperationSensitivity.Skip); }
internal static FolderHierarchySyncState GetSyncState(SyncStateStorage syncStateStorage, Folder syncStateParentFolder, StoreObjectId storeObjectId, ISyncLogger syncLogger = null) { SyncStateInfo syncStateInfo = new FolderHierarchySyncStateInfo(); StoreObject syncStateStoreObject = SyncState.GetSyncStateStoreObject(syncStateStorage, syncStateParentFolder, syncStateInfo, syncLogger, new PropertyDefinition[0]); if (syncStateStoreObject == null) { return(null); } SyncStateMetadata syncState = syncStateStorage.DeviceMetadata.GetSyncState(syncStateParentFolder.Session as MailboxSession, syncStateInfo.UniqueName, syncLogger); return(new FolderHierarchySyncState(syncStateStorage, syncStateStoreObject, syncState, syncStateInfo, false, syncLogger)); }
public CalendarGroupEntryInfo(string calendarName, VersionedId id, LegacyCalendarColor color, StoreObjectId calendarId, Guid parentGroupId, byte[] calendarOrdinal, ExDateTime lastModifiedTime) : base(id, calendarOrdinal, lastModifiedTime) { Util.ThrowOnNullArgument(calendarName, "calendarName"); EnumValidator.ThrowIfInvalid <LegacyCalendarColor>(color, "color"); this.CalendarId = calendarId; this.CalendarName = calendarName; this.LegacyCalendarColor = color; this.ParentGroupClassId = parentGroupId; this.CalendarColor = LegacyCalendarColorConverter.FromLegacyCalendarColor(color); }
internal override AggregateOperationResult Delete(DefaultFolderContext context, DeleteItemFlags deleteItemFlags, StoreObjectId id) { throw new NotSupportedException("The defaultFolder does not support deletion."); }
internal static StoreObjectId CreateVersion(StoreSession session, StoreObjectId itemId, StoreObjectId versionFolderId) { StoreObjectId result; using (CoreCalendarItemVersion coreCalendarItemVersion = new CoreCalendarItemVersion(session)) { using (MapiProp mapiProp = session.GetMapiProp(itemId, OpenEntryFlags.DeferredErrors | OpenEntryFlags.ShowSoftDeletes)) { coreCalendarItemVersion.underlyingMessage = Folder.InternalCreateMapiMessage(session, versionFolderId, CreateMessageType.Normal); coreCalendarItemVersion.CopyRequiredData((MapiMessage)mapiProp); object thisObject = null; bool flag = false; try { if (session != null) { session.BeginMapiCall(); session.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } coreCalendarItemVersion.underlyingMessage.SetReadFlag(SetReadFlags.ClearRnPending | SetReadFlags.CleanNrnPending); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("CoreCalendarItemVersion::CreateVersion. Failed to set read flag of underlying message.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("CoreCalendarItemVersion::CreateVersion. Failed to set read flag of underlying message.", new object[0]), ex2 }); } finally { try { if (session != null) { session.EndMapiCall(); if (flag) { session.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } } coreCalendarItemVersion.Save(); StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(coreCalendarItemVersion.underlyingMessage.GetProp(PropTag.EntryId).GetBytes(), itemId.ObjectType); CoreCalendarItemVersion.perfCounters.DumpsterCalendarLogsRate.Increment(); result = storeObjectId; } return(result); }
internal void Add(StoreObjectId folderId, UserConfigurationName configName, StoreObjectId itemId) { this.SharedCacheEntryManager.AddUserConfigurationCachedEntry(folderId, configName.Name, itemId, this.mailboxSession.LogonType == LogonType.Owner); }
protected override void CheckItemBelongsToThisFolder(StoreObjectId storeObjectIds) { }
internal override CalendarItemBase GetCorrelatedItemInternal(bool cache, bool shouldDetectDuplicateIds, out IEnumerable <VersionedId> detectedDuplicatesIds) { ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, bool>((long)this.GetHashCode(), "Storage.MeetingMessage.GetCorrelatedItem: GOID={0}; cache={1}", this.GlobalObjectId, cache); if (!(base.Session is MailboxSession)) { detectedDuplicatesIds = null; return(null); } if (this.cachedCorrelatedItem != null) { if (!shouldDetectDuplicateIds) { ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.GetCorrelatedItemInternal: GOID={0}. Returning cached correlated item.", this.GlobalObjectId); CalendarItemBase result = this.cachedCorrelatedItem; if (!cache) { this.cachedCorrelatedItem.SetDisposeTrackerStacktraceToCurrentLocation(); this.cachedCorrelatedItem = null; } detectedDuplicatesIds = Array <VersionedId> .Empty; return(result); } ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.GetCorrelatedItemInternal: GOID={0}. Clearing cached item.", this.GlobalObjectId); this.cachedCorrelatedItem.Dispose(); this.cachedCorrelatedItem = null; } MailboxSession calendarMailboxSession; try { calendarMailboxSession = MeetingMessage.GetCalendarMailboxSession(this); } catch (NotSupportedWithServerVersionException ex) { ExTraceGlobals.MeetingMessageTracer.Information((long)this.GetHashCode(), "MeetingMessage::GetCorrelatedItemInternal. Calendar mailbox session failed to open due to not supported server version."); throw new CorrelationFailedException(ex.LocalizedString, ex); } catch (AdUserNotFoundException ex2) { ExTraceGlobals.MeetingMessageTracer.Information((long)this.GetHashCode(), "MeetingMessage::GetCorrelatedItemInternal. Calendar mailbox session failed to open due to not being able to find the owner's mailbox."); throw new CorrelationFailedException(ex2.LocalizedString, ex2); } StoreObjectId defaultFolderId = calendarMailboxSession.GetDefaultFolderId(DefaultFolderType.Calendar); if (defaultFolderId == null) { ExTraceGlobals.MeetingMessageTracer.Information((long)this.GetHashCode(), "MeetingMessage::GetCorrelatedItemInternal. Calendar folder is not found. We treat it as correlated calendar item has been deleted."); detectedDuplicatesIds = null; return(null); } CalendarItemBase calendarItemBase = null; bool flag = false; try { using (CalendarFolder calendarFolder = CalendarFolder.Bind(calendarMailboxSession, defaultFolderId)) { int i = 0; while (i < 2) { ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, int>((long)this.GetHashCode(), "Storage.MeetingMessage.GetCorrelatedItemInternal: GOID={0}. Retrying fetch count={1}", this.GlobalObjectId, i); this.FetchCorrelatedItemId(calendarFolder, shouldDetectDuplicateIds, out detectedDuplicatesIds); if (this.correlatedItemId != null) { try { calendarItemBase = CalendarItemBase.Bind(calendarMailboxSession, this.correlatedItemId.ObjectId); } catch (OccurrenceNotFoundException) { ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.GetCorrelatedItemInternal: GOID={0}. Occurrence not found.", this.GlobalObjectId); this.possibleDeletedOccurrenceId = this.correlatedItemId.ObjectId; this.correlatedItemId = null; break; } catch (ObjectNotFoundException) { ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.GetCorrelatedItemInternal: GOID={0}. Calendar item id was found but calendar item got deleted.", this.GlobalObjectId); this.correlatedItemId = null; goto IL_259; } catch (WrongObjectTypeException innerException) { throw new CorruptDataException(ServerStrings.ExNonCalendarItemReturned("Unknown"), innerException); } catch (ArgumentException) { throw new CorruptDataException(ServerStrings.ExNonCalendarItemReturned("Unknown")); } goto IL_20D; IL_259: i++; continue; IL_20D: calendarItemBase.OpenAsReadWrite(); if (base.Id != null) { calendarItemBase.AssociatedItemId = base.Id; } if (cache) { ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.GetCorrelatedItemInternal: GOID={0}. Caching correlated calendar item.", this.GlobalObjectId); this.cachedCorrelatedItem = calendarItemBase; } flag = true; return(calendarItemBase); } break; } } } finally { if (!flag) { Util.DisposeIfPresent(calendarItemBase); } } detectedDuplicatesIds = null; return(null); }
internal void AddUserConfigurationCachedEntry(StoreObjectId folderId, string configName, StoreObjectId itemId, bool canCleanse) { UserConfigurationCacheEntry value = new UserConfigurationCacheEntry(configName, folderId, itemId); LinkedListNode <UserConfigurationCacheEntry> node = new LinkedListNode <UserConfigurationCacheEntry>(value); lock (this.userConfigCacheEntryList) { for (LinkedListNode <UserConfigurationCacheEntry> linkedListNode = this.userConfigCacheEntryList.First; linkedListNode != null; linkedListNode = linkedListNode.Next) { UserConfigurationCacheEntry value2 = linkedListNode.Value; if (value2.CheckMatch(configName, folderId)) { linkedListNode.Value = value; return; } } if (canCleanse && this.userConfigCacheEntryList.Count > 32) { this.userConfigCacheEntryList.RemoveLast(); ExTraceGlobals.UserConfigurationTracer.TraceDebug <int>((long)this.GetHashCode(), "UserConfigurationCache::Add. The cache has reached the capacity: {0} the last entry was removed.", 32); } this.userConfigCacheEntryList.AddFirst(node); } }
public override CalendarItemBase TryGetCorrelatedItemFromHintId(MailboxSession session, StoreObjectId hintId) { if (hintId != null) { try { CalendarItemBase calendarItemBase = CalendarItemBase.Bind(session, hintId); if (!this.ValidateCorrelatedItem(calendarItemBase)) { calendarItemBase.Dispose(); throw new CorrelationFailedException(ServerStrings.ExCorrelationFailedForOccurrence(this.Subject)); } calendarItemBase.OpenAsReadWrite(); calendarItemBase.IsCorrelated = true; this.correlatedItemId = calendarItemBase.Id; calendarItemBase.AssociatedItemId = base.Id; this.externalCorrelatedCalendarItem = calendarItemBase; this.getCorrelatedItemCalled = true; return(calendarItemBase); } catch (Exception arg) { ExTraceGlobals.MeetingMessageTracer.TraceError <string, Exception>((long)this.GetHashCode(), "Exception thrown when trying to bind to calendar item id hint passed from meeting series message ordering agent. Mailbox = {0}, exception = {1}.", session.MailboxOwnerLegacyDN, arg); } } return(null); }
internal bool TryGetUserConfigurationCachedEntry(UserConfigurationName configName, StoreObjectId folderId, out UserConfigurationCacheEntry cacheEntry) { bool result; lock (this.userConfigCacheEntryList) { for (LinkedListNode <UserConfigurationCacheEntry> linkedListNode = this.userConfigCacheEntryList.First; linkedListNode != null; linkedListNode = linkedListNode.Next) { UserConfigurationCacheEntry value = linkedListNode.Value; if (value.CheckMatch(configName.Name, folderId)) { cacheEntry = value; return(true); } } cacheEntry = null; result = false; } return(result); }
internal static ImportCalendarResults ImportCalendar(Stream inputStream, string charset, InboundConversionOptions options, StoreSession session, StoreObjectId folderId, Deadline deadline) { ImportCalendarResults result; using (CalendarFolder calendarFolder = CalendarFolder.Bind(session, folderId)) { result = ICalSharingHelper.ImportCalendar(inputStream, charset, options, session, calendarFolder, deadline, ExDateTime.MinValue, ExDateTime.MaxValue); } return(result); }
internal void ParseUserConfigurationCacheEntries(BinaryReader reader) { reader.ReadUInt16(); int num = reader.ReadInt32(); this.hasUserConfigurationLoaded = true; if (num <= 32) { for (int i = 0; i < num; i++) { string configName = reader.ReadString(); int count = reader.ReadInt32(); byte[] byteArray = reader.ReadBytes(count); count = reader.ReadInt32(); byte[] byteArray2 = reader.ReadBytes(count); this.AddUserConfigurationCachedEntry(StoreObjectId.Parse(byteArray, 0), configName, StoreObjectId.Parse(byteArray2, 0), true); } return; } ExTraceGlobals.UserConfigurationTracer.TraceError <int>((long)this.GetHashCode(), "UserConfigurationCache::Load. The retreived cache count is too big, persisted data is corrupted. Count = {0}.", num); }
protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag) { StoreSession session = propertyBag.Context.Session; if (session == null) { ExTraceGlobals.StorageTracer.TraceDebug((long)propertyBag.GetHashCode(), "ReminderDueByProperty: StoreObject is not present and the property bag is not a QueryResultsPropertyBag. First should be present when accessing a property on an object, and the second one - when called from a view. All other cases are wrong."); return(propertyBag.GetValue(InternalSchema.ReminderDueByInternal)); } PropertyError result = new PropertyError(InternalSchema.ReminderDueBy, PropertyErrorCode.GetCalculatedPropertyError); CalendarItem calendarItem = propertyBag.Context.StoreObject as CalendarItem; InternalRecurrence internalRecurrence = null; if (calendarItem != null) { try { internalRecurrence = (InternalRecurrence)calendarItem.Recurrence; goto IL_206; } catch (RecurrenceFormatException ex) { ExTraceGlobals.StorageTracer.TraceDebug <string, StoreObjectId>((long)session.GetHashCode(), "Unable to parse recurrence info. Using the stored value for DueBy.\r\n\tError: {0}\r\n\tID:{1}", ex.Message, (calendarItem.Id != null) ? calendarItem.Id.ObjectId : null); return(result); } catch (CorruptDataException ex2) { ExTraceGlobals.StorageTracer.TraceDebug <string, StoreObjectId>((long)session.GetHashCode(), "Unable to parse the organizer timezone. Using the stored value for DueBy.\r\n\tError: {0}\r\n\tID:{1}", ex2.Message, (calendarItem.Id != null) ? calendarItem.Id.ObjectId : null); return(result); } } byte[] entryId; if (Util.TryConvertTo <byte[]>(propertyBag.GetValue(InternalSchema.EntryId), out entryId)) { VersionedId versionedId = new VersionedId(StoreObjectId.FromProviderSpecificId(entryId), Array <byte> .Empty); byte[] array = propertyBag.GetValue(InternalSchema.AppointmentRecurrenceBlob) as byte[]; if (array != null) { string valueOrDefault = propertyBag.GetValueOrDefault <string>(InternalSchema.TimeZone, string.Empty); byte[] valueOrDefault2 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneBlob); byte[] valueOrDefault3 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneDefinitionRecurring); ExTimeZone timeZoneFromProperties = TimeZoneHelper.GetTimeZoneFromProperties(valueOrDefault, valueOrDefault2, valueOrDefault3); if (timeZoneFromProperties == null) { ExTraceGlobals.StorageTracer.TraceDebug <string, StoreObjectId>((long)session.GetHashCode(), "Unable to parse the organizer timezone. Using the stored value for DueBy.\r\n\tError: {0}\r\n\tID:{1}", "organizerTimeZone is null", versionedId.ObjectId); return(result); } try { internalRecurrence = InternalRecurrence.GetRecurrence(versionedId, session, array, timeZoneFromProperties, CalendarItem.DefaultCodePage); } catch (RecurrenceFormatException ex3) { ExTraceGlobals.StorageTracer.TraceDebug <string, StoreObjectId>((long)session.GetHashCode(), "Unable to parse recurrence info. Using the stored value for DueBy.\r\n\tError: {0}\r\n\tID:{1}", ex3.Message, versionedId.ObjectId); return(result); } catch (CorruptDataException ex4) { ExTraceGlobals.StorageTracer.TraceDebug <string, StoreObjectId>((long)session.GetHashCode(), "Unable to parse the organizer timezone. Using the stored value for DueBy.\r\n\tError: {0}\r\n\tID:{1}", ex4.Message, versionedId.ObjectId); return(result); } } } IL_206: bool defaultIsSet; int defaultMinutesBeforeStart; ExDateTime value; if (internalRecurrence == null || !Util.TryConvertTo <bool>(propertyBag.GetValue(InternalSchema.ReminderIsSetInternal), out defaultIsSet) || !Util.TryConvertTo <int>(propertyBag.GetValue(InternalSchema.ReminderMinutesBeforeStartInternal), out defaultMinutesBeforeStart) || !Util.TryConvertTo <ExDateTime>(propertyBag.GetValue(InternalSchema.ReminderNextTime), out value)) { return(propertyBag.GetValue(InternalSchema.ReminderDueByInternal)); } ExDateTime probeTime = Reminder.GetProbeTime(Reminder.GetTimeNow(session.ExTimeZone), new ExDateTime?(value)); OccurrenceInfo mostRecentOccurrence; try { mostRecentOccurrence = CalendarItem.CustomReminder.GetMostRecentOccurrence(internalRecurrence, probeTime, defaultIsSet, defaultMinutesBeforeStart); } catch (CorruptDataException) { return(result); } if (mostRecentOccurrence == null) { return(new PropertyError(this, PropertyErrorCode.NotFound)); } return(mostRecentOccurrence.StartTime); }
protected override void CreateOrUpdateSharingBinding(PublishingSubscriptionData subscriptionData, string localFolderName, StoreObjectId folderId) { if (this.InternetCalendarBindingExists(folderId)) { return; } this.CreateInternetCalendarBinding(subscriptionData, folderId); }
protected override void CreateOrUpdateSharingBinding(SharingSubscriptionData sharingSubscriptionData, string localFolderName, StoreObjectId folderId) { SharingBindingData bindingData = SharingBindingData.CreateSharingBindingData(sharingSubscriptionData.DataType, sharingSubscriptionData.SharerName, sharingSubscriptionData.SharerIdentity, sharingSubscriptionData.RemoteFolderName, sharingSubscriptionData.RemoteFolderId, localFolderName, folderId, sharingSubscriptionData.IsPrimary); new SharingBindingManager(base.MailboxSession).CreateOrUpdateSharingBinding(bindingData); }
private void CreateInternetCalendarBinding(PublishingSubscriptionData subscriptionData, StoreObjectId folderId) { using (Item item = MessageItem.CreateAssociated(base.MailboxSession, folderId)) { item[BindingItemSchema.SharingProviderGuid] = PublishingFolderManager.InternetCalendarProviderGuid; item[StoreObjectSchema.ItemClass] = "IPM.Sharing.Binding.In"; item[BindingItemSchema.SharingLocalType] = subscriptionData.DataType.ContainerClass; item.Save(SaveMode.NoConflictResolution); ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, StoreObjectId>((long)this.GetHashCode(), "{0}: PublishingFolderManager.CreateInternetCalendarBinding saved binding message for folder id: {1}", base.MailboxSession.MailboxOwner, subscriptionData.LocalFolderId); } }
private static StoreObjectId EntryIdToStoreObjectId(byte[] entryId, StoreObjectType storeObjectType) { return(StoreObjectId.FromProviderSpecificId(entryId, storeObjectType)); }
public void SpoolerLockMessage(StoreObjectId messageId, SpoolerMessageLockState lockState) { EnumValidator.ThrowIfInvalid <SpoolerMessageLockState>(lockState, "lockState"); Util.ThrowOnNullArgument(messageId, "messageId"); MapiStore.MessageLockState messageLockState = MapiStore.MessageLockState.Lock; switch (lockState) { case SpoolerMessageLockState.Lock: messageLockState = MapiStore.MessageLockState.Lock; break; case SpoolerMessageLockState.Unlock: messageLockState = MapiStore.MessageLockState.Unlock; break; case SpoolerMessageLockState.Finished: messageLockState = MapiStore.MessageLockState.Finished; break; } StoreSession storeSession = this.session; bool flag = false; try { if (storeSession != null) { storeSession.BeginMapiCall(); storeSession.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } this.session.Mailbox.MapiStore.SpoolerSetMessageLockState(messageId.ProviderLevelItemId, messageLockState); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetMessageLockState, ex, storeSession, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiStore.SpoolerSetMessageLockState failed.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetMessageLockState, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiStore.SpoolerSetMessageLockState failed.", new object[0]), ex2 }); } finally { try { if (storeSession != null) { storeSession.EndMapiCall(); if (flag) { storeSession.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } }