aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs
diff options
context:
space:
mode:
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.cs96
1 files changed, 96 insertions, 0 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
new file mode 100644
index 000000000..56228e1c5
--- /dev/null
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/ViewModels/EnvironmentUpgradeViewVM.cs
@@ -0,0 +1,96 @@
+using Microsoft.Azure.Management.AppService.Fluent;
+using Microsoft.Azure.Management.Fluent;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.AzureUtils.Deployment;
+using Tango.Core.Commands;
+using Tango.SharedUI;
+
+namespace Tango.AzureUtils.UI.ViewModels
+{
+ public class EnvironmentUpgradeViewVM : AzureDashboardViewModel
+ {
+ private List<IWebAppBase> _apps;
+ public List<IWebAppBase> Apps
+ {
+ get { return _apps; }
+ set { _apps = value; RaisePropertyChangedAuto(); }
+ }
+
+ private IWebAppBase _selectedSourceApp;
+ public IWebAppBase SelectedSourceApp
+ {
+ get { return _selectedSourceApp; }
+ set { _selectedSourceApp = value; RaisePropertyChangedAuto(); }
+ }
+
+ private IWebAppBase _selectedTargetAPp;
+ public IWebAppBase SelectedTargetApp
+ {
+ get { return _selectedTargetAPp; }
+ set { _selectedTargetAPp = value; RaisePropertyChangedAuto(); }
+ }
+
+ private DeploymentManager _deploymentManager;
+ public DeploymentManager DeploymentManager
+ {
+ get { return _deploymentManager; }
+ set { _deploymentManager = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _canUpgrade;
+ public bool CanUpgrade
+ {
+ get { return _canUpgrade; }
+ set { _canUpgrade = value; RaisePropertyChangedAuto(); }
+ }
+
+ public RelayCommand ValidateUpgradeCommand { get; set; }
+
+ public EnvironmentUpgradeViewVM()
+ {
+ ValidateUpgradeCommand = new RelayCommand(() => ValidateUpgrade());
+ }
+
+ public override void OnAuthenticated(IAzure azure, List<IWebAppBase> apps)
+ {
+ Apps = apps;
+
+ SelectedSourceApp = Apps.FirstOrDefault();
+ SelectedTargetApp = Apps.FirstOrDefault();
+
+ DeploymentManager = new DeploymentManager(azure);
+ DeploymentManager.Progress += (x, e) => StatusManager.UpdateStatus(e);
+ DeploymentManager.UpgradeConfiguration.PropertyChanged += (x, e) => CanUpgrade = false;
+ }
+
+ private async void ValidateUpgrade()
+ {
+ if (SelectedSourceApp == null || SelectedTargetApp == null)
+ {
+ return;
+ }
+
+ try
+ {
+ IsFree = false;
+ StatusManager.UpdateStatus(AzureUtilsStage.Validating, "Validating configuration...", true);
+ await DeploymentManager.ValidateUpgrade(SelectedSourceApp, SelectedTargetApp);
+ CanUpgrade = true;
+ StatusManager.UpdateStatus(AzureUtilsStage.Ready, "Configuration validated successfully.");
+ }
+ catch (Exception ex)
+ {
+ CanUpgrade = false;
+ StatusManager.UpdateStatus(ex);
+ }
+ finally
+ {
+ IsFree = true;
+ }
+ }
+ }
+}