Example #1
0
        public Task <DeliveryOutput> DeliverAsync(IFileManager fileManager, Delivery deliveryInfo)
        {
            Id       = deliveryInfo.DroneId;
            delivery = deliveryInfo;

            if (delivery.Routes.Count > CAPACITY)
            {
                throw new TransportException("Drone capacity exceeded.", Id);
            }

            return(Task.Run(() =>
            {
                var locations = new List <Location>();
                foreach (var route in delivery.Routes)
                {
                    while (route.MoveNext())
                    {
                        Move(route.Current);
                    }
                    locations.Add((Location)CurrentLocation.Clone());
                }

                var result = new DeliveryOutput(locations, Id, fileManager);

                return result;
            }));
        }
Example #2
0
        private async Task ManageFailedTaskAsync(Task finishedTask)
        {
            var concreteException = (ExceptionBase)finishedTask.Exception.InnerException;
            var deliveryOutput    = new DeliveryOutput(concreteException, fileManager);

            DeliveryStatus.Add(deliveryOutput.DroneId, deliveryOutput);

            // Save file with output information
            await deliveryOutput.SaveAsync();
        }