private void CollectionViewSource_Filter(object sender, FilterEventArgs e)
        {
            BuildDefinitionInfo buildDefinitionInfo = e.Item as BuildDefinitionInfo;

            if (buildDefinitionInfo == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(_filterText))
            {
                e.Accepted = true;
            }
            else if (Regex.IsMatch(buildDefinitionInfo.Name, _filterText, RegexOptions.IgnoreCase))
            {
                e.Accepted = true;
            }
            else
            {
                e.Accepted = false;
            }
        }
Example #2
0
        private static void DeleteBuildsForDefinition(ApplicationTask task, IBuildServer buildServer, int step, BuildDefinitionInfo buildDefinition)
        {
            var buildDetailSpec = buildServer.CreateBuildDetailSpec(new[] { buildDefinition.Uri, });
            var buildsToDelete  = buildServer.QueryBuilds(buildDetailSpec).Builds;

            if (buildsToDelete.Any())
            {
                task.SetProgress(step, string.Format(CultureInfo.CurrentCulture, "Deleting {0} builds for definition \"{1}\" in Team Project \"{2}\"", buildsToDelete.Count(), buildDefinition.Name, buildDefinition.TeamProject));
                foreach (var buildToDelete in buildsToDelete)
                {
                    try
                    {
                        buildToDelete.Delete(DeleteOptions.All);
                    }
                    catch (Exception exc)
                    {
                        task.SetWarning(string.Format(CultureInfo.CurrentCulture, "An error occurred while deleting build number \"{0}\" for definition \"{1}\" in Team Project \"{2}\"", buildToDelete.BuildNumber, buildDefinition.Name, buildDefinition.TeamProject), exc);
                    }
                }
            }
        }