private static void DiffItemParts(BodyFragmentInfo parentBodyFragment, LoadedItemPart childItemPart) { if (childItemPart.UniqueFragmentInfo != null) { return; } if (parentBodyFragment != null) { BodyDiffer bodyDiffer = new BodyDiffer(childItemPart.BodyFragmentInfo, parentBodyFragment); childItemPart.UniqueFragmentInfo = bodyDiffer.UniqueBodyPart; childItemPart.DisclaimerFragmentInfo = bodyDiffer.DisclaimerPart; return; } childItemPart.UniqueFragmentInfo = childItemPart.BodyFragmentInfo.Trim(); childItemPart.DisclaimerFragmentInfo = FragmentInfo.Empty; }
private void SetUniqueBody(IMessageItem escalatedMessage, IMailboxSession mailboxSession) { StoreId messageStoreId = this.GetMessageStoreId(escalatedMessage.InReplyTo, mailboxSession); if (messageStoreId != null) { using (IMessageItem messageItem = this.xsoFactory.BindToMessage(mailboxSession, messageStoreId, null)) { BodyDiffer bodyDiffer = new BodyDiffer(messageItem.Body.GetConversationBodyScanner(), escalatedMessage.Body.GetConversationBodyScanner()); FragmentInfo uniqueBodyPart = bodyDiffer.UniqueBodyPart; using (TextWriter textWriter = escalatedMessage.Body.OpenTextWriter(new BodyWriteConfiguration(BodyFormat.TextHtml))) { using (HtmlWriter htmlWriter = new HtmlWriter(textWriter)) { uniqueBodyPart.WriteHtml(htmlWriter); } } } } }
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; } } } } } }); }