Ejemplo n.º 1
0
 public void persist(Experiment experiment)
 {
     if (wasRecording) {
         long id = DataManager.put(experiment);
         foreach (Stat stat in data) {
             stat.experiment = id;
         }
         DataManager.put(data);
         clear();
     }
 }
Ejemplo n.º 2
0
        public static long put(Experiment experiment)
        {
            SQLiteConnection connection = Connection.getConnection();
            string sql = "INSERT INTO experiment(name, date) VALUES(@ename, @edate)";
            SQLiteCommand command = new SQLiteCommand(sql, connection);
            command.Parameters.Add("@ename", DbType.String);
            command.Parameters["@ename"].Value = experiment.name;
            command.Parameters.Add("@edate", DbType.Int64);
            command.Parameters["@edate"].Value = experiment.date;
            command.ExecuteNonQuery();

            sql = "SELECT MAX(_id) FROM experiment";
            command = new SQLiteCommand(sql, connection);
            SQLiteDataReader rdr = command.ExecuteReader();
            long id = -1;
            while (rdr.Read())
            {
                id = rdr.GetInt64(0);
            }
            return id;
        }