Пример #1
0
        public void Deliver(IDistributable distributable)
        {
            var endpoints = _endpointRepository.GetEndpointsForProfile(distributable.ProfileName);

            foreach (var endpoint in endpoints)
            {
                try
                {
                    DeliverToEndpoint((TDistributable)distributable, endpoint);

                    _deliveryRepository?.RecordDelivery(new Delivery(distributable.Id, endpoint.Id));

                    OnSuccess((TDistributable)distributable, endpoint);

                    //TODO: Mark file as delivered to endpoint.
                    //Not all deliveries may be idempotent so we only ever want to deliver a file once.
                }
                catch (Exception exception)
                {
                    //Call virtual OnError method and then continue to the next endpoint delivery.
                    OnError((TDistributable)distributable, endpoint, exception);
                }
            }
        }