private bool SetBodySummary(IConversationTree conversationTree, ref IStorePropertyBag propertyBag, object summary, StoreObjectId storeId)
        {
            bool result = false;
            QueryResultPropertyBag queryResultPropertyBag = new QueryResultPropertyBag(propertyBag, ConversationDataExtractor.BodyPropertiesCanBeExtracted, new object[]
            {
                summary,
                summary
            });

            propertyBag = queryResultPropertyBag.AsIStorePropertyBag();
            IConversationTreeNode conversationTreeNode = null;

            conversationTree.TryGetConversationTreeNode(storeId, out conversationTreeNode);
            foreach (StoreObjectId storeObjectId in conversationTreeNode.ToListStoreObjectId())
            {
                if (storeObjectId.Equals(storeId))
                {
                    LoadedItemPart loadedItemPart;
                    if (this.loadedItemParts.TryGetValue(storeObjectId, out loadedItemPart))
                    {
                        loadedItemPart.AddBodySummary(summary);
                        result = true;
                    }
                    conversationTreeNode.UpdatePropertyBag(storeObjectId, propertyBag);
                }
            }
            return(result);
        }
        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 bool CanExtractItemPart(IConversationTree conversationTree, IStorePropertyBag propertyBag, out ParticipantTable recipientTable, out List <Participant> replyToParticipants)
        {
            IConversationTreeNode treeNode = null;
            StoreObjectId         objectId = ((VersionedId)propertyBag.TryGetProperty(ItemSchema.Id)).ObjectId;

            recipientTable      = null;
            replyToParticipants = null;
            if (!conversationTree.TryGetConversationTreeNode(objectId, out treeNode))
            {
                throw new ArgumentException("No ConversationTreeNode can be found for the passed StorePropertyBag");
            }
            if (this.itemParts.ContainsKey(objectId))
            {
                return(true);
            }
            if (this.OnBeforeItemLoad != null)
            {
                LoadItemEventArgs loadItemEventArgs = new LoadItemEventArgs(treeNode, propertyBag);
                this.OnBeforeItemLoad(this, loadItemEventArgs);
                if (loadItemEventArgs.MessagePropertyDefinitions != null)
                {
                    foreach (PropertyDefinition propertyDefinition in loadItemEventArgs.MessagePropertyDefinitions)
                    {
                        ICollection <PropertyDefinition> requiredPropertyDefinitionsWhenReading = propertyDefinition.RequiredPropertyDefinitionsWhenReading;
                        foreach (PropertyDefinition propertyDefinition2 in requiredPropertyDefinitionsWhenReading)
                        {
                            if (!conversationTree.IsPropertyLoaded(propertyDefinition2) && !ConversationDataExtractor.nonNativePropertiesCanBeExtracted.Contains(propertyDefinition2) && !ConversationDataExtractor.BodyPropertiesCanBeExtracted.Contains(propertyDefinition2))
                            {
                                this.optimizationInfo.UpdateItemExtraPropertiesNeeded(objectId);
                                return(false);
                            }
                        }
                    }
                }
            }
            if (true.Equals(propertyBag.TryGetProperty(StoreObjectSchema.IsRestricted)))
            {
                this.optimizationInfo.UpdateItemIrmProtected(objectId);
                return(false);
            }
            if (true.Equals(propertyBag.TryGetProperty(InternalSchema.MapiHasAttachment)))
            {
                if (true.Equals(propertyBag.TryGetProperty(ItemSchema.HasAttachment)))
                {
                    this.optimizationInfo.UpdateItemAttachmentPresent(objectId);
                }
                this.optimizationInfo.UpdateItemMapiAttachmentPresent(objectId);
                return(false);
            }
            recipientTable      = new ParticipantTable();
            replyToParticipants = new List <Participant>();
            if (!this.TryExtractRecipients(propertyBag, recipientTable, replyToParticipants))
            {
                this.optimizationInfo.UpdateItemParticipantNotFound(objectId);
                return(false);
            }
            return(true);
        }
        private bool CanSkipDiffing(IConversationTree conversationTree, LoadedItemPart loadedItemPart, out ExtractionData extractionData)
        {
            extractionData = null;
            IConversationTreeNode conversationTreeNode;

            if (conversationTree.TryGetConversationTreeNode(loadedItemPart.ObjectId, out conversationTreeNode))
            {
                IConversationTreeNode parentNode = conversationTreeNode.ParentNode;
                return(parentNode != null && parentNode.HasData && this.IsBodyPartPresent(loadedItemPart.BodyFragmentInfo, parentNode.StorePropertyBags[0], out extractionData));
            }
            return(false);
        }
        public StoreObjectId GetParentId(StoreObjectId itemId, bool allowCrossConversation)
        {
            IConversationTree conversationTree = allowCrossConversation ? this.conversationFamilyTree : this.selectedConversationTree;

            if (itemId == conversationTree.RootMessageId)
            {
                return(null);
            }
            IConversationTreeNode conversationTreeNode;

            if (conversationTree.TryGetConversationTreeNode(itemId, out conversationTreeNode) && conversationTreeNode.ParentNode != null && conversationTreeNode.ParentNode.HasData)
            {
                return(conversationTreeNode.ParentNode.MainStoreObjectId);
            }
            return(null);
        }
Esempio n. 6
0
        public void LoadItemParts(IConversationTree conversationTree, IList <StoreObjectId> storeIds, string searchString, CultureInfo cultureinfo, out List <IConversationTreeNode> nodes)
        {
            Util.ThrowOnNullOrEmptyArgument(storeIds, "storeIds");
            nodes = new List <IConversationTreeNode>(0);
            this.ConversationDataExtractor.LoadItemParts(conversationTree, new Collection <StoreObjectId>(storeIds));
            if (string.IsNullOrEmpty(searchString))
            {
                nodes = this.MatchAllNodes(storeIds);
                return;
            }
            IList <string> words = null;

            if (this.InternalTryAqsMatch(storeIds, searchString, cultureinfo, out words, out nodes))
            {
                return;
            }
            bool flag = false;

            foreach (StoreObjectId storeObjectId in storeIds)
            {
                ItemPart itemPart = this.ConversationDataExtractor.GetItemPart(conversationTree, storeObjectId);
                if (itemPart.UniqueFragmentInfo != null && itemPart.UniqueFragmentInfo.IsMatchFound(words))
                {
                    IConversationTreeNode item = null;
                    if (conversationTree.TryGetConversationTreeNode(storeObjectId, out item))
                    {
                        nodes.Add(item);
                        flag = true;
                    }
                }
            }
            if (!flag)
            {
                nodes = this.MatchAllNodes(storeIds);
            }
        }
        private void LoadItemPart(IConversationTree conversationTree, IStorePropertyBag propertyBag)
        {
            StoreObjectId objectId = ((VersionedId)propertyBag.TryGetProperty(ItemSchema.Id)).ObjectId;

            if (this.loadedItemParts.ContainsKey(objectId))
            {
                return;
            }
            IConversationTreeNode treeNode = null;

            if (!conversationTree.TryGetConversationTreeNode(objectId, out treeNode))
            {
                throw new ArgumentException("No ConversationTreeNode can be found for the passed StorePropertyBag");
            }
            LoadItemEventArgs loadItemEventArgs = new LoadItemEventArgs(treeNode, propertyBag);

            PropertyDefinition[] array = null;
            if (this.OnBeforeItemLoad != null)
            {
                this.OnBeforeItemLoad(this, loadItemEventArgs);
                if (loadItemEventArgs.OpportunisticLoadPropertyDefinitions != null && loadItemEventArgs.MessagePropertyDefinitions != null)
                {
                    array = new PropertyDefinition[loadItemEventArgs.OpportunisticLoadPropertyDefinitions.Length + loadItemEventArgs.MessagePropertyDefinitions.Length];
                    loadItemEventArgs.MessagePropertyDefinitions.CopyTo(array, 0);
                    loadItemEventArgs.OpportunisticLoadPropertyDefinitions.CopyTo(array, loadItemEventArgs.MessagePropertyDefinitions.Length);
                }
                else if (loadItemEventArgs.OpportunisticLoadPropertyDefinitions != null)
                {
                    array = loadItemEventArgs.OpportunisticLoadPropertyDefinitions;
                }
                else
                {
                    array = loadItemEventArgs.MessagePropertyDefinitions;
                }
            }
            LoadedItemPart loadedItemPart = this.itemPartLoader.Load(propertyBag[ItemSchema.Id] as StoreId, propertyBag, loadItemEventArgs.HtmlStreamOptionCallback, array, this.bytesLoadedForConversation, this.isSmimeSupported, this.domainName);

            if (loadedItemPart.DidLoadSucceed)
            {
                this.bytesLoadedForConversation += loadedItemPart.BytesLoaded;
            }
            this.loadedItemParts.Add(objectId, loadedItemPart);
            this.AddRecipientToRecipientDisplayNameCache(this.loadedItemParts[objectId]);
            this.optimizationInfo.UpdateItemOpened(objectId);
            if (propertyBag.TryGetProperty(InternalSchema.MapiHasAttachment).Equals(true))
            {
                this.optimizationInfo.UpdateItemMapiAttachmentPresent(objectId);
                if (propertyBag.TryGetProperty(ItemSchema.HasAttachment).Equals(true))
                {
                    this.optimizationInfo.UpdateItemAttachmentPresent(objectId);
                }
            }
            if (!this.itemParts.ContainsKey(objectId))
            {
                this.itemParts.Add(objectId, this.loadedItemParts[objectId]);
                return;
            }
            this.loadedItemParts[objectId].UniqueFragmentInfo     = this.itemParts[objectId].UniqueFragmentInfo;
            this.loadedItemParts[objectId].DisclaimerFragmentInfo = this.itemParts[objectId].DisclaimerFragmentInfo;
            this.itemParts[objectId] = this.loadedItemParts[objectId];
        }