public void SetRetentionPolicies(IEnumerable <Uri> buildDefinitions, BuildRetentionPolicy policies)
        {
            const BuildReason Reason = BuildReason.Triggered | BuildReason.Manual;

            foreach (var bd in this.buildServer.QueryBuildDefinitionsByUri(buildDefinitions.ToArray()))
            {
                UpdateRetentionPolicy(bd, Reason, policies.StoppedKeep, policies.StoppedDeleteOptions, BuildStatus.Stopped);
                UpdateRetentionPolicy(bd, Reason, policies.FailedKeep, policies.FailedDeleteOptions, BuildStatus.Failed);
                UpdateRetentionPolicy(bd, Reason, policies.PartiallySucceededKeep, policies.PartiallySucceededDeleteOptions, BuildStatus.PartiallySucceeded);
                UpdateRetentionPolicy(bd, Reason, policies.SucceededKeep, policies.SucceededDeleteOptions, BuildStatus.Succeeded);
                bd.Save();
            }
        }
 public void SetRetentionPolicies(IEnumerable<Uri> buildDefinitions, BuildRetentionPolicy policies)
 {
     const BuildReason Reason = BuildReason.Triggered | BuildReason.Manual;
     foreach (var bd in this.buildServer.QueryBuildDefinitionsByUri(buildDefinitions.ToArray()))
     {
         UpdateRetentionPolicy(bd, Reason, policies.StoppedKeep, policies.StoppedDeleteOptions, BuildStatus.Stopped);
         UpdateRetentionPolicy(bd, Reason, policies.FailedKeep, policies.FailedDeleteOptions, BuildStatus.Failed);
         UpdateRetentionPolicy(bd, Reason, policies.PartiallySucceededKeep, policies.PartiallySucceededDeleteOptions, BuildStatus.PartiallySucceeded);
         UpdateRetentionPolicy(bd, Reason, policies.SucceededKeep, policies.SucceededDeleteOptions, BuildStatus.Succeeded);
         bd.Save();
     }
 }
        private void OnOK(object sender, RoutedEventArgs e)
        {
            var p = new BuildRetentionPolicy();

            SetPolicies(this.StoppedWhatToDelete, this.StoppedKeep.Text, ref p.StoppedDeleteOptions, ref p.StoppedKeep);
            SetPolicies(this.FailedWhatToDelete, this.FailedKeep.Text, ref p.FailedDeleteOptions, ref p.FailedKeep);
            SetPolicies(this.PartiallySucceededWhatToDelete, this.PartiallySucceededKeep.Text, ref p.PartiallySucceededDeleteOptions, ref p.PartiallySucceededKeep);
            SetPolicies(this.SuceededWhatToDelete, this.SucceededKeep.Text, ref p.SucceededDeleteOptions, ref p.SucceededKeep);

            this.BuildRetentionPolicy = p;
            DialogResult = true;
            this.Close();
        }