/// <summary> This constructor saves the information it gets /// <param name="source"> Used for getting back </param> /// <param name="dbCommunicator"> Used to save routes </param> /// <param name="newRoute"> Used to create the new route </param> /// <param name="airportCode"> Used to know which route is linked to </param> /// </summary> public RouteSaverForm(Form source, DatabaseCommunicator.DatabaseCommunicator dbCommunicator, List <Importer.Point> newRoute, string airportCode) { this.source = source; InitializeComponent(); route = newRoute; this.airportCode = airportCode; this.dbCommunicator = dbCommunicator; routeType = ""; AcceptButton = confirmButton; }
/// <summary> This method create XML files from database and export to a folder. /// <param name="db"> The database db contains informations which the created files need to have. </param> /// <returns> Returns true if the new files are created. </returns> /// </summary> public override bool ExportFiles(DatabaseCommunicator.DatabaseCommunicator db) { string folderName = @"ExportFolder"; // Delete the folder if exist if (System.IO.Directory.Exists(folderName)) { System.IO.DirectoryInfo di = new DirectoryInfo(folderName); foreach (FileInfo file in di.EnumerateFiles()) { file.Delete(); } foreach (DirectoryInfo dir in di.EnumerateDirectories()) { dir.Delete(true); } } List <string> allAirports = db.GetAirports(); foreach (string airport in allAirports) { List <string> routes = db.GetAirportRoutes(airport); try { // Create a folder for an airport string pathString = System.IO.Path.Combine(folderName, airport); System.IO.Directory.CreateDirectory(pathString); for (int i = 0; i < routes.Count; i++) { string route = routes[i]; List <Point> points = db.GetRoute(route); // Create XML-file for a route string routeXML = @"" + folderName + "/" + airport + "/" + route + ".xml"; CreateXMLFile(routeXML, points); } } catch (Exception ex) { throw new Exception("The Export Failed!"); } } return(true); }
/// <summary> This constructor saves dbCommunicator and list all routes. </summary> public ViewRoutesForm(DatabaseCommunicator.DatabaseCommunicator dbCommunicator) { InitializeComponent(); this.dbCommunicator = dbCommunicator; this.SetUpRoutes(); }