[chronojump] New method to get List<Person> from session
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] New method to get List<Person> from session
- Date: Sat, 13 Jun 2020 15:47:46 +0000 (UTC)
commit 3acf5e1cf659ae27df5417ed0661efcd9130f8e9
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Jun 12 18:04:49 2020 +0200
New method to get List<Person> from session
src/sqlite/personSession.cs | 45 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 44 insertions(+), 1 deletion(-)
---
diff --git a/src/sqlite/personSession.cs b/src/sqlite/personSession.cs
index 45976102..f5345b63 100644
--- a/src/sqlite/personSession.cs
+++ b/src/sqlite/personSession.cs
@@ -257,7 +257,50 @@ class SqlitePersonSession : Sqlite
return ps;
}
-
+
+ //sessionID can be -1
+ //TODO: add the sessionID -1 code
+ public static List<Person> SelectCurrentSessionPersonsAsList (int sessionID)
+ {
+ string tp = Constants.PersonTable;
+ string tps = Constants.PersonSessionTable;
+
+ string tpsString = "";
+
+ Sqlite.Open();
+ dbcmd.CommandText = "SELECT " + tp + ".*" +
+ " FROM " + tp + ", " + tps +
+ " WHERE " + tps + ".sessionID == " + sessionID +
+ " AND " + tp + ".uniqueID == " + tps + ".personID " +
+ " ORDER BY upper(" + tp + ".name)";
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ List<Person> person_l = new List<Person>();
+ while(reader.Read())
+ {
+ Person person = new Person(
+ Convert.ToInt32(reader[0].ToString()), //uniqueID
+ reader[1].ToString(), //name
+ reader[2].ToString(), //sex
+ UtilDate.FromSql(reader[3].ToString()), //dateBorn
+ Convert.ToInt32(reader[4].ToString()), //race
+ Convert.ToInt32(reader[5].ToString()), //countryID
+ reader[6].ToString(), //description
+ reader[7].ToString(), //future1: rfid
+ reader[8].ToString(), //future2: clubID
+ Convert.ToInt32(reader[9].ToString()) //serverUniqueID
+ );
+ person_l.Add(person);
+ }
+
+ reader.Close();
+ Sqlite.Close();
+
+ return person_l;
+ }
//the difference between this select and others, is that this returns and ArrayList of Persons
//this is better than return the strings that can produce bugs in the future
//use this in the future:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]