[chronojump] SqliteJumpRj.SelectJumpData can write person.Name in description



commit 6689fd77def0c962d7e9be0f4166693415d1e35f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Mar 8 11:52:10 2022 +0100

    SqliteJumpRj.SelectJumpData can write person.Name in description

 src/chronojump.cs          |  2 +-
 src/gui/app1/chronojump.cs | 10 +++++-----
 src/jumpsRjFatigue.cs      |  2 +-
 src/old/server.cs          |  2 +-
 src/sqlite/jumpRj.cs       | 16 ++++++++++++++--
 5 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/src/chronojump.cs b/src/chronojump.cs
index d8602a40a..fcae24bd0 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -779,7 +779,7 @@ public class ChronoJump
                int existsTempData = Sqlite.TempDataExists(tableName);
                if(existsTempData > 0)
                {
-                       JumpRj myJumpRj = SqliteJumpRj.SelectJumpData("tempJumpRj", existsTempData, false);
+                       JumpRj myJumpRj = SqliteJumpRj.SelectJumpData("tempJumpRj", existsTempData, false, 
false);
                        try {
                                myJumpRj.InsertAtDB (true, Constants.JumpRjTable);
                        } catch {} //pitty, cannot insert
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 8af96faf6..65465d14f 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -1235,7 +1235,7 @@ public partial class ChronoJumpWindow
                                }
                        } else if(myTv == treeview_jumps_rj) {
                                if (myTreeViewJumpsRj.EventSelectedID > 0) {
-                                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false );
+                                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false, false );
                                        treeviewJumpsRjContextMenu(myJump);
                                }
                        } else if(myTv == treeview_runs) {
@@ -1674,7 +1674,7 @@ public partial class ChronoJumpWindow
 
                //graph the jump on realtime cairo graph. Using selectedJumpRj to avoid SQL select 
continuously
                if(selectedJumpRj == null || selectedJumpRj.UniqueID != myTreeViewJumpsRj.EventSelectedID)
-                       selectedJumpRj = SqliteJumpRj.SelectJumpData("jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false);
+                       selectedJumpRj = SqliteJumpRj.SelectJumpData("jumpRj", 
myTreeViewJumpsRj.EventSelectedID, true, false); //true: personNameInComment
 
                blankJumpReactiveRealtimeCaptureGraph ();
                PrepareJumpReactiveRealtimeCaptureGraph (selectedJumpRj.tvLast, selectedJumpRj.tcLast,
@@ -6322,7 +6322,7 @@ LogB.Debug("mc finished 5");
                //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
                if (myTreeViewJumpsRj.EventSelectedID > 0) {
                        //3.- obtain the data of the selected jump
-                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false );
+                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false, false );
                        eventOldPerson = myJump.PersonID;
                
                        //4.- edit this jump
@@ -6359,7 +6359,7 @@ LogB.Debug("mc finished 5");
        {
                LogB.Information("edit selected jump RJ accepted");
        
-               JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", myTreeViewJumpsRj.EventSelectedID, 
false );
+               JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", myTreeViewJumpsRj.EventSelectedID, 
false, false );
                
                //if person changed, fill treeview again, if not, only update it's line
                if(eventOldPerson == myJump.PersonID)
@@ -7118,7 +7118,7 @@ LogB.Debug("mc finished 5");
                //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
                if (myTreeViewJumpsRj.EventSelectedID > 0) {
                        //3.- obtain the data of the selected jump
-                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false );
+                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false, false );
                
                        //4.- edit this jump
                        repairJumpRjWin = RepairJumpRjWindow.Show(app1, myJump, preferences.digitsNumber);
diff --git a/src/jumpsRjFatigue.cs b/src/jumpsRjFatigue.cs
index d1568ddd3..a8c71916f 100644
--- a/src/jumpsRjFatigue.cs
+++ b/src/jumpsRjFatigue.cs
@@ -37,7 +37,7 @@ public class JumpsRjFatigue
        public void Calculate (int uniqueID, Statistic statistic)
        {
                //1 get data
-               JumpRj jumpRj = SqliteJumpRj.SelectJumpData (Constants.JumpRjTable, uniqueID, false);
+               JumpRj jumpRj = SqliteJumpRj.SelectJumpData (Constants.JumpRjTable, uniqueID, false, false);
 
                //2 convert to list of PointF
                List<double> y_l = jumpRj.HeightList; //(statistic == Statistic.HEIGHTS)
diff --git a/src/old/server.cs b/src/old/server.cs
index 6a399a6f4..764c80ab7 100644
--- a/src/old/server.cs
+++ b/src/old/server.cs
@@ -260,7 +260,7 @@ public class Server
                                foreach(string myJump in jumps) {
                                        string [] js = myJump.Split(new char[] {':'});
                                        //select jump
-                                       Jump test = SqliteJump.SelectJumpData(Convert.ToInt32(js[1]), true); 
//uniqueID
+                                       Jump test = SqliteJump.SelectJumpData(Convert.ToInt32(js[1]), false, 
true); //uniqueID
                                        //fix it to server person, session keys
                                        test.PersonID = person.ServerUniqueID;
                                        test.SessionID = currentSession.ServerUniqueID;
diff --git a/src/sqlite/jumpRj.cs b/src/sqlite/jumpRj.cs
index 87c81be90..34a814d72 100644
--- a/src/sqlite/jumpRj.cs
+++ b/src/sqlite/jumpRj.cs
@@ -251,14 +251,23 @@ class SqliteJumpRj : SqliteJump
                return myJumps;
        }
 
-       public static JumpRj SelectJumpData(string tableName, int uniqueID, bool dbconOpened)
+       public static JumpRj SelectJumpData(string table, int uniqueID, bool personNameInComment, bool 
dbconOpened)
        {
                //tableName is jumpRj or tempJumpRj
 
                if(!dbconOpened)
                        Sqlite.Open();
 
-               dbcmd.CommandText = "SELECT * FROM " + tableName + " WHERE uniqueID == " + uniqueID;
+               if(personNameInComment)
+               {
+                       //select jumpRj.*, person77.name from jumpRj, person77 where jumpRj.personID = 
person77.uniqueID order by uniqueID DESC limit 5;
+                       string tp = Constants.PersonTable;
+                       dbcmd.CommandText = "SELECT " + table + ".*, " + tp + ".Name" +
+                               " FROM " + table + ", " + tp +
+                               " WHERE " + table + ".personID = " + tp + ".uniqueID" +
+                               " AND " + table + ".uniqueID = " + uniqueID;
+               } else
+                       dbcmd.CommandText = "SELECT * FROM " + table + " WHERE uniqueID = " + uniqueID;
                
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();
@@ -268,10 +277,13 @@ class SqliteJumpRj : SqliteJump
                reader.Read();
 
                JumpRj myJump = new JumpRj(DataReaderToStringArray(reader, 19));
+               if(personNameInComment)
+                       myJump.Description = reader[19].ToString(); //person.Name
 
                reader.Close();
                if(!dbconOpened)
                        Sqlite.Close();
+
                return myJump;
        }
 


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