private StoreId GetMessageStoreId(string internetId, IMailboxSession session) { if (string.IsNullOrEmpty(internetId)) { return(null); } IStorePropertyBag[] array = AllItemsFolderHelper.FindItemsFromInternetId((MailboxSession)session, internetId, new StorePropertyDefinition[] { CoreItemSchema.Id }); if (array == null || array.Length == 0) { return(null); } IStorePropertyBag storePropertyBag = array[0]; if (storePropertyBag == null) { return(null); } VersionedId valueOrDefault = storePropertyBag.GetValueOrDefault <VersionedId>(CoreItemSchema.Id, null); if (valueOrDefault == null) { return(null); } return(valueOrDefault.ObjectId); }
// Token: 0x060003CF RID: 975 RVA: 0x0001B13C File Offset: 0x0001933C private void CollectItemsMarkedForExpiration(MailboxSession session) { base.Assistant.ThrowIfShuttingDown(base.MailboxDataForTags.MailboxSession.MailboxOwner); ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer>((long)this.GetHashCode(), "{0}: About to collect items for expiration.", this); PropertyIndexHolder propertyIndexHolder = new PropertyIndexHolder(ExpirationTagEnforcer.ItemDataColumns); AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(session, AllItemsFolderHelper.SupportedSortBy.RetentionDate, delegate(QueryResult queryResults) { ComparisonFilter seekFilter = new ComparisonFilter(ComparisonOperator.LessThanOrEqual, ItemSchema.RetentionDate, this.MailboxDataForTags.UtcNow.Date); if (queryResults.SeekToCondition(SeekReference.OriginBeginning, seekFilter)) { bool flag = false; while (!flag) { object[][] rows = queryResults.GetRows(100); ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer, int>((long)this.GetHashCode(), "{0}: GetRows returned {1} items.", this, rows.Length); if (rows.Length <= 0) { break; } foreach (object[] array2 in rows) { if (array2[propertyIndexHolder.RetentionDateIndex] == null || array2[propertyIndexHolder.RetentionDateIndex] is PropertyError) { flag = true; break; } this.EnlistItem(array2, propertyIndexHolder.PolicyTagIndex, propertyIndexHolder.RetentionDateIndex, propertyIndexHolder); } this.Assistant.ThrottleStoreCallAndCheckForShutdown(this.MailboxDataForTags.MailboxSession.MailboxOwner); } } return(true); }, ExpirationTagEnforcer.ItemDataColumns); }
private static StoreObjectId FindInitiationMessage(MailboxSession session, string initiationMessageId, string approvalRequestMessageId, out long messageSearchElapsedMilliseconds) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); IStorePropertyBag[] array = AllItemsFolderHelper.FindItemsFromInternetId(session, initiationMessageId, NdrOofHandler.PropertiesNeededFromInitiationForFinding); StoreObjectId result = null; if (array != null) { NdrOofHandler.diag.TraceDebug <int, string>(0L, "Found {0} initiation messages for this NDR/OOF. Init messageId={1}.", array.Length, initiationMessageId); for (int i = 0; i < array.Length; i++) { string text = array[i].TryGetProperty(MessageItemSchema.ApprovalRequestMessageId) as string; string value; string text2; if (!string.IsNullOrEmpty(text) && FindMessageUtils.TryParseMessageId(text, out value, out text2)) { approvalRequestMessageId.StartsWith(value, StringComparison.Ordinal); result = ((VersionedId)array[i][ItemSchema.Id]).ObjectId; break; } } } stopwatch.Stop(); messageSearchElapsedMilliseconds = stopwatch.ElapsedMilliseconds; return(result); }
// Token: 0x06000FA8 RID: 4008 RVA: 0x0005C9C0 File Offset: 0x0005ABC0 internal List <ItemScanner> GetItemsToScan() { List <ItemScanner> itemList = new List <ItemScanner>(10); AllItemsFolderHelper.CheckAndCreateDefaultFolders(this.mailboxSession); AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(this.mailboxSession, AllItemsFolderHelper.SupportedSortBy.ReceivedTime, delegate(QueryResult queryResults) { for (;;) { object[][] rows = queryResults.GetRows(500); ItemSampler.Tracer.TraceDebug <ItemSampler, int>((long)this.GetHashCode(), "{0}: GetRows returned {1} items.", this, rows.Length); if (rows.Length <= 0) { return(true); } foreach (object[] array2 in rows) { VersionedId versionedId = array2[0] as VersionedId; if (versionedId != null) { itemList.Add(new ItemScanner(this.mailboxSession, versionedId.ObjectId)); if (itemList.Count >= 2000) { goto Block_2; } } } } Block_2: return(true); }, ItemSampler.dataColumns); return(itemList); }
public void LoadMailboxMessage(string internetMessageId) { MailboxSession session = (MailboxSession)this.storeSession; try { this.context.BeginTrackLatency(LatencyComponent.StoreDriverDeliveryRpc); IEnumerable <IStorePropertyBag> source = AllItemsFolderHelper.FindItemsFromInternetId(session, internetMessageId, ItemQueryType.NoNotifications, new PropertyDefinition[] { ItemSchema.Id }); if (source.Count <IStorePropertyBag>() != 1) { throw new UnexpectedMessageCountException(string.Format("The number of messages found was unexpected. Count: {0}", source.Count <IStorePropertyBag>())); } IStorePropertyBag storePropertyBag = source.First <IStorePropertyBag>(); StoreObjectId objectId = ((VersionedId)storePropertyBag[ItemSchema.Id]).ObjectId; this.messageItem = MessageItem.Bind(session, objectId); if (this.messageItem == null) { throw new System.Data.ObjectNotFoundException("The requested message was not loaded."); } this.messageItem.OpenAsReadWrite(); } catch (Microsoft.Exchange.Data.Storage.ObjectNotFoundException innerException) { throw new System.Data.ObjectNotFoundException("The requested message was not loaded.", innerException); } finally { TimeSpan additionalLatency = this.context.EndTrackLatency(LatencyComponent.StoreDriverDeliveryRpc); this.context.AddRpcLatency(additionalLatency, "Load message"); } }
public static LinkedItemProps FindItemBySharePointId(MailboxSession session, Guid sharePointId, PerformanceCounter performanceCounter) { if (performanceCounter != null) { performanceCounter.Start(OperationType.FileLookupById); } object[] array = AllItemsFolderHelper.FindItemBySharePointId(session, sharePointId); if (array != null) { return(new LinkedItemProps((StoreObjectId)array[0], (StoreObjectId)array[1], (Uri)array[2])); } if (performanceCounter != null) { performanceCounter.Stop(OperationType.FileLookupById, 1); } return(null); }
// Token: 0x060003D0 RID: 976 RVA: 0x0001B360 File Offset: 0x00019560 private void CollectItemsMarkedForMove(MailboxSession session) { base.Assistant.ThrowIfShuttingDown(base.MailboxDataForTags.MailboxSession.MailboxOwner); ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer>((long)this.GetHashCode(), "{0}: About to collect items marked for move via archive tag.", this); PropertyIndexHolder propertyIndexHolder = new PropertyIndexHolder(ExpirationTagEnforcer.ItemDataColumns); AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(session, AllItemsFolderHelper.SupportedSortBy.ArchiveDate, delegate(QueryResult queryResults) { ComparisonFilter seekFilter = new ComparisonFilter(ComparisonOperator.LessThanOrEqual, ItemSchema.ArchiveDate, this.MailboxDataForTags.UtcNow.Date); if (queryResults.SeekToCondition(SeekReference.OriginBeginning, seekFilter)) { bool flag = false; while (!flag) { object[][] rows = queryResults.GetRows(100); ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer, int>((long)this.GetHashCode(), "{0}: GetRows returned {1} items.", this, rows.Length); if (rows.Length <= 0) { break; } foreach (object[] array2 in rows) { if (array2[propertyIndexHolder.ArchiveDateIndex] == null || array2[propertyIndexHolder.ArchiveDateIndex] is PropertyError) { flag = true; break; } if (array2[propertyIndexHolder.RetentionDateIndex] != null && array2[propertyIndexHolder.RetentionDateIndex] is ExDateTime && ((ExDateTime)array2[propertyIndexHolder.RetentionDateIndex]).UniversalTime < this.MailboxDataForTags.UtcNow.Date) { ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer>((long)this.GetHashCode(), "{0}: Both retention date and archive date of the item have passed. Then the retention date wins. Skip adding the item to MTA list", this); } else { this.EnlistItem(array2, propertyIndexHolder.ArchiveTagIndex, propertyIndexHolder.ArchiveDateIndex, propertyIndexHolder); } } this.Assistant.ThrottleStoreCallAndCheckForShutdown(this.MailboxDataForTags.MailboxSession.MailboxOwner); } } return(true); }, ExpirationTagEnforcer.ItemDataColumns); }
public override IEnumerable <ComplianceItem> GetNextPage() { if (this.reachedEnd) { return(null); } List <ComplianceItem> items = new List <ComplianceItem>(); AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(this.mailboxContainer.Session, AllItemsFolderHelper.SupportedSortBy.ReceivedTime, delegate(QueryResult queryResults) { queryResults.SeekToOffset(SeekReference.OriginBeginning, this.currentPage++ *this.PageSize); object[][] rows = queryResults.GetRows(this.PageSize); if (rows.Length != this.PageSize) { this.reachedEnd = true; } for (int i = 0; i < rows.Length; i++) { items.Add(new ExMailComplianceItem(this.mailboxContainer.Session, rows[i])); } return(true); }, ExMailComplianceItem.MailDataColumns); return(items); }
private static bool SearchByTopic(IXSOFactory xsoFactory, IMailboxSession session, ICorePropertyBag persistPropertyBag, ConversationIndexTrackingEx indexTrackingEx, out IStorePropertyBag foundPropertyBag, out bool didConversationIdMatch, out bool didReferencesMatch, params PropertyDefinition[] propsToReturn) { foundPropertyBag = null; didConversationIdMatch = false; didReferencesMatch = false; Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(persistPropertyBag, "persistPropertyBag"); Util.ThrowOnNullArgument(propsToReturn, "propsToReturn"); ICollection <PropertyDefinition> properties = InternalSchema.Combine <PropertyDefinition>(propsToReturn, new PropertyDefinition[] { ItemSchema.ConversationTopicHash }); string incomingConversationTopic = persistPropertyBag.GetValueOrDefault <string>(ItemSchema.ConversationTopic); ConversationIndex conversationIndex; bool isValidIncomingIndex = ConversationIndex.TryCreate(persistPropertyBag.TryGetProperty(ItemSchema.ConversationIndex) as byte[], out conversationIndex); ConversationId incomingConversationId = isValidIncomingIndex ? ConversationId.Create(conversationIndex.Guid) : null; if (incomingConversationTopic == null) { return(false); } bool didConversationIdMatchLocal = false; bool didReferencesMatchLocal = false; int incomingConversationTopicHash = (int)AllItemsFolderHelper.GetHashValue(incomingConversationTopic); Stopwatch stopwatch = Stopwatch.StartNew(); IStorePropertyBag storePropertyBag = xsoFactory.RunQueryOnAllItemsFolder <IStorePropertyBag>(session, AllItemsFolderHelper.SupportedSortBy.ConversationTopicHash, incomingConversationTopicHash, null, delegate(QueryResult queryResult) { bool flag = queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.ConversationTopicHash, incomingConversationTopicHash)); if (flag) { IStorePropertyBag storePropertyBag2 = null; for (int i = 0; i < 5; i++) { IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(1); if (propertyBags.Length != 1) { break; } int?num = propertyBags[0].TryGetProperty(ItemSchema.ConversationTopicHash) as int?; if (num == null || num.Value != incomingConversationTopicHash) { break; } string foundTopic = propertyBags[0].TryGetProperty(ItemSchema.ConversationTopic) as string; if (ConversationIndex.CompareTopics(incomingConversationTopic, foundTopic)) { if (storePropertyBag2 == null) { storePropertyBag2 = propertyBags[0]; } ConversationIndex conversationIndex2; bool flag2 = ConversationIndex.TryCreate(propertyBags[0].TryGetProperty(ItemSchema.ConversationIndex) as byte[], out conversationIndex2); if (flag2) { if (isValidIncomingIndex) { ConversationId conversationId = ConversationId.Create(conversationIndex2.Guid); if (conversationId.Equals(incomingConversationId)) { didConversationIdMatchLocal = true; return(propertyBags[0]); } } else if (AggregationByItemClassReferencesSubjectProcessor.MatchMessageIdWithReferences(persistPropertyBag, propertyBags[0])) { didReferencesMatchLocal = true; return(propertyBags[0]); } } } if (!queryResult.SeekToCondition(SeekReference.OriginCurrent, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.ConversationTopicHash, incomingConversationTopicHash))) { break; } } if (storePropertyBag2 != null) { return(storePropertyBag2); } } return(null); }, properties); stopwatch.Stop(); if (indexTrackingEx != null) { indexTrackingEx.Trace("SBT", stopwatch.ElapsedMilliseconds.ToString()); } if (storePropertyBag != null) { foundPropertyBag = storePropertyBag; didConversationIdMatch = didConversationIdMatchLocal; didReferencesMatch = didReferencesMatchLocal; return(true); } return(false); }
private static bool SearchByReferences(IXSOFactory xsoFactory, IMailboxSession session, ICorePropertyBag persistPropertyBag, ConversationIndexTrackingEx indexTrackingEx, bool searchByDupedMessage, out IStorePropertyBag foundPropertyBag, params PropertyDefinition[] propsToReturn) { foundPropertyBag = null; Util.ThrowOnNullArgument(propsToReturn, "propsToReturn"); Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(persistPropertyBag, "persistPropertyBag"); List <string> internetIds = new List <string>(); if (searchByDupedMessage) { string valueOrDefault = persistPropertyBag.GetValueOrDefault <string>(ItemSchema.InternetMessageId, string.Empty); if (!string.IsNullOrEmpty(valueOrDefault)) { internetIds.Add(valueOrDefault); } } string valueOrDefault2 = persistPropertyBag.GetValueOrDefault <string>(ItemSchema.InReplyTo, string.Empty); if (!string.IsNullOrEmpty(valueOrDefault2)) { internetIds.Add(valueOrDefault2); } string valueOrDefault3 = persistPropertyBag.GetValueOrDefault <string>(ItemSchema.InternetReferences, string.Empty); if (!string.IsNullOrEmpty(valueOrDefault3)) { string[] array = valueOrDefault3.Split(AggregationByItemClassReferencesSubjectProcessor.ReferencesSeparators, StringSplitOptions.RemoveEmptyEntries); if (array != null && array.Length > 0) { int num = array.Length - 1; for (int i = num; i >= 0; i--) { if (!string.IsNullOrEmpty(array[i]) && !internetIds.Contains(array[i])) { internetIds.Add(array[i]); if (internetIds.Count >= 50) { break; } } } } } if (internetIds.Count > 0) { ICollection <PropertyDefinition> properties = InternalSchema.Combine <PropertyDefinition>(propsToReturn, new PropertyDefinition[] { ItemSchema.InternetMessageIdHash }); Stopwatch stopwatch = Stopwatch.StartNew(); IStorePropertyBag storePropertyBag = xsoFactory.RunQueryOnAllItemsFolder <IStorePropertyBag>(session, AllItemsFolderHelper.SupportedSortBy.InternetMessageIdHash, delegate(QueryResult queryResult) { using (List <string> .Enumerator enumerator = internetIds.GetEnumerator()) { IL_A6: while (enumerator.MoveNext()) { string text = enumerator.Current; int hashValue = (int)AllItemsFolderHelper.GetHashValue(text); if (queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.InternetMessageIdHash, hashValue))) { IStorePropertyBag[] propertyBags; string text2; do { propertyBags = queryResult.GetPropertyBags(1); if (propertyBags == null || propertyBags.Length != 1) { goto IL_A6; } int?num2 = propertyBags[0].TryGetProperty(ItemSchema.InternetMessageIdHash) as int?; if (num2 == null || num2.Value != hashValue) { goto IL_A6; } text2 = (propertyBags[0].TryGetProperty(ItemSchema.InternetMessageId) as string); }while (string.IsNullOrEmpty(text2) || !string.Equals(text, text2, StringComparison.OrdinalIgnoreCase)); return(propertyBags[0]); } } } return(null); }, properties); stopwatch.Stop(); if (indexTrackingEx != null) { indexTrackingEx.Trace("SBMID", stopwatch.ElapsedMilliseconds.ToString()); } if (storePropertyBag != null) { foundPropertyBag = storePropertyBag; return(true); } } return(false); }
public void Aggregate(ICorePropertyBag item, bool shouldSearchForDuplicatedMessage, out IStorePropertyBag parentItem, out ConversationIndex newIndex, out ConversationIndex.FixupStage stage) { newIndex = ConversationIndex.Empty; stage = ConversationIndex.FixupStage.Unknown; string valueOrDefault = item.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty); parentItem = null; if (!string.IsNullOrEmpty(valueOrDefault)) { if (ObjectClass.IsMeetingMessage(valueOrDefault)) { if (AggregationByItemClassReferencesSubjectProcessor.FixupMeetingMessage(this.xsoFactory, this.session, new AggregationByItemClassReferencesSubjectProcessor.PropertyDefinitionListConstructorDelegate(this.GetSearchPropertyDefinitions), item, ref newIndex, ref stage, out parentItem)) { return; } } else if (ObjectClass.IsSmsMessage(valueOrDefault)) { AggregationBySmsItemClassProcessor aggregationBySmsItemClassProcessor = new AggregationBySmsItemClassProcessor(this.xsoFactory, this.session, this.indexTrackingEx); aggregationBySmsItemClassProcessor.Aggregate(item, out newIndex, out stage); return; } } ConversationIndex conversationIndex; bool flag = ConversationIndex.TryCreate(item.TryGetProperty(ItemSchema.ConversationIndex) as byte[], out conversationIndex); if (this.indexTrackingEx != null) { if (flag) { this.indexTrackingEx.Trace(conversationIndex); } else { this.indexTrackingEx.Trace("II", "<invalid>"); } } if (AggregationByItemClassReferencesSubjectProcessor.SearchByReferences(this.xsoFactory, this.session, item, this.indexTrackingEx, shouldSearchForDuplicatedMessage, out parentItem, this.GetSearchPropertyDefinitions(null))) { bool flag2 = false; if (shouldSearchForDuplicatedMessage) { string a = item.TryGetProperty(ItemSchema.InternetMessageId) as string; string text = parentItem.TryGetProperty(ItemSchema.InternetMessageId) as string; flag2 = (!string.IsNullOrEmpty(text) && string.Equals(a, text, StringComparison.OrdinalIgnoreCase)); } if (flag2) { this.CalculateBasedOnMessageWithSameInternetMessageId(item, parentItem, out stage, out newIndex); } else { this.CalculateBasedOnReferenceMessage(item, parentItem, out stage, out newIndex); } } string text2 = item.TryGetProperty(ItemSchema.NormalizedSubject) as string; if (stage == ConversationIndex.FixupStage.Unknown) { if (string.IsNullOrEmpty(item.GetValueOrDefault <string>(ItemSchema.SubjectPrefix)) && flag) { if (conversationIndex.Components.Count > 1) { byte[] incomingConversationIdBytes = ConversationId.Create(conversationIndex.Guid).GetBytes(); int conversationIdHash = (int)AllItemsFolderHelper.GetHashValue(incomingConversationIdBytes); Stopwatch stopwatch = Stopwatch.StartNew(); parentItem = this.xsoFactory.RunQueryOnAllItemsFolder <IStorePropertyBag>(this.session, AllItemsFolderHelper.SupportedSortBy.ConversationIdHash, conversationIdHash, null, delegate(QueryResult queryResult) { IStorePropertyBag[] propertyBags; byte[] array; do { propertyBags = queryResult.GetPropertyBags(1); if (propertyBags == null || propertyBags.Length != 1) { goto IL_69; } int?num = propertyBags[0].TryGetProperty(ItemSchema.ConversationIdHash) as int?; if (num == null || num.Value != conversationIdHash) { goto IL_69; } array = (propertyBags[0].TryGetProperty(InternalSchema.MapiConversationId) as byte[]); }while (array == null || !Util.CompareByteArray(incomingConversationIdBytes, array)); return(propertyBags[0]); IL_69: return(null); }, this.GetSearchPropertyDefinitions(new StorePropertyDefinition[] { InternalSchema.MapiConversationId, ItemSchema.ConversationIdHash })); stopwatch.Stop(); if (this.indexTrackingEx != null) { this.indexTrackingEx.Trace("SBCID", stopwatch.ElapsedMilliseconds.ToString()); } if (parentItem != null && !ConversationIndex.CompareTopics(parentItem.TryGetProperty(ItemSchema.ConversationTopic) as string, text2)) { newIndex = ConversationIndex.CreateNew(); stage = ConversationIndex.FixupStage.H11; if (this.indexTrackingEx != null) { string text3 = parentItem.TryGetProperty(ItemSchema.InternetMessageId) as string; if (text3 != null) { this.indexTrackingEx.Trace("S3", text3); } } } } if (stage == ConversationIndex.FixupStage.Unknown) { newIndex = conversationIndex; bool flag3 = parentItem != null; if (flag3) { bool?flag4 = parentItem.TryGetProperty(ItemSchema.ConversationIndexTracking) as bool?; stage = ((flag4 == null || !flag4.Value) ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H14); } else { stage = ConversationIndex.FixupStage.H4; } } } else { if (string.IsNullOrEmpty(item.GetValueOrDefault <string>(ItemSchema.InReplyTo, string.Empty)) && string.IsNullOrEmpty(item.GetValueOrDefault <string>(ItemSchema.InternetReferences, string.Empty)) && string.IsNullOrEmpty(item.GetValueOrDefault <string>(ItemSchema.SubjectPrefix)) && !flag) { TopicHashCache topicHashCache = TopicHashCache.Load(this.xsoFactory, this.session, 50); if (string.IsNullOrEmpty(text2) || !topicHashCache.Contains(AllItemsFolderHelper.GetHashValue(text2))) { newIndex = ConversationIndex.CreateNew(); stage = ConversationIndex.FixupStage.H12; } } bool flag5; bool flag6; if (stage == ConversationIndex.FixupStage.Unknown && AggregationByItemClassReferencesSubjectProcessor.SearchByTopic(this.xsoFactory, this.session, item, this.indexTrackingEx, out parentItem, out flag5, out flag6, this.GetSearchPropertyDefinitions(new StorePropertyDefinition[] { ItemSchema.ReceivedTime, ItemSchema.InReplyTo, ItemSchema.InternetReferences }))) { if (this.indexTrackingEx != null) { string text4 = parentItem.TryGetProperty(ItemSchema.InternetMessageId) as string; if (text4 != null) { this.indexTrackingEx.Trace("S2", text4); } } bool?flag7 = parentItem.TryGetProperty(ItemSchema.ConversationIndexTracking) as bool?; bool flag8 = flag7 == null || !flag7.Value; if (flag5) { newIndex = conversationIndex; stage = (flag8 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H5); } else { ConversationIndex conversationIndex2; bool flag9 = ConversationIndex.TryCreate(parentItem.TryGetProperty(ItemSchema.ConversationIndex) as byte[], out conversationIndex2); if (flag6) { ExDateTime?valueAsNullable = item.GetValueAsNullable <ExDateTime>(ItemSchema.SentTime); newIndex = ((valueAsNullable != null) ? ConversationIndex.Create(conversationIndex2.Guid, valueAsNullable.Value) : ConversationIndex.Create(conversationIndex2.Guid)); stage = (flag8 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H6); } else { object obj = parentItem.TryGetProperty(ItemSchema.ReceivedTime); string valueOrDefault2 = item.GetValueOrDefault <string>(ItemSchema.SubjectPrefix); if (obj != null && obj is ExDateTime) { ExDateTime dt = (ExDateTime)obj; TimeSpan timeSpan = ExDateTime.Now - dt; if (timeSpan.TotalHours >= -72.0 && timeSpan.TotalHours <= 72.0 && flag9) { if (flag) { newIndex = conversationIndex.UpdateGuid(conversationIndex2.Guid); stage = (flag8 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H9); } else if (!string.IsNullOrEmpty(valueOrDefault2)) { ExDateTime?valueAsNullable2 = item.GetValueAsNullable <ExDateTime>(ItemSchema.SentTime); if (valueAsNullable2 != null) { newIndex = ConversationIndex.Create(conversationIndex2.Guid, valueAsNullable2.Value); } else { newIndex = ConversationIndex.Create(conversationIndex2.Guid); } stage = (flag8 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H6); } } } } } } } } if (stage == ConversationIndex.FixupStage.Unknown) { if (!string.IsNullOrEmpty(item.GetValueOrDefault <string>(ItemSchema.SubjectPrefix))) { TopicHashCache topicHashCache2 = TopicHashCache.Load(this.xsoFactory, this.session, 50); uint hashValue = AllItemsFolderHelper.GetHashValue(text2); topicHashCache2.Add(hashValue); TopicHashCache.Save(topicHashCache2, this.xsoFactory, this.session); if (this.indexTrackingEx != null) { this.indexTrackingEx.Trace("THA", hashValue.ToString()); } } if (flag) { newIndex = conversationIndex; stage = ConversationIndex.FixupStage.H7; return; } newIndex = ConversationIndex.CreateNew(); stage = ConversationIndex.FixupStage.H8; } }
// Token: 0x0600010A RID: 266 RVA: 0x0000677A File Offset: 0x0000497A public void ProcessBodyTag() { ExWatson.SendReportOnUnhandledException(delegate() { List <IStorePropertyBag> propertyBagList = new List <IStorePropertyBag>(100); ExDateTime toProcessDate = ExDateTime.UtcNow.Subtract(TimeSpan.FromDays(15.0)); int indexTrackingCounter = 0; bool trackingCheckRequired = true; string text = null; string text2 = null; string text3 = null; bool flag = false; try { using (MailboxSession session = MailboxSession.OpenAsAdmin(this.principal, CultureInfo.InvariantCulture, "Client=TBA;Action=Conversation Assistant")) { text = session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(); AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(session, AllItemsFolderHelper.SupportedSortBy.ReceivedTime, delegate(QueryResult queryResults) { bool flag2 = false; int num = 0; while (!flag2) { IStorePropertyBag[] propertyBags = queryResults.GetPropertyBags(50); if (propertyBags.Length <= 0) { break; } foreach (IStorePropertyBag storePropertyBag2 in propertyBags) { num++; if (num >= 10000) { BodyTagProcessor.Tracer.TraceDebug <string>(0L, "Skip querying as we have reached our maximum limit of emails we want to process for {0}", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()); flag2 = true; break; } string text5 = storePropertyBag2.TryGetProperty(StoreObjectSchema.ItemClass) as string; if (!string.IsNullOrEmpty(text5) && ObjectClass.IsMessage(text5, false)) { if (!(BodyTagProcessor.GetProperty <ExDateTime>(storePropertyBag2, ItemSchema.ReceivedTime, ExDateTime.MinValue) >= toProcessDate)) { flag2 = true; break; } if (trackingCheckRequired && !(storePropertyBag2.TryGetProperty(ItemSchema.ConversationIndexTracking) is PropertyError)) { indexTrackingCounter++; if (indexTrackingCounter >= 10) { BodyTagProcessor.Tracer.TraceDebug <string>(0L, "Not processing BodyTag for mailbox {0}", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()); flag2 = true; break; } } if (storePropertyBag2.TryGetProperty(ItemSchema.BodyTag) is PropertyError || storePropertyBag2.TryGetProperty(ItemSchema.BodyTag) == null) { propertyBagList.Add(storePropertyBag2); } } } trackingCheckRequired = false; } return(true); }, new PropertyDefinition[] { ItemSchema.Id, StoreObjectSchema.ItemClass, ItemSchema.ReceivedTime, ItemSchema.BodyTag, ItemSchema.ConversationIndexTracking }); if (propertyBagList.Count == 0 || indexTrackingCounter >= 10) { string text4 = (propertyBagList.Count == 0) ? " 0 messages to process" : " IndexTrackingCounter reached its limit"; Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_BodyTagProcessingSkipped, null, new object[] { text, text4 }); return; } Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_TotalNumberOfItemsForBodyTagProcessing, null, new object[] { propertyBagList.Count, text }); foreach (IStorePropertyBag storePropertyBag in propertyBagList) { try { using (MessageItem messageItem = MessageItem.Bind(session, storePropertyBag[ItemSchema.Id] as StoreId)) { if (!(messageItem is RightsManagedMessageItem)) { messageItem.OpenAsReadWrite(); messageItem[ItemSchema.BodyTag] = messageItem.Body.CalculateBodyTag(); messageItem.Save(SaveMode.ResolveConflicts); } } } catch (ObjectNotFoundException) { BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "ObjectNotFound exception thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text); } catch (AccessDeniedException) { BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "AccessDenied exception thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text); } catch (CorruptDataException) { BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "Corrupt data exception thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text); } catch (VirusException) { BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "Virus exception thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text); } catch (PropertyErrorException) { BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "PropertyErrorException thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text); } catch (StoragePermanentException ex) { if (!(ex.InnerException is MapiExceptionCallFailed)) { throw; } BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "MapiExceptionCallFailed thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text); } } } Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_BodyTagProcessingSucceeded, null, new object[] { text }); } catch (ObjectNotFoundException ex2) { flag = true; text2 = ex2.Message; text3 = ex2.StackTrace; } catch (CorruptDataException ex3) { flag = true; text2 = ex3.Message; text3 = ex3.StackTrace; } catch (QuotaExceededException ex4) { flag = true; text2 = ex4.Message; text3 = ex4.StackTrace; } catch (MessageSubmissionExceededException ex5) { flag = true; text2 = ex5.Message; text3 = ex5.StackTrace; } catch (ConnectionFailedPermanentException ex6) { flag = true; text2 = ex6.Message; text3 = ex6.StackTrace; } catch (MailboxUnavailableException ex7) { flag = true; text2 = ex7.Message; text3 = ex7.StackTrace; } catch (StorageTransientException ex8) { flag = true; text2 = ex8.Message; text3 = ex8.StackTrace; } catch (StoragePermanentException ex9) { if (!(ex9.InnerException is MapiExceptionJetErrorLogDiskFull)) { throw; } flag = true; text2 = ex9.Message; text3 = ex9.StackTrace; } finally { if (flag) { Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_BodyTagProcessingFailed, null, new object[] { text, text2 ?? "<null>", text3 ?? "<null>" }); } } }, delegate(object exception) { Exception ex = exception as Exception; if (ex != null) { Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_BodyTagProcessingFailed, null, new object[] { this.principal.MailboxInfo.PrimarySmtpAddress.ToString(), ex.Message ?? "<null>", ex.StackTrace ?? "<null>" }); } return(true); }, ReportOptions.None); }
// Token: 0x060003CC RID: 972 RVA: 0x0001AE68 File Offset: 0x00019068 private void CollectMigratedItemsMarkedForHoldExpiration() { base.Assistant.ThrowIfShuttingDown(base.MailboxDataForTags.MailboxSession.MailboxOwner); ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer>((long)this.GetHashCode(), "{0}: About to collect items for expiration.", this); AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(base.MailboxDataForTags.MailboxSession, AllItemsFolderHelper.SupportedSortBy.EhaMigrationExpiryDate, new AllItemsFolderHelper.DoQueryProcessing <bool>(this.MigratedMessageQueryProcessor), ExpirationTagEnforcer.ItemDataColumnsWithHoldExpirationDate); }
internal static bool CheckDuplicateInitiationAndUpdateIdIfNecessary(MessageItem message) { message.Load(InitiationProcessor.PropertiesForUniquenessCheck); string internetMessageId = message.InternetMessageId; string text; if (!InitiationProcessor.TryGetIdentiferFromInitiationMessageId(internetMessageId, out text)) { return(false); } InitiationProcessor.diag.TraceDebug <string, string>(0L, "Find dup for init message messageid='{0}' identifier='{1}'.", internetMessageId, text); string text2 = message.TryGetProperty(MessageItemSchema.ApprovalRequestor) as string; string text3 = message.TryGetProperty(MessageItemSchema.ApprovalApplicationData) as string; MailboxSession session = (MailboxSession)message.Session; IStorePropertyBag[] array; try { array = AllItemsFolderHelper.FindItemsFromInternetId(session, text, InitiationProcessor.PropertiesForUniquenessCheck); } catch (ObjectNotFoundException arg) { InitiationProcessor.diag.TraceError <ObjectNotFoundException>(0L, "Exception - {0}", arg); return(false); } bool flag = false; bool flag2 = false; if (array != null && array.Length > 0) { InitiationProcessor.diag.TraceDebug <int, string>(0L, "Found {0} initiation messages with the message id. messageId={1}.", array.Length, text); for (int i = 0; i < array.Length; i++) { flag = true; string text4 = array[i].TryGetProperty(MessageItemSchema.ApprovalRequestor) as string; string text5 = array[i].TryGetProperty(MessageItemSchema.ApprovalApplicationData) as string; if (string.Equals(text4, text2, StringComparison.OrdinalIgnoreCase) && string.Equals(text5, text3, StringComparison.OrdinalIgnoreCase)) { flag2 = true; break; } InitiationProcessor.diag.TraceDebug(0L, "Matching message-id={0} unmatched data requestor={1} data={2} found: requestor={3} data={4}.", new object[] { text, text2, text3, text4, text5 }); } } InitiationProcessor.diag.TraceDebug <string, bool, bool>(0L, "'{0}' found={1}, duplicateInitiation = {2}", text, flag, flag2); if (!flag2) { if (flag) { message.InternetMessageId = Guid.NewGuid().ToString().Substring(0, 5) + "_" + internetMessageId; InitiationProcessor.diag.TraceDebug <string, string>(0L, "Rewriting from message id from {0} to {1}", internetMessageId, message.InternetMessageId); } else if (!flag) { message.InternetMessageId = text; } } return(flag2); }
private static ApprovalRequestUpdater.Result FindAndUpdateExistingApprovalRequest(MessageItem updateMessage, int decision, string decisionMaker, ExDateTime decisionTime, string messageId) { bool updated = false; string local; string domain; if (!FindMessageUtils.TryParseMessageId(messageId, out local, out domain)) { return(ApprovalRequestUpdater.Result.InvalidUpdateMessage); } ApprovalRequestUpdater.diag.TraceDebug <string>(0L, "Update approval request: messageid={0}", messageId); MessageStatus messageStatus = StorageExceptionHandler.RunUnderExceptionHandler(ApprovalRequestUpdater.MessageConverterInstance, delegate { MailboxSession mailboxSession = (MailboxSession)updateMessage.Session; StoreObjectId storeObjectId = null; for (int i = 0; i < 25; i++) { string internetMessageId = ApprovalRequestWriter.FormatApprovalRequestMessageId(local, i, domain, false); IStorePropertyBag[] array = AllItemsFolderHelper.FindItemsFromInternetId(mailboxSession, internetMessageId, new PropertyDefinition[] { ItemSchema.Id }); if (array != null && array.Length > 0) { ApprovalRequestUpdater.diag.TraceDebug <int>(0L, "Found {0} to update, picking the first.", array.Length); storeObjectId = ((VersionedId)array[0][ItemSchema.Id]).ObjectId; break; } } if (storeObjectId != null) { using (MessageItem messageItem = MessageItem.Bind(mailboxSession, storeObjectId)) { if (ApprovalRequestUpdater.VerifyAndUpdateApprovalRequest(mailboxSession, updateMessage.Sender, decision, decisionMaker, decisionTime, messageItem)) { ConflictResolutionResult conflictResolutionResult = messageItem.Save(SaveMode.ResolveConflicts); if (conflictResolutionResult.SaveStatus != SaveResult.Success) { ApprovalRequestUpdater.diag.TraceDebug <string, SaveResult>(0L, "Saving message: {0}, resulted in an update conflict ({1}). Ignored", messageId, conflictResolutionResult.SaveStatus); } AggregateOperationResult aggregateOperationResult = mailboxSession.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[] { storeObjectId }); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { ApprovalRequestUpdater.diag.TraceDebug <string, OperationResult>(0L, "Delete message: {0}, resulted in failure {1} Ignored", messageId, aggregateOperationResult.OperationResult); } updated = true; } } } }); if (!updated) { ApprovalRequestUpdater.diag.TraceDebug <string>(0L, "Couldn't find message: {0}, ignored", messageId); return(ApprovalRequestUpdater.Result.NotFound); } if (MessageStatus.Success != messageStatus) { ApprovalRequestUpdater.diag.TraceDebug <string, string>(0L, "Message ({0}) processing was not successful ({1}), ignoring..", messageId, (messageStatus.Exception == null) ? "NULL exception" : messageStatus.Exception.Message); return(ApprovalRequestUpdater.Result.SaveConflict); } return(ApprovalRequestUpdater.Result.UpdatedSucessfully); }