public ActionResult DeleteConfirmed(int id) { route route = db.routes.Find(id); db.routes.Remove(route); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "route_id,source,destination")] route route) { if (ModelState.IsValid) { db.Entry(route).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(route)); }
// // GET: /route/Delete/5 public ActionResult Delete(int id = 0) { route route = db.route.Find(id); if (route == null) { return(HttpNotFound()); } return(View(route)); }
private GameObject getIdleMover(route route) { GameObject[] movers = GameObject.FindGameObjectsWithTag("mover"); try { GameObject result = harvestableRessource.GetClosestMover(movers, true, route.getTarget().transform).gameObject; return(result); } catch (NullReferenceException ex) { return(null); } }
public List <Point> GetRoutePoint(string loginName, string routeName) { waterdataEntities entity = new waterdataEntities(); users objuser = entity.users.SingleOrDefault(s => s.login_name == loginName); route objroute = entity.route.SingleOrDefault(s => s.route_name == routeName && s.user_id == objuser.user_id); List <Point> points = new List <Point>(); string pointstr = objroute.route_points; points = JsonConvert.DeserializeObject <List <Point> >(pointstr); return(points); }
public ActionResult Edit(route route) { if (ModelState.IsValid) { db.Entry(route).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.requisition = new SelectList(db.requisition, "id", "description", route.requisition); return(View(route)); }
// // GET: /route/Edit/5 public ActionResult Edit(int id = 0) { route route = db.route.Find(id); if (route == null) { return(HttpNotFound()); } ViewBag.requisition = new SelectList(db.requisition, "id", "description", route.requisition); return(View(route)); }
/// </summary> private void RouteList_SelectionChanged(object sender, SelectionChangedEventArgs e) { // if an item is selected if (RouteList.SelectedIndex != -1) { // get the currently selected city and pass the information to the // forecast details page route route = (route)RouteList.SelectedItem; this.NavigationService.Navigate(new Uri("/StopsPage.xaml?RouteId=" + route.RouteId, UriKind.Relative)); } }
public ActionResult Edit([Bind(Include = "ID_route,destination,departure_time,route_number,days_of_movement,distance,ticket_price,ID_stopping")] route route) { if (ModelState.IsValid) { db.Entry(route).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_stopping = new SelectList(db.stopping, "ID_stopping", "stop_name", route.ID_stopping); return(View(route)); }
public ActionResult Create([Bind(Include = "id,length,numOfLocation")] route route) { if (ModelState.IsValid) { db.routes.Add(route); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(route)); }
public ActionResult Create(route route) { if (ModelState.IsValid) { db.route.Add(route); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.requisition = new SelectList(db.requisition, "id", "description", route.requisition); return(View(route)); }
public bool RouteChange(string taskName, string routeName, string loginName, string shipName) { waterdataEntities entity = new waterdataEntities(); users objuser = entity.users.SingleOrDefault(s => s.login_name == loginName); task mytask = entity.task.SingleOrDefault(s => s.task_name == taskName && s.user_id == objuser.user_id); route route = entity.route.SingleOrDefault(s => s.route_name == routeName && s.user_id == objuser.user_id); ship ship = entity.ship.SingleOrDefault(s => s.ship_name == shipName && s.company_id == objuser.company_id); mytask.ship_id = ship.ship_id; mytask.route_id = route.route_id; entity.SaveChanges(); return(true); }
/// <summary> /// APP获取最新路径 /// </summary> /// <param name="shipId"></param> /// <returns></returns> public AppRoute AppGetLastRoute(int shipId) { waterdataEntities entity = new waterdataEntities(); task lastTask = entity.task.Where(s => s.ship_id == shipId).OrderByDescending(s => s.create_time).First(); route lastRoute = entity.route.SingleOrDefault(s => s.route_id == lastTask.route_id); AppRoute Route = new AppRoute() { RoueteId = lastRoute.route_id.ToString(), RoueteName = lastRoute.route_name, RoutePoints = lastRoute.route_points }; return(Route); }
// GET: /Route/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } route route = db.routes.Find(id); if (route == null) { return(HttpNotFound()); } return(View(route)); }
public ActionResult Create([Bind(Include = "route_id,source,destination")] route route) { ViewBag.source = new SelectList(db.locations, "location_name", "location_name"); ViewBag.destination = new SelectList(db.locations, "location_name", "location_name"); if (ModelState.IsValid) { db.routes.Add(route); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(route)); }
public ActionResult Create(RouteM xx) { BusdbEntities db = new BusdbEntities(); route r = new route(); r.rid = xx.Routeid; r.from_location = xx.FromLocation; r.to_location = xx.ToLocation; db.routes.Add(r); db.SaveChanges(); return(RedirectToAction("index")); }
public String saveJson(string value, string name) { using (var webClient = new WebClient()) { try { var jsonContent = webClient.DownloadString(value); var SteamDetails = JsonConvert.DeserializeObject <dynamic>(jsonContent); var coords = SteamDetails.trips[0].geometry.coordinates; var distance = SteamDetails.trips[0].distance; if (distance == 0) { return("Error"); } route newRoute = new route(); newRoute.id = db.routes.Count() == 0 ? 0 : (db.routes.Max(l => l.id) + 1); newRoute.length = 1; newRoute.numOfLocation = coords.Count; newRoute.name = name; db.routes.Add(newRoute); db.SaveChanges(); foreach (var point in coords) { Point newPoint = new Point(); newPoint.id = db.Points.Count() == 0 ? 0 : (db.Points.Max(l => l.id) + 1); newPoint.latitude = point[1]; newPoint.longitude = point[0]; newPoint.route_id = newRoute.id; db.routes.Find(newRoute.id).Points.Add(newPoint); db.Points.Add(newPoint); db.SaveChanges(); } db.SaveChanges(); } catch (WebException wex) { return("Error"); } } return(value.ToString()); //var states = ((JObject)value["states"]["2009"]).Properties().Select(x => new { StateCode = x.Name, //Rate = Convert.ToDecimal(x.Value.ToString()) }); }
private void checkDestroyed(route route) { if (route.getOrigin() == null || route.getTarget() == null) { if (route is routeSolotype) { routes.Remove((routeSolotype)route); } else { routesAllType.Remove((routeAllType)route); } } }
// GET: routes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } route route = db.route.Find(id); if (route == null) { return(HttpNotFound()); } ViewBag.ID_stopping = new SelectList(db.stopping, "ID_stopping", "stop_name", route.ID_stopping); return(View(route)); }
public batiment(int t) { type = t; reseau = 0; mag = new magasin(10, 5, 1); maison = new maison(10); route = new route(10); ferme = new ferme(10, 10, 1); mine = new mine(12, 12, 1); scierie = new scierie(12, 12, 1); monu = new monument(100, 100, 100); ecole = new ecole(20, 20, 20); entrepos = new entrepos(10, 5, 10); gardeManger = new gardeManger(10, 5, 10); maison2 = new maison2(10); }
public void Initialise(route route) { startPos = player.transform.position; steps = new Queue <BannerStep>(); foreach (leg currentLeg in route.legs) { eta = DateTime.Now.AddSeconds(currentLeg.duration);// currentLeg.duration; foreach (step currentStep in currentLeg.steps) { steps.Enqueue(new BannerStep(currentStep.maneuver, currentStep.distance)); } } start = true; }
public JsonResult Edit(int id) { Dictionary <string, object> result = new Dictionary <string, object>(); try { route route = _dbContext.routes.Find(id); serializeToModel(ref route); _dbContext.SaveChanges(); } catch (Exception exc) { result.Add("error", exc.Message); } return(Json(result, JsonRequestBehavior.DenyGet)); }
private void serializeToModel(ref route route) { if (Request.Form["from_airport_id"] == "") { route.from_airport_id = null; } else { route.from_airport_id = int.Parse(Request.Form["from_airport_id"]); } if (Request.Form["to_airport_id"] == "") { route.to_airport_id = null; } else { route.to_airport_id = int.Parse(Request.Form["to_airport_id"]); } if (Request.Form["starting_address"] == "") { route.starting_address = null; } else { route.starting_address = Request.Form["starting_address"]; } if (Request.Form["distance"] == "") { route.distance = null; } else { route.distance = int.Parse(Request.Form["distance"]); } route.type = Request.Form["type"]; route.starting_time = TimeSpan.Parse(Request.Form["starting_time"]); route.final_address = Request.Form["final_address"]; route.duration = int.Parse(Request.Form["duration"]); route.total_seats = int.Parse(Request.Form["total_seats"]); route.cost = int.Parse(Request.Form["cost"]); }
/// <summary> /// 添加路径 /// </summary> /// <param name="routeName"></param> /// <param name="userId"></param> /// <param name="point"></param> /// <returns></returns> public bool AddRoute(string routeName, int userId, string point) { waterdataEntities entity = new waterdataEntities(); route route = entity.route.FirstOrDefault(s => s.route_name == routeName && s.user_id == userId); if (route != null) { return(false); } route newRoute = new route() { user_id = userId, route_name = routeName, route_points = point }; entity.route.Add(newRoute); entity.SaveChanges(); return(true); }
public bool UpdateRoute(string routeName, string loginName, string newrouteName) { waterdataEntities entity = new waterdataEntities(); entity.Configuration.ValidateOnSaveEnabled = false; users objuser = entity.users.SingleOrDefault(s => s.login_name == loginName); bool result = false; route myroute = entity.route.SingleOrDefault(s => s.route_name == newrouteName); if (myroute == null) { route objroute = entity.route.SingleOrDefault(s => s.user_id == objuser.user_id && s.route_name == newrouteName); if (newrouteName != null) { objroute.route_name = newrouteName; result = true; } entity.SaveChanges(); } return(result); }
private void serializeToTransferModel(ref transfer transfer) { route route = null; if (Request.Form["route_id"] != "") { transfer.route_id = int.Parse(Request.Form["route_id"]); route = _dbContext.routes.Find(transfer.route_id); } else { transfer.route_id = null; } transfer.starting_date = DateTime.Parse(Request.Form["starting_date"]); transfer.created_at = Utils.dtToTimestamp(DateTime.Now); transfer.callout_id = int.Parse(Request.Form["callout_id"]); transfer.is_baby = Request.Form["is_baby"] == "on" ? 1 : 0; transfer.is_baggage = Request.Form["is_baggage"] == "on" ? 1 : 0; transfer.payment = 0; if (route != null) { transfer.payment = route.cost; } if (transfer.is_baggage == 1) { transfer.payment += transfer.payment / 10; } if (transfer.is_baby == 1) { transfer.payment = 0; } }
public void Recalculate() { int firstsector, lastsector; firstsector = lees(From.Text); lastsector = lees(To.Text); if (firstsector == 0 || lastsector == 0) { Results.Text = "Please fill in <From> and <To> with sector numbers"; return; } route MyRoute = plotter.plot_course(firstsector, lastsector, toegelaten, !checkBox1.Checked); string Resulttext; if (MyRoute == null) { Results.Text = "No route has been found between " + firstsector + " and " + lastsector + " with the current settings."; return; } Resulttext = "Shortest route goes through " + MyRoute.length + " sectors, " + MyRoute.warps + " warps and it takes " + MyRoute.totalturns + " turns."; int curgalaxy = 0; foreach (int sector in MyRoute.sectors) { if (everything.getgalaxynum(sector) != curgalaxy) { Resulttext += "\n\n" + everything.getgalaxyname(everything.getgalaxynum(sector)) + " galaxy:\n"; curgalaxy = everything.getgalaxynum(sector); } else { Resulttext += " - "; } Resulttext += sector.ToString(); } Results.Text = Resulttext; }
public JsonResult Delete(int id) { Dictionary <string, object> result = new Dictionary <string, object>(); try { route route = _dbContext.routes.Find(id); if (route != null) { _dbContext.routes.Remove(route); _dbContext.SaveChanges(); } else { result.Add("error", "Маршрут не найден"); } } catch (Exception exc) { result.Add("error", exc.Message); } return(Json(result, JsonRequestBehavior.DenyGet)); }
public void bruteFindFastest(List<node> nodes, node startnode) { int[] nodeIDlist = new int[nodes.Count() - 1]; float[,] distancelist = this.distanceList(nodes); int numperms = this.FactNum(nodes.Count() - 1); int[] fastestpath = new int[nodes.Count()]; int[] currentpath = new int[nodes.Count()]; route fastestroute; route currentroute; fastestpath[0] = startnode.id; currentpath[0] = startnode.id; int count = 0; for (int i = 0; i < nodes.Count(); i++) { if (nodes[i].id != startnode.id) { nodeIDlist[count] = nodes[i].id; count++; } } nodeIDlist.CopyTo(fastestpath, 1); fastestroute = new route(distancelist, fastestpath); for (int i = 0; i < numperms - 1; i++) { nodeIDlist = NextPermutation(nodeIDlist); nodeIDlist.CopyTo(currentpath, 1); currentroute = new route(distancelist, currentpath); if (currentroute.netdistance < fastestroute.netdistance) { currentpath.CopyTo(fastestpath, 0); fastestroute = new route(distancelist, fastestpath); } } fastestroute.printPath(); Console.WriteLine("\nDistance: " + fastestroute.netdistance); Console.WriteLine("Traveling from and back to Node# " + startnode.id); }
private void Genetics() { List <route> population = new List <route>(); int pop_size = 1000; int min_dist = int.MaxValue; //create population for (int p = 0; p < pop_size; p++) { route r = new route(); for (int i = 0; i < my_destinations.Count; i++) { r.gene.Add(i); } Shuffle(r.gene); population.Add(r); } for (int i = 0; i < population.Count; i++) { population[i].total_dist = get_dist(population[i].gene); } while (true) { population = population.OrderBy(p => p.total_dist).ToList(); int k = 10; int m = pop_size / k; for (int j = m - 1; j >= 0; j--) { for (int l = j * k; l < (j + 1) * k - 1; l++) { population[l] = new route(population[j]); } } Console.WriteLine(population[0].total_dist); if (population[0].total_dist < min_dist) { min_dist = population[0].total_dist; string rr = ""; for (int j = 0; j < population[0].gene.Count; j++) { rr += "\'" + my_destinations[population[0].gene[j]].ToString() + "\', "; } rr += "\'" + my_destinations[population[0].gene[0]] + "\'"; Console.WriteLine("{0} <----- best", min_dist); Generate_Map(min_dist, rr); } if (population.Count % 2 == 1) { population.Remove(population[population.Count - 1]); } for (int i = 0; i < population.Count; i += 2) { Crossover(ref population[i].gene, ref population[i + 1].gene); if (rng.Next(0, 100) < 25) { mutate(ref population[i].gene); } if (rng.Next(0, 100) < 35) { mutate(ref population[i + 1].gene); } population[i].total_dist = get_dist(population[i].gene); population[i + 1].total_dist = get_dist(population[i + 1].gene); } } }
public JsonResult Suggestions(int id) { double totalPayment = 0; // С вкладки Заявки Админки при клике на заявку сюда приходит id выбранной заявки callout callout = _dbContext.callouts.Where(c => c.id == id).FirstOrDefault(); // Сбор данных о авиабилетах List <object> airticketsList = new List <object>(); foreach (airticket airticket in callout.airtickets) { flight flight = airticket.flight; double payment = 0; if (flight != null) { payment = flight.cost; } if (airticket.is_baggage == 1) { payment += payment * 0.1; } if (airticket.is_baby == 1) { payment = 0; } totalPayment += payment; airticketsList.Add(new { id = airticket.id, created_datetime = Utils.tsToDateTime(airticket.created_at).ToString(Constants.ddMMMyyyyHmmss), departure_at = airticket.departure_at, flight = flight != null ? new { id = flight.id, airline_name = flight.airline.name, code = flight.code, duration = flight.duration, cost = flight.cost, total_seats = flight.total_seats } : null, payment = airticket.payment == 0 ? payment : airticket.payment, is_baggage = airticket.is_baggage, is_baby = airticket.is_baby }); } // Сбор данных о трансферах List <object> transfersList = new List <object>(); foreach (transfer transfer in callout.transfers) { route route = transfer.route; airport fromAirport = null; airport toAirport = null; double payment = 0; if (route != null) { fromAirport = route.airport; toAirport = route.airport1; payment = route.cost; } if (transfer.is_baggage == 1) { payment += payment * 0.1; } if (transfer.is_baby == 1) { payment = 0; } totalPayment += payment; transfersList.Add(new { id = transfer.id, starting_date = transfer.starting_date.ToString(Constants.ddMMMyyyy), created_datetime = Utils.tsToDateTime(transfer.created_at).ToString(Constants.ddMMMyyyyHmmss), is_baggage = transfer.is_baggage, is_baby = transfer.is_baby, payment = transfer.payment == 0 ? payment : transfer.payment, route = route != null ? new { id = route.id, type = route.type, from_airport = fromAirport != null ? new { id = fromAirport.id, name = fromAirport.name, city_name = fromAirport.city.name } : null, to_airport = toAirport != null ? new { id = toAirport.id, name = toAirport.name, city_name = toAirport.city.name } : null, starting_address = route.starting_address, starting_time = route.starting_time.ToString(Constants.hhmmss), final_address = route.final_address, duration = route.duration, total_seats = route.total_seats, distance = route.distance, cost = route.cost, } : null }); } // Сбор данных о желаемых комнатах List <object> calloutRoomsList = new List <object>(); foreach (callout_room calloutRoom in callout.callout_room) { room room = calloutRoom.room; hotel hotel = room.hotel; food food = hotel.food; city city = hotel.city; country country = city.country; int numberNights = calloutRoom.duration / 24; double payment = calloutRoom.room.cost_per_day * numberNights; totalPayment += payment; calloutRoomsList.Add(new { id = calloutRoom.id, created_datetime = Utils.tsToDateTime(calloutRoom.created_at).ToString(Constants.ddMMMyyyyHmmss), start_living_datetime = Utils.tsToDateTime(calloutRoom.start_living_at).ToString(Constants.ddMMMyyyyHmmss), start_living_at = calloutRoom.start_living_at, duration = calloutRoom.duration, payment = calloutRoom.payment == 0 ? payment : calloutRoom.payment, room = new { id = room.id, number = room.number, @class = room.type, seats_number = room.seats_number, room_size = room.room_size, description = room.description, hotel = new { id = hotel.id, name = hotel.name, stars_number = hotel.stars_number, distance_to_beach = hotel.distance_to_beach, food = food != null ? new { id = food.id, type = food.type, description = food.description } : null, city = new { id = city.id, name = city.name, country = new { id = country.id, name = country.name } } } } }); } // Сбор данных об экскурсиях в заявке List <object> excursionOrdersList = new List <object>(); foreach (excursion_order excursionOrder in callout.excursion_order) { excursion excursion = excursionOrder.excursion; double payment = excursion.cost; if (excursionOrder.is_privilege == 1) { payment -= payment * 0.5; } if (excursionOrder.is_baby == 1) { payment = 0; } totalPayment += payment; excursionOrdersList.Add(new { id = excursionOrder.id, created_datetime = Utils.tsToDateTime(excursionOrder.created_at).ToString(Constants.ddMMMyyyyHmmss), starting_address = excursionOrder.starting_address, starting_datetime = Utils.tsToDateTime(excursionOrder.starting_at).ToString(Constants.ddMMMyyyy), starting_at = excursionOrder.starting_at, is_baby = excursionOrder.is_baby, is_privilege = excursionOrder.is_privilege, is_custom = excursionOrder.is_custom, bus_place_number = excursionOrder.bus_place_number, payment = excursionOrder.payment == 0 ? payment : excursionOrder.payment, excursion = new { id = excursion.id, name = excursion.name, starting_time = excursion.starting_time != null ? ((TimeSpan)excursion.starting_time).ToString(Constants.hhmmss) : null, duration = excursion.duration, city_name = excursion.city != null ? excursion.city.name : null, description = excursion.description } }); } // Сбор данных о платных услугах в заявке List <object> hotelServiceOrdersList = new List <object>(); foreach (hotel_service_order hotelServiceOrder in callout.hotel_service_order) { hotel_service service = hotelServiceOrder.hotel_service; double payment = service.cost_per_min * hotelServiceOrder.duration; totalPayment += payment; hotelServiceOrdersList.Add(new { id = hotelServiceOrder.id, created_datetime = Utils.tsToDateTime(hotelServiceOrder.created_at).ToString(Constants.ddMMMyyyyHmmss), provision_datetime = Utils.tsToDateTime(hotelServiceOrder.provision_at).ToString(Constants.ddMMMyyyyHmmss), provision_at = hotelServiceOrder.provision_at, duration = hotelServiceOrder.duration, payment = hotelServiceOrder.payment == 0 ? payment : hotelServiceOrder.payment, room = hotelServiceOrder.room != null ? new { id = hotelServiceOrder.room.id, number = hotelServiceOrder.room.number } : null, hotel_service = new { id = service.id, hotel_name = service.hotel.name, description = service.description, starting_time = service.starting_time != null ? ((TimeSpan)service.starting_time).ToString(Constants.hhmmss) : null } }); } // возврат данных на фронтэнд (клиенту) return(Json(new { airtickets = airticketsList, transfers = transfersList, callout_rooms = calloutRoomsList, excursion_orders = excursionOrdersList, hotel_service_orders = hotelServiceOrdersList, total_payment = totalPayment, is_services = airticketsList.Count() > 0 || transfersList.Count() > 0 || calloutRoomsList.Count() > 0 || excursionOrdersList.Count() > 0 || hotelServiceOrdersList.Count() > 0 }, JsonRequestBehavior.DenyGet)); }