Exemple #1
0
        public void Create_Scenario(Create_Scenario cmd)
        {
            var scenarioDto = cmd.Scenario;

            var destinationIds = scenarioDto.Deliveries.Select(o => o.Known_Destination_Id);
            var destinations = DocumentSession.Advanced.LuceneQuery<Destination>().WhereIn("Id", destinationIds).ToList();

            //foreach (var order in scenarioDto.Deliveries)
            //{
            //    if (order.DestinationExternalId.IsNullOrEmpty())
            //        continue;
            //    var destination = new Destination
            //    {
            //        Id = order.Known_Destination_Id,
            //        Name = "None",
            //        ExternalId = order.DestinationExternalId,
            //        UserId = scenarioDto.UserId,
            //        Location = new Location(order.Latitude, order.Longitude),
            //        Address = Address.Parse(order.Address),
            //    };
            //    //DocumentSession.Store(destination);
            //    destinations.Add(destination);
            //}

            var scenario = new Scenario
            {
                //Id = scenarioDto.Id,
                UserId = scenarioDto.UserId,
                Created = DateTime.Now,
                Date = scenarioDto.Date,
                Name = scenarioDto.Name,

                Deliveries = scenarioDto.Deliveries.Select(o => new Delivery
                {
                    ExternalId = o.ExternalId,
                    Known_Destination = destinations.Where(d => d.Id == o.Known_Destination_Id).DefaultIfEmpty(Destination.Empty).SingleOrDefault(),

                    Volume = new Quantity(o.Volume, new Unit(o.Volume_Unit)),
                    Weight = new Quantity(o.Weight, new Unit(o.Weight_Unit)),
                    Location = new Location(o.Latitude, o.Longitude),
                    Address = Address.Parse(o.Address),
                }).ToList(),

                Distances = scenarioDto.Distances.Select(d => new Distance
                {
                    From = new Location(d.From_Latitide, d.From_Longitude),
                    To = new Location(d.To_Latitide, d.To_Longitude),
                    Km = d.Km,
                    Time = TimeSpan.FromSeconds(d.TimeInSeconds)
                }).ToList(),

            };

            DocumentSession.Store(scenario);

            DocumentSession.SaveChanges();
        }
 public Routing_Algorithm(Scenario scenario)
 {
     Scenario = scenario;
 }
Exemple #3
0
 public Algorithm_Dummy(Scenario scenario)
     : base(scenario)
 {
 }
Exemple #4
0
 public Algorithm_Random(Scenario scenario)
     : base(scenario)
 {
 }