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);
        }
        private ParticipantTable LoadReplyAllParticipantsPerTypeImpl(IConversationTree conversationTree, ICollection <IConversationTreeNode> nodes, SmartPropertyDefinition propertyDefinition)
        {
            ParticipantTable participantTable = this.LoadParticipantsPerType(new ConversationDataExtractor.ParticipantPerTypeLoaderDelegate(this.LoadReplyAllParticipantField), conversationTree, nodes, propertyDefinition);

            participantTable[RecipientItemType.Cc].ExceptWith(participantTable[RecipientItemType.To]);
            return(participantTable);
        }
Esempio n. 3
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 ParticipantSet LoadReplyAllParticipants(IConversationTree conversationTree, IConversationTreeNode node)
 {
     return(this.LoadReplyAllParticipantsImpl(conversationTree, new IConversationTreeNode[]
     {
         node
     }, InternalSchema.ReplyAllDisplayNames));
 }
 private IEnumerable <IParticipant> LoadFrom(IConversationTree conversationTree, IConversationTreeNode node)
 {
     return(this.LoadParticipants(conversationTree, new ConversationDataExtractor.ParticipantLoaderDelegate(this.LoadFromField), new List <IConversationTreeNode>
     {
         node
     }));
 }
        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);
        }
 internal ConversationState(IMailboxSession session, IConversationTree conversationTree, ICollection <IConversationTreeNode> nodesToExclude)
 {
     this.conversationTree = conversationTree;
     this.session          = session;
     this.treeNode         = new MiniStateTreeNode(conversationTree, new Func <StoreObjectId, long>(this.StoreIdToIdHash), nodesToExclude);
     this.InitializeSerializedState();
 }
        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 RecursiveLoadBodyFragments(IConversationTree conversationTree, ICollection <StoreObjectId> itemPartsToLoad)
 {
     foreach (IConversationTreeNode treeNode in conversationTree)
     {
         bool flag;
         this.RecursiveLoadBodyFragments(conversationTree, treeNode, itemPartsToLoad, out flag);
     }
 }
        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 ParticipantSet LoadReplyAllParticipantsImpl(IConversationTree conversationTree, ICollection <IConversationTreeNode> nodes, SmartPropertyDefinition propertyDefinition)
        {
            ParticipantSet   participantSet   = new ParticipantSet();
            ParticipantTable participantTable = this.LoadReplyAllParticipantsPerTypeImpl(conversationTree, nodes, propertyDefinition);

            participantSet.UnionWith(participantTable[RecipientItemType.To]);
            participantSet.UnionWith(participantTable[RecipientItemType.Cc]);
            return(participantSet);
        }
Esempio n. 12
0
 internal Conversation(ConversationId conversationId, IConversationTree conversationTree, MailboxSession session, ConversationDataExtractor conversationDataExtractor, IConversationTreeFactory conversationTreeFactory, ConversationStateFactory stateFactory)
 {
     this.conversationId            = conversationId;
     this.conversationTree          = conversationTree;
     this.session                   = session;
     this.conversationDataExtractor = conversationDataExtractor;
     this.conversationTreeFactory   = conversationTreeFactory;
     this.stateFactory              = stateFactory;
 }
Esempio n. 13
0
 internal MiniStateTreeNode(IConversationTree conversationTree, Func <StoreObjectId, long> idConverter, ICollection <IConversationTreeNode> nodesToExclude)
 {
     foreach (IConversationTreeNode conversationTreeNode in conversationTree)
     {
         if (nodesToExclude == null || !nodesToExclude.Contains(conversationTreeNode))
         {
             this.ChildNodes.Add(new MiniStateTreeNode(conversationTreeNode, idConverter, nodesToExclude));
         }
     }
 }
Esempio n. 14
0
        public virtual Conversation CreateConversation(ConversationId conversationId, IList <StoreObjectId> folderIds, bool useFolderIdsAsExclusionList, bool isIrmEnabled, bool isSmimeSupported, string domainName, params PropertyDefinition[] requestedProperties)
        {
            HashSet <PropertyDefinition> hashSet                   = this.SanitizePropertiesRequested(requestedProperties);
            List <IStorePropertyBag>     queryResult               = this.MembersQuery.Query(conversationId, hashSet, folderIds, useFolderIdsAsExclusionList);
            IConversationTree            conversationTree          = this.TreeFactory.Create(queryResult, hashSet);
            ConversationStateFactory     stateFactory              = new ConversationStateFactory(this.Session, conversationTree);
            ConversationDataExtractor    conversationDataExtractor = this.DataExtractorFactory.Create(isIrmEnabled, hashSet, conversationId, conversationTree, isSmimeSupported, domainName);

            return(this.InternalCreateConversation(conversationId, conversationDataExtractor, stateFactory, conversationTree));
        }
        private List <IConversationTree> CreateThreadTrees(ICollection <PropertyDefinition> propertyDefinitions, Dictionary <object, List <IStorePropertyBag> > aggregatedMessages)
        {
            List <IConversationTree> list = new List <IConversationTree>();

            foreach (KeyValuePair <object, List <IStorePropertyBag> > keyValuePair in aggregatedMessages)
            {
                IConversationTree item = this.conversationThreadTreeFactory.Create(keyValuePair.Value, propertyDefinitions);
                list.Add(item);
            }
            return(list);
        }
        public IThreadedConversation CreateConversation(ConversationId conversationId, IList <StoreObjectId> folderIds, bool useFolderIdsAsExclusionList, bool isIrmEnabled, bool isSmimeSupported, string domainName, params PropertyDefinition[] requestedItemProperties)
        {
            ICollection <PropertyDefinition> defaultThreadProperties = ThreadedConversationFactory.DefaultThreadProperties;
            HashSet <PropertyDefinition>     hashSet = this.SanitizePropertiesRequested(requestedItemProperties, defaultThreadProperties);
            Dictionary <object, List <IStorePropertyBag> > aggregatedMessages = this.QueryMessages(conversationId, folderIds, useFolderIdsAsExclusionList, hashSet);
            IConversationTree         conversationTree          = this.CreateTree(hashSet, aggregatedMessages);
            ConversationStateFactory  stateFactory              = this.CreateStateFactory(conversationTree);
            List <IConversationTree>  threadTrees               = this.CreateThreadTrees(hashSet, aggregatedMessages);
            ConversationDataExtractor conversationDataExtractor = this.dataExtractorFactory.Create(isIrmEnabled, hashSet, conversationId, conversationTree, isSmimeSupported, domainName);

            return(this.InternalCreateConversation(conversationId, conversationDataExtractor, stateFactory, conversationTree, threadTrees, defaultThreadProperties));
        }
        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);
        }
        private int UpdateItems(IConversationTree conversationTree, List <GroupOperationResult> results)
        {
            int num = 0;

            foreach (IConversationTreeNode conversationTreeNode in conversationTree)
            {
                for (int i = 0; i < conversationTreeNode.StorePropertyBags.Count; i++)
                {
                    if (!this.CanSkipProcessing(conversationTreeNode.StorePropertyBags[i]))
                    {
                        StoreId       storeId = conversationTreeNode.StorePropertyBags[i].TryGetProperty(ItemSchema.Id) as StoreId;
                        List <string> list    = null;
                        if (ConversationActionItem.MergeCategories(conversationTreeNode.StorePropertyBags[i].TryGetProperty(ItemSchema.Categories) as string[], this.AlwaysCategorizeValue, this.ConversationActionLastCategorySet, out list))
                        {
                            try
                            {
                                using (Item item = Microsoft.Exchange.Data.Storage.Item.Bind(base.Session, storeId, null))
                                {
                                    num++;
                                    item.OpenAsReadWrite();
                                    if (list.Count == 0)
                                    {
                                        item.Delete(ItemSchema.Categories);
                                    }
                                    else
                                    {
                                        item[ItemSchema.Categories] = list.ToArray();
                                    }
                                    item.Save(SaveMode.ResolveConflicts);
                                    results.Add(new GroupOperationResult(OperationResult.Succeeded, new StoreObjectId[]
                                    {
                                        StoreId.GetStoreObjectId(storeId)
                                    }, null));
                                }
                            }
                            catch (LocalizedException storageException)
                            {
                                results.Add(new GroupOperationResult(OperationResult.Failed, new StoreObjectId[]
                                {
                                    StoreId.GetStoreObjectId(storeId)
                                }, storageException));
                            }
                        }
                    }
                }
            }
            if (ConversationActionItem.NeedToAddCategory(this.ConversationActionLastCategorySet, this.AlwaysCategorizeValue))
            {
                this.ConversationActionLastCategorySet = this.AlwaysCategorizeValue;
            }
            return(num);
        }
        private IList <IConversationThread> CreateConversationThreads(IConversationTree tree, List <IConversationTree> threadTrees, ConversationDataExtractor conversationDataExtractor, ICollection <PropertyDefinition> requestedThreadProperties)
        {
            bool isSingleThreadConversation = threadTrees.Count == 1;
            ConversationThreadDataExtractor threadDataExtractor = new ConversationThreadDataExtractor(requestedThreadProperties, tree, isSingleThreadConversation);
            IList <IConversationThread>     list = new List <IConversationThread>();

            foreach (IConversationTree threadTree in threadTrees)
            {
                ConversationThread item = new ConversationThread(conversationDataExtractor, threadDataExtractor, threadTree, this.conversationTreeFactory);
                list.Add(item);
            }
            return(list);
        }
        private void AddBodySummary(IConversationTree conversationTree, ref IStorePropertyBag propertyBag, FragmentInfo bodyFragment)
        {
            StoreObjectId objectId = ((VersionedId)propertyBag.TryGetProperty(ItemSchema.Id)).ObjectId;

            if (!this.bodySummaryLoadedNodes.Contains(objectId))
            {
                this.bodySummaryLoadedNodes.Add(objectId);
                string summaryText = bodyFragment.GetSummaryText();
                if (!this.SetBodySummary(conversationTree, ref propertyBag, summaryText, objectId))
                {
                    this.optimizationInfo.UpdateItemSummaryConstructed(objectId);
                }
            }
        }
        public int Process(bool markAsClutter, IConversationTree conversationTree, List <GroupOperationResult> results)
        {
            ArgumentValidator.ThrowIfNull("results", results);
            int           num            = 0;
            StoreObjectId storeObjectId  = markAsClutter ? this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox) : this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Clutter);
            StoreObjectId storeObjectId2 = markAsClutter ? this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Clutter) : this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);

            if (storeObjectId == null || storeObjectId2 == null)
            {
                return(num);
            }
            List <StoreObjectId> list = new List <StoreObjectId>();

            foreach (IConversationTreeNode conversationTreeNode in conversationTree)
            {
                for (int i = 0; i < conversationTreeNode.StorePropertyBags.Count; i++)
                {
                    StoreId id = conversationTreeNode.StorePropertyBags[i].TryGetProperty(ItemSchema.Id) as StoreId;
                    if (storeObjectId.Equals(conversationTreeNode.StorePropertyBags[i].TryGetProperty(StoreObjectSchema.ParentItemId) as StoreObjectId))
                    {
                        list.Add(StoreId.GetStoreObjectId(id));
                    }
                }
            }
            if (list.Count > 0)
            {
                try
                {
                    using (Folder folder = Folder.Bind(this.mailboxSession, storeObjectId))
                    {
                        using (Folder folder2 = Folder.Bind(this.mailboxSession, storeObjectId2))
                        {
                            GroupOperationResult groupOperationResult = folder.MoveItems(folder2.Id, list.ToArray());
                            results.Add(groupOperationResult);
                            if (groupOperationResult.OperationResult != OperationResult.Failed)
                            {
                                num += groupOperationResult.ObjectIds.Count;
                            }
                        }
                    }
                }
                catch (LocalizedException storageException)
                {
                    results.Add(new GroupOperationResult(OperationResult.Failed, list, storageException));
                }
            }
            return(num);
        }
Esempio n. 22
0
        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);
        }
        private ParticipantSet LoadParticipants(IConversationTree conversationTree, ConversationDataExtractor.ParticipantLoaderDelegate loaderDelegate, ICollection <IConversationTreeNode> nodes)
        {
            ParticipantSet participantSet = new ParticipantSet();

            nodes = (nodes ?? conversationTree.ToList <IConversationTreeNode>());
            foreach (IConversationTreeNode conversationTreeNode in nodes)
            {
                if (conversationTreeNode.HasData)
                {
                    foreach (IStorePropertyBag propertyBag in conversationTreeNode.StorePropertyBags)
                    {
                        participantSet.UnionWith(loaderDelegate(propertyBag));
                    }
                }
            }
            return(participantSet);
        }
        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 AddBodySummaryError(IConversationTree conversationTree, ref IStorePropertyBag propertyBag)
        {
            StoreObjectId objectId = ((VersionedId)propertyBag.TryGetProperty(ItemSchema.Id)).ObjectId;

            if (!this.bodySummaryLoadedNodes.Contains(objectId) && this.loadedItemParts.ContainsKey(objectId))
            {
                if (!this.loadedItemParts[objectId].DidLoadSucceed)
                {
                    this.bodySummaryLoadedNodes.Add(objectId);
                    PropertyError summary = new PropertyError(InternalSchema.TextBody, PropertyErrorCode.NotEnoughMemory);
                    this.SetBodySummary(conversationTree, ref propertyBag, summary, objectId);
                    return;
                }
                if (this.InternalHasIrmFailed(objectId))
                {
                    this.bodySummaryLoadedNodes.Add(objectId);
                    PropertyError summary2 = new PropertyError(InternalSchema.TextBody, PropertyErrorCode.AccessDenied);
                    this.SetBodySummary(conversationTree, ref propertyBag, summary2, objectId);
                }
            }
        }
        public List <StoreObjectId> GetMessageIdsForPreread(IConversationTree tree)
        {
            List <StoreObjectId> list = new List <StoreObjectId>(1);

            foreach (IConversationTreeNode conversationTreeNode in tree)
            {
                bool flag = false;
                if (!conversationTreeNode.HasChildren)
                {
                    flag = true;
                }
                else if (conversationTreeNode.GetValueOrDefault <byte[]>(ItemSchema.BodyTag, null) == null)
                {
                    flag = true;
                }
                if (flag)
                {
                    list.Add(conversationTreeNode.MainStoreObjectId);
                }
            }
            return(list);
        }
Esempio n. 27
0
        public ConversationFamily CreateConversation(ConversationId conversationId, IList <StoreObjectId> folderIds, bool useFolderIdsAsExclusionList, bool isIrmEnabled, bool isSmimeSupported, string domainName, params PropertyDefinition[] requestedProperties)
        {
            Util.ThrowOnNullArgument(conversationId, "conversationId");
            HashSet <PropertyDefinition> hashSet = this.conversationFamilyTreeFactory.CalculatePropertyDefinitionsToBeLoaded(requestedProperties);
            List <IStorePropertyBag>     list    = this.membersQuery.Query(this.ConversationFamilyId, hashSet, folderIds, useFolderIdsAsExclusionList);
            Dictionary <object, List <IStorePropertyBag> > dictionary = this.membersQuery.AggregateMembersPerField(ItemSchema.ConversationId, this.ConversationFamilyId, list);
            List <IStorePropertyBag> list2;

            if (!dictionary.TryGetValue(conversationId, out list2))
            {
                list2 = new List <IStorePropertyBag>();
                dictionary.Add(conversationId, list2);
            }
            IConversationTree         conversationTree = this.SelectedConversationTreeFactory.Create(list2, hashSet);
            ConversationDataExtractor dataExtractor    = this.dataExtractorFactory.Create(isIrmEnabled, hashSet, conversationId, conversationTree, isSmimeSupported, domainName);

            if (dictionary.Count > 1)
            {
                IConversationTree conversationFamilyTree = this.conversationFamilyTreeFactory.Create(list, hashSet);
                return(this.InternalCreateConversationFamilyWithSeveralConversations(dataExtractor, conversationFamilyTree, conversationId, conversationTree));
            }
            return(this.InternalCreateConversationFamilyWithSingleConversation(dataExtractor, conversationTree));
        }
Esempio n. 28
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);
            }
        }
        public IStorePropertyBag ConstructThreadAggregatedProperties(IConversationTree threadTree)
        {
            PropertyAggregationContext context = new PropertyAggregationContext(threadTree.StorePropertyBags.ToList <IStorePropertyBag>());

            return(ApplicationAggregatedProperty.Aggregate(context, this.propertiesToAggregate));
        }
 internal ConversationThreadDataExtractor(ICollection <PropertyDefinition> propertiesToAggregate, IConversationTree conversationTree, bool isSingleThreadConversation)
 {
     this.conversationTree           = conversationTree;
     this.isSingleThreadConversation = isSingleThreadConversation;
     this.propertiesToAggregate      = propertiesToAggregate;
 }