Ejemplo n.º 1
0
        public virtual GatewayResponse Send(string sessionData, IEnumerable <Message> messages)
        {
            if (messages.Count() == 0)
            {
                throw new ArgumentException("Message list must contain at least one message", "messages");
            }

            var result = new GatewayResponse();

            var thisBatchSize = BatchSize > 0 ? BatchSize : messages.Count();

            var skip = 0;

            while (messages.Count() > skip)
            {
                var messageList     = messages.Skip(skip).Take(thisBatchSize).ToList();
                var transportResult = Transport.Send(BuildPayload(sessionData, messageList));
                var batchResults    = ParseTransportResults(messageList, transportResult);
                result.Results = result.Results == null ? batchResults : result.Results.Union(batchResults);
                skip          += thisBatchSize;
            }

            return(result);
        }