static void removeWaypointRoutes(String connectionParams) { NpgsqlConnection connection = new NpgsqlConnection(connectionParams); connection.Open(); NpgsqlTransaction transaction = connection.BeginTransaction(); try { RoutesReader reader = new RoutesReader(connection); RouteGenerator generator = new RouteGenerator(connection); // read all waypoint routes List <Route> waypointRoutes = reader.readRoutesStartingWith("Waypoint"); // delete them generator.deleteRoutes(waypointRoutes); transaction.Commit(); } catch (Exception exception) { try { transaction.Rollback(); } catch (Exception rollbackException) { Console.WriteLine("Rollback failed :("); } } connection.Close(); }
private static void addAtoms(String connectionParams) { NpgsqlConnection connection = new NpgsqlConnection(connectionParams); connection.Open(); NpgsqlTransaction transaction = connection.BeginTransaction(); try { RoutesReader routesReader = new RoutesReader(connection); AtomGenerator generator = new AtomGenerator(connection); RouteGenerator routeGenerator = new RouteGenerator(connection); generator.deleteAllAtomsAndActivities(); //Route source1 = routesReader.readRouteByName("Escape3"); //Route source2 = routesReader.readRouteByName("Escape3_reversed"); //Route source3 = routesReader.readRouteByName("Source3"); //Route cornerRoute = routesReader.readRouteByName("Corner"); //addAtomsToRoute(source1, generator, 100); //addAtomsToRoute(source2, generator, 100); //addAtomsToRoute(source3, generator, 100); //addAtomsToRoute(cornerRoute, generator); //AtomObject ambulance = new AtomObject("Ambulance1", -1, 34.8514473088014, 32.1008536878526); //generator.createAtom(ambulance); //generator.addAtomToTreeObject(ambulance); //routeGenerator.generateReversedRoute("Escape3"); transaction.Commit(); } catch (Exception exception) { try { transaction.Rollback(); } catch (Exception rollbackException) { Console.WriteLine("Rollback failed :("); } } connection.Close(); }
private static void addAtoms(String connectionParams) { NpgsqlConnection connection = new NpgsqlConnection(connectionParams); connection.Open(); NpgsqlTransaction transaction = connection.BeginTransaction(); try { RoutesReader routesReader = new RoutesReader(connection); AtomGenerator generator = new AtomGenerator(connection); RouteGenerator routeGenerator = new RouteGenerator(connection); generator.deleteAllAtomsAndActivities(); Route source1 = routesReader.readRouteByName("Escape3"); Route source2 = routesReader.readRouteByName("Escape3_reversed"); //Route source3 = routesReader.readRouteByName("Source3"); //Route cornerRoute = routesReader.readRouteByName("Corner"); //addAtomsToRoute(source1, generator, 100); //addAtomsToRoute(source2, generator, 100); //addAtomsToRoute(source3, generator, 100); //addAtomsToRoute(cornerRoute, generator); //AtomObject ambulance = new AtomObject("Ambulance1", -1, 34.8514473088014, 32.1008536878526); //generator.createAtom(ambulance); //generator.addAtomToTreeObject(ambulance); //routeGenerator.generateReversedRoute("Escape3"); transaction.Commit(); } catch (Exception exception) { try { transaction.Rollback(); } catch (Exception rollbackException) { Console.WriteLine("Rollback failed :("); } } connection.Close(); }
public void generateReversedRoute(String routeName, String reversedRouteName) { RoutesReader routesReader = new RoutesReader(connection); Route route = routesReader.readRouteByName(routeName); Route reversedRoute = new Route(); reversedRoute.guid = Util.CreateGuid(); reversedRoute.name = reversedRouteName; reversedRoute.owner = route.owner; reversedRoute.routeTypeId = route.routeTypeId; reversedRoute.routePoints = new List <DPoint>(); // copy points to reversed route foreach (DPoint point in route.routePoints) { reversedRoute.routePoints.Add(point); } // reverse route points reversedRoute.routePoints.Reverse(); //after reading route generate a new GUID for it, change its name and reverse its route points saveRouteToDB(reversedRoute); }
public void generateReversedRoute(String routeName, String reversedRouteName) { RoutesReader routesReader = new RoutesReader(connection); Route route = routesReader.readRouteByName(routeName); Route reversedRoute = new Route(); reversedRoute.guid = Util.CreateGuid(); reversedRoute.name = reversedRouteName; reversedRoute.owner = route.owner; reversedRoute.routeTypeId = route.routeTypeId; reversedRoute.routePoints = new List<DPoint>(); // copy points to reversed route foreach (DPoint point in route.routePoints) { reversedRoute.routePoints.Add(point); } // reverse route points reversedRoute.routePoints.Reverse(); //after reading route generate a new GUID for it, change its name and reverse its route points saveRouteToDB(reversedRoute); }
static void removeWaypointRoutes(String connectionParams) { NpgsqlConnection connection = new NpgsqlConnection(connectionParams); connection.Open(); NpgsqlTransaction transaction = connection.BeginTransaction(); try { RoutesReader reader = new RoutesReader(connection); RouteGenerator generator = new RouteGenerator(connection); // read all waypoint routes List<Route> waypointRoutes = reader.readRoutesStartingWith("Waypoint"); // delete them generator.deleteRoutes(waypointRoutes); transaction.Commit(); } catch (Exception exception) { try { transaction.Rollback(); } catch (Exception rollbackException) { Console.WriteLine("Rollback failed :("); } } connection.Close(); }