[chronojump] SqliteRunEncoder.Select returns a List<> instead of array



commit b954d31fdea899f326ba653f4727a1f2253440a6
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Mar 3 11:39:15 2021 +0100

    SqliteRunEncoder.Select returns a List<> instead of array

 src/gui/app1/runEncoder.cs  |  5 ++---
 src/sqlite/personSession.cs |  4 ++--
 src/sqlite/runEncoder.cs    | 13 +++++++------
 3 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index 7d22529f..21551989 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -731,7 +731,7 @@ public partial class ChronoJumpWindow
 
        private void run_encoder_load ()
        {
-               ArrayList data = SqliteRunEncoder.Select(false, -1, currentPerson.UniqueID, 
currentSession.UniqueID);
+               List<RunEncoder> data = SqliteRunEncoder.Select(false, -1, currentPerson.UniqueID, 
currentSession.UniqueID);
 
                ArrayList dataPrint = new ArrayList();
                int count = 1;
@@ -810,8 +810,7 @@ public partial class ChronoJumpWindow
 
                genericWin.HideAndNull();
 
-               ArrayList data = SqliteRunEncoder.Select(false, uniqueID, currentPerson.UniqueID, 
currentSession.UniqueID);
-               RunEncoder re = (RunEncoder) data[0];
+               RunEncoder re = (RunEncoder) SqliteRunEncoder.Select(false, uniqueID, currentPerson.UniqueID, 
currentSession.UniqueID)[0];
                if(re == null)
                {
                        new DialogMessage(Constants.MessageTypes.WARNING, Constants.FileNotFoundStr());
diff --git a/src/sqlite/personSession.cs b/src/sqlite/personSession.cs
index 53005c2a..f29dd29d 100644
--- a/src/sqlite/personSession.cs
+++ b/src/sqlite/personSession.cs
@@ -515,8 +515,8 @@ class SqlitePersonSession : Sqlite
                }
 
                // 6) delete runEncoder and related triggers
-               ArrayList re_a = SqliteRunEncoder.Select (true, -1, -1, Convert.ToInt32(sessionID));
-               foreach(RunEncoder re in re_a)
+               List<RunEncoder> re_l = SqliteRunEncoder.Select (true, -1, -1, Convert.ToInt32(sessionID));
+               foreach(RunEncoder re in re_l)
                {
                        SqliteRunEncoder.DeleteSQLAndFiles (true, re); //deletes also the .csv
 
diff --git a/src/sqlite/runEncoder.cs b/src/sqlite/runEncoder.cs
index adea3286..5773118c 100644
--- a/src/sqlite/runEncoder.cs
+++ b/src/sqlite/runEncoder.cs
@@ -21,6 +21,7 @@
 using System;
 //using System.Data;
 using System.Collections;
+using System.Collections.Generic; //List<T>
 using System.IO; //DirectoryInfo
 using Mono.Data.Sqlite;
 using System.Text.RegularExpressions; //Regex
@@ -127,7 +128,7 @@ class SqliteRunEncoder : Sqlite
                        Util.FileDelete(re.FullVideoURL);
        }
 
-       public static ArrayList Select (bool dbconOpened, int uniqueID, int personID, int sessionID)
+       public static List<RunEncoder> Select (bool dbconOpened, int uniqueID, int personID, int sessionID)
        {
                openIfNeeded(dbconOpened);
 
@@ -154,11 +155,11 @@ class SqliteRunEncoder : Sqlite
                SqliteDataReader reader;
                reader = dbcmd.ExecuteReader();
 
-               ArrayList array = new ArrayList(1);
-               RunEncoder fs;
+               List<RunEncoder> list = new List<RunEncoder>();
+               RunEncoder re;
 
                while(reader.Read()) {
-                       fs = new RunEncoder (
+                       re = new RunEncoder (
                                        Convert.ToInt32(reader[0].ToString()),  //uniqueID
                                        Convert.ToInt32(reader[1].ToString()),  //personID
                                        Convert.ToInt32(reader[2].ToString()),  //sessionID
@@ -174,13 +175,13 @@ class SqliteRunEncoder : Sqlite
                                        reader[11].ToString(),                  //videoURL
                                        reader[12].ToString()                   //exerciseName
                                        );
-                       array.Add(fs);
+                       list.Add(re);
                }
 
                reader.Close();
                closeIfNeeded(dbconOpened);
 
-               return array;
+               return list;
        }
 
        public static ArrayList SelectRowsOfAnExercise(bool dbconOpened, int exerciseID)


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