public async Task Handle(StartRequest <ReleaseEnvironmentWidget> request, CancellationToken cancellationToken) { var dialog = new ConfirmationDialog($"Are you sure you want to start {request.DataContext.Name}?"); if (_dialogService.ShowDialog(dialog) != DialogResult.Yes) { return; } if (request.DataContext.Parent is ReleaseWidget parent) { var api = new AzureDevOpsApi(parent.ConnectionSettings); var response = await api.GetReleasesAsync(parent.Project, parent.DefinitionId, 1, cancellationToken).ConfigureAwait(false); if (response.Count == 0) { throw new Exception("Release not found."); } var release = response.Value.First(); await api.DeployAsync(parent.Project, release.Id, request.DataContext.DeploymentId, cancellationToken).ConfigureAwait(false); request.DataContext.State = State.Queued; } }
public async Task Handle(HealthCheckRequest <ReleaseWidget> request, CancellationToken cancellationToken) { var widget = request.DataContext; var api = new AzureDevOpsApi(widget.ConnectionSettings); var releases = await api.GetReleasesAsync(widget.Project, widget.DefinitionId, 1, cancellationToken).ConfigureAwait(false); if (releases.Count == 0) { widget.State = State.None; return; } var release = releases.Value.First(); UpdateInfo(widget, release); _uiAction.Invoke(() => UpdateEnvironments(widget, release)); var deployments = await api.GetDeploymentsAsync(widget.Project, widget.DefinitionId, 10, cancellationToken).ConfigureAwait(false); if (deployments.Count > 0) { UpdateHistory(widget, deployments.Value.ToList()); } }