//! Get the satellites selected for Schedule /*! * /param string Logfile */ private List <One_Sgp4.Tle> getSatelliteData(string logfile) { satTleData = new List <One_Sgp4.Tle>(); //get selected Satellites to calculate Orbits for (int i = 0; i < checkedSatellites.Items.Count; i++) { if (checkedSatellites.GetItemChecked(i)) { One_Sgp4.Tle sattle = _MainDataBase.getTleDataFromDB(checkedSatellites.Items[i].ToString()); satTleData.Add(sattle); updateLog(logfile, "Adding Satellite: " + sattle.getName()); } } return(satTleData); }
//! Write TLE-Data to DataBase /*! * \param tleData TLEData to be writen in DataBase. */ public void writeTleData(One_Sgp4.Tle tleData) { if (!isConnected) { connectDB(); } SQLiteCommand command = new SQLiteCommand(m_dbConnection); SQLiteCommand addSatCommand = new SQLiteCommand(m_dbConnection); int count = 0; command.CommandText = String.Format("SELECT count(*) FROM {0} WHERE noradID='{1}';", Constants.TleDB, tleData.getNoradID()); try { count = Convert.ToInt32(command.ExecuteScalar()); } catch { count = 0; } if (count == 0) { command.CommandText = String.Format( Constants.insertTle, Constants.TleDB, tleData.getName(), tleData.getNoradID(), tleData.getClassification(), tleData.getStartYear(), tleData.getStartNr(), tleData.getPice(), tleData.getEpochYear(), tleData.getEpochDay(), tleData.getFirstMeanMotion(), tleData.getSecondMeanMotion(), tleData.getDrag(), tleData.getEphemeris(), tleData.getSetNumber(), tleData.getFirstCheckSum(), tleData.getSatNumber(), tleData.getInclination(), tleData.getRightAscendingNode(), tleData.getEccentriciy(), tleData.getPerigee(), tleData.getMeanAnomoly(), tleData.getMeanMotion(), tleData.getRelevationNumber(), tleData.getSecCheckSum()); command.ExecuteNonQuery(); addSatCommand.CommandText = String.Format( Constants.insertSat, Constants.SatDB, tleData.getName(), tleData.getNoradID()); addSatCommand.ExecuteNonQuery(); } else { //delet old Entry command.CommandText = String.Format( Constants.deleteTLE, Constants.TleDB, tleData.getNoradID()); command.ExecuteNonQuery(); //insert new Entry command.CommandText = String.Format( Constants.insertTle, Constants.TleDB, tleData.getName(), tleData.getNoradID(), tleData.getClassification(), tleData.getStartYear(), tleData.getStartNr(), tleData.getPice(), tleData.getEpochYear(), tleData.getEpochDay(), tleData.getFirstMeanMotion(), tleData.getSecondMeanMotion(), tleData.getDrag(), tleData.getEphemeris(), tleData.getSetNumber(), tleData.getFirstCheckSum(), tleData.getSatNumber(), tleData.getInclination(), tleData.getRightAscendingNode(), tleData.getEccentriciy(), tleData.getPerigee(), tleData.getMeanAnomoly(), tleData.getMeanMotion(), tleData.getRelevationNumber(), tleData.getSecCheckSum()); command.ExecuteNonQuery(); SQLiteCommand delcommand = new SQLiteCommand(m_dbConnection); delcommand.CommandText = String.Format( Constants.deleteSatellite2, Constants.SatDB, tleData.getNoradID()); delcommand.ExecuteNonQuery(); addSatCommand.CommandText = String.Format( Constants.insertSat, Constants.SatDB, tleData.getName(), tleData.getNoradID()); addSatCommand.ExecuteNonQuery(); } }