Beispiel #1
0
        private AcknowledgeMessage ExecuteMultiBatchOperation(IMessage message)
        {
            //May contain multiple batched, create, update or delete operations that involve
            //more than one destination, that is, more than one remote adapter
            AcknowledgeMessage responseMessage = null;
            DataMessage        dataMessage     = message as DataMessage;
            IList messages = dataMessage.body as IList;

            DataServiceTransaction dataServiceTransaction = DataServiceTransaction.Begin(this);

            dataServiceTransaction.ClientId = message.clientId as string;
            //correlate al generated messages
            dataServiceTransaction.CorrelationId = message.messageId;

            string    currentDestination  = null;
            ArrayList currentMessageBatch = new ArrayList();

            for (int i = 0; i < messages.Count; i++)
            {
                DataMessage     batchMessage    = messages[i] as DataMessage;
                string          destination     = batchMessage.destination;
                DataDestination dataDestination = GetDestination(batchMessage) as DataDestination;

                if (currentDestination != null && destination != currentDestination &&
                    currentMessageBatch.Count > 0)
                {
                    MessageBatch messageBatch = ServiceBatch(message, currentMessageBatch);
                    dataServiceTransaction.AddProcessedMessageBatch(messageBatch);
                    currentMessageBatch = new ArrayList();
                }
                currentMessageBatch.Add(batchMessage);
                currentDestination = destination;

                if (batchMessage is UpdateCollectionMessage)
                {
                    dataServiceTransaction.AddClientUpdateCollection(batchMessage as UpdateCollectionMessage);
                }
            }
            if (currentMessageBatch.Count > 0)
            {
                MessageBatch messageBatch = ServiceBatch(message, currentMessageBatch);
                dataServiceTransaction.AddProcessedMessageBatch(messageBatch);
            }

            dataServiceTransaction.Commit();
            IList outgoingMessages = dataServiceTransaction.GetOutgoingMessages();

            responseMessage = new AcknowledgeMessage();
            object[] result = new object[outgoingMessages.Count];
            outgoingMessages.CopyTo(result, 0);
            responseMessage.body = result;            //outgoingMessages.ToArray(typeof(object));
            return(responseMessage);
        }
Beispiel #2
0
        private AcknowledgeMessage ExecuteMultiBatchOperation(IMessage message)
        {
            AcknowledgeMessage message2 = null;
            MessageBatch       batch;
            DataMessage        message3 = message as DataMessage;
            IList body = message3.body as IList;
            DataServiceTransaction transaction = DataServiceTransaction.Begin(this);

            transaction.ClientId      = message.clientId as string;
            transaction.CorrelationId = message.messageId;
            string    str      = null;
            ArrayList messages = new ArrayList();

            for (int i = 0; i < body.Count; i++)
            {
                DataMessage     message4    = body[i] as DataMessage;
                string          str2        = message4.destination;
                DataDestination destination = base.GetDestination(message4) as DataDestination;
                if (((str != null) && (str2 != str)) && (messages.Count > 0))
                {
                    batch = this.ServiceBatch(message, messages);
                    transaction.AddProcessedMessageBatch(batch);
                    messages = new ArrayList();
                }
                messages.Add(message4);
                str = str2;
                if (message4 is UpdateCollectionMessage)
                {
                    transaction.AddClientUpdateCollection(message4 as UpdateCollectionMessage);
                }
            }
            if (messages.Count > 0)
            {
                batch = this.ServiceBatch(message, messages);
                transaction.AddProcessedMessageBatch(batch);
            }
            transaction.Commit();
            IList outgoingMessages = transaction.GetOutgoingMessages();

            message2 = new AcknowledgeMessage();
            object[] array = new object[outgoingMessages.Count];
            outgoingMessages.CopyTo(array, 0);
            message2.body = array;
            return(message2);
        }