[chronojump] export session copy files done (need deletes on db and pulsebars)



commit 2eaaea0be834e3b7f4e15239ab69e89132536002
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jun 26 16:07:14 2020 +0200

    export session copy files done (need deletes on db and pulsebars)

 src/gui/app1/session/export.cs | 98 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 96 insertions(+), 2 deletions(-)
---
diff --git a/src/gui/app1/session/export.cs b/src/gui/app1/session/export.cs
index a47e4a6f..015c4e18 100644
--- a/src/gui/app1/session/export.cs
+++ b/src/gui/app1/session/export.cs
@@ -25,17 +25,18 @@ using System.Diagnostics;  //Stopwatch
 using System.Threading;
 using Mono.Unix;
 
+//uses some code on gui/app1/session/backup.cs
 public partial class ChronoJumpWindow
 {
+       private Thread app1s_threadExport;
+
        private void on_button_session_export_pre_clicked (object o, EventArgs args)
        {
-               /*
                if(! app1s_getDatabaseFile())
                {
                        new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error. Cannot 
find database."));
                        return;
                }
-               */
 
                app1s_label_export_destination.Text = "";
                app1s_label_export_progress.Text = "";
@@ -71,6 +72,99 @@ public partial class ChronoJumpWindow
                app1s_fc.Destroy();
        }
 
+       private void on_app1s_button_export_start_clicked (object o, EventArgs args)
+       {
+               try {
+                       bool exists = false;
+                       if(Directory.Exists(app1s_fileCopy))
+                       {
+                               LogB.Information(string.Format("Directory {0} exists, created at {1}",
+                                                       app1s_fileCopy, 
Directory.GetCreationTime(app1s_fileCopy)));
+                               exists = true;
+                       }
+
+                       if(exists) {
+                               LogB.Information("Overwrite...");
+                               ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Are you sure 
you want to overwrite: "), "", app1s_fileCopy);
+                               confirmWin.Button_accept.Clicked += new 
EventHandler(app1s_export_on_overwrite_file_accepted);
+                       } else {
+                               app1s_uc = new UtilCopy(currentSession.UniqueID);
+                               app1s_threadExport = new Thread(new ThreadStart(app1s_copyRecursive));
+                               GLib.Idle.Add (new GLib.IdleHandler (app1s_ExportPulseGTK));
+
+//                             app1s_backup_doing_sensitive_start_end(true);
+
+                               LogB.ThreadStart();
+                               app1s_threadExport.Start();
+                       }
+               }
+               catch {
+                       string myString = string.Format(Catalog.GetString("Cannot copy to {0} "), 
app1s_fileCopy);
+                       new DialogMessage(Constants.MessageTypes.WARNING, myString);
+               }
+       }
+
+       private bool app1s_ExportPulseGTK ()
+       {
+               if ( ! app1s_threadExport.IsAlive ) {
+               /*
+                       LogB.ThreadEnding();
+                       app1s_ExportPulseEnd();
+
+                       LogB.ThreadEnded();
+                       */
+                       return false;
+               }
+
+               /*
+               app1s_pulsebarExportActivity.Pulse();
+               app1s_pulsebarExportDirs.Fraction = UtilAll.DivideSafeFraction(app1s_uc.ExportMainDirsCount, 
6);
+               //6 for: database, encoder, forceSensor, logs, multimedia, raceAnalyzer
+
+               app1s_pulsebarExportDirs.Text = app1s_uc.LastMainDir;
+               app1s_pulsebarExportSecondDirs.Fraction =
+                       UtilAll.DivideSafeFraction(app1s_uc.ExportSecondDirsCount, 
app1s_uc.ExportSecondDirsLength);
+               app1s_pulsebarExportSecondDirs.Text = app1s_uc.LastSecondDir;
+
+               Thread.Sleep (30);
+               //LogB.Debug(app1s_threadExport.ThreadState.ToString());
+               */
+               return true;
+       }
+
+       private void app1s_export_on_overwrite_file_accepted(object o, EventArgs args)
+       {
+               try {
+                       Directory.Delete(app1s_fileCopy, true);
+                       app1s_uc = new UtilCopy(currentSession.UniqueID);
+                       app1s_threadExport = new Thread(new ThreadStart(app1s_copyRecursive));
+                       GLib.Idle.Add (new GLib.IdleHandler (app1s_ExportPulseGTK));
+
+//                     app1s_backup_doing_sensitive_start_end(true);
+
+                       LogB.ThreadStart();
+                       app1s_threadExport.Start();
+               } catch {
+                       new DialogMessage(Constants.MessageTypes.WARNING,
+                               string.Format(Catalog.GetString("Cannot copy to {0} "), app1s_fileCopy));
+               }
+       }
+
+       static long app1s_exportElapsedMs;
+       private void app1s_export()
+       {
+               app1s_exportElapsedMs = 0;
+               Stopwatch sw = new Stopwatch();
+               sw.Start();
+
+               app1s_uc.CopyFilesRecursively(new DirectoryInfo(Util.GetParentDir(false)), new 
DirectoryInfo(app1s_fileCopy), 0);
+
+               //TODO: now need to open database and delete unwanted sessions, and all stuff related to 
those sessions
+
+               sw.Stop();
+
+               app1s_exportElapsedMs = sw.ElapsedMilliseconds;
+       }
 
        private void on_app1s_button_export_cancel_or_close_clicked (object o, EventArgs args)
        {


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