public void DeleteAllInactiveTags() { Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id; VssConnection connection = Context.Connection; TaggingHttpClient taggingClient = connection.GetClient <TaggingHttpClient>(); WebApiTagDefinitionList listofTags = taggingClient.GetTagsAsync(projectId, true).Result; List <WebApiTagDefinition> listofInactiveTags = listofTags.Where(x => x.Active == false).ToList <WebApiTagDefinition>(); Console.WriteLine("Get list of inactive tags: Done"); Console.WriteLine("Start deleting inactive tags..."); foreach (var tag in listofInactiveTags) { Console.WriteLine(" Delete tag '{0}'", tag.Name); try { taggingClient.DeleteTagAsync(projectId, tag.Id).SyncResult(); } catch (AggregateException ex) { Console.WriteLine(" Error: {0}", ex.InnerException.Message); } } Console.WriteLine(""); Console.WriteLine("Completed"); }
public WebApiTagDefinitionList GetListOfTags() { Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id; VssConnection connection = Context.Connection; TaggingHttpClient taggingClient = connection.GetClient <TaggingHttpClient>(); WebApiTagDefinitionList listofTags = taggingClient.GetTagsAsync(projectId).Result; Console.WriteLine("List of tags:"); foreach (var tag in listofTags) { Console.WriteLine(" ({0}) - {1}", tag.Id.ToString(), tag.Name); } return(listofTags); }
public List <WebApiTagDefinition> GetListOfTagsIncludeInactive() { Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id; VssConnection connection = Context.Connection; TaggingHttpClient taggingClient = connection.GetClient <TaggingHttpClient>(); WebApiTagDefinitionList listofTags = taggingClient.GetTagsAsync(projectId, true).Result; List <WebApiTagDefinition> listofInactiveTags = listofTags.Where(x => x.Active == false).ToList <WebApiTagDefinition>(); Console.WriteLine("List of inactive tags:"); foreach (var tag in listofInactiveTags) { Console.WriteLine(" ({0}) - {1}", tag.Id.ToString(), tag.Name); } return(listofInactiveTags); }