예제 #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();
        }
예제 #2
0
        public void Insert_New_Scenario()
        {
            var container = Container.Init_Container();
            var service = container.Resolve<ScenarioService>();

            var cmd = new Create_Scenario
            {

            };
            service.Create_Scenario(cmd);
        }
예제 #3
0
        public void Test_Algorithm_Random()
        {
            var container = Container.Init_Container().Configure_Raven_For_Testing();

            var service = container.Resolve<ScenarioService>();
            var documentStore = container.Resolve<IDocumentSession>();

            var cmd = new Create_Scenario
            {
                Scenario = Test_Helper.Build_Random_Scenario()
            };

            service.Create_Scenario(cmd);

            var scenario = documentStore.Query<Routing.Domain.Aggregates.Scenario>().First();

            service.Execute_Simulation(new Execute_Simulation { Algorithm = Algorithm.Random, ScenarioId = scenario.Id });
        }
예제 #4
0
 //[PrincipalPermission(SecurityAction.Demand)]
 public void Create_Scenario(Create_Scenario command)
 {
     Service.Create_Scenario(command);
 }
예제 #5
0
 public ActionResult Create_Scenario(Create_Scenario cmd)
 {
     return View();
 }