public bool ConversationNodeContainedInChildren(IConversationTree conversationTree, IConversationTreeNode node) { if (node.HasChildren) { this.LoadItemParts(conversationTree, (from n in node.ChildNodes select n.MainStoreObjectId).ToList <StoreObjectId>()); } ItemPart itemPart = this.GetItemPart(conversationTree, node.MainStoreObjectId); if (itemPart != null && itemPart.Attachments != null && itemPart.Attachments.Count > 0) { return(false); } foreach (IConversationTreeNode conversationTreeNode in node.ChildNodes) { if (this.HasLoadedItemPart(conversationTreeNode.MainStoreObjectId)) { LoadedItemPart loadedItemPart = this.GetItemPart(conversationTree, node.MainStoreObjectId) as LoadedItemPart; ExtractionData extractionData = null; if (loadedItemPart.BodyFragmentInfo != null && this.IsBodyPartPresent(loadedItemPart.BodyFragmentInfo, node.StorePropertyBags[0], true, out extractionData)) { return(true); } } } return(false); }
public ItemPart GetItemPart(IConversationTree conversationTree, StoreObjectId itemId) { IStorePropertyBag propertyBag = null; ItemPart itemPart = null; IConversationTreeNode conversationTreeNode = null; if (!conversationTree.TryGetConversationTreeNode(itemId, out conversationTreeNode) || !conversationTreeNode.TryGetPropertyBag(itemId, out propertyBag)) { throw new ArgumentException("No ConversationTreeNode/PropertyBag can be found for the passed StoreObjectId"); } if (!this.itemParts.TryGetValue(itemId, out itemPart)) { this.LoadItemPart(conversationTree, propertyBag); itemPart = this.loadedItemParts[itemId]; } if (itemPart is LoadedItemPart && !itemPart.DidLoadSucceed) { return(itemPart); } if (itemPart.UniqueFragmentInfo == null) { LoadedItemPart loadedItemPart = (LoadedItemPart)itemPart; ExtractionData extractionData; if (!this.CanSkipDiffing(conversationTree, loadedItemPart, out extractionData)) { BodyFragmentInfo parentBodyFragment = null; if (conversationTreeNode.ParentNode.HasData) { StoreObjectId mainStoreObjectId = conversationTreeNode.ParentNode.MainStoreObjectId; if (this.treeNodeBodyFragment.ContainsKey(mainStoreObjectId)) { parentBodyFragment = this.treeNodeBodyFragment[mainStoreObjectId].Key; } else { LoadedItemPart loadedItemPart2 = null; if (!this.loadedItemParts.TryGetValue(mainStoreObjectId, out loadedItemPart2)) { IStorePropertyBag propertyBag2; if (!conversationTreeNode.ParentNode.TryGetPropertyBag(mainStoreObjectId, out propertyBag2)) { throw new ArgumentException("No Property bag can be found for the passed StoreObjectId on the ParentNode"); } this.LoadItemPart(conversationTree, propertyBag2); loadedItemPart2 = this.loadedItemParts[mainStoreObjectId]; } parentBodyFragment = loadedItemPart2.BodyFragmentInfo; } } ConversationDataExtractor.DiffItemParts(parentBodyFragment, loadedItemPart); } else { itemPart.UniqueFragmentInfo = extractionData.ChildUniqueBody; itemPart.DisclaimerFragmentInfo = extractionData.ChildDisclaimer; } } return(itemPart); }
private void AddRecipientToRecipientDisplayNameCache(ItemPart itemPart) { IStorePropertyBag storePropertyBag = itemPart.StorePropertyBag; Participant participant = storePropertyBag.TryGetProperty(ItemSchema.Sender) as Participant; if (participant != null) { this.AddParticipantToRecipientDisplayNameCache(participant); } Participant participant2 = storePropertyBag.TryGetProperty(ItemSchema.From) as Participant; if (participant2 != null) { this.AddParticipantToRecipientDisplayNameCache(participant2); } }
public ParticipantSet CalculateAllRecipients(IConversationTree conversationTree, ICollection <IConversationTreeNode> loadedNodes) { loadedNodes = (loadedNodes ?? conversationTree); HashSet <StoreObjectId> hashSet = new HashSet <StoreObjectId>(from node in loadedNodes select node.MainStoreObjectId); if (!this.ConversationDataLoaded) { this.LoadItemPartsOrBodySummaries(conversationTree, hashSet); } ParticipantSet participantSet = new ParticipantSet(); foreach (StoreObjectId itemId in hashSet) { ItemPart itemPart = this.GetItemPart(conversationTree, itemId); participantSet.UnionWith(itemPart.AllRecipients); } return(participantSet); }
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; } } } } } }); }