Exemple #1
0
        private bool CalculateBasedOnReferenceMessage(ICorePropertyBag message, IStorePropertyBag referenceItem, out ConversationIndex.FixupStage stage, out ConversationIndex newIndex)
        {
            bool result = true;

            newIndex = ConversationIndex.Empty;
            stage    = ConversationIndex.FixupStage.Unknown;
            if (this.indexTrackingEx != null)
            {
                string text = referenceItem.TryGetProperty(ItemSchema.InternetMessageId) as string;
                if (text != null)
                {
                    this.indexTrackingEx.Trace("S1", text);
                }
            }
            string            text2 = message.TryGetProperty(ItemSchema.NormalizedSubject) as string;
            ConversationIndex conversationIndex;
            bool flag = ConversationIndex.TryCreate(referenceItem.TryGetProperty(ItemSchema.ConversationIndex) as byte[], out conversationIndex);
            ConversationIndex conversationIndex2;
            bool flag2 = ConversationIndex.TryCreate(message.TryGetProperty(ItemSchema.ConversationIndex) as byte[], out conversationIndex2);
            bool?flag3 = referenceItem.TryGetProperty(ItemSchema.ConversationIndexTracking) as bool?;
            bool flag4 = flag3 == null || !flag3.Value;

            if (flag)
            {
                string value = referenceItem.TryGetProperty(ItemSchema.ConversationTopic) as string;
                if (string.IsNullOrEmpty(value) || (!string.IsNullOrEmpty(text2) && text2.EndsWith(value, StringComparison.OrdinalIgnoreCase)))
                {
                    string text3 = message.TryGetProperty(ItemSchema.InReplyTo) as string;
                    string text4 = referenceItem.TryGetProperty(ItemSchema.InternetMessageId) as string;
                    if (!string.IsNullOrEmpty(text3) && !string.IsNullOrEmpty(text4) && string.Compare(text3, text4, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if (conversationIndex.IsParentOf(conversationIndex2))
                        {
                            newIndex = conversationIndex2;
                            stage    = (flag4 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H1);
                            result   = false;
                        }
                        else
                        {
                            ExDateTime?valueAsNullable = message.GetValueAsNullable <ExDateTime>(ItemSchema.SentTime);
                            if (valueAsNullable != null)
                            {
                                newIndex = ConversationIndex.CreateFromParent(conversationIndex.Bytes, valueAsNullable.Value);
                            }
                            else
                            {
                                newIndex = ConversationIndex.CreateFromParent(conversationIndex.Bytes);
                            }
                            stage = (flag4 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H2);
                        }
                    }
                    else if (flag2)
                    {
                        if (conversationIndex.IsAncestorOf(conversationIndex2))
                        {
                            newIndex = conversationIndex2;
                            stage    = (flag4 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H1);
                            result   = false;
                        }
                        else
                        {
                            newIndex = conversationIndex2.UpdateGuid(conversationIndex.Guid);
                            newIndex = newIndex.UpdateHeader(conversationIndex.Header);
                            stage    = (flag4 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H10);
                        }
                    }
                    else
                    {
                        newIndex = ConversationIndex.CreateFromParent(conversationIndex.Bytes);
                        stage    = (flag4 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H2);
                    }
                }
                else
                {
                    newIndex = ConversationIndex.CreateNew();
                    stage    = ConversationIndex.FixupStage.H3;
                }
            }
            return(result);
        }