// Token: 0x06000114 RID: 276 RVA: 0x00006EAC File Offset: 0x000050AC
        private static void HandleSmsMessage(MailboxSession session, Item item, MailboxData mailboxData, ConversationIndexTrackingEx indexTrackingEx)
        {
            MessageItem messageItem = item as MessageItem;

            if (messageItem == null)
            {
                SentItemsProcessor.Tracer.TraceDebug(0L, "{0}: the SMS message is not MessageItem", new object[]
                {
                    TraceContext.Get()
                });
                return;
            }
            RecipientCollection recipients = messageItem.Recipients;

            if (recipients.Count == 0)
            {
                return;
            }
            using (SmsRecipientInfoCache smsRecipientInfoCache = SmsRecipientInfoCache.Create(session, SentItemsProcessor.Tracer))
            {
                Dictionary <ConversationIndex, Recipient> dictionary = new Dictionary <ConversationIndex, Recipient>(recipients.Count);
                for (int i = recipients.Count - 1; i >= 0; i--)
                {
                    Recipient   recipient   = recipients[i];
                    Participant participant = recipient.Participant;
                    if (!(participant == null) && !string.IsNullOrEmpty(participant.EmailAddress))
                    {
                        string text = null;
                        if (string.Equals(participant.RoutingType, "MOBILE", StringComparison.OrdinalIgnoreCase))
                        {
                            text = participant.EmailAddress;
                            smsRecipientInfoCache.AddRecipient(participant);
                        }
                        else if (string.Equals(participant.RoutingType, "SMTP", StringComparison.OrdinalIgnoreCase))
                        {
                            ProxyAddress proxyAddress;
                            if (SmtpProxyAddress.TryDeencapsulate(participant.EmailAddress, out proxyAddress) && string.Equals(proxyAddress.PrefixString, "MOBILE", StringComparison.OrdinalIgnoreCase))
                            {
                                text = proxyAddress.AddressString;
                            }
                            smsRecipientInfoCache.AddRecipient(new Participant(participant.DisplayName, text, "MOBILE"));
                        }
                        if (text != null)
                        {
                            ConversationIndex conversationIndex = ConversationIndex.GenerateFromPhoneNumber(text);
                            if (!(conversationIndex == ConversationIndex.Empty))
                            {
                                recipients.RemoveAt(i);
                                if (!dictionary.ContainsKey(conversationIndex))
                                {
                                    dictionary.Add(conversationIndex, recipient);
                                }
                            }
                        }
                    }
                }
                if (recipients.Count > 0)
                {
                    messageItem.Save(SaveMode.ResolveConflicts);
                    messageItem.Load();
                }
                int num = 0;
                foreach (KeyValuePair <ConversationIndex, Recipient> keyValuePair in dictionary)
                {
                    num++;
                    AggregationBySmsItemClassProcessor.ChunkSmsConversation(XSOFactory.Default, session, keyValuePair.Key, indexTrackingEx);
                    if (num < dictionary.Count || recipients.Count > 0)
                    {
                        SentItemsProcessor.CloneSmsItem(session, messageItem, mailboxData, keyValuePair.Value, keyValuePair.Key);
                    }
                    else
                    {
                        recipients.Add(keyValuePair.Value);
                        SentItemsProcessor.SaveSmsItem(messageItem, keyValuePair.Key);
                        messageItem.Load();
                    }
                }
                smsRecipientInfoCache.Commit();
            }
        }
        // Token: 0x06000113 RID: 275 RVA: 0x00006C64 File Offset: 0x00004E64
        internal static void HandleEventInternal(MapiEvent mapiEvent, MailboxSession session, StoreObject storeItem, MailboxData mailboxData)
        {
            SentItemsProcessor.Tracer.TraceDebug(0L, "{0}: Calling SentItemsProcessor.HandleEventInternal", new object[]
            {
                TraceContext.Get()
            });
            Item item = (Item)storeItem;

            if (item == null)
            {
                SentItemsProcessor.Tracer.TraceError(0L, "{0}: HandleEventInternal received null item", new object[]
                {
                    TraceContext.Get()
                });
                return;
            }
            if (ObjectClass.IsSmsMessage(item.ClassName))
            {
                try
                {
                    ConversationIndexTrackingEx conversationIndexTrackingEx = ConversationIndexTrackingEx.Create();
                    SentItemsProcessor.HandleSmsMessage(session, item, mailboxData, conversationIndexTrackingEx);
                    SentItemsProcessor.Tracer.TraceDebug <object, ConversationIndexTrackingEx>(0L, "{0}: ChunkSmsConversation traces: {1}", TraceContext.Get(), conversationIndexTrackingEx);
                }
                catch (ObjectNotFoundException)
                {
                    SentItemsProcessor.Tracer.TraceDebug(0L, "{0}: ObjectNotFoundException thrown while processing SMS item in Sent Items folder", new object[]
                    {
                        TraceContext.Get()
                    });
                }
                return;
            }
            try
            {
                ConversationId valueOrDefault = item.GetValueOrDefault <ConversationId>(ItemSchema.ConversationId);
                if (valueOrDefault == null)
                {
                    SentItemsProcessor.Tracer.TraceError(0L, "{0}: Found item without conversation id", new object[]
                    {
                        TraceContext.Get()
                    });
                }
                else
                {
                    int             totalActionItemCount;
                    IList <StoreId> list    = ConversationActionItem.QueryConversationActionsFolder(session, valueOrDefault, 1, out totalActionItemCount);
                    StoreId         storeId = (list != null) ? list[0] : null;
                    mailboxData.UpdateConversationActionsEnabledStatus(totalActionItemCount);
                    if (storeId == null)
                    {
                        SentItemsProcessor.Tracer.TraceDebug <object, ConversationId>(0L, "{0}: No action item associated found for message with conversation Id = {1}", TraceContext.Get(), valueOrDefault);
                    }
                    else
                    {
                        using (ConversationActionItem conversationActionItem = ConversationActionItem.Bind(session, storeId))
                        {
                            if (conversationActionItem.IsCorrectVersion())
                            {
                                if (conversationActionItem.AlwaysCategorizeValue != null)
                                {
                                    List <string> categoriesForItem = conversationActionItem.GetCategoriesForItem(item.TryGetProperty(ItemSchema.Categories) as string[]);
                                    if (categoriesForItem != null)
                                    {
                                        SentItemsProcessor.Tracer.TraceDebug(0L, "{0}: Processed categories on item", new object[]
                                        {
                                            TraceContext.Get()
                                        });
                                        item.SafeSetProperty(ItemSchema.Categories, categoriesForItem.ToArray());
                                        item.Save(SaveMode.ResolveConflicts);
                                        item.Load();
                                    }
                                }
                                conversationActionItem.Save(SaveMode.ResolveConflicts);
                            }
                        }
                    }
                }
            }
            catch (ObjectNotFoundException)
            {
                SentItemsProcessor.Tracer.TraceDebug(0L, "{0}: ObjectNotFoundException thrown while processing action item", new object[]
                {
                    TraceContext.Get()
                });
            }
        }
예제 #3
0
        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);
        }
        public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args)
        {
            ConversationsProcessingAgent.tracer.TraceDebug(0L, "Called ConversationsProcessingAgent.OnPromotedMessageHandler");
            if (args == null)
            {
                return;
            }
            StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args;

            if (ConversationsProcessingAgent.ShouldSkipMessageProcessing(storeDriverDeliveryEventArgsImpl))
            {
                return;
            }
            if (storeDriverDeliveryEventArgsImpl.MailboxOwner == null)
            {
                return;
            }
            MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession;

            if (mailboxSession.MailboxOwner.MailboxInfo.Location.ServerVersion <= 1937801369)
            {
                if (ConversationsProcessingAgent.tracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    ConversationsProcessingAgent.tracer.TraceDebug <string, string>((long)this.GetHashCode(), "Backend server version (0x{0}) is less than minimum required (0x{1})", mailboxSession.MailboxOwner.MailboxInfo.Location.ServerVersion.ToString("X"), 1937801369.ToString("X"));
                }
                return;
            }
            ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Processing incoming message");
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                if (storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies == null)
                {
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies = new Dictionary <PropertyDefinition, object>();
                }
                ConversationIndexTrackingEx conversationIndexTrackingEx = ConversationIndexTrackingEx.Create();
                this.performanceContext = ConversationsProcessingAgent.conversationLatencyDetectionContextFactory.CreateContext("15.00.1497.012", "FIXUP", new IPerformanceDataProvider[0]);
                if (!this.isBodyTagCalculated)
                {
                    ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Calculating body tag");
                    Stopwatch stopwatch2 = Stopwatch.StartNew();
                    if (storeDriverDeliveryEventArgsImpl.ReplayItem.IsRestricted)
                    {
                        if (!this.TryCalculateIrmBodyTag(storeDriverDeliveryEventArgsImpl))
                        {
                            this.bodyTag = null;
                        }
                    }
                    else if (PropertyError.IsPropertyNotFound(storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.BodyTag)))
                    {
                        this.bodyTag = storeDriverDeliveryEventArgsImpl.ReplayItem.Body.CalculateBodyTag(out this.latestMessageWordCount);
                    }
                    else
                    {
                        this.bodyTag = storeDriverDeliveryEventArgsImpl.ReplayItem.GetValueOrDefault <byte[]>(ItemSchema.BodyTag);
                        this.latestMessageWordCount = storeDriverDeliveryEventArgsImpl.ReplayItem.GetValueOrDefault <int>(MessageItemSchema.LatestMessageWordCount, int.MinValue);
                    }
                    stopwatch2.Stop();
                    conversationIndexTrackingEx.Trace("BT", stopwatch2.ElapsedMilliseconds.ToString());
                    this.isBodyTagCalculated = true;
                }
                if (this.bodyTag != null)
                {
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.BodyTag] = this.bodyTag;
                    if (this.latestMessageWordCount >= 0)
                    {
                        storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.LatestMessageWordCount] = this.latestMessageWordCount;
                        storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(MessageItemSchema.LatestMessageWordCount, this.latestMessageWordCount);
                    }
                }
                if (this.forceAllAttachmentsHidden)
                {
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.AllAttachmentsHidden] = true;
                }
                if (!ConversationIndex.CompareTopics(storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.ConversationTopic) as string, storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.NormalizedSubject) as string))
                {
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationTopic] = ((storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.NormalizedSubject) as string) ?? string.Empty);
                }
                if (!storeDriverDeliveryEventArgsImpl.MessageClass.Equals("IPM.WorkingSet.Signal", StringComparison.InvariantCulture))
                {
                    ConversationAggregationResult conversationAggregationResult = new ConversationAggregationResult();
                    ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Fixing up the conversation id");
                    try
                    {
                        IConversationAggregator conversationAggregator;
                        if (ConversationAggregatorFactory.TryInstantiateAggregatorForDelivery(mailboxSession, storeDriverDeliveryEventArgsImpl.MailboxOwner, conversationIndexTrackingEx, out conversationAggregator))
                        {
                            conversationAggregationResult = conversationAggregator.Aggregate(storeDriverDeliveryEventArgsImpl.ReplayItem.CoreItem);
                        }
                        else
                        {
                            ConversationsProcessingAgent.tracer.TraceError((long)this.GetHashCode(), "Not able to identify a valid conversationAggregator");
                            conversationAggregationResult.ConversationIndex = ConversationIndex.CreateNew();
                            conversationAggregationResult.Stage             = ConversationIndex.FixupStage.Error;
                        }
                    }
                    catch (ObjectNotFoundException arg)
                    {
                        ConversationsProcessingAgent.tracer.TraceError <ObjectNotFoundException>((long)this.GetHashCode(), "Exception - {0}", arg);
                        conversationAggregationResult.ConversationIndex = ConversationIndex.CreateNew();
                        conversationAggregationResult.Stage             = ConversationIndex.FixupStage.Error;
                    }
                    this.performanceContext.StopAndFinalizeCollection();
                    conversationIndexTrackingEx.Trace("FIXUP", this.performanceContext.Elapsed.TotalMilliseconds.ToString());
                    ConversationsProcessingAgent.tracer.TraceDebug <int>((long)this.GetHashCode(), "FixupStage = {0}", (int)conversationAggregationResult.Stage);
                    ConversationId conversationId = ConversationId.Create(conversationAggregationResult.ConversationIndex);
                    ConversationsProcessingAgent.tracer.TraceDebug <ConversationId>((long)this.GetHashCode(), "ConversationId (CID) for item: {0}", conversationId);
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndex] = conversationAggregationResult.ConversationIndex.ToByteArray();
                    storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationIndex, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndex]);
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationFamilyId] = conversationAggregationResult.ConversationFamilyId;
                    storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationFamilyId, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationFamilyId]);
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.SupportsSideConversation] = conversationAggregationResult.SupportsSideConversation;
                    storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.SupportsSideConversation, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.SupportsSideConversation]);
                    byte[] value;
                    if (this.TryCalculateConversationCreatorSid(mailboxSession, storeDriverDeliveryEventArgsImpl.MailboxOwner, conversationAggregationResult, storeDriverDeliveryEventArgsImpl.ReplayItem.PropertyBag, out value))
                    {
                        storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationCreatorSID] = value;
                        storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationCreatorSID, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationCreatorSID]);
                    }
                    conversationIndexTrackingEx.TraceVersionAndHeuristics(conversationAggregationResult.Stage.ToString());
                    storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndexTrackingEx] = conversationIndexTrackingEx.ToString();
                    if (conversationAggregationResult.Stage != ConversationIndex.FixupStage.L1)
                    {
                        storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndexTracking] = true;
                        storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationIndexTracking, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndexTracking]);
                    }
                    ConversationsProcessingAgent.tracer.TraceDebug <ConversationIndexTrackingEx>((long)this.GetHashCode(), "Time Spent in different stages - {0}", conversationIndexTrackingEx);
                    ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Processing conversation actions");
                    if (!ConversationIndex.IsFixUpCreatingNewConversation(conversationAggregationResult.Stage))
                    {
                        this.ProcessConversationActions(conversationId, storeDriverDeliveryEventArgsImpl);
                    }
                    if (ConversationIndex.IsFixupAddingOutOfOrderMessageToConversation(conversationAggregationResult.Stage))
                    {
                        if (storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents == null)
                        {
                            storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents = new Dictionary <PropertyDefinition, object>();
                        }
                        storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents[ItemSchema.ConversationLoadRequiredByInference] = true;
                    }
                }
            }
            finally
            {
                stopwatch.Stop();
                MSExchangeConversationsProcessing.LastMessageProcessingTime.RawValue = stopwatch.ElapsedMilliseconds;
                ConversationsProcessingAgent.averageMessageProcessingTime.Update(stopwatch.ElapsedMilliseconds);
                ConversationsProcessingAgent.tracer.TraceDebug <long>((long)this.GetHashCode(), "Exiting ConversationsProcessing.ProcessMessage.  Total execution time = {0} ms.", stopwatch.ElapsedMilliseconds);
            }
        }
예제 #5
0
 public static IAggregationByItemClassReferencesSubjectProcessor CreateInstance(IXSOFactory xsoFactory, IMailboxSession session, bool requestExtraPropertiesWhenSearching, ConversationIndexTrackingEx indexTrackingEx)
 {
     PropertyDefinition[] array;
     if (requestExtraPropertiesWhenSearching)
     {
         List <PropertyDefinition> list = new List <PropertyDefinition>();
         list.AddRange(AggregationByItemClassReferencesSubjectProcessor.MinimumRequiredPropertyDefinitionsList);
         list.AddRange(AggregationByItemClassReferencesSubjectProcessor.SideConversationProcessingEnabledRequiredPropertyDefinitionsList);
         array = list.ToArray();
     }
     else
     {
         array = AggregationByItemClassReferencesSubjectProcessor.MinimumRequiredPropertyDefinitionsList;
     }
     return(new AggregationByItemClassReferencesSubjectProcessor(xsoFactory, session, array, indexTrackingEx));
 }
예제 #6
0
        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);
        }
예제 #7
0
 public AggregationByItemClassReferencesSubjectProcessor(IXSOFactory xsoFactory, IMailboxSession session, PropertyDefinition[] basicSearchPropertyDefinitions, ConversationIndexTrackingEx indexTrackingEx)
 {
     this.session         = session;
     this.indexTrackingEx = indexTrackingEx;
     this.xsoFactory      = xsoFactory;
     this.basicSearchPropertyDefinitions = basicSearchPropertyDefinitions;
 }
 public ConversationAggregatorFactory(IMailboxSession session, IMailboxOwner mailboxOwner, IXSOFactory xsoFactory, ConversationIndexTrackingEx indexTrackingEx)
 {
     this.mailboxOwner    = mailboxOwner;
     this.session         = session;
     this.xsoFactory      = xsoFactory;
     this.indexTrackingEx = indexTrackingEx;
 }
        public static bool TryInstantiateAggregatorForDelivery(IMailboxSession session, IMailboxOwner mailboxOwner, ConversationIndexTrackingEx indexTrackingEx, out IConversationAggregator aggregator)
        {
            ConversationAggregatorFactory conversationAggregatorFactory = new ConversationAggregatorFactory(session, mailboxOwner, XSOFactory.Default, indexTrackingEx);

            return(conversationAggregatorFactory.TryInstantiateAggregatorForDelivery(out aggregator));
        }
        public static bool TryInstantiateAggregatorForDelivery(IMailboxSession session, MiniRecipient miniRecipient, ConversationIndexTrackingEx indexTrackingEx, out IConversationAggregator aggregator)
        {
            MailboxOwnerFactory mailboxOwnerFactory = new MailboxOwnerFactory(session);

            return(ConversationAggregatorFactory.TryInstantiateAggregatorForDelivery(session, mailboxOwnerFactory.Create(miniRecipient), indexTrackingEx, out aggregator));
        }
        public static bool TryInstantiateAggregatorForSave(IMailboxSession session, CoreItemOperation saveOperation, ICoreItem item, ConversationIndexTrackingEx indexTrackingEx, out IConversationAggregator aggregator)
        {
            MailboxOwnerFactory           mailboxOwnerFactory           = new MailboxOwnerFactory(session);
            ConversationAggregatorFactory conversationAggregatorFactory = new ConversationAggregatorFactory(session, mailboxOwnerFactory.Create(), XSOFactory.Default, indexTrackingEx);

            return(conversationAggregatorFactory.TryInstantiateAggregatorForSave(saveOperation, item, out aggregator));
        }