Ejemplo n.º 1
0
 public int AircraftPositionUpdate(AircraftPositionDesignator ap)
 {
     lock (db.DBCommand)
     {
         db.DBCommand.CommandText = "UPDATE " + AircraftPositionDesignator.TableName + " SET Hex = @Hex, Call = @Call, Lat = @Lat, Lon = @Lon, Alt = @Alt, Track = @Track, Speed = @Speed, LastUpdated = @LastUpdated WHERE Hex = @Hex AND LastUpdated = @LastUpdated";
         db.DBCommand.Parameters.Clear();
         db.DBCommand.Parameters.Add(ap.AsString("Hex"));
         db.DBCommand.Parameters.Add(ap.AsString("Call"));
         db.DBCommand.Parameters.Add(ap.AsDouble("Lat"));
         db.DBCommand.Parameters.Add(ap.AsDouble("Lon"));
         db.DBCommand.Parameters.Add(ap.AsDouble("Alt"));
         db.DBCommand.Parameters.Add(ap.AsDouble("Track"));
         db.DBCommand.Parameters.Add(ap.AsDouble("Speed"));
         db.DBCommand.Parameters.Add(ap.AsUNIXTime("LastUpdated"));
         return(db.ExecuteNonQuery(db.DBCommand));
     }
 }
Ejemplo n.º 2
0
 public int AircraftPositionInsert(AircraftPositionDesignator ap)
 {
     lock (db.DBCommand)
     {
         db.DBCommand.CommandText = "INSERT INTO " + AircraftPositionDesignator.TableName + " (Hex, Call, Lat, Lon, Alt, Track, Speed, LastUpdated) VALUES (@Hex, @Call, @Lat, @Lon, @Alt, @Track, @Speed, @LastUpdated)";
         db.DBCommand.Parameters.Clear();
         db.DBCommand.Parameters.Add(ap.AsString("Hex"));
         db.DBCommand.Parameters.Add(ap.AsString("Call"));
         db.DBCommand.Parameters.Add(ap.AsDouble("Lat"));
         db.DBCommand.Parameters.Add(ap.AsDouble("Lon"));
         db.DBCommand.Parameters.Add(ap.AsDouble("Alt"));
         db.DBCommand.Parameters.Add(ap.AsDouble("Track"));
         db.DBCommand.Parameters.Add(ap.AsDouble("Speed"));
         db.DBCommand.Parameters.Add(ap.AsUNIXTime("LastUpdated"));
         return(db.ExecuteNonQuery(db.DBCommand));
     }
 }
Ejemplo n.º 3
0
 public int AircraftPositionDelete(AircraftPositionDesignator ap)
 {
     lock (db.DBCommand)
     {
         db.DBCommand.CommandText = "DELETE FROM " + AircraftPositionDesignator.TableName + " WHERE Hex = @Hex AND LastUpdated = @LastUpdated";
         db.DBCommand.Parameters.Clear();
         db.DBCommand.Parameters.Add(ap.AsString("Hex"));
         db.DBCommand.Parameters.Add(ap.AsUNIXTime("LastUpdated"));
         return(db.ExecuteNonQuery(db.DBCommand));
     }
 }
Ejemplo n.º 4
0
 public bool AircraftPositionExists(AircraftPositionDesignator ap)
 {
     lock (db.DBCommand)
     {
         db.DBCommand.CommandText = "SELECT EXISTS (SELECT LastUpdated FROM " + AircraftPositionDesignator.TableName + " WHERE Hex = @Hex AND LastUpdated = @LastUpdated";
         db.DBCommand.Parameters.Clear();
         db.DBCommand.Parameters.Add(ap.AsString("Hex"));
         db.DBCommand.Parameters.Add(ap.AsUNIXTime("LastUpdated"));
         object result = db.DBCommand.ExecuteScalar();
         if (IsValid(result) && ((long)result > 0))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 5
0
 public AircraftPositionDesignator AircraftPositionFind(AircraftPositionDesignator ap)
 {
     lock (db.DBCommand)
     {
         db.DBCommand.CommandText = "SELECT * FROM " + AircraftPositionDesignator.TableName + " WHERE Hex = @Hex AND LastUpdated = @LastUpdated";
         db.DBCommand.Parameters.Clear();
         db.DBCommand.Parameters.Add(ap.AsString("Hex"));
         db.DBCommand.Parameters.Add(ap.AsUNIXTime("LastUpdated"));
         try
         {
             DataTable Result = db.Select(db.DBCommand);
             if (IsValid(Result) && (Result.Rows.Count > 0))
             {
                 return(new AircraftPositionDesignator(Result.Rows[0]));
             }
         }
         catch (Exception ex)
         {
             Log.WriteMessage(ex.ToString(), LogLevel.Error);
         }
     }
     return(null);
 }