aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-11-26 17:33:02 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-11-26 17:33:02 +0200
commitca29510e1e336c4d68aaa926cfea6eb72ce42779 (patch)
tree298c10a1567df22cf594054271dd5ce656f09c12 /Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels
parent6c43f97559613443e781917a827c3b644db03490 (diff)
downloadTango-ca29510e1e336c4d68aaa926cfea6eb72ce42779.tar.gz
Tango-ca29510e1e336c4d68aaa926cfea6eb72ce42779.zip
Working on backup/restore...
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupViewVM.cs6
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreViewVM.cs113
2 files changed, 115 insertions, 4 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupViewVM.cs
index dd561c5be..ab8d0248f 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupViewVM.cs
@@ -71,14 +71,14 @@ namespace Tango.PPC.BackupRestore.ViewModels
public String BackupLocation
{
get { return _backupLocation; }
- set { _backupLocation = value; RaisePropertyChangedAuto(); }
+ set { _backupLocation = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
private String _backupName;
public String BackupName
{
get { return _backupName; }
- set { _backupName = value; RaisePropertyChangedAuto(); }
+ set { _backupName = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
public RelayCommand BackupCommand { get; set; }
@@ -88,7 +88,7 @@ namespace Tango.PPC.BackupRestore.ViewModels
public BackupViewVM()
{
BrowseBackupLocationCommand = new RelayCommand(BrowseBackupLocation);
- BackupCommand = new RelayCommand(StartBackup);
+ BackupCommand = new RelayCommand(StartBackup, () => !String.IsNullOrWhiteSpace(BackupName) && BackupLocation != null);
IsBackupJobs = true;
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreViewVM.cs
index 904fd9e52..ec6083436 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreViewVM.cs
@@ -3,15 +3,126 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.Core.Commands;
+using Tango.Core.DI;
+using Tango.Explorer;
+using Tango.PPC.BackupRestore.Views;
using Tango.PPC.Common;
+using Tango.PPC.Common.BackupRestore;
+using Tango.PPC.Storage;
namespace Tango.PPC.BackupRestore.ViewModels
{
public class RestoreViewVM : PPCViewModel
{
+ private string _backupFileLocation;
+
+ [TangoInject]
+ public IBackupManager BackupManager { get; set; }
+
+ private String _backupFileName;
+ public String BackupFileName
+ {
+ get { return _backupFileName; }
+ set { _backupFileName = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
+ }
+
+ private RestoreSettings _restoreSettings;
+ public RestoreSettings RestoreSettings
+ {
+ get { return _restoreSettings; }
+ set { _restoreSettings = value; RaisePropertyChangedAuto(); }
+ }
+
+ private BackupFile _backupFile;
+ public BackupFile BackupFile
+ {
+ get { return _backupFile; }
+ set { _backupFile = value; RaisePropertyChangedAuto(); }
+ }
+
+ private BackupRestoreProgressEventArgs _currentRestoreProgress;
+ public BackupRestoreProgressEventArgs CurrentRestoreProgress
+ {
+ get { return _currentRestoreProgress; }
+ set { _currentRestoreProgress = value; RaisePropertyChangedAuto(); }
+ }
+
+ public RelayCommand BrowseForBackupCommand { get; set; }
+
+ public RelayCommand RestoreCommand { get; set; }
+
+ public RestoreViewVM()
+ {
+ RestoreSettings = new RestoreSettings();
+ RestoreCommand = new RelayCommand(StartRestore, () => BackupFileName != null);
+ BrowseForBackupCommand = new RelayCommand(BrowseForBackup);
+ }
+
+ private async void StartRestore()
+ {
+ await NavigationManager.NavigateTo<BackupRestoreModule>(nameof(RestoreProgressView));
+
+ if (IsFree)
+ {
+ IsFree = false;
+ var result = await BackupManager.Restore(_backupFileLocation, RestoreSettings);
+ IsFree = true;
+ }
+ }
+
+ private async void BrowseForBackup()
+ {
+ var result = await NavigationManager.
+ NavigateForResult<StorageModule,
+ Storage.Views.MainView, ExplorerFileItem,
+ Storage.Models.StorageNavigationRequest>(
+ new Storage.Models.StorageNavigationRequest()
+ {
+ Intent = Storage.Models.StorageNavigationIntent.LoadFile,
+ Filter = ExplorerFileDefinition.Backup.Extension,
+ Title = "Select Backup File",
+ });
+
+ if (result != null)
+ {
+ _backupFileLocation = result.Path;
+
+ try
+ {
+ BackupFile = await BackupManager.ExtractBackupConfiguration(_backupFileLocation);
+ BackupFileName = System.IO.Path.GetFileName(result.Path);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, $"Error extracting backup configuration from file '{_backupFileLocation}'.");
+ await NotificationProvider.ShowError($"Error occurred while trying to extract the backup file information\n{ex.FlattenMessage()}");
+ }
+ }
+ }
+
+ public override void OnNavigatedFrom()
+ {
+ base.OnNavigatedFrom();
+ BackupFileName = null;
+ BackupFile = null;
+ _backupFileLocation = null;
+ }
+
+ public override void OnApplicationReady()
+ {
+ base.OnApplicationReady();
+ BackupManager.Progress += BackupManager_Progress;
+ }
+
+ private void BackupManager_Progress(object sender, BackupRestoreProgressEventArgs e)
+ {
+ CurrentRestoreProgress = e;
+ }
+
public override void OnApplicationStarted()
{
-
+
}
}
}