[chronojump] networks 2.1.3 code, rfids can be reassigned to a new person



commit 0ffbcfdd49197120f4c3260cec090e82a7cf2e2e
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jul 27 13:58:08 2021 +0200

    networks 2.1.3 code, rfids can be reassigned to a new person

 src/gui/networks.cs  | 18 ++++++++++++++++++
 src/sqlite/person.cs | 13 +++++++++++++
 2 files changed, 31 insertions(+)
---
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index c124326ce..44dd751da 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -738,6 +738,7 @@ public partial class ChronoJumpWindow
                else if(json.Connected && pLocal.UniqueID != pServer.UniqueID)
                {
                        LogB.Information("PersonID on client does not match personID on server for rfid: " + 
capturedRFID);
+                       /* previous to 2.1.3 was not accepted (rfids cannot be reassigned to a new person)
                        if(dialogMessageNotAtServer == null || ! dialogMessageNotAtServer.Visible)
                        {
                                dialogMessageNotAtServer = new DialogMessage(Constants.MessageTypes.WARNING,
@@ -746,6 +747,23 @@ public partial class ChronoJumpWindow
 
                                compujumpPersonLogoutDo();
                        }
+                       */
+
+                       // 2.1.3 code, rfids can be reassigned to a new person
+                       // a wristband of a new player has been introduced, but this wristband we had 
previously locally assigned to another player
+                       // 1 delete rfid on previous person
+                       // 2 create new person with the server rfid, personSession
+
+                       // 1 delete rfid on previous person
+                       SqlitePerson.UpdateRFID (pLocal.UniqueID, "");
+
+                       // 2 create new person with the server rfid, personSession
+                       currentPerson = new Person (true, pServer.UniqueID, pServer.Name, pServer.Future1, 
json.LastPersonByRFIDImageURL);
+                       insertAndAssignPersonSessionIfNeeded(json);
+
+                       personChanged(); //GTK
+                       label_person_change();
+                       pChangedShowTasks = true;
                } else {
                        LogB.Information("RFID person exists locally!!");
 
diff --git a/src/sqlite/person.cs b/src/sqlite/person.cs
index 978508da2..307d38a6d 100644
--- a/src/sqlite/person.cs
+++ b/src/sqlite/person.cs
@@ -658,4 +658,17 @@ finishForeach:
                dbcmd.ExecuteNonQuery();
                Sqlite.Close();
        }
+
+       //used on compujump
+       public static void UpdateRFID (int uniqueID, string rfid)
+       {
+               Sqlite.Open();
+               dbcmd.CommandText = "UPDATE " + Constants.PersonTable +
+                       " SET future1 = \"" + rfid +
+                       "\" WHERE uniqueID = " + uniqueID;
+
+               LogB.SQL(dbcmd.CommandText.ToString());
+               dbcmd.ExecuteNonQuery();
+               Sqlite.Close();
+       }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]