public int SignalLevelDelete(SignalLevelDesignator sd) { lock (db.DBCommand) { db.DBCommand.CommandText = "DELETE FROM " + SignalLevelDesignator.TableName + " WHERE LastUpdated = @LastUpdated"; db.DBCommand.Parameters.Clear(); db.DBCommand.Parameters.Add(sd.AsUNIXTime("LastUpdated")); return(db.ExecuteNonQuery(db.DBCommand)); } }
public int SignalLevelUpdate(SignalLevelDesignator sd) { lock (db.DBCommand) { db.DBCommand.CommandText = "UPDATE " + SignalLevelDesignator.TableName + " SET Level = @Level, LastUpdated = @LastUpdated WHERE LastUpdated = @LastUpdated"; db.DBCommand.Parameters.Clear(); db.DBCommand.Parameters.Add(sd.AsDouble("Level")); db.DBCommand.Parameters.Add(sd.AsUNIXTime("LastUpdated")); return(db.ExecuteNonQuery(db.DBCommand)); } }
public int SignalLevelInsert(SignalLevelDesignator sd) { lock (db.DBCommand) { db.DBCommand.CommandText = "INSERT INTO " + SignalLevelDesignator.TableName + " (Level, LastUpdated) VALUES (@Level, @LastUpdated)"; db.DBCommand.Parameters.Clear(); db.DBCommand.Parameters.Add(sd.AsDouble("Level")); db.DBCommand.Parameters.Add(sd.AsUNIXTime("LastUpdated")); return(db.ExecuteNonQuery(db.DBCommand)); } }
public int SignalLevelInsertOrUpdateIfNewer(SignalLevelDesignator sd) { DateTime dt = SignalLevelFindLastUpdated(sd); if (dt == DateTime.MinValue) { return(SignalLevelInsert(sd)); } if (dt < sd.LastUpdated) { return(SignalLevelUpdate(sd)); } return(0); }
public DateTime SignalLevelFindLastUpdated(SignalLevelDesignator sd) { lock (db.DBCommand) { db.DBCommand.CommandText = "SELECT LastUpdated FROM " + SignalLevelDesignator.TableName + " WHERE LastUpdated = @LastUpdated"; db.DBCommand.Parameters.Clear(); db.DBCommand.Parameters.Add(sd.AsUNIXTime("LastUpdated")); object result = db.ExecuteScalar(db.DBCommand); if (IsValid(result)) { return(SQLiteEntry.UNIXTimeToDateTime((int)result)); } } return(DateTime.MinValue); }
public bool SignalLevelExists(SignalLevelDesignator sd) { lock (db.DBCommand) { db.DBCommand.CommandText = "SELECT EXISTS (SELECT LastUpdated FROM " + SignalLevelDesignator.TableName + " WHERE LastUpdated = @LastUpdated"; db.DBCommand.Parameters.Clear(); db.DBCommand.Parameters.Add(sd.AsUNIXTime("LastUpdated")); object result = db.DBCommand.ExecuteScalar(); if (IsValid(result) && ((long)result > 0)) { return(true); } } return(false); }
public SignalLevelDesignator SignalLevelFind(SignalLevelDesignator sd) { lock (db.DBCommand) { db.DBCommand.CommandText = "SELECT * FROM " + SignalLevelDesignator.TableName + " WHERE LastUpdated = @LastUpdated"; db.DBCommand.Parameters.Clear(); db.DBCommand.Parameters.Add(sd.AsUNIXTime("LastUpdated")); try { DataTable Result = db.Select(db.DBCommand); if ((Result != null) && (Result.Rows.Count > 0)) { return(new SignalLevelDesignator(Result.Rows[0])); } } catch (Exception ex) { Log.WriteMessage(ex.ToString(), LogLevel.Error); } } return(null); }
public int SignalLevelDelete(DateTime lastupdated) { SignalLevelDesignator sd = new SignalLevelDesignator(lastupdated); return(SignalLevelDelete(sd)); }
public DateTime SignalLevelFindlastUpdated(DateTime lastupdated) { SignalLevelDesignator sd = new SignalLevelDesignator(lastupdated); return(SignalLevelFindLastUpdated(sd)); }
public bool SignalLevelExists(DateTime lastupdated) { SignalLevelDesignator sd = new SignalLevelDesignator(lastupdated); return(SignalLevelExists(sd)); }