blob: 56228e1c5495b602d137278206e8c93c420984dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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;
}
}
}
}
|