Esempio n. 1
0
        private HashSet <StoreObjectId> GetLocalItemIds(StoreObjectId localFolderId)
        {
            HashSet <StoreObjectId> hashSet = new HashSet <StoreObjectId>();

            foreach (IConversationTreeNode conversationTreeNode in this.ConversationTree)
            {
                foreach (StoreObjectId storeObjectId in conversationTreeNode.ToListStoreObjectId())
                {
                    StoreObjectId valueOrDefault = conversationTreeNode.GetValueOrDefault <StoreObjectId>(storeObjectId, StoreObjectSchema.ParentItemId, null);
                    if (localFolderId == null || localFolderId.CompareTo(valueOrDefault) == 0)
                    {
                        hashSet.Add(storeObjectId);
                    }
                }
            }
            if (hashSet.Count == 0 && localFolderId != null)
            {
                using (Folder folder = Folder.Bind(this.session, localFolderId))
                {
                    SearchFolder searchFolder = folder as SearchFolder;
                    if (searchFolder != null)
                    {
                        using (QueryResult queryResult = searchFolder.ConversationItemQuery(null, new SortBy[]
                        {
                            new SortBy(ConversationItemSchema.ConversationId, SortOrder.Ascending)
                        }, new PropertyDefinition[]
                        {
                            ConversationItemSchema.ConversationItemIds
                        }))
                        {
                            if (queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ConversationItemSchema.ConversationId, this.ConversationId)))
                            {
                                IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(1);
                                if (propertyBags.Length > 0)
                                {
                                    StoreObjectId[] array = propertyBags[0].TryGetProperty(ConversationItemSchema.ConversationItemIds) as StoreObjectId[];
                                    if (array != null)
                                    {
                                        foreach (StoreObjectId item in array)
                                        {
                                            hashSet.Add(item);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(hashSet);
        }