[chronojump] exhibitionTest temp upload on Chronojump start
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] exhibitionTest temp upload on Chronojump start
- Date: Fri, 1 Mar 2019 12:27:53 +0000 (UTC)
commit 72cddce4a17cd883866591858e99b416270eb34e
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Mar 1 13:27:09 2019 +0100
exhibitionTest temp upload on Chronojump start
src/gui/exhibition.cs | 22 ++++++++++++++++++++++
src/gui/networks.cs | 3 +++
src/sqlite/json.cs | 47 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+)
---
diff --git a/src/gui/exhibition.cs b/src/gui/exhibition.cs
index 3273bd2e..7d22b46b 100644
--- a/src/gui/exhibition.cs
+++ b/src/gui/exhibition.cs
@@ -21,6 +21,7 @@
using System;
using Gtk;
using Glade;
+using System.Collections.Generic; //List
public partial class ChronoJumpWindow
{
@@ -192,4 +193,25 @@ public partial class ChronoJumpWindow
}
}
+ private void uploadExhibitionTestsPending()
+ {
+ Json json = new Json();
+ Sqlite.Open(); // ---------------->
+
+ List<ExhibitionTest> listEtTemp = SqliteJson.SelectTempExhibitionTest(true);
+ if(listEtTemp.Count > 0)
+ {
+ foreach(ExhibitionTest et in listEtTemp)
+ {
+ bool success = json.UploadExhibitionTest(et);
+ LogB.Information(json.ResultMessage);
+ if(success)
+ SqliteJson.DeleteTempExhibitionTest(true, et); //delete the record
+ }
+ }
+
+ Sqlite.Close(); // <----------------
+
+ }
+
}
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 11a14835..98be0c83 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -199,7 +199,10 @@ public partial class ChronoJumpWindow
}
if(configChronojump.Exhibition)
+ {
exhibitionGuiAtStart(configChronojump.ExhibitionStationType);
+ uploadExhibitionTestsPending();
+ }
configDo();
}
diff --git a/src/sqlite/json.cs b/src/sqlite/json.cs
index ab6af0e8..4deb3507 100644
--- a/src/sqlite/json.cs
+++ b/src/sqlite/json.cs
@@ -260,5 +260,52 @@ class SqliteJson : Sqlite
closeIfNeeded(dbconOpened);
}
+ public static List<ExhibitionTest> SelectTempExhibitionTest (bool dbconOpened)
+ {
+ openIfNeeded(dbconOpened);
+
+ dbcmd.CommandText = "SELECT * FROM " + tableExhibitionTest + " ORDER BY personID";
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader = dbcmd.ExecuteReader();
+
+ List<ExhibitionTest> l = new List<ExhibitionTest>();
+ while(reader.Read())
+ {
+ ExhibitionTest et = new ExhibitionTest(
+ Convert.ToInt32(reader[0]), //schoolID
+ Convert.ToInt32(reader[1]), //groupID
+ Convert.ToInt32(reader[2]), //personID
+ (ExhibitionTest.testTypes) Enum.Parse(
+ typeof(ExhibitionTest.testTypes), reader[3].ToString()),
//testType
+ Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString()))
//result
+ );
+
+ l.Add(et);
+ }
+
+ reader.Close();
+ closeIfNeeded(dbconOpened);
+
+ return l;
+ }
+
+ public static void DeleteTempExhibitionTest(bool dbconOpened, ExhibitionTest et)
+ {
+ openIfNeeded(dbconOpened);
+
+ dbcmd.CommandText = "Delete FROM " + tableExhibitionTest + " WHERE " +
+ "schoolID = " + et.schoolID + " AND " +
+ "groupID = " + et.groupID + " AND " +
+ "personID = " + et.personID + " AND " +
+ "testType = \"" + et.testType.ToString() + "\" AND " +
+ "result = " + et.resultToJson;
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ closeIfNeeded(dbconOpened);
+ }
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]