[chronojump/michrolab] admin (Networks) can use another DB (using DataDir on config). TODO: foreign SQL may need to be upda



commit fcc8eaccc9a481c1c13c9ad1c9c087d23c87e576
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jun 8 10:06:53 2022 +0200

    admin (Networks) can use another DB (using DataDir on config). TODO: foreign SQL may need to be updated

 src/config.cs       | 12 ++++++++++++
 src/gui/networks.cs | 11 +++++++++++
 src/util.cs         | 10 +++++++---
 3 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/src/config.cs b/src/config.cs
index 4982f5698..15d8ef901 100644
--- a/src/config.cs
+++ b/src/config.cs
@@ -29,6 +29,7 @@ public class Config
        public static bool UseSystemColor; //do nothing at all
        public static Gdk.Color ColorBackground;
        public static bool ColorBackgroundIsDark;
+       public static string DataDirStatic = "";
 
        public enum SessionModeEnum { STANDARD, UNIQUE, MONTHLY }
 
@@ -60,6 +61,8 @@ public class Config
        public bool LowHeight; //devices with less than 500 px vertical, like Odroid Go Super
        public bool LowCPU; //workaround to not show realtime graph on force sensor capture (until its 
optimized)
        public bool GuiTest;
+       public string DataDir = ""; //on chronojump-networks admin to replace GetLocalDataDir (), think if 
Import has to be disabled
+
        /*
         * unused because the default serverURL chronojump.org is ok:
         * public string ExhibitionServerURL = "";
@@ -145,6 +148,15 @@ public class Config
                                                LowCPU = true;
                                        else if(parts[0] == "GuiTest" && Util.StringToBool(parts[1]))
                                                GuiTest = true;
+                                       else if(parts[0] == "DataDir" && parts[1] != "")
+                                       {
+                                               DataDir = parts[1];
+                                               /*
+                                                  DataDirStatic is assigned later to not be active on 
chronojump.cs,
+                                                  start when gui is started, to not mess with 
runningFileName and others
+                                               DataDirStatic = parts[1]; //called from Util.GetLocalDataDir
+                                                */
+                                       }
                                } while(true);
                        }
                }
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 1462cbfbe..f0b85b430 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -284,6 +284,17 @@ public partial class ChronoJumpWindow
                        SqliteJson.UploadExhibitionTestsPending();
                }
 
+               if (configChronojump.DataDir != "")
+               {
+                       Sqlite.DisConnect ();
+
+                       //called from Util.GetLocalDataDir
+                       Config.DataDirStatic = configChronojump.DataDir;
+                       Sqlite.SetHome ();
+
+                       Sqlite.Connect ();
+               }
+
                configDo();
        }
        private void RFIDStart()
diff --git a/src/util.cs b/src/util.cs
index 7a393c0db..53b1d2fe0 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -969,10 +969,14 @@ public class Util
        //this will check if any config path is present
        public static string GetLocalDataDir (bool withFinalSeparator)
        {
-               //if (defaultPath)
+               if (Config.DataDirStatic == "")
                        return UtilAll.GetDefaultLocalDataDir (withFinalSeparator); //this can be checked by 
Mini
-               //else
-               //      return ""; //TODO
+               else {
+                       if (withFinalSeparator)
+                                return Config.DataDirStatic + Path.DirectorySeparatorChar;
+                       else
+                                return Config.DataDirStatic;
+               }
        }
 
        public static string GetConfigFileName() {


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