[chronojump] Networks: month change not only at boot, also when user is identified.
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Networks: month change not only at boot, also when user is identified.
- Date: Tue, 16 Jul 2019 12:21:30 +0000 (UTC)
commit ba22a70c0d89e161a4127e4b813f30abcc767b39
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jul 16 13:49:01 2019 +0200
Networks: month change not only at boot, also when user is identified.
Fixes https://gitlab.gnome.org/GNOME/chronojump/issues/77
On networks months (MONTHLY) are too long
src/gui/networks.cs | 81 +++++++++++++++++++++++++++++++++--------------------
1 file changed, 50 insertions(+), 31 deletions(-)
---
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 53b2a7c6..8060cf6c 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -420,37 +420,9 @@ public partial class ChronoJumpWindow
//configChronojump.SessionMode == Config.SessionModeEnum.MONTHLY
string yearMonthStr = UtilDate.GetCurrentYearMonthStr();
- LogB.Information("yearMonthStr: " + yearMonthStr);
- if(! Sqlite.Exists(false, Constants.SessionTable, yearMonthStr))
- {
- //this creates the session and inserts at DB
- currentSession = new Session(
- yearMonthStr, "", DateTime.Today, //name,
place, dateTime
- Constants.SportUndefinedID,
Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID,
- "", Constants.ServerUndefinedID); //comments, serverID
-
- //insert personSessions from last month
- string yearLastMonthStr = UtilDate.GetCurrentYearLastMonthStr();
- if(Sqlite.Exists(false, Constants.SessionTable, yearLastMonthStr))
- {
- Session s = SqliteSession.SelectByName(yearLastMonthStr);
-
- //import all persons from last session
- List<PersonSession> personSessions =
SqlitePersonSession.SelectPersonSessionList(s.UniqueID);
-
- //convert all personSessions to currentSession
- //and nullify UniqueID in order to be inserted incrementally
by SQL
- foreach(PersonSession ps in personSessions)
- {
- ps.UniqueID = -1;
- ps.SessionID = currentSession.UniqueID;
- }
-
-
- //insert personSessions using a transaction
- new SqlitePersonSessionTransaction(personSessions);
- }
- } else
+ if(needToCreateMonthlySession(yearMonthStr))
+ createMonthlySession(yearMonthStr);
+ else
currentSession = SqliteSession.SelectByName(yearMonthStr);
}
@@ -488,6 +460,45 @@ public partial class ChronoJumpWindow
label_rfid_encoder_wait.Visible = false;
}
+ private bool needToCreateMonthlySession(string yearMonthStr)
+ {
+ LogB.Information("yearMonthStr: " + yearMonthStr);
+
+ return(! Sqlite.Exists(false, Constants.SessionTable, yearMonthStr));
+ }
+
+ private void createMonthlySession(string yearMonthStr)
+ {
+ //this creates the session and inserts at DB
+ currentSession = new Session(
+ yearMonthStr, "", DateTime.Today, //name, place, dateTime
+ Constants.SportUndefinedID, Constants.SpeciallityUndefinedID,
Constants.LevelUndefinedID,
+ "", Constants.ServerUndefinedID); //comments, serverID
+
+ setApp1Title(currentSession.Name, current_menuitem_mode);
+
+ //insert personSessions from last month
+ string yearLastMonthStr = UtilDate.GetCurrentYearLastMonthStr();
+ if(Sqlite.Exists(false, Constants.SessionTable, yearLastMonthStr))
+ {
+ Session s = SqliteSession.SelectByName(yearLastMonthStr);
+
+ //import all persons from last session
+ List<PersonSession> personSessions =
SqlitePersonSession.SelectPersonSessionList(s.UniqueID);
+
+ //convert all personSessions to currentSession
+ //and nullify UniqueID in order to be inserted incrementally by SQL
+ foreach(PersonSession ps in personSessions)
+ {
+ ps.UniqueID = -1;
+ ps.SessionID = currentSession.UniqueID;
+ }
+
+ //insert personSessions using a transaction
+ new SqlitePersonSessionTransaction(personSessions);
+ }
+ }
+
DialogMessage dialogMessageNotAtServer;
private bool pulseRFID ()
{
@@ -631,6 +642,10 @@ public partial class ChronoJumpWindow
SqlitePerson.Update(pLocal);
}
+ string yearMonthStr = UtilDate.GetCurrentYearMonthStr();
+ if(needToCreateMonthlySession(yearMonthStr))
+ createMonthlySession(yearMonthStr);
+
currentPerson = pLocal;
insertAndAssignPersonSessionIfNeeded(json);
@@ -663,6 +678,10 @@ public partial class ChronoJumpWindow
LogB.Information("RFID person exists locally!!");
if(rfidIsDifferent || dialogPersonPopup == null || ! dialogPersonPopup.Visible)
{
+ string yearMonthStr = UtilDate.GetCurrentYearMonthStr();
+ if(needToCreateMonthlySession(yearMonthStr))
+ createMonthlySession(yearMonthStr);
+
currentPerson = pLocal;
insertAndAssignPersonSessionIfNeeded(json);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]