Exemple #1
0
        private IMessage UpdateCollection(UpdateCollectionMessage updateCollectionMessage, IList messages)
        {
            IList updateCollectionRanges = updateCollectionMessage.body as IList;

            for (int i = 0; i < updateCollectionRanges.Count; i++)
            {
                UpdateCollectionRange updateCollectionRange = updateCollectionRanges[i] as UpdateCollectionRange;
                for (int j = 0; j < updateCollectionRange.identities.Length; j++)
                {
                    string   messageId = updateCollectionRange.identities[j] as string;
                    Identity identity  = null;
                    if (messageId != null)
                    {
                        //Search for previous Create or CreateAndSequence
                        //This was a "pending update collection" sent from the client and it must be replaced by the actual Identity
                        IMessage    refMessage  = GetMessage(messages, messageId);
                        DataMessage dataMessage = refMessage as DataMessage;
                        if (dataMessage != null)
                        {
                            DataDestination dataDestination = this.Destination as DataDestination;
                            identity = Identity.GetIdentity(dataMessage.body, dataDestination);
                        }
                        //replace with the actual identity
                        updateCollectionRange.identities[j] = identity;
                    }
                    else
                    {
                        IDictionary identityMap = updateCollectionRange.identities[j] as IDictionary;
                        if (identityMap != null)
                        {
                            identity = new Identity(identityMap);
                        }
                    }

                    IList fillParameters = updateCollectionMessage.collectionId as IList;

                    IAssembler assembler = GetAssembler();
                    if (assembler != null)
                    {
                        if (updateCollectionRange.updateType == UpdateCollectionRange.InsertIntoCollection)
                        {
                            assembler.AddItemToFill(fillParameters, updateCollectionRange.position + j, identity);
                        }
                        if (updateCollectionRange.updateType == UpdateCollectionRange.DeleteFromCollection)
                        {
                            assembler.RemoveItemFromFill(fillParameters, updateCollectionRange.position, identity);
                        }
                    }
                }
            }
            return(updateCollectionMessage);
        }
Exemple #2
0
        private IMessage UpdateCollection(UpdateCollectionMessage updateCollectionMessage, IList messages)
        {
            IList body = updateCollectionMessage.body as IList;

            for (int i = 0; i < body.Count; i++)
            {
                UpdateCollectionRange range = body[i] as UpdateCollectionRange;
                for (int j = 0; j < range.identities.Length; j++)
                {
                    string   messageId = range.identities[j] as string;
                    Identity identity  = null;
                    if (messageId != null)
                    {
                        DataMessage message = this.GetMessage(messages, messageId) as DataMessage;
                        if (message != null)
                        {
                            DataDestination destination = base.Destination as DataDestination;
                            identity = Identity.GetIdentity(message.body, destination);
                        }
                        range.identities[j] = identity;
                    }
                    else
                    {
                        IDictionary map = range.identities[j] as IDictionary;
                        if (map != null)
                        {
                            identity = new Identity(map);
                        }
                    }
                    IList      collectionId = updateCollectionMessage.collectionId;
                    IAssembler assembler    = this.GetAssembler();
                    if (assembler != null)
                    {
                        if (range.updateType == 0)
                        {
                            assembler.AddItemToFill(collectionId, range.position + j, identity);
                        }
                        if (range.updateType == 1)
                        {
                            assembler.RemoveItemFromFill(collectionId, range.position, identity);
                        }
                    }
                }
            }
            return(updateCollectionMessage);
        }