Exemple #1
0
        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");
        }
Exemple #2
0
        public void DeleteTag()
        {
            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            Guid tagId     = new Guid("C807AEE9-D3FA-468D-BFD5-66C2B3D42AD3"); //TODO

            VssConnection     connection    = Context.Connection;
            TaggingHttpClient taggingClient = connection.GetClient <TaggingHttpClient>();

            try
            {
                taggingClient.DeleteTagAsync(projectId, tagId).SyncResult();

                Console.WriteLine("Tag '{0}' deleted", tagId);
            }
            catch (AggregateException ex)
            {
                if (ex.InnerException.GetType().Equals(typeof(TagNotFoundException)))
                {
                    Console.WriteLine("TagId '{0}' not found", tagId);
                }
                else
                {
                    Console.WriteLine("Error: {0}", ex.Message);
                }
            }
        }
        public void DeleteTag()
        {
            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            Guid tagId     = new Guid("C807AEE9-D3FA-468D-BFD5-66C2B3D42AD3"); //TODO

            VssConnection     connection    = Context.Connection;
            TaggingHttpClient taggingClient = connection.GetClient <TaggingHttpClient>();

            taggingClient.DeleteTagAsync(projectId, tagId).SyncResult();

            Console.WriteLine("Tag '{0}' deleted", tagId);
        }