internal OccurrenceInfo(VersionedId versionedId, ExDateTime occurrenceDateId, ExDateTime originalStartTime, ExDateTime startTime, ExDateTime endTime) { this.OriginalStartTime = originalStartTime; this.OccurrenceDateId = occurrenceDateId; this.VersionedId = versionedId; this.StartTime = startTime; this.EndTime = endTime; }
private IEnumerable <IStorePropertyBag> EnumerateCandidatesThatMatchDefaultNamingConvention() { string defaultFolderDisplayName; if (!OscProviderRegistry.TryGetDefaultFolderDisplayName(this.provider, out defaultFolderDisplayName)) { OscProviderCandidateFolderEnumerator.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "Candidate folder enumerator: provider {0} is unknown. Cannot enumerate candidates that match naming convention", this.provider); } else { TextFilter displayNameStartsWithProviderName = new TextFilter(FolderSchema.DisplayName, defaultFolderDisplayName, MatchOptions.Prefix, MatchFlags.IgnoreCase); OscProviderCandidateFolderEnumerator.Tracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "Candidate folder enumerator: the default folder display name for provider {0} is {1}", this.provider, defaultFolderDisplayName); using (IFolder rootFolder = this.xsoFactory.BindToFolder(this.session, this.session.GetDefaultFolderId(DefaultFolderType.Root))) { using (IQueryResult subFoldersQuery = rootFolder.IFolderQuery(FolderQueryFlags.None, null, OscProviderCandidateFolderEnumerator.SortByDisplayNameAscending, OscProviderCandidateFolderEnumerator.FolderPropertiesToLoad)) { if (!subFoldersQuery.SeekToCondition(SeekReference.OriginBeginning, displayNameStartsWithProviderName, SeekToConditionFlags.AllowExtendedFilters)) { OscProviderCandidateFolderEnumerator.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Candidate folder enumerator: SeekToCondition = false. No folder has display name matching {0}", defaultFolderDisplayName); yield break; } IStorePropertyBag[] folders = subFoldersQuery.GetPropertyBags(10); while (folders.Length > 0) { foreach (IStorePropertyBag folder in folders) { string displayName = folder.GetValueOrDefault <string>(FolderSchema.DisplayName, string.Empty); VersionedId folderId = folder.GetValueOrDefault <VersionedId>(FolderSchema.Id, null); if (folderId == null) { OscProviderCandidateFolderEnumerator.Tracer.TraceError <string>((long)this.GetHashCode(), "Candidate folder enumerator: skipping bogus folder '{0}' because it has a blank id.", displayName); } else { string containerClass = folder.GetValueOrDefault <string>(StoreObjectSchema.ContainerClass, string.Empty); if (string.IsNullOrEmpty(containerClass) || !ObjectClass.IsContactsFolder(containerClass)) { OscProviderCandidateFolderEnumerator.Tracer.TraceDebug <string, VersionedId>((long)this.GetHashCode(), "Candidate folder enumerator: skipping folder '{0}' (ID={1}) because it's not a contacts folder.", displayName, folderId); } else { if (string.IsNullOrEmpty(displayName) || !displayName.StartsWith(defaultFolderDisplayName, StringComparison.OrdinalIgnoreCase)) { OscProviderCandidateFolderEnumerator.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Candidate folder enumerator: we've iterated past candidates that follow the naming convention. Current folder is '{0}'", displayName); yield break; } OscProviderCandidateFolderEnumerator.Tracer.TraceDebug <string, VersionedId>((long)this.GetHashCode(), "Candidate folder enumerator: folder: {0}; id: {1}; is a good candidate.", displayName, folderId); yield return(folder); } } } folders = subFoldersQuery.GetPropertyBags(10); } } } } yield break; }
private void ClearCloudIdFromContact(VersionedId contact, string displayName) { using (IContact contact2 = this.xsoFactory.BindToContact(this.session, contact, null)) { contact2.Delete(ItemSchema.CloudId); contact2.Save(SaveMode.ResolveConflicts); OscFolderMigration.Tracer.TraceDebug <string, StoreObjectId>((long)this.GetHashCode(), "OSC folder migration: cleared cloud id of contact {0} (id={1})", displayName, contact.ObjectId); } }
public TaskGroupInfo(string groupName, VersionedId id, Guid groupClassId, TaskGroupType groupType, byte[] groupOrdinal, ExDateTime lastModifiedTime) : base(id, groupOrdinal, lastModifiedTime) { Util.ThrowOnNullArgument(groupName, "groupName"); EnumValidator.ThrowIfInvalid <TaskGroupType>(groupType, "groupType"); this.GroupName = groupName; this.GroupClassId = groupClassId; this.GroupType = groupType; this.TaskFolders = new List <TaskGroupEntryInfo>(); }
internal PublishingSubscriptionData(VersionedId id, string dataType, Uri publishingUrl, string remoteFolderName, StoreObjectId localFolderId) { this.Id = id; this.DataType = SharingDataType.FromPublishName(dataType); this.PublishingUrl = publishingUrl; this.RemoteFolderName = remoteFolderName; this.LocalFolderId = localFolderId; this.Key = new PublishingSubscriptionKey(this.PublishingUrl); }
private void AssignCloudIdToContact(VersionedId contact, string cloudId, string displayName) { using (IContact contact2 = this.xsoFactory.BindToContact(this.session, contact, null)) { contact2[ItemSchema.CloudId] = cloudId; contact2.Save(SaveMode.ResolveConflicts); OscFolderMigration.Tracer.TraceDebug <string, string, StoreObjectId>((long)this.GetHashCode(), "OSC folder migration: stamped cloud id '{0}' on contact {1} (id={2})", cloudId, displayName, contact.ObjectId); } }
internal static void UpdateOriginalItemProperties(Item sentItem) { object[] array = ReplyForwardUtils.DecodeReplyForwardStatus(sentItem.TryGetProperty(InternalSchema.ReplyForwardStatus) as string); if (array == null) { return; } if ((int)array[0] < 0) { return; } PropertyDefinition[] array2 = new PropertyDefinition[] { InternalSchema.LastVerbExecuted, InternalSchema.LastVerbExecutionTime, InternalSchema.IconIndex, InternalSchema.MessageAnswered }; object[] array3 = new object[array2.Length]; VersionedId storeId = VersionedId.Deserialize((string)array[2]); try { using (Item item = Item.Bind(sentItem.Session, storeId)) { if (!(item is CalendarItemBase)) { array3[0] = (int)array[0]; array3[1] = ExDateTime.GetNow(sentItem.Session.ExTimeZone); if (item is MeetingMessage) { array3[2] = item.GetValueOrDefault <int>(InternalSchema.IconIndex, -1); } else { array3[2] = (int)array[1]; } array3[3] = true; item.SetProperties(array2, array3); ConflictResolutionResult conflictResolutionResult = item.Save(SaveMode.ResolveConflicts); if (conflictResolutionResult.SaveStatus != SaveResult.Success) { ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "ReplyForwardCommon::UpdateOriginalItemProperties. {0}", "The original item has been changed thus update on the original item may not be done accurately."); } } } } catch (StoragePermanentException arg) { ExTraceGlobals.StorageTracer.TraceDebug <StoragePermanentException>(0L, "ReplyForwardCommon::UpdateOriginalItemProperties. The parent item cannot be found. It might have been deleted. Exception = {0}.", arg); } catch (StorageTransientException arg2) { ExTraceGlobals.StorageTracer.TraceDebug <StorageTransientException>(0L, "ReplyForwardCommon::UpdateOriginalItemProperties. The parent item cannot be found. It might have been deleted. Exception = {0}.", arg2); } }
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); }
public static IPushNotificationSubscriptionItem CreateOrUpdateSubscription(IMailboxSession session, IXSOFactory xsoFactory, IFolder folder, string subscriptionId, PushNotificationServerSubscription subscription) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(xsoFactory, "xsoFactory"); Util.ThrowOnNullArgument(folder, "folder"); Util.ThrowOnNullOrEmptyArgument(subscriptionId, "subscriptionId"); Util.ThrowOnNullArgument(subscription, "subscription"); ExTraceGlobals.StorageNotificationSubscriptionTracer.TraceDebug <string, IExchangePrincipal>((long)subscription.GetHashCode(), "PushNotificationSubscriptionItem.CreateOrUpdateSubscription: Searching for Subscription {0} on Mailbox {1}.", subscriptionId, session.MailboxOwner); IStorePropertyBag[] array = PushNotificationSubscriptionItem.GetSubscriptionById(folder, subscriptionId).ToArray <IStorePropertyBag>(); IPushNotificationSubscriptionItem pushNotificationSubscriptionItem = null; try { if (array.Length >= 1) { if (array.Length > 1) { ExTraceGlobals.StorageNotificationSubscriptionTracer.TraceWarning <string, Guid>(0L, "PushNotificationSubscriptionItem.CreateOrUpdateSubscription: AmbiguousSubscription for subscription {0} and user {1}", subscriptionId, session.MailboxGuid); } IStorePropertyBag storePropertyBag = array[0]; VersionedId valueOrDefault = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null); if (valueOrDefault == null) { ExTraceGlobals.StorageNotificationSubscriptionTracer.TraceError <string>((long)storePropertyBag.GetHashCode(), "PushNotificationSubscriptionItem.CreateOrUpdateSubscription: Cannot resolve the ItemSchema.Id property from the Enumerable.", subscriptionId); throw new CannotResolvePropertyException(ItemSchema.Id.Name); } ExTraceGlobals.StorageNotificationSubscriptionTracer.TraceDebug <VersionedId>((long)storePropertyBag.GetHashCode(), "PushNotificationSubscriptionItem.CreateOrUpdateSubscription: Found one existing subscription with ItemSchema.Id = {0}.", valueOrDefault); pushNotificationSubscriptionItem = xsoFactory.BindToPushNotificationSubscriptionItem(session, valueOrDefault, null); pushNotificationSubscriptionItem.LastUpdateTimeUTC = ExDateTime.UtcNow; subscription.LastSubscriptionUpdate = (DateTime)pushNotificationSubscriptionItem.LastUpdateTimeUTC; pushNotificationSubscriptionItem.SerializedNotificationSubscription = subscription.ToJson(); ConflictResolutionResult conflictResolutionResult = pushNotificationSubscriptionItem.Save(SaveMode.ResolveConflicts); if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict) { ExTraceGlobals.StorageNotificationSubscriptionTracer.TraceError <string>((long)storePropertyBag.GetHashCode(), "PushNotificationSubscriptionItem.CreateOrUpdateSubscription: Save failed due to conflicts for subscription {0}.", subscriptionId); throw new SaveConflictException(ServerStrings.ExSaveFailedBecauseOfConflicts(subscriptionId)); } pushNotificationSubscriptionItem.Load(SubscriptionItemEnumeratorBase.PushNotificationSubscriptionItemProperties); } else { ExTraceGlobals.StorageNotificationSubscriptionTracer.TraceDebug((long)subscription.GetHashCode(), "PushNotificationSubscriptionItem.CreateOrUpdateSubscription: Cannot resolve given subscription, about to create a new SubscriptionItem."); pushNotificationSubscriptionItem = PushNotificationSubscriptionItem.Create(session, xsoFactory, folder.StoreObjectId, subscriptionId, subscription); } } catch { if (pushNotificationSubscriptionItem != null) { pushNotificationSubscriptionItem.Dispose(); } throw; } return(pushNotificationSubscriptionItem); }
private VersionedId GetVersionedId(IStorePropertyBag propertyBag) { VersionedId valueOrDefault = propertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null); if (valueOrDefault != null) { return(valueOrDefault); } ExTraceGlobals.StorageNotificationSubscriptionTracer.TraceError((long)this.GetHashCode(), "PushNotificationStorage.GetPushNotificationSubscriptionIds: A subscription with an empty ItemSchema.Id value was returned by the Enumerator."); throw new CannotResolvePropertyException(ItemSchema.Id.Name); }
private static VersionedId FindAssociatedMessageId(MailboxSession session, Guid clsIdGuid) { byte[] array = clsIdGuid.ToByteArray(); VersionedId result; using (Folder folder = Folder.Bind(session, DefaultFolderType.CommonViews)) { using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.Associated, null, OutlookSearchFolder.SortByForAssociatedMessage, new PropertyDefinition[] { ItemSchema.Id, InternalSchema.AssociatedSearchFolderId, InternalSchema.ItemClass })) { QueryFilter seekFilter = new ComparisonFilter(ComparisonOperator.Equal, InternalSchema.AssociatedSearchFolderId, array); if (!queryResult.SeekToCondition(SeekReference.OriginBeginning, seekFilter)) { result = null; } else { seekFilter = new ComparisonFilter(ComparisonOperator.Equal, InternalSchema.ItemClass, "IPM.Microsoft.WunderBar.SFInfo"); if (!queryResult.SeekToCondition(SeekReference.OriginCurrent, seekFilter)) { result = null; } else { object[][] rows = queryResult.GetRows(2); if (rows.Length >= 1 && ArrayComparer <byte> .Comparer.Equals(array, rows[0][1] as byte[])) { VersionedId versionedId = Microsoft.Exchange.Data.Storage.PropertyBag.CheckPropertyValue <VersionedId>(ItemSchema.Id, rows[0][0]); if (rows.Length > 1) { string value = rows[1][2] as string; if (!string.IsNullOrEmpty(value) && ArrayComparer <byte> .Comparer.Equals(array, rows[1][1] as byte[]) && "IPM.Microsoft.WunderBar.SFInfo".Equals(value, StringComparison.OrdinalIgnoreCase)) { ExTraceGlobals.StorageTracer.Information(0L, "OutlookSearchFolder::FindAssociatedMessageId. Found more than one associated message for the search folder. Only the first associated message will be used."); } } result = versionedId; } else { result = null; } } } } } return(result); }
internal SharingBindingData(VersionedId itemId, SharingDataType dataType, string initiatorName, string initiatorSmtpAddress, string remoteFolderName, string remoteFolderId, string localFolderName, StoreObjectId localFolderId, bool isDefaultFolderShared, DateTime?lastSyncTimeUtc) { this.Id = itemId; this.DataType = dataType; this.InitiatorName = initiatorName; this.InitiatorSmtpAddress = initiatorSmtpAddress; this.RemoteFolderName = remoteFolderName; this.RemoteFolderId = remoteFolderId; this.LocalFolderName = localFolderName; this.LocalFolderId = localFolderId; this.IsDefaultFolderShared = isDefaultFolderShared; this.LastSyncTimeUtc = lastSyncTimeUtc; }
internal static void SplitStoreObjectIdAndChangeKey(StoreId id, out StoreObjectId storeObjectId, out byte[] changeKey) { VersionedId versionedId = id as VersionedId; if (versionedId != null) { changeKey = versionedId.ChangeKeyAsByteArray(); storeObjectId = versionedId.ObjectId; return; } changeKey = null; storeObjectId = (StoreObjectId)id; }
private void RetrieveSnapshots() { this.itemSnapshots = new List <object[]>(this.folder.InternalGetCalendarView(this.importWindowStart, this.importWindowEnd, false, false, true, RecurrenceExpansionOption.IncludeMaster, InternetCalendarSchema.ImportQuery)); this.itemsToDelete = new List <StoreId>(this.itemSnapshots.Count); foreach (object[] array in this.itemSnapshots) { VersionedId versionedId = (VersionedId)array[this.QueryIndexId]; if (!(versionedId.ObjectId is OccurrenceStoreObjectId)) { this.itemsToDelete.Add(versionedId.ObjectId); } } }
internal static VersionedId GetAssociatedId(MessageItem message) { string valueOrDefault = message.GetValueOrDefault <string>(InternalSchema.ReplyForwardStatus, string.Empty); object[] array = ReplyForwardUtils.DecodeReplyForwardStatus(valueOrDefault); VersionedId result = null; if (array != null && array.Length == 3 && array[2] is string) { result = VersionedId.Deserialize(Convert.FromBase64String((string)array[2])); } return(result); }
public static StoreObjectId GetStoreObjectId(StoreId id) { if (id == null) { return(null); } VersionedId versionedId = id as VersionedId; if (versionedId != null) { return(versionedId.ObjectId); } return(id as StoreObjectId); }
public static string GetValueString(object value) { if (value == null) { return(null); } string text = value as string; if (text != null) { return(ContactLinkingStrings.GetValueString(text)); } byte[] array = value as byte[]; if (array != null) { return(ContactLinkingStrings.GetValueString(array)); } Guid?nullableGuid = value as Guid?; if (nullableGuid != null) { return(ContactLinkingStrings.GetValueString(nullableGuid)); } VersionedId versionedId = value as VersionedId; if (versionedId != null) { return(ContactLinkingStrings.GetValueString(versionedId)); } IEnumerable enumerable = value as IEnumerable; if (enumerable != null) { return(ContactLinkingStrings.GetValueString(enumerable)); } ExDateTime?nullableExDateTime = value as ExDateTime?; if (nullableExDateTime != null) { return(ContactLinkingStrings.GetValueString(nullableExDateTime)); } DateTime?nullableDateTime = value as DateTime?; if (nullableDateTime != null) { return(ContactLinkingStrings.GetValueString(nullableDateTime)); } return(value.ToString()); }
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 void UpdateItemSnapshots(GlobalObjectId goid, VersionedId newItemId, Item promotedItem) { object[] array = this.FindItemSnapshotByGoid(goid, false); bool flag = array == null; if (flag) { array = new object[InternetCalendarSchema.ImportQuery.Length]; this.itemSnapshots.Add(array); } for (int i = 0; i < InternetCalendarSchema.ImportQuery.Length; i++) { array[i] = promotedItem.TryGetProperty(InternetCalendarSchema.ImportQuery[i]); } array[this.QueryIndexId] = newItemId; }
private void UpdateAssociatedSearchFolderLastUsedTime() { VersionedId versionedId = OutlookSearchFolder.FindAssociatedMessageId((MailboxSession)base.Session, (Guid)this[InternalSchema.OutlookSearchFolderClsId]); if (versionedId != null) { using (MessageItem messageItem = MessageItem.Bind(base.Session, versionedId)) { int num = OutlookSearchFolder.ConvertUtcDateTimeToRTime(ExDateTime.UtcNow); messageItem[MessageItemSchema.AssociatedSearchFolderLastUsedTime] = num; messageItem.Save(SaveMode.NoConflictResolution); return; } } ExTraceGlobals.StorageTracer.Information <string>((long)this.GetHashCode(), "OutlookSearchFolder::UpdateAssociatedSearchFolderLastUsedTime. Failed to update the last used time of the search folder in its associated message. Associated message not found. SearchFolder DisplayName = {0}.", base.DisplayName); }
internal SharingSubscriptionData(VersionedId id, string dataType, string sharerIdentity, string sharerName, string remoteFolderId, string remoteFolderName, bool isPrimary, Uri sharerIdentityFederationUri, Uri sharingUrl, StoreObjectId localFolderId, string sharingKey, string subscriberIdentity) { this.Id = id; this.DataType = SharingDataType.FromExternalName(dataType); this.SharerIdentity = sharerIdentity; this.SharerName = sharerName; this.RemoteFolderId = remoteFolderId; this.RemoteFolderName = remoteFolderName; this.IsPrimary = isPrimary; this.SharerIdentityFederationUri = sharerIdentityFederationUri; this.SharingUrl = sharingUrl; this.LocalFolderId = localFolderId; this.SharingKey = sharingKey; this.SubscriberIdentity = subscriberIdentity; this.Key = new SharingSubscriptionKey(this.SharerIdentity, this.RemoteFolderId); }
public PersonId Unlink(MailboxSession session, PersonId personId, VersionedId contactId) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(personId, "personId"); Util.ThrowOnNullArgument(contactId, "contactId"); base.PerformanceTracker.Start(); PersonId result; try { IList <ContactInfoForLinking> list = this.QueryPersonContacts(session, personId); if (list == null || list.Count == 0) { throw new ObjectNotFoundException(ServerStrings.ExItemNotFound); } base.LogEvent(new SchemaBasedLogEvent <ContactLinkingLogSchema.ContactUnlinking> { { ContactLinkingLogSchema.ContactUnlinking.ItemId, contactId.ObjectId }, { ContactLinkingLogSchema.ContactUnlinking.PersonId, personId } }); ContactInfoForLinking matchingContactByItemId = ManualLink.GetMatchingContactByItemId(list, contactId); if (matchingContactByItemId != null) { this.UnlinkContact(matchingContactByItemId, list); base.Commit(list); result = matchingContactByItemId.PersonId; } else { ContactLink.Tracer.TraceDebug <VersionedId, PersonId>((long)this.GetHashCode(), "ManualLink.Unlink: contact {0} not found in person set: {1}", contactId, personId); result = null; } } finally { base.PerformanceTracker.Stop(); base.LogEvent(base.PerformanceTracker.GetLogEvent()); } return(result); }
private void RemoveStaleItem(IStoreSession session, IStorePropertyBag staleItem) { VersionedId valueOrDefault = staleItem.GetValueOrDefault <VersionedId>(ItemSchema.Id, null); ExDateTime valueOrDefault2 = staleItem.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue); this.Tracer.TraceDebug <VersionedId, ExDateTime>((long)this.GetHashCode(), "SingleInstanceItemHandler<T>:RemoveStaleItem - Removing stale metadata item with ID={0} and ModifiedTime={1}", valueOrDefault, valueOrDefault2); try { session.Delete(DeleteItemFlags.HardDelete, new StoreId[] { valueOrDefault }); } catch (ObjectNotFoundException arg) { this.Tracer.TraceWarning <VersionedId, ObjectNotFoundException>((long)this.GetHashCode(), "SingleInstanceItemHandler<T>:RemoveStaleItem - Failed to remove stale metadata item with ID {0} as object was not found. Exception: {1}", valueOrDefault, arg); } }
private void SendCancellationBasedOnFoundIntent(VersionedId cancelledVersionId) { using (CalendarItemBase calendarItemBase = CalendarItemBase.Bind(base.Session, cancelledVersionId)) { IList <Attendee> rumAttendees = this.GetRumAttendees(calendarItemBase); CancellationRumInfo info; if (this.GlobalObjectId.IsCleanGlobalObjectId) { info = CancellationRumInfo.CreateMasterInstance(rumAttendees); } else { info = CancellationRumInfo.CreateOccurrenceInstance(this.GlobalObjectId.Date, rumAttendees); } Dictionary <GlobalObjectId, List <Attendee> > dictionary = new Dictionary <GlobalObjectId, List <Attendee> >(1); RumAgent.Instance.SendRums(info, false, calendarItemBase, ref dictionary); } }
private static TaskGroupInfo GetTaskGroupInfoFromRow(IStorePropertyBag row) { VersionedId id = (VersionedId)row.TryGetProperty(ItemSchema.Id); byte[] valueOrDefault = row.GetValueOrDefault <byte[]>(TaskGroupSchema.GroupClassId, null); string valueOrDefault2 = row.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty); byte[] valueOrDefault3 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.Ordinal, null); ExDateTime valueOrDefault4 = row.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue); Guid safeGuidFromByteArray = FolderTreeData.GetSafeGuidFromByteArray(valueOrDefault); if (safeGuidFromByteArray.Equals(Guid.Empty)) { ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found task group with invalid group class id. ArrayLength: {0}", (valueOrDefault == null) ? -1 : valueOrDefault.Length); return(null); } return(new TaskGroupInfo(valueOrDefault2, id, safeGuidFromByteArray, TaskGroup.GetGroupTypeFromGuid(safeGuidFromByteArray), valueOrDefault3, valueOrDefault4)); }
protected override PublishingSubscriptionData CreateDataObjectFromItem(object[] properties) { VersionedId versionedId = SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <VersionedId>(properties, 1); if (versionedId == null) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal>((long)this.GetHashCode(), "{0}: subscription is missing ID", base.MailboxSession.MailboxOwner); return(null); } string text = SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <string>(properties, 4); if (string.IsNullOrEmpty(text)) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingDataType", base.MailboxSession.MailboxOwner, versionedId); return(null); } string text2 = SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <string>(properties, 5); if (string.IsNullOrEmpty(text2)) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingUrl", base.MailboxSession.MailboxOwner, versionedId); return(null); } if (!Uri.IsWellFormedUriString(text2, UriKind.Absolute)) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, string>((long)this.GetHashCode(), "{0}: subscription {1} has invalid ExternalSharingUrl: {2}", base.MailboxSession.MailboxOwner, versionedId, text2); return(null); } string text3 = SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <string>(properties, 6); if (string.IsNullOrEmpty(text3)) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingRemoteFolderName", base.MailboxSession.MailboxOwner, versionedId); return(null); } byte[] array = SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <byte[]>(properties, 2); if (array == null || array.Length == 0) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingLocalFolderId", base.MailboxSession.MailboxOwner, versionedId); return(null); } return(new PublishingSubscriptionData(versionedId, text, new Uri(text2), text3, StoreObjectId.Deserialize(array))); }
private void ResolveConflictAfterCreation(TKey subscriptionKey, VersionedId subscriptionId) { object[] array = this.FindFirstByKey(subscriptionKey); VersionedId versionedId = (VersionedId)array[1]; if (!subscriptionId.ObjectId.Equals(versionedId.ObjectId)) { ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: A race condition occurred. This subscription is about to be deleted due to duplication: {0}", this.mailboxSession.MailboxOwner, subscriptionId); AggregateOperationResult aggregateOperationResult = this.mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[] { subscriptionId }); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, AggregateOperationResult>((long)this.GetHashCode(), "{0}: Failed to delete this subscription {1}: {2}", this.mailboxSession.MailboxOwner, subscriptionId, aggregateOperationResult); } throw new SharingConflictException(); } }
public IEnumerator <IStorePropertyBag> GetEnumerator() { ContactFoldersEnumeratorOptions foldersEnumeratorOptions = ContactFoldersEnumeratorOptions.SkipHiddenFolders | ContactFoldersEnumeratorOptions.SkipDeletedFolders | ContactFoldersEnumeratorOptions.IncludeParentFolder; ContactFoldersEnumerator foldersEnumerator = new ContactFoldersEnumerator(this.session, new XSOFactory(), this.folderType, foldersEnumeratorOptions, new PropertyDefinition[0]); foreach (IStorePropertyBag folderPropertyBag in foldersEnumerator) { VersionedId folderId = folderPropertyBag.GetValueOrDefault <VersionedId>(FolderSchema.Id, null); IFolder folder; try { folder = this.xsoFactory.BindToFolder(this.session, folderId.ObjectId); } catch (ObjectNotFoundException) { RecursiveContactsEnumerator.Tracer.TraceError <VersionedId, Guid>((long)this.GetHashCode(), "Failed to bind to folder. FolderId: {0}. Mailbox: {1}.", folderId, this.session.MailboxOwner.MailboxInfo.MailboxGuid); continue; } try { using (IQueryResult contactsQuery = folder.IItemQuery(ItemQueryType.None, null, null, this.properties)) { IStorePropertyBag[] contacts = contactsQuery.GetPropertyBags(100); while (contacts.Length > 0) { foreach (IStorePropertyBag contactPropertyBag in contacts) { if (contactPropertyBag != null && !(contactPropertyBag.TryGetProperty(ItemSchema.Id) is PropertyError) && ObjectClass.IsContact(contactPropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, null))) { yield return(contactPropertyBag); } } contacts = contactsQuery.GetPropertyBags(100); } } } finally { folder.Dispose(); } } yield break; }
private void CreateOrHijackAssociatedMessage(VersionedId associatedMessageId, SearchFolderCriteria criteria) { MailboxSession mailboxSession = (MailboxSession)base.Session; MessageItem messageItem = null; try { if (associatedMessageId == null) { messageItem = MessageItem.CreateAssociated(base.Session, mailboxSession.SafeGetDefaultFolderId(DefaultFolderType.CommonViews)); } else { messageItem = MessageItem.Bind(base.Session, associatedMessageId); } messageItem[InternalSchema.ItemClass] = "IPM.Microsoft.WunderBar.SFInfo"; messageItem[InternalSchema.AssociatedSearchFolderId] = ((Guid)this[InternalSchema.OutlookSearchFolderClsId]).ToByteArray(); messageItem[InternalSchema.DisplayName] = this[FolderSchema.DisplayName]; messageItem[ItemSchema.Subject] = this[FolderSchema.DisplayName]; ExtendedFolderFlags?valueAsNullable = base.GetValueAsNullable <ExtendedFolderFlags>(FolderSchema.ExtendedFolderFlags); if (valueAsNullable != null) { messageItem[InternalSchema.AssociatedSearchFolderFlags] = valueAsNullable.Value; } int num = OutlookSearchFolder.ConvertUtcDateTimeToRTime(ExDateTime.UtcNow); messageItem[InternalSchema.AssociatedSearchFolderLastUsedTime] = num; messageItem[InternalSchema.AssociatedSearchFolderExpiration] = num; messageItem[InternalSchema.AssociatedSearchFolderTemplateId] = 1; messageItem[InternalSchema.AssociatedSearchFolderTag] = 0; this.WriteOutlookSearchFolderDefinitionBlob(messageItem, criteria); messageItem[InternalSchema.AssociatedSearchFolderStorageType] = 72; messageItem.Save(SaveMode.FailOnAnyConflict); } finally { if (messageItem != null) { messageItem.Dispose(); messageItem = null; } } }
public void Delete(MailboxSession itemStore) { List <object[]> results = this.QueryItems(itemStore); VersionedId mostRecentItem = this.GetMostRecentItem(results); if (mostRecentItem != null) { try { itemStore.Delete(DeleteItemFlags.HardDelete, new StoreId[] { mostRecentItem }); } catch (ObjectNotFoundException) { SingleInstanceItemHandler.Tracer.TraceError <SingleInstanceItemHandler, VersionedId, IExchangePrincipal>((long)this.GetHashCode(), "{0}: ObjectNotFoundException encountred while trying to delete object, itemId='{1}' on mailbox {2}", this, mostRecentItem, itemStore.MailboxOwner); } } }