예제 #1
0
        private static StoreObjectType?TryDetectFolderTreeDataStoreObjectType(ICorePropertyBag propertyBag, string itemClass, StoreObjectType detectedType)
        {
            StoreObjectType?result = null;

            if (ObjectClass.IsFolderTreeData(itemClass))
            {
                propertyBag.Load(new StorePropertyDefinition[]
                {
                    FolderTreeDataSchema.GroupSection,
                    FolderTreeDataSchema.Type
                });
                FolderTreeDataSection?valueAsNullable  = propertyBag.GetValueAsNullable <FolderTreeDataSection>(FolderTreeDataSchema.GroupSection);
                FolderTreeDataType?   valueAsNullable2 = propertyBag.GetValueAsNullable <FolderTreeDataType>(FolderTreeDataSchema.Type);
                if (valueAsNullable == FolderTreeDataSection.Calendar)
                {
                    if (valueAsNullable2 == FolderTreeDataType.Header)
                    {
                        result = new StoreObjectType?(StoreObjectType.CalendarGroup);
                    }
                    else if (valueAsNullable2 == FolderTreeDataType.NormalFolder || valueAsNullable2 == FolderTreeDataType.SharedFolder)
                    {
                        result = new StoreObjectType?(StoreObjectType.CalendarGroupEntry);
                    }
                }
                else if (valueAsNullable == FolderTreeDataSection.First)
                {
                    result = new StoreObjectType?(StoreObjectType.FavoriteFolderEntry);
                }
                else if (valueAsNullable == FolderTreeDataSection.Tasks)
                {
                    if (valueAsNullable2 == FolderTreeDataType.Header)
                    {
                        result = new StoreObjectType?(StoreObjectType.TaskGroup);
                    }
                    else if (valueAsNullable2 == FolderTreeDataType.NormalFolder)
                    {
                        result = new StoreObjectType?(StoreObjectType.TaskGroupEntry);
                    }
                }
            }
            return(result);
        }
예제 #2
0
        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;
            }
        }
예제 #3
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);
        }
예제 #4
0
 public static bool WasMessageEverProcessed(ICorePropertyBag propertyBag)
 {
     return(propertyBag.GetValueAsNullable <bool>(ItemSchema.ConversationIndexTracking) != null);
 }