Пример #1
0
        private static void AddEnvironments(VSTSRelease_v1 vstsRelease, VSTSReleaseDetails releaseDetails)
        {
            if (vstsRelease == null || vstsRelease.Items == null)
            {
                throw new InvalidOperationException();
            }

            foreach (var environment in releaseDetails.Environments)
            {
                var node = vstsRelease.Items.FirstOrDefault(i => i.Name == environment.Name);

                if (node == null)
                {
                    node = new VSTSReleaseEnvironment
                    {
                        Name          = environment.Name,
                        EnvironmentId = environment.Id
                    };

                    Application.Current.Dispatcher.Invoke(() => vstsRelease.Add(node));
                }

                node.State = environment.State;
            }
        }
Пример #2
0
        private static void AddEnvironments(VSTSRelease_v1 widget, VSTSReleaseDetails release)
        {
            foreach (var env in release.Environments)
            {
                var environment = widget.Items.FirstOrDefault(i => i is VSTSReleaseEnvironment e && e.EnvironmentId == env.Id) ?? AddEnvironment(widget, env);

                environment.State = env.State;
            }
        }
Пример #3
0
        private void RemoveTasks(VSTSRelease_v1 node, VSTSReleaseDetails releaseDetails)
        {
            if (node == null || node.Items == null)
            {
                throw new InvalidOperationException();
            }

            foreach (var nodeItem in node.Items)
            {
                foreach (var nodeItemItem in nodeItem.Items.ToArray())
                {
                    Application.Current.Dispatcher.Invoke(() => nodeItem.Remove(nodeItemItem));
                }
            }
        }
Пример #4
0
        private static void RemoveEnvironments(VSTSRelease_v1 node, VSTSReleaseDetails releaseDetails)
        {
            if (node == null || node.Items == null)
            {
                throw new InvalidOperationException();
            }

            var environments = node.Items
                               .Where(k => !releaseDetails.Environments.Any(e => e.Name == k.Name))
                               .ToList();

            foreach (var environment in environments)
            {
                Application.Current.Dispatcher.Invoke(() => node.Remove(environment));
            }
        }
Пример #5
0
 private void AddTasks(VSTSRelease_v1 vstsRelease, VSTSReleaseDetails releaseDetails)
 {
     foreach (var environment in releaseDetails.Environments.Where(e => e.State != State.Ok))
     {
         var node = vstsRelease.Items.First(i => i.Name == environment.Name);
         foreach (var deploymentAttempt in environment.DeploySteps.Where(ds => ds.State != State.Ok))
         {
             foreach (var releaseTask in deploymentAttempt.ReleaseDeployPhases.SelectMany(rdp => rdp.DeploymentJobs).SelectMany(dj => dj.Tasks).Where(t => t.State != State.Ok))
             {
                 Item task = new VSTSReleaseTask()
                 {
                     Name = releaseTask.Name, State = releaseTask.State
                 };
                 Application.Current.Dispatcher.Invoke(() => node.Add(task));
             }
         }
     }
 }