[chronojump] ForceSensor RunEncoder delete, deletes also the video (if exists)



commit d0602d5a61be7b7ab05171d40776115d13497b9d
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Sep 18 17:06:31 2019 +0200

    ForceSensor RunEncoder delete, deletes also the video (if exists)

 src/constants.cs          |  2 +-
 src/forceSensor.cs        |  9 +++++++++
 src/gui/forceSensor.cs    |  2 +-
 src/runEncoder.cs         |  9 +++++++++
 src/sqlite/forceSensor.cs |  7 +++++--
 src/sqlite/runEncoder.cs  | 11 +++++++----
 6 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index 191eaf22..27392413 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -112,7 +112,7 @@ public class Constants
        public const string SubtractionBetweenTests = "Subtraction between tests";
 
        //tests types (dont' use character '-' will be used multimedia file names)
-       public enum TestTypes { JUMP, JUMP_RJ, RUN, RUN_I, FORCESENSOR, RT, PULSE, MULTICHRONOPIC, ENCODER }
+       public enum TestTypes { JUMP, JUMP_RJ, RUN, RUN_I, FORCESENSOR, RT, PULSE, MULTICHRONOPIC, ENCODER, 
RACEANALYZER }
        public static string JumpSimpleName = "Jump simple";
        public static string JumpReactiveName = "Jump reactive";
        public static string RunSimpleName = "Run simple";
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 9af80a94..5132f03c 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -187,6 +187,15 @@ public class ForceSensor
        {
                get { return Util.GetForceSensorSessionDir(sessionID) + Path.DirectorySeparatorChar + 
filename; }
        }
+       public string FullVideoURL
+       {
+               get {
+                       if(videoURL == "")
+                               return "";
+
+                       return Util.GetVideoFileName(sessionID, Constants.TestTypes.FORCESENSOR, uniqueID);
+               }
+       }
        public string Filename
        {
                get { return filename; }
diff --git a/src/gui/forceSensor.cs b/src/gui/forceSensor.cs
index 1d2ed483..ae0b64e0 100644
--- a/src/gui/forceSensor.cs
+++ b/src/gui/forceSensor.cs
@@ -1515,7 +1515,7 @@ LogB.Information(" re R ");
        private void forceSensorDeleteTestDo(ForceSensor fs)
        {
                //int uniqueID = currentForceSensor.UniqueID;
-               SqliteForceSensor.DeleteSQLAndFile (false, fs); //deletes also the .csv
+               SqliteForceSensor.DeleteSQLAndFiles (false, fs); //deletes also the .csv
        }
 
        // ---- end of forceSensorDeleteTest stuff -------
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index d522e895..b24d2425 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -165,6 +165,15 @@ public class RunEncoder
        {
                get { return Util.GetRunEncoderSessionDir(sessionID) + Path.DirectorySeparatorChar + 
filename; }
        }
+       public string FullVideoURL
+       {
+               get {
+                       if(videoURL == "")
+                               return "";
+
+                       return Util.GetVideoFileName(sessionID, Constants.TestTypes.RACEANALYZER, uniqueID);
+               }
+       }
        public string Filename
        {
                get { return filename; }
diff --git a/src/sqlite/forceSensor.cs b/src/sqlite/forceSensor.cs
index f4a8a0a5..d0a1a3e5 100644
--- a/src/sqlite/forceSensor.cs
+++ b/src/sqlite/forceSensor.cs
@@ -111,7 +111,7 @@ class SqliteForceSensor : Sqlite
                DeleteSQLAndFile (dbconOpened, fs);
        }
        */
-       public static void DeleteSQLAndFile (bool dbconOpened, ForceSensor fs)
+       public static void DeleteSQLAndFiles (bool dbconOpened, ForceSensor fs)
        {
                openIfNeeded(dbconOpened);
 
@@ -122,8 +122,11 @@ class SqliteForceSensor : Sqlite
 
                closeIfNeeded(dbconOpened);
 
-               //delete the file
+               //delete the files
                Util.FileDelete(fs.FullURL);
+
+               if(fs.FullVideoURL != "")
+                       Util.FileDelete(fs.FullVideoURL);
        }
 
        //SELECT forceSensor.*, forceSensorExercise.Name FROM forceSensor, forceSensorExercise WHERE 
forceSensor.exerciseID = forceSensorExercise.UniqueID ORDER BY forceSensor.uniqueID;
diff --git a/src/sqlite/runEncoder.cs b/src/sqlite/runEncoder.cs
index d5f1ab15..faf1da66 100644
--- a/src/sqlite/runEncoder.cs
+++ b/src/sqlite/runEncoder.cs
@@ -109,19 +109,22 @@ class SqliteRunEncoder : Sqlite
                DeleteSQLAndFile (dbconOpened, fs);
        }
        */
-       public static void DeleteSQLAndFile (bool dbconOpened, RunEncoder fs)
+       public static void DeleteSQLAndFiles (bool dbconOpened, RunEncoder re)
        {
                openIfNeeded(dbconOpened);
 
-               dbcmd.CommandText = "DELETE FROM " + table + " WHERE uniqueID = " + fs.UniqueID;
+               dbcmd.CommandText = "DELETE FROM " + table + " WHERE uniqueID = " + re.UniqueID;
 
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();
 
                closeIfNeeded(dbconOpened);
 
-               //delete the file
-               Util.FileDelete(fs.FullURL);
+               //delete the files
+               Util.FileDelete(re.FullURL);
+
+               if(re.FullVideoURL != "")
+                       Util.FileDelete(re.FullVideoURL);
        }
 
        public static ArrayList Select (bool dbconOpened, int uniqueID, int personID, int sessionID)


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