[chronojump] DB: 2.14 run, runInterval, tempRunInterval with datetime. Also execute run, runI.
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] DB: 2.14 run, runInterval, tempRunInterval with datetime. Also execute run, runI.
- Date: Tue, 16 Mar 2021 19:18:43 +0000 (UTC)
commit 08a853c790749d2175a4f9d44f3ed531ece1ff51
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Mar 16 20:17:25 2021 +0100
DB: 2.14 run, runInterval, tempRunInterval with datetime. Also execute run, runI.
src/execute/run.cs | 17 +++++++++++------
src/run.cs | 22 +++++++++++++++++-----
src/sqlite/main.cs | 19 ++++++++++++++++++-
src/sqlite/run.cs | 20 ++++++++++++--------
src/sqlite/runInterval.cs | 18 +++++++++++-------
5 files changed, 69 insertions(+), 27 deletions(-)
---
diff --git a/src/execute/run.cs b/src/execute/run.cs
index 6c4f12fd..2280af5a 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -815,15 +815,18 @@ LogB.Information("going to call pwc.CaptureStart ()");
description += descriptionAddReactionTime(reactionTimeMS, pDN, speedStartArrival);
string table = Constants.RunTable;
+ string datetime = UtilDate.ToFile(DateTime.Now);
uniqueID = SqliteRun.Insert(false, table, "NULL", personID, sessionID,
type, distance, trackTime, description,
Util.BoolToNegativeInt(simulated),
- !startIn //initialSpeed true if not startIn
+ !startIn, //initialSpeed true if not startIn
+ datetime
);
//define the created object
- eventDone = new Run(uniqueID, personID, sessionID, type, distance, trackTime, description,
Util.BoolToNegativeInt(simulated), !startIn);
+ eventDone = new Run(uniqueID, personID, sessionID, type, distance, trackTime, description,
+ Util.BoolToNegativeInt(simulated), !startIn, datetime);
if(graphAllTypes)
type = "";
@@ -1293,7 +1296,7 @@ public class RunIntervalExecute : RunExecute
else if(measureReactionTime && reactionTimeMS > 0)
description += descriptionAddReactionTime(reactionTimeMS, pDN, speedStartArrival);
-
+ string datetime = UtilDate.ToFile(DateTime.Now);
if(tempTable)
SqliteRunInterval.Insert(false, Constants.TempRunIntervalTable, "NULL", personID,
sessionID, type,
@@ -1302,7 +1305,8 @@ public class RunIntervalExecute : RunExecute
description,
limitString,
Util.BoolToNegativeInt(simulated),
- !startIn //initialSpeed true if not startIn
+ !startIn, //initialSpeed true if not startIn
+ datetime
);
else {
uniqueID = SqliteRunInterval.Insert(false, Constants.RunIntervalTable, "NULL",
personID, sessionID, type,
@@ -1311,12 +1315,13 @@ public class RunIntervalExecute : RunExecute
description,
limitString,
Util.BoolToNegativeInt(simulated),
- !startIn
+ !startIn,
+ datetime
);
//define the created object
eventDone = new RunInterval(uniqueID, personID, sessionID, type, distanceTotal,
timeTotal, distanceInterval, intervalTimesString,
- tracksHere, description, limitString,
Util.BoolToNegativeInt(simulated), !startIn);
+ tracksHere, description, limitString,
Util.BoolToNegativeInt(simulated), !startIn, datetime);
/*
string tempValuesString;
diff --git a/src/run.cs b/src/run.cs
index 8129b77b..41a0299e 100644
--- a/src/run.cs
+++ b/src/run.cs
@@ -36,6 +36,7 @@ public class Run : Event
//protected Chronopic cp;
protected bool metersSecondsPreferred;
+ protected string datetime;
/*
//used by the updateTimeProgressBar for display its time information
@@ -51,7 +52,7 @@ public class Run : Event
}
//after inserting database (SQL)
- public Run(int uniqueID, int personID, int sessionID, string type, double distance, double time,
string description, int simulated, bool initialSpeed)
+ public Run(int uniqueID, int personID, int sessionID, string type, double distance, double time,
string description, int simulated, bool initialSpeed, string datetime)
{
this.uniqueID = uniqueID;
this.personID = personID;
@@ -62,6 +63,7 @@ public class Run : Event
this.description = description;
this.simulated = simulated;
this.initialSpeed = initialSpeed;
+ this.datetime = datetime;
}
//used to select a run at SqliteRun.SelectNormalRunData and at Sqlite.convertTables
@@ -76,6 +78,7 @@ public class Run : Event
this.description = eventString[6].ToString();
this.simulated = Convert.ToInt32(eventString[7]);
this.initialSpeed = Util.IntToBool(Convert.ToInt32(eventString[8]));
+ this.datetime = eventString[9];
}
public static List<Event> RunListToEventList(List<Run> runs)
@@ -93,9 +96,12 @@ public class Run : Event
uniqueID.ToString(),
personID, sessionID,
type, distance, time,
- description, simulated, initialSpeed);
+ description, simulated, initialSpeed, datetime);
}
+ public override string ToString() {
+ return uniqueID + ":" + personID + ":" + sessionID + ":" + type + ":" + distance + ":" + time
+ ":" + datetime + ":" + description + ":" + simulated + ":" + initialSpeed;
+ }
public virtual double Speed
{
@@ -129,7 +135,11 @@ public class Run : Event
get { return initialSpeed; }
set { initialSpeed = value; }
}
-
+
+ public string Datetime {
+ get { return datetime; }
+ set { datetime = value; }
+ }
~Run() {}
@@ -151,7 +161,7 @@ public class RunInterval : Run
}
//after inserting database (SQL)
- public RunInterval(int uniqueID, int personID, int sessionID, string type, double distanceTotal,
double timeTotal, double distanceInterval, string intervalTimesString, double tracks, string description,
string limited, int simulated, bool initialSpeed)
+ public RunInterval(int uniqueID, int personID, int sessionID, string type, double distanceTotal,
double timeTotal, double distanceInterval, string intervalTimesString, double tracks, string description,
string limited, int simulated, bool initialSpeed, string datetime)
{
this.uniqueID = uniqueID;
this.personID = personID;
@@ -166,6 +176,7 @@ public class RunInterval : Run
this.limited = limited;
this.simulated = simulated;
this.initialSpeed = initialSpeed;
+ this.datetime = datetime;
}
//used to select a run at SqliteRun.SelectIntervalRunData and at Sqlite.convertTables
@@ -184,6 +195,7 @@ public class RunInterval : Run
this.limited = eventString[10].ToString();
this.simulated = Convert.ToInt32(eventString[11]);
this.initialSpeed = Util.IntToBool(Convert.ToInt32(eventString[12]));
+ this.datetime = eventString[13];
}
@@ -194,7 +206,7 @@ public class RunInterval : Run
type, distanceTotal, timeTotal,
distanceInterval, intervalTimesString,
tracks, description,
- limited, simulated, initialSpeed);
+ limited, simulated, initialSpeed, datetime);
}
public string IntervalTimesString
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index cb1b339d..80a13da2 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -129,7 +129,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
- static string lastChronojumpDatabaseVersion = "2.13";
+ static string lastChronojumpDatabaseVersion = "2.14";
public Sqlite()
{
@@ -2887,6 +2887,22 @@ class Sqlite
currentVersion = updateVersion("2.13");
}
+ if(currentVersion == "2.13")
+ {
+ LogB.SQL("Doing alter table run, runInterval, tempRunInterval add datetime");
+ try {
+ //sqlite does not have drop column
+ executeSQL("ALTER TABLE " + Constants.RunTable + " ADD COLUMN
datetime TEXT;");
+ executeSQL("ALTER TABLE " + Constants.RunIntervalTable + " ADD COLUMN
datetime TEXT;");
+ executeSQL("ALTER TABLE " + Constants.TempRunIntervalTable + " ADD
COLUMN datetime TEXT;");
+ } catch {
+ LogB.SQL("Catched at Doing alter table run, runInterval,
tempRunInterval add datetime.");
+
+ }
+ LogB.SQL("Done!");
+
+ currentVersion = updateVersion("2.14");
+ }
@@ -3108,6 +3124,7 @@ class Sqlite
//just testing: 1.79 - 1.80 Converted DB to 1.80 Created table ForceSensorElasticBandGlue and moved
stiffnessString records there
+ //2.13 - 2.14 Converted DB to 2.14 Doing alter table run, runInterval, tempRunInterval add
datetime
//2.12 - 2.13 Converted DB to 2.13 Inserted prefs: PersonSelectWinImages, ExportGraphWidth,
ExportGraphHeight
//2.11 - 2.12 Converted DB to 2.12 Inserted prefs: forceSensorAnalyzeMaxAVGInWindow
//2.10 - 2.11 Converted DB to 2.11 Inserted prefs: clientNewsDatetime
diff --git a/src/sqlite/run.cs b/src/sqlite/run.cs
index aa97a786..a577e530 100644
--- a/src/sqlite/run.cs
+++ b/src/sqlite/run.cs
@@ -49,7 +49,8 @@ class SqliteRun : Sqlite
"time FLOAT, " +
"description TEXT, " +
"simulated INT, " +
- "initialSpeed INT )";
+ "initialSpeed INT, " +
+ "datetime TEXT )";
dbcmd.ExecuteNonQuery();
}
@@ -58,7 +59,7 @@ class SqliteRun : Sqlite
* Run class methods
*/
- public static int Insert(bool dbconOpened, string tableName, string uniqueID, int personID, int
sessionID, string type, double distance, double time, string description, int simulated, bool initialSpeed)
+ public static int Insert(bool dbconOpened, string tableName, string uniqueID, int personID, int
sessionID, string type, double distance, double time, string description, int simulated, bool initialSpeed,
string datetime)
{
if(! dbconOpened)
Sqlite.Open();
@@ -67,11 +68,11 @@ class SqliteRun : Sqlite
uniqueID = "NULL";
dbcmd.CommandText = "INSERT INTO " + tableName +
- " (uniqueID, personID, sessionID, type, distance, time, description,
simulated, initialSpeed)" +
+ " (uniqueID, personID, sessionID, type, distance, time, description,
simulated, initialSpeed, datetime)" +
" VALUES (" + uniqueID + ", " +
+ personID + ", " + sessionID + ", \"" + type + "\", "
+ Util.ConvertToPoint(distance) + ", " + Util.ConvertToPoint(time) + ", \"" +
- description + "\", " + simulated + ", " + Util.BoolToInt(initialSpeed) + ")" ;
+ description + "\", " + simulated + ", " + Util.BoolToInt(initialSpeed) + ",
\"" + datetime + "\")";
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -148,7 +149,8 @@ class SqliteRun : Sqlite
int count = new int();
count = 0;
- while(reader.Read()) {
+ while(reader.Read())
+ {
myArray.Add (reader[0].ToString() + ":" + //person.name
reader[1].ToString() + ":" + //run.uniqueID
reader[2].ToString() + ":" + //run.personID
@@ -158,7 +160,8 @@ class SqliteRun : Sqlite
Util.ChangeDecimalSeparator(reader[6].ToString()) + ":" + //run.time
reader[7].ToString() + ":" + //description
reader[8].ToString() + ":" + //simulated
- Util.IntToBool(Convert.ToInt32(reader[9])) //initialSpeed
+ Util.IntToBool(Convert.ToInt32(reader[9])) + ":" + //initialSpeed
+ reader[10].ToString() //datetime
);
count ++;
}
@@ -213,7 +216,8 @@ class SqliteRun : Sqlite
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[6].ToString())),
//run.time
reader[7].ToString(), //description
Convert.ToInt32(reader[8].ToString()), //simulated
- Util.IntToBool(Convert.ToInt32(reader[9])) //initialSpeed
+ Util.IntToBool(Convert.ToInt32(reader[9])), //initialSpeed
+ reader[10].ToString() //datetime
);
if(personNameInComment)
@@ -245,7 +249,7 @@ class SqliteRun : Sqlite
reader = dbcmd.ExecuteReader();
reader.Read();
- Run myRun = new Run(DataReaderToStringArray(reader, 9));
+ Run myRun = new Run(DataReaderToStringArray(reader, 10));
reader.Close();
if(!dbconOpened)
diff --git a/src/sqlite/runInterval.cs b/src/sqlite/runInterval.cs
index d40ecfa3..e963eebb 100644
--- a/src/sqlite/runInterval.cs
+++ b/src/sqlite/runInterval.cs
@@ -50,11 +50,12 @@ class SqliteRunInterval : SqliteRun
"description TEXT, " +
"limited TEXT, " +
"simulated INT, " +
- "initialSpeed INT)";
+ "initialSpeed INT, " +
+ "datetime TEXT )";
dbcmd.ExecuteNonQuery();
}
- public static int Insert(bool dbconOpened, string tableName, string uniqueID, int personID, int
sessionID, string type, double distanceTotal, double timeTotal, double distanceInterval, string
intervalTimesString, double tracks, string description, string limited, int simulated, bool initialSpeed )
+ public static int Insert(bool dbconOpened, string tableName, string uniqueID, int personID, int
sessionID, string type, double distanceTotal, double timeTotal, double distanceInterval, string
intervalTimesString, double tracks, string description, string limited, int simulated, bool initialSpeed,
string datetime)
{
if(! dbconOpened)
Sqlite.Open();
@@ -63,7 +64,7 @@ class SqliteRunInterval : SqliteRun
uniqueID = "NULL";
dbcmd.CommandText = "INSERT INTO "+ tableName +
- " (uniqueID, personID, sessionID, type, distanceTotal, timeTotal,
distanceInterval, intervalTimesString, tracks, description, limited, simulated, initialSpeed)" +
+ " (uniqueID, personID, sessionID, type, distanceTotal, timeTotal,
distanceInterval, intervalTimesString, tracks, description, limited, simulated, initialSpeed, datetime)" +
"VALUES (" + uniqueID + ", " +
personID + ", " + sessionID + ", \"" + type + "\", " +
Util.ConvertToPoint(distanceTotal) + ", " +
@@ -72,7 +73,8 @@ class SqliteRunInterval : SqliteRun
Util.ConvertToPoint(intervalTimesString) + "\", " +
Util.ConvertToPoint(tracks) + ", \"" +
description + "\", \"" + limited + "\", " + simulated + ", " +
- Util.BoolToInt(initialSpeed) + ")" ;
+ Util.BoolToInt(initialSpeed) + ", \"" +
+ datetime + "\")";
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -127,7 +129,8 @@ class SqliteRunInterval : SqliteRun
int count = new int();
count = 0;
- while(reader.Read()) {
+ while(reader.Read())
+ {
myArray.Add (reader[0].ToString() + ":" + //person.name
reader[1].ToString() + ":" + //runInterval.uniqueID
reader[2].ToString() + ":" + //runInterval.personID
@@ -141,7 +144,8 @@ class SqliteRunInterval : SqliteRun
reader[10].ToString() + ":" + //description
reader[11].ToString() + ":" + //limited
reader[12].ToString() + ":" + //simulated
- Util.IntToBool(Convert.ToInt32(reader[13])) //initialSpeed
+ Util.IntToBool(Convert.ToInt32(reader[13])) + ":" + //initialSpeed
+ reader[14].ToString() //datetime
);
count ++;
}
@@ -176,7 +180,7 @@ class SqliteRunInterval : SqliteRun
reader = dbcmd.ExecuteReader();
reader.Read();
- RunInterval myRun = new RunInterval(DataReaderToStringArray(reader, 13));
+ RunInterval myRun = new RunInterval(DataReaderToStringArray(reader, 14));
reader.Close();
if(!dbconOpened)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]