[chronojump] Networks: updates a person name if changed on server



commit f60edd4d4bee13eeae5c60d1572648a50a89d3b8
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jul 27 10:21:32 2021 +0200

    Networks: updates a person name if changed on server

 src/gui/networks.cs  |  9 ++++++++-
 src/sqlite/person.cs | 12 ++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 10d15c6a1..baf7fcd63 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -112,7 +112,7 @@ public partial class ChronoJumpWindow
        private static bool networksRunIntervalCanChangePersonSQLReady;
        private static DateTime startedRFIDWait; //just to display a message at the moment of try to 
wristband change while capturing
        private bool rfidProcessCancel;
-       private bool rfidIsDifferent;
+       private bool rfidIsDifferent; //new rfid capture is different than previous
        private bool needManageCompujumpCapturingReset; //useful to manage wristbands while capture
        //private bool compujumpAutologout;
        //private static CompujumpAutologout compujumpAutologout;
@@ -761,6 +761,13 @@ public partial class ChronoJumpWindow
                                if(needToCreateMonthlySession(yearMonthStr))
                                        createMonthlySession(yearMonthStr);
 
+                               //update person if name changed
+                               if(pServer.Name != pLocal.Name)
+                               {
+                                       pLocal.Name = pServer.Name;
+                                       SqlitePerson.UpdateName (pLocal.UniqueID, pLocal.Name);
+                               }
+
                                currentPerson = pLocal;
                                insertAndAssignPersonSessionIfNeeded(json);
 
diff --git a/src/sqlite/person.cs b/src/sqlite/person.cs
index ea85988d7..978508da2 100644
--- a/src/sqlite/person.cs
+++ b/src/sqlite/person.cs
@@ -646,4 +646,16 @@ finishForeach:
                Sqlite.Close();
        }
 
+       //used on compujump
+       public static void UpdateName (int uniqueID, string name)
+       {
+               Sqlite.Open();
+               dbcmd.CommandText = "UPDATE " + Constants.PersonTable +
+                       " SET name = \"" + name +
+                       "\" 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]