Beispiel #1
0
        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());
            }
        }
Beispiel #2
0
        public async Task Handle(HealthCheckRequest <ReleaseEnvironmentWidget> request, CancellationToken cancellationToken)
        {
            var widget = request.DataContext;

            if (widget.Parent is ReleaseWidget parent && parent.DefinitionId != 0)
            {
                var api = new AzureDevOpsApi(parent.ConnectionSettings);

                var response = await api.GetDeploymentsAsync(parent.Project, parent.DefinitionId, widget.DefinitionEnvironmentId, 10, cancellationToken).ConfigureAwait(false);

                var deployments = response.Value.ToList();

                if (deployments.Any())
                {
                    deployments.Reverse();

                    var maxDuration = deployments.Max(deployment => deployment.Duration);

                    deployments.ForEach(deployment => deployment.Percentage = (double)deployment.Duration.Ticks / maxDuration.Ticks);
                }

                widget.JobHistory = deployments;
            }
        }