Esempio n. 1
0
        public IConversationTree GetNewestSubTree(IConversationTree conversationTree, int count)
        {
            if (count <= 0)
            {
                throw new ArgumentException("Count should be greater than 0", "count");
            }
            ExTraceGlobals.ConversationTracer.TraceDebug <int, int>((long)this.GetHashCode(), "ConversationTreeFactory.GetNewestSubTree: count: {0}, tree size: {1}", count, conversationTree.Count);
            if (count >= conversationTree.Count)
            {
                return(conversationTree);
            }
            IConversationTree         trimmedConversationTree = null;
            ConversationTreeSortOrder sortOrder = ConversationTreeSortOrder.ChronologicalDescending;

            conversationTree.ExecuteSortedAction(sortOrder, delegate(ConversationTreeSortOrder treeOriginalSortOrder)
            {
                List <IStorePropertyBag> list = new List <IStorePropertyBag>(count);
                foreach (IConversationTreeNode conversationTreeNode in conversationTree)
                {
                    if (count-- <= 0)
                    {
                        break;
                    }
                    list.AddRange(conversationTreeNode.StorePropertyBags);
                }
                trimmedConversationTree = this.Create(list, null);
                trimmedConversationTree.Sort(treeOriginalSortOrder);
            });
            return(trimmedConversationTree);
        }
        public Dictionary <IConversationTreeNode, ParticipantSet> LoadAddedParticipants(IConversationTree conversationTree)
        {
            Dictionary <IConversationTreeNode, ParticipantSet> participantsPerNode = new Dictionary <IConversationTreeNode, ParticipantSet>(ConversationTreeNodeBase.EqualityComparer);

            conversationTree.ExecuteSortedAction(ConversationTreeSortOrder.ChronologicalAscending, delegate(ConversationTreeSortOrder param0)
            {
                ParticipantSet participantSet = new ParticipantSet();
                foreach (IConversationTreeNode conversationTreeNode in conversationTree)
                {
                    ParticipantSet participantSet2 = this.LoadReplyAllParticipantsImpl(conversationTree, new IConversationTreeNode[]
                    {
                        conversationTreeNode
                    }, InternalSchema.ReplyDisplayNames);
                    ParticipantSet participantSet3 = new ParticipantSet();
                    foreach (IParticipant participant in participantSet2)
                    {
                        if (participantSet.Add(participant))
                        {
                            participantSet3.Add(participant);
                        }
                    }
                    if (participantSet3.Any <IParticipant>())
                    {
                        participantsPerNode.Add(conversationTreeNode, participantSet3);
                    }
                    participantSet.UnionWith(this.LoadFrom(conversationTree, conversationTreeNode));
                }
            });
            return(participantsPerNode);
        }
 private void LoadItemPartsOrBodySummaries(IConversationTree conversationTree, ICollection <StoreObjectId> storeIds)
 {
     conversationTree.ExecuteSortedAction(ConversationTreeSortOrder.ChronologicalDescending, delegate(ConversationTreeSortOrder param0)
     {
         HashSet <StoreObjectId> hashSet = null;
         if (storeIds != null && storeIds.Any <StoreObjectId>())
         {
             hashSet = new HashSet <StoreObjectId>(storeIds);
         }
         this.RecursiveLoadBodyFragments(conversationTree, hashSet);
         foreach (IConversationTreeNode conversationTreeNode in conversationTree)
         {
             if (!this.treeNodeBodyFragment.ContainsKey(conversationTreeNode.MainStoreObjectId))
             {
                 for (int i = 0; i < conversationTreeNode.StorePropertyBags.Count; i++)
                 {
                     IStorePropertyBag storePropertyBag = conversationTreeNode.StorePropertyBags[i];
                     this.AddBodySummaryError(conversationTree, ref storePropertyBag);
                 }
             }
             else
             {
                 FragmentInfo fragmentInfo         = FragmentInfo.Empty;
                 FragmentInfo disclaimerFragment   = FragmentInfo.Empty;
                 BodyFragmentInfo bodyFragmentInfo = this.treeNodeBodyFragment[conversationTreeNode.MainStoreObjectId].Key;
                 fragmentInfo = bodyFragmentInfo;
                 if (conversationTreeNode.ParentNode.HasData && this.treeNodeBodyFragment.ContainsKey(conversationTreeNode.ParentNode.MainStoreObjectId))
                 {
                     BodyFragmentInfo key = this.treeNodeBodyFragment[conversationTreeNode.ParentNode.MainStoreObjectId].Key;
                     ExtractionData extractionData;
                     if (this.IsBodyPartPresent(bodyFragmentInfo, conversationTreeNode.ParentNode.StorePropertyBags[0], out extractionData))
                     {
                         fragmentInfo       = extractionData.ChildUniqueBody;
                         disclaimerFragment = extractionData.ChildDisclaimer;
                     }
                     else
                     {
                         BodyDiffer bodyDiffer = new BodyDiffer(bodyFragmentInfo, key);
                         fragmentInfo          = bodyDiffer.UniqueBodyPart;
                         disclaimerFragment    = bodyDiffer.DisclaimerPart;
                     }
                 }
                 for (int j = 0; j < conversationTreeNode.StorePropertyBags.Count; j++)
                 {
                     IStorePropertyBag storePropertyBag2 = conversationTreeNode.StorePropertyBags[j];
                     StoreObjectId objectId = ((VersionedId)storePropertyBag2.TryGetProperty(ItemSchema.Id)).ObjectId;
                     this.AddBodySummary(conversationTree, ref storePropertyBag2, fragmentInfo);
                     if (!conversationTreeNode.HasChildren)
                     {
                         this.OptimizationCounters.UpdateItemIsLeafNode(objectId);
                     }
                     if (!this.itemParts.ContainsKey(objectId))
                     {
                         ParticipantTable recipients;
                         List <Participant> replyToParticipants;
                         if (this.treeNodeBodyFragment[conversationTreeNode.MainStoreObjectId].Value && this.CanExtractItemPart(conversationTree, storePropertyBag2, out recipients, out replyToParticipants))
                         {
                             this.optimizationInfo.UpdateItemExtracted(objectId);
                             ItemPart itemPart = this.itemPartLoader.Create(objectId, storePropertyBag2, fragmentInfo, disclaimerFragment, recipients, replyToParticipants);
                             this.itemParts.Add(objectId, itemPart);
                             this.AddRecipientToRecipientDisplayNameCache(itemPart);
                         }
                         else if (hashSet != null && hashSet.Contains(objectId))
                         {
                             this.LoadItemPart(conversationTree, storePropertyBag2);
                             bodyFragmentInfo = this.loadedItemParts[objectId].BodyFragmentInfo;
                         }
                     }
                 }
             }
         }
     });
 }