internal KeyValuePair <List <StoreObjectId>, List <StoreObjectId> > CalculateChanges(byte[] otherSerializedState)
        {
            Util.ThrowOnNullOrEmptyArgument(otherSerializedState, "otherSerializedState");
            MiniStateTreeNode right = MiniStateTreeNode.DeSerialize(otherSerializedState);
            KeyValuePair <List <long>, List <long> > affectedIds = this.treeNode.GetAffectedIds(right);
            KeyValuePair <List <StoreObjectId>, List <StoreObjectId> > result = new KeyValuePair <List <StoreObjectId>, List <StoreObjectId> >(new List <StoreObjectId>(affectedIds.Key.Count), new List <StoreObjectId>(affectedIds.Value.Count));

            for (int i = 0; i < affectedIds.Key.Count; i++)
            {
                result.Key.Add(this.hashToIdMap[affectedIds.Key[i]]);
            }
            for (int j = 0; j < affectedIds.Value.Count; j++)
            {
                result.Value.Add(this.hashToIdMap[affectedIds.Value[j]]);
            }
            foreach (IConversationTreeNode conversationTreeNode in this.conversationTree)
            {
                ConversationTreeNode conversationTreeNode2 = (ConversationTreeNode)conversationTreeNode;
                foreach (StoreObjectId storeObjectId in conversationTreeNode2.ToListStoreObjectId())
                {
                    bool valueOrDefault = conversationTreeNode2.GetValueOrDefault <bool>(storeObjectId, MessageItemSchema.IsDraft, false);
                    if (valueOrDefault && !result.Key.Contains(storeObjectId) && !result.Value.Contains(storeObjectId))
                    {
                        result.Value.Add(storeObjectId);
                    }
                }
            }
            return(result);
        }
示例#2
0
 public override bool UpdatePropertyBag(StoreObjectId itemId, IStorePropertyBag bag)
 {
     for (int i = 0; i < this.storePropertyBags.Count; i++)
     {
         if (ConversationTreeNode.RetrieveStoreObjectId(this.storePropertyBags[i]).Equals(itemId))
         {
             this.storePropertyBags[i] = bag;
             return(true);
         }
     }
     return(false);
 }
示例#3
0
 public override List <StoreObjectId> ToListStoreObjectId()
 {
     if (this.ids == null)
     {
         this.ids = new List <StoreObjectId>();
         if (this.HasData)
         {
             foreach (IStorePropertyBag bag in this.StorePropertyBags)
             {
                 this.ids.Add(ConversationTreeNode.RetrieveStoreObjectId(bag));
             }
         }
     }
     return(this.ids);
 }
示例#4
0
 public override bool TryGetPropertyBag(StoreObjectId itemId, out IStorePropertyBag bag)
 {
     bag = null;
     if (!this.HasData || itemId == null)
     {
         return(false);
     }
     foreach (IStorePropertyBag storePropertyBag in this.StorePropertyBags)
     {
         if (itemId.Equals(ConversationTreeNode.RetrieveStoreObjectId(storePropertyBag)))
         {
             bag = storePropertyBag;
             return(true);
         }
     }
     return(false);
 }
 public static void FixupConversationMessagesCreatorSid(MailboxSession mailboxSession, ConversationIndex conversationIndex, byte[] conversationCreatorSid)
 {
     ConversationCreatorHelper.ConversationCreatorDefinitionData conversationCreatorDefinitionData = new ConversationCreatorHelper.ConversationCreatorDefinitionData(mailboxSession, conversationIndex);
     foreach (IConversationTreeNode conversationTreeNode in conversationCreatorDefinitionData.Conversation.ConversationTree)
     {
         ConversationTreeNode conversationTreeNode2 = (ConversationTreeNode)conversationTreeNode;
         foreach (StoreObjectId storeId in conversationTreeNode2.ToListStoreObjectId())
         {
             using (Item item = Item.Bind(mailboxSession, storeId, null))
             {
                 item.OpenAsReadWrite();
                 item.SetOrDeleteProperty(ItemSchema.ConversationCreatorSID, conversationCreatorSid);
                 item.Save(SaveMode.ResolveConflicts);
             }
         }
     }
 }
        private void RecursiveLoadBodyFragments(IConversationTree conversationTree, IConversationTreeNode treeNode, ICollection <StoreObjectId> itemPartsToLoad, out bool forceParentLoadBodyFragment)
        {
            IStorePropertyBag storePropertyBag = null;
            StoreObjectId     storeObjectId    = null;

            forceParentLoadBodyFragment = false;
            if (treeNode.HasData)
            {
                foreach (IStorePropertyBag storePropertyBag2 in treeNode.StorePropertyBags)
                {
                    StoreObjectId objectId = ((VersionedId)storePropertyBag2.TryGetProperty(ItemSchema.Id)).ObjectId;
                    storePropertyBag = storePropertyBag2;
                    storeObjectId    = objectId;
                    if (itemPartsToLoad == null || itemPartsToLoad.Contains(objectId))
                    {
                        forceParentLoadBodyFragment = true;
                        break;
                    }
                }
            }
            BodyFragmentInfo bodyFragmentInfo = null;
            bool             flag             = false;
            bool             flag2            = false;

            foreach (IConversationTreeNode conversationTreeNode in treeNode.ChildNodes)
            {
                ConversationTreeNode conversationTreeNode2 = (ConversationTreeNode)conversationTreeNode;
                bool flag3;
                this.RecursiveLoadBodyFragments(conversationTree, conversationTreeNode2, itemPartsToLoad, out flag3);
                flag2 = (flag2 || flag3);
                if (storePropertyBag != null)
                {
                    if (this.itemParts.ContainsKey(storeObjectId))
                    {
                        flag             = true;
                        bodyFragmentInfo = (this.treeNodeBodyFragment.ContainsKey(treeNode.MainStoreObjectId) ? this.treeNodeBodyFragment[treeNode.MainStoreObjectId].Key : null);
                    }
                    else if (this.treeNodeBodyFragment.ContainsKey(conversationTreeNode2.MainStoreObjectId))
                    {
                        ExtractionData extractionData;
                        this.IsBodyPartPresent(this.treeNodeBodyFragment[conversationTreeNode2.MainStoreObjectId].Key, storePropertyBag, out extractionData);
                        if (extractionData != null && extractionData.BodyFragment != null)
                        {
                            if (!flag && extractionData.IsFormatReliable)
                            {
                                bodyFragmentInfo = extractionData.BodyFragment;
                                flag             = true;
                            }
                            else if (bodyFragmentInfo == null)
                            {
                                bodyFragmentInfo = extractionData.BodyFragment;
                            }
                        }
                    }
                }
            }
            if (!treeNode.HasData)
            {
                return;
            }
            bool flag4 = false;

            if (itemPartsToLoad != null && itemPartsToLoad.Contains(storeObjectId) && !flag)
            {
                flag4 = true;
            }
            else if (bodyFragmentInfo == null && (forceParentLoadBodyFragment || flag2))
            {
                flag4 = true;
            }
            if (flag4 && !this.loadedItemParts.ContainsKey(storeObjectId))
            {
                this.LoadItemPart(conversationTree, storePropertyBag);
            }
            if (this.loadedItemParts.ContainsKey(storeObjectId))
            {
                LoadedItemPart loadedItemPart = this.loadedItemParts[storeObjectId];
                if (this.InternalHasIrmFailed(storeObjectId))
                {
                    bodyFragmentInfo = null;
                }
                else
                {
                    bodyFragmentInfo = loadedItemPart.BodyFragmentInfo;
                    flag             = true;
                }
            }
            if (bodyFragmentInfo != null)
            {
                this.treeNodeBodyFragment[treeNode.MainStoreObjectId] = new KeyValuePair <BodyFragmentInfo, bool>(bodyFragmentInfo, flag);
            }
        }