示例#1
0
 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));
     }
 }
示例#2
0
 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));
     }
 }
示例#3
0
 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));
     }
 }
示例#4
0
        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);
        }
示例#5
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);
 }
示例#6
0
 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);
 }
示例#7
0
 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);
 }
示例#8
0
        public int SignalLevelDelete(DateTime lastupdated)
        {
            SignalLevelDesignator sd = new SignalLevelDesignator(lastupdated);

            return(SignalLevelDelete(sd));
        }
示例#9
0
        public DateTime SignalLevelFindlastUpdated(DateTime lastupdated)
        {
            SignalLevelDesignator sd = new SignalLevelDesignator(lastupdated);

            return(SignalLevelFindLastUpdated(sd));
        }
示例#10
0
        public bool SignalLevelExists(DateTime lastupdated)
        {
            SignalLevelDesignator sd = new SignalLevelDesignator(lastupdated);

            return(SignalLevelExists(sd));
        }