//Select statement public List <GeneralDataSet> SelectGeneralData() { string query = "SELECT * FROM " + MySQLConnection.table_name; List <GeneralDataSet> list = new List <GeneralDataSet>(); //Open connection if (MySQLconn.State == System.Data.ConnectionState.Open) { //Create Command MySqlCommand cmd = new MySqlCommand(query, MySQLconn); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list int index = 0; while (dataReader.Read()) { GeneralDataSet DataSet = new GeneralDataSet(); DataSet.OID = dataReader["OID"].ToString(); DataSet.ARCID = (string)dataReader["ARCID"]; DataSet.IFPLID = (string)dataReader["IFPLID"]; DataSet.ADEP = (string)dataReader["ADEP"]; DataSet.ADES = (string)dataReader["ADES"]; DataSet.EOBD = (string)dataReader["EOBD"]; DataSet.EOBT = (string)dataReader["EOBT"]; DataSet.ARCTYPE = (string)dataReader["ARCTYPE"]; DataSet.REG = (string)dataReader["REG"]; DataSet.ARCADDR = (string)dataReader["ARCADDR"]; DataSet.F15 = (string)dataReader["F15"]; DataSet.FLAG = (string)dataReader["FLAG"]; DataSet.TSTARTTIME = dataReader["TSTARTTIME"].ToString(); DataSet.TENDTIME = dataReader["TENDTIME"].ToString(); DataSet.TPOINTS = (string)dataReader["TPOINTS"]; DataSet.FLTSOURCE = (string)dataReader["FLTSOURCE"]; DataSet.FLTSTATE = (string)dataReader["FLTSTATE"]; DataSet.LASTUPD = dataReader["LASTUPD"].ToString(); DataSet.STATUS = (string)dataReader["STATUS"]; DataSet.CBSFLTSTATE = dataReader["CBSFLTSTATE"].ToString(); list.Add(DataSet); index++; } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); //return list to be displayed return(list); } else { return(list); } }
public void Commit_One_Flight(GeneralDataSet Data_Set_One_Flight) { //OID, ARCID, IFPLID, ADEP, ADES, EOBD, EOBT, ARCTYPE, REG, ARCADDR, F15, FLAG, TSTARTTIME, TENDTIME, TPOINTS, FLTSOURCE, FLTSTATE, LASTUPD, STATUS, CBSFLTSTATE string query = "INSERT INTO " + MySQLConnection.table_name + " (OID, ARCID, IFPLID, ADEP, ADES, EOBD, EOBT, ARCTYPE, REG, ARCADDR, F15, FLAG, TSTARTTIME, TENDTIME, TPOINTS, FLTSOURCE, FLTSTATE, LASTUPD, STATUS, CBSFLTSTATE) " + " VALUES (" + Get_With_Quitation(Data_Set_One_Flight.OID) + "," + Get_With_Quitation(Data_Set_One_Flight.ARCID) + "," + Get_With_Quitation(Data_Set_One_Flight.IFPLID) + "," + Get_With_Quitation(Data_Set_One_Flight.ADEP) + "," + Get_With_Quitation(Data_Set_One_Flight.ADES) + "," + Get_With_Quitation(Data_Set_One_Flight.EOBD) + "," + Get_With_Quitation(Data_Set_One_Flight.EOBT) + "," + Get_With_Quitation(Data_Set_One_Flight.ARCTYPE) + "," + Get_With_Quitation(Data_Set_One_Flight.REG) + "," + Get_With_Quitation(Data_Set_One_Flight.ARCADDR) + "," + Get_With_Quitation(Data_Set_One_Flight.F15) + "," + Get_With_Quitation(Data_Set_One_Flight.FLAG) + "," + Get_With_Quitation(Data_Set_One_Flight.TSTARTTIME) + "," + Get_With_Quitation(Data_Set_One_Flight.TENDTIME) + "," + Get_With_Quitation(Data_Set_One_Flight.TPOINTS) + "," + Get_With_Quitation(Data_Set_One_Flight.FLTSOURCE) + "," + Get_With_Quitation(Data_Set_One_Flight.FLTSTATE) + "," + Get_With_Quitation(Data_Set_One_Flight.LASTUPD) + "," + Get_With_Quitation(Data_Set_One_Flight.STATUS) + "," + Get_With_Quitation(Data_Set_One_Flight.CBSFLTSTATE) + ")"; //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, MySQLconn); try { //Execute command cmd.ExecuteNonQuery(); } catch (Exception e) { MessageBox.Show(e.Message); } }
public static void Handle_New_File() { try { // Lets first extract location of the directory with the data of the flight to be analised string Data_Location_File = Properties.Settings.Default.TriggerLocation + "\\data_location.txt"; // Check if the data location file exists if (System.IO.File.Exists(Data_Location_File)) { // Yes we found it, so lets parse it and extract all flight data locations string[] Flights_To_Analyse_Locations = Extract_Paths_To_Each_Flight_To_Be_Analysed(Data_Location_File); // There are some data for this flight, so lets extract it if (Flights_To_Analyse_Locations.Length > 0) { // Lets first try to extract the general data from the MAIN direct foreach (string File_Path in Flights_To_Analyse_Locations) { // Lets first try to extract the general data from the MAIN directory string[] File_To_Look_For = Directory.GetFiles(File_Path + "\\MAIN", "MAIN_Closure*.xml", SearchOption.TopDirectoryOnly); if (File_To_Look_For.Length > 0) { try { using (MyStreamReader = System.IO.File.OpenText(File_To_Look_For[0])) { if (MyStreamReader != null) { GeneralDataSet DataSet = new GeneralDataSet(); if (DataSet.Populate_General_Data(File_To_Look_For[0])) { MySqlGeneralDataHandler MySql = new MySqlGeneralDataHandler(); MySql.Initialise_General(); MySql.Commit_One_Flight(DataSet); MySql.CloseConnection(); MySqlCalculatedDataHandler MySql_Calculated = new MySqlCalculatedDataHandler(); MySql_Calculated.Initialise_Calculated(); CalculatedDataSet Calculated_DataSet = new CalculatedDataSet(); MySql_Calculated.Commit_One_Flight(Calculated_DataSet); MySql_Calculated.CloseConnection(); } MyStreamReader.Close(); MyStreamReader.Dispose(); } } } catch { } } // Now try to extract the trajectory from the actual track flown File_To_Look_For = Directory.GetFiles(File_Path + "\\TRACK", "TRACK_FlownTrack.kml", SearchOption.TopDirectoryOnly); if (File_To_Look_For.Length > 0) { XmlTextReader xtr = new XmlTextReader(File_To_Look_For[0]); xtr.WhitespaceHandling = WhitespaceHandling.None; xtr.Read(); char[] delimiterChars = { '\n' }; string Line; while (xtr.Read()) //load loop { // Parse the file if (xtr.Name == "coordinates") { Line = xtr.ReadString(); string New_Line = Line.Replace("\t", string.Empty); string[] Words_One_Point = New_Line.Split(delimiterChars); char[] One_Line_delimiterChars = { ',' }; String trajectory = ""; bool Is_First_Point = false; DateTime FirstPointTime = new DateTime(); foreach (string One_Line in Words_One_Point) { if (One_Line.Length > 1) { string[] One_Point_Data = One_Line.Split(One_Line_delimiterChars); string LAT, LON, FL, TIME; LAT = One_Point_Data[0]; LON = One_Point_Data[1]; FL = One_Point_Data[2]; TIME = One_Point_Data[3]; DateTime ThisTime = GetDate_Time_From_YYYYMMDDHHMMSS(TIME); if (Is_First_Point == false) { Is_First_Point = true; FirstPointTime = GetDate_Time_From_YYYYMMDDHHMMSS(TIME); TIME = "0"; } else { TimeSpan CalculateTime = ThisTime - FirstPointTime; TIME = Math.Round(CalculateTime.TotalSeconds).ToString(); } trajectory = trajectory + LON + "," + LAT + "," + FL + "," + TIME + "," + "N/A,;"; } } // lat1,lon1,alt1,time1,name1,flags1;lat2,lon2,alt2,time2,name2,flags2;... //trajectory = "52.3081,4.7642,0,0,EHAM,;52.2442,5.2569,13400,248,IVLUT,;52.1097,5.5653,14000,388,LUNIX,;52.0617,5.6756,16300,434,RENDI,;51.9756,5.8358,19600,509,EDUPO,;51.8558,6.0589,23200,603,NAPRO,;51.7681,6.22,25300,669,DEPAD,;51.6389,6.455,27900,767,AMOSU,;51.4047,6.8758,32100,930,MISGO,;50.7836,7.5942,38900,1291,COL,;50.5214,7.8231,40400,1434,MONAX,;49.7489,8.48,41000,1866,RIDSU,TOC;49.4653,8.6792,41000,2021,ABUKA,;48.9931,8.5842,41000,2252,KRH,;48.17,8.3214,41000,2668,NATOR,;47.8583,8.3967,41000,2823,TITIX,;47.6894,8.4369,41000,2908,TRA,;47.2603,8.5,41000,3120,RIPUS,;47.0394,8.5322,41000,3231,GERSA,TOD;46.6067,8.5942,30500,3435,SOSON,;46.4361,8.6183,26900,3523,DEGAD,;46.1044,8.665,25000,3702,ODINA,;45.5592,9.5072,17000,4142,TZO,;45.2264,9.5411,9700,4349,COD,;45.4494,9.2783,353,4821,LIML,;"; Calculate_Penetration_Points CPP = new Calculate_Penetration_Points(); List <Sectors.Intersection> ip = CPP.Calculate(trajectory); List <Generate_KML.Waypoint> WPT_List = new List <Generate_KML.Waypoint>(); for (int i = 0; i < ip.Count; i++) { Generate_KML.Waypoint WPT = new Generate_KML.Waypoint(); WPT.Flight_Level = ip[i].point.getAltitude().ToString(); WPT.Position.SetPosition(new GeoCordSystemDegMinSecUtilities.LatLongDecimal(ip[i].point.getLatitude(), ip[i].point.getLongitude())); WPT.ETO = ip[i].point.getTime().ToString(); WPT_List.Add(WPT); } Generate_KML.Generate_Output(WPT_List); break; } } } } } } } catch { } }