diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-06 18:20:21 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-06 18:20:21 +0200 |
| commit | 0baf31baf01a291b6d2c6f5d45fb15fbbc146198 (patch) | |
| tree | 96d6fc1b4a5f1385ce2224233ea076d85972ee0d /Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs | |
| parent | 258399bb206839cdb7cd276839675fa14910bc36 (diff) | |
| download | Tango-0baf31baf01a291b6d2c6f5d45fb15fbbc146198.tar.gz Tango-0baf31baf01a291b6d2c6f5d45fb15fbbc146198.zip | |
Working on Azure Utils.
Diffstat (limited to 'Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs index 56228e1c5..695ef9d4f 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.AzureUtils.Deployment; +using Tango.AzureUtils.Environment; using Tango.Core.Commands; using Tango.SharedUI; @@ -34,11 +35,11 @@ namespace Tango.AzureUtils.UI.ViewModels set { _selectedTargetAPp = value; RaisePropertyChangedAuto(); } } - private DeploymentManager _deploymentManager; - public DeploymentManager DeploymentManager + private EnvironmentManager _environmentManager; + public EnvironmentManager EnvironmentManager { - get { return _deploymentManager; } - set { _deploymentManager = value; RaisePropertyChangedAuto(); } + get { return _environmentManager; } + set { _environmentManager = value; RaisePropertyChangedAuto(); } } private bool _canUpgrade; @@ -48,11 +49,23 @@ namespace Tango.AzureUtils.UI.ViewModels set { _canUpgrade = value; RaisePropertyChangedAuto(); } } + private UpgradeEnvironmentConfiguration _config; + public UpgradeEnvironmentConfiguration Config + { + get { return _config; } + set { _config = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand ValidateUpgradeCommand { get; set; } + public RelayCommand UpgradeEnvironmentCommand { get; set; } + public EnvironmentUpgradeViewVM() { + Config = new UpgradeEnvironmentConfiguration(); ValidateUpgradeCommand = new RelayCommand(() => ValidateUpgrade()); + UpgradeEnvironmentCommand = new RelayCommand(() => UpgradeEnvironment()); } public override void OnAuthenticated(IAzure azure, List<IWebAppBase> apps) @@ -62,9 +75,8 @@ namespace Tango.AzureUtils.UI.ViewModels SelectedSourceApp = Apps.FirstOrDefault(); SelectedTargetApp = Apps.FirstOrDefault(); - DeploymentManager = new DeploymentManager(azure); - DeploymentManager.Progress += (x, e) => StatusManager.UpdateStatus(e); - DeploymentManager.UpgradeConfiguration.PropertyChanged += (x, e) => CanUpgrade = false; + EnvironmentManager = new EnvironmentManager(azure); + EnvironmentManager.Progress += (x, e) => StatusManager.UpdateStatus(e); } private async void ValidateUpgrade() @@ -78,7 +90,7 @@ namespace Tango.AzureUtils.UI.ViewModels { IsFree = false; StatusManager.UpdateStatus(AzureUtilsStage.Validating, "Validating configuration...", true); - await DeploymentManager.ValidateUpgrade(SelectedSourceApp, SelectedTargetApp); + await EnvironmentManager.ValidateEnvironmentUpgrade(SelectedSourceApp, SelectedTargetApp, Config); CanUpgrade = true; StatusManager.UpdateStatus(AzureUtilsStage.Ready, "Configuration validated successfully."); } @@ -92,5 +104,22 @@ namespace Tango.AzureUtils.UI.ViewModels IsFree = true; } } + + private async void UpgradeEnvironment() + { + try + { + IsFree = false; + await EnvironmentManager.UpgradeEnvironment(SelectedSourceApp, SelectedTargetApp, Config); + } + catch (Exception ex) + { + StatusManager.UpdateStatus(ex); + } + finally + { + IsFree = true; + } + } } } |
