From ca18248f6203d7567a2276ec76360aedd4cfda0b Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 25 Nov 2019 16:38:54 +0200 Subject: Working on Backup/Restore... --- .../BackupRestore/BackupFile.cs | 64 ++++++++++++++++++++++ .../BackupRestore/BackupMode.cs | 23 ++++++++ .../BackupRestoreProgressEventArgs.cs | 36 ++++++++++++ .../BackupRestore/BackupRestoreStage.cs | 47 ++++++++++++++++ .../BackupRestore/BackupSettings.cs | 19 +++++++ .../BackupRestore/IBackupManager.cs | 34 ++++++++++++ .../Tango.PPC.Common/BackupRestore/BackupMode.cs | 12 ++++ .../BackupRestoreProgressEventArgs.cs | 16 ++++++ 8 files changed, 251 insertions(+) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupFile.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupMode.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupRestoreProgressEventArgs.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupRestoreStage.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupSettings.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/IBackupManager.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/BackupRestore/BackupMode.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/BackupRestore/BackupRestoreProgressEventArgs.cs diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupFile.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupFile.cs new file mode 100644 index 000000000..4425aad9e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupFile.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Web; + +namespace Tango.PPC.Common.BackupRestore +{ + /// + /// Represents a backup file record. + /// + public class BackupFile + { + /// + /// Gets or sets the backup name. + /// + public String Name { get; set; } + + /// + /// Gets or sets the creation date. + /// + public DateTime Date { get; set; } + + /// + /// Gets or sets the machine serial number. + /// + public String MachineSerialNumber { get; set; } + + /// + /// Gets or sets the application version. + /// + public String ApplicationVersion { get; set; } + + /// + /// Gets or sets the firmware version. + /// + public String FirmwareVersion { get; set; } + + /// + /// Gets or sets the settings file. + /// + public String SettingsFile { get; set; } + + /// + /// Gets or sets the job files. + /// + public List JobFiles { get; set; } + + /// + /// Gets or sets the backup settings. + /// + public BackupSettings Settings { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public BackupFile() + { + Settings = new BackupSettings(); + JobFiles = new List(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupMode.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupMode.cs new file mode 100644 index 000000000..8533ce22a --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupMode.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.BackupRestore +{ + /// + /// Represents a backup mode. + /// + public enum BackupMode + { + /// + /// Jobs only backup. + /// + Jobs, + /// + /// Complete backup of data, app binaries, firmware and settings file. + /// + Full, + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupRestoreProgressEventArgs.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupRestoreProgressEventArgs.cs new file mode 100644 index 000000000..d12db7b56 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupRestoreProgressEventArgs.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.BackupRestore +{ + /// + /// Represents a backup restore procedure progress. + /// + /// + public class BackupRestoreProgressEventArgs : EventArgs + { + /// + /// Gets or sets a value indicating whether the progress is intermediate. + /// + public bool IsIntermediate { get; set; } + + /// + /// Gets or sets the progress value. + /// + public double Progress { get; set; } + + + /// + /// Gets or sets the maximum progress. + /// + public double MaxProgress { get; set; } + + /// + /// Gets or sets the progress stage. + /// + public BackupRestoreStage Stage { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupRestoreStage.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupRestoreStage.cs new file mode 100644 index 000000000..efef2d4d0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupRestoreStage.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.BackupRestore +{ + /// + /// Represents a backup restore procedure stage. + /// + public enum BackupRestoreStage + { + [Description("Initializing")] + Initializing, + + //Backup + [Description("Backing up data...")] + BackingupDatabase, + [Description("Backing up application...")] + BackingupApplication, + [Description("Backing up settings...")] + BackingupSettings, + [Description("Writing settings...")] + WritingSettings, + [Description("Compressing files...")] + CompressingFiles, + [Description("Finalizing backup...")] + FinalizingBackup, + + //Restore + [Description("Validating backup...")] + ValidatingBackup, + [Description("Extracting content...")] + ExtractingContent, + [Description("Restoring data...")] + RestoringDatabase, + + + [Description("Done")] + Done, + + [Description("Error")] + Error, + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupSettings.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupSettings.cs new file mode 100644 index 000000000..b2021ba39 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/BackupSettings.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.BackupRestore +{ + /// + /// Represents a backup settings. + /// + public class BackupSettings + { + /// + /// Gets or sets the backup mode. + /// + public BackupMode Mode { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/IBackupManager.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/IBackupManager.cs new file mode 100644 index 000000000..a50f0ab60 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/BackupRestore/IBackupManager.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.BackupRestore +{ + /// + /// Represents a backup/restore manager. + /// + public interface IBackupManager + { + /// + /// Occurs when the backup/restore procedure makes progress. + /// + event EventHandler Progress; + + /// + /// Creates a backup file containing database, application and firmware versions. + /// + /// The file path. + /// Backup configuration. + /// + Task CreateBackup(String filePath, BackupSettings settings); + + /// + /// Restores a backup located in the specified file path. + /// + /// The file path. + /// + Task Restore(String filePath); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/BackupRestore/BackupMode.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/BackupRestore/BackupMode.cs new file mode 100644 index 000000000..5e2f6d168 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/BackupRestore/BackupMode.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.BackupRestore +{ + class BackupMode + { + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/BackupRestore/BackupRestoreProgressEventArgs.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/BackupRestore/BackupRestoreProgressEventArgs.cs new file mode 100644 index 000000000..402db821a --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/BackupRestore/BackupRestoreProgressEventArgs.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.BackupRestore +{ + public class BackupRestoreEventArgs : EventArgs + { + public bool IsIntermediate { get; set; } + public double Progress { get; set; } + public double MaxProgress { get; set; } + public BackupRestoreStage Stage { get; set; } + } +} -- cgit v1.3.1