Ejemplo n.º 1
0
        public WorkItemDelete DeleteWorkItem(int id)
        {
            VssConnection connection = new VssConnection(_uri, _credentials);
            WorkItemTrackingHttpClient workItemTrackingHttpClient = connection.GetClient <WorkItemTrackingHttpClient>();
            WorkItemDelete             results = workItemTrackingHttpClient.DeleteWorkItemAsync(id, false).Result;

            return(results);
        }
Ejemplo n.º 2
0
        public WorkItemDelete DeleteWorkItems()
        {
            int id = _id;

            int[] ids = _ids;

            VssConnection connection = Context.Connection;
            WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>();

            WorkItemDelete result = workItemTrackingClient.DeleteWorkItemAsync(id).Result;

            result = workItemTrackingClient.DeleteWorkItemAsync(ids[0]).Result;
            result = workItemTrackingClient.DeleteWorkItemAsync(ids[1]).Result;
            result = workItemTrackingClient.DeleteWorkItemAsync(ids[2]).Result;

            return(result);
        }
        public NotificationSubscription UnfollowWorkItem()
        {
            NotificationSubscription newFollowSubscription;

            // Step 1: Get a work item to follow. For this sample, just create a temporary work item.
            WorkItem newWorkItem;

            using (new ClientSampleHttpLoggerOutputSuppression())
            {
                WorkItemsSample witSample = new WorkItemsSample();
                witSample.Context = this.Context;
                newWorkItem       = witSample.CreateWorkItem();
            }

            string workItemArtifactUri = "vstfs:///WorkItemTracking/WorkItem/" + newWorkItem.Id;

            // Step 2: Follow this workitem by creating a subscription
            NotificationSubscriptionCreateParameters createParams = new NotificationSubscriptionCreateParameters()
            {
                Filter  = new ArtifactFilter(workItemArtifactUri),
                Channel = new UserSubscriptionChannel()
            };

            VssConnection          connection         = Context.Connection;
            NotificationHttpClient notificationClient = Context.Connection.GetClient <NotificationHttpClient>();

            newFollowSubscription = notificationClient.CreateSubscriptionAsync(createParams).Result;

            LogSubscription(newFollowSubscription);

            // Step 3: Query for the follow subscription
            SubscriptionQuery query = new SubscriptionQuery()
            {
                Conditions = new[]
                {
                    new SubscriptionQueryCondition()
                    {
                        Filter = new ArtifactFilter(workItemArtifactUri)
                    }
                }
            };
            NotificationSubscription followSubscription = notificationClient.QuerySubscriptionsAsync(query).Result.FirstOrDefault();

            // Step 4: Now, unfollow the above workitem, by deleting the subscription
            if (followSubscription != null)
            {
                notificationClient.DeleteSubscriptionAsync(followSubscription.Id).SyncResult();
            }

            // Step 5: Cleanup the temporary work item
            using (new ClientSampleHttpLoggerOutputSuppression())
            {
                WorkItemTrackingHttpClient witClient = connection.GetClient <WorkItemTrackingHttpClient>();
                witClient.DeleteWorkItemAsync(newWorkItem.Id.Value, destroy: true);
            }

            return(followSubscription);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Delete a work item to Recycle Bin
        /// </summary>
        /// <param name="teamProjectName"></param>
        /// <param name="workItemID"></param>
        /// <param name="removePermanently"></param>
        static void DeleteWorkItem(string teamProjectName, int workItemID, bool removePermanently = false)
        {
            var deletedWI = WitClient.DeleteWorkItemAsync(teamProjectName, workItemID, removePermanently).Result;

            Console.WriteLine("Deleted work item:");

            Console.WriteLine("{0} : {1} : {2} : {3}", deletedWI.Project, deletedWI.Type, deletedWI.Id, deletedWI.Name);
            Console.WriteLine("Deleted by : {0} : {1}", deletedWI.DeletedBy, deletedWI.DeletedDate);
        }
Ejemplo n.º 5
0
        public void PermenentlyDeleteMultipleWorkItems()
        {
            int[] ids = _ids;

            VssConnection connection = Context.Connection;
            WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>();

            WorkItemDelete delResult;

            delResult = workItemTrackingClient.DeleteWorkItemAsync(ids[0]).Result;
            delResult = workItemTrackingClient.DeleteWorkItemAsync(ids[1]).Result;
            delResult = workItemTrackingClient.DeleteWorkItemAsync(ids[2]).Result;

            List <WorkItemDeleteReference> result = workItemTrackingClient.GetDeletedWorkItemsAsync(ids).Result;

            foreach (var item in result)
            {
                workItemTrackingClient.DestroyWorkItemAsync(Convert.ToInt32(item.Id));
            }
        }
Ejemplo n.º 6
0
        public void PermenentlyDeleteWorkItem()
        {
            int id = _id;

            VssConnection connection = Context.Connection;
            WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>();

            WorkItemDelete result = workItemTrackingClient.DeleteWorkItemAsync(id).Result;

            workItemTrackingClient.DestroyWorkItemAsync(id);
        }
Ejemplo n.º 7
0
        public WorkItemDelete DeleteWorkItem()
        {
            int id = Convert.ToInt32(Context.GetValue <WorkItem>("$newWorkItem2").Id);

            // Get a client
            VssConnection connection = Context.Connection;
            WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>();

            // Delete the work item (but don't destroy it completely)
            WorkItemDelete results = workItemTrackingClient.DeleteWorkItemAsync(id, destroy: false).Result;

            return(results);
        }
Ejemplo n.º 8
0
        public WorkItemDelete DeleteWorkItem()
        {
            WorkItem workitem;

            if (!Context.TryGetValue <WorkItem>("$newWorkItem", out workitem) || workitem.Id == null)
            {
                Console.WriteLine("Run the create sample before running this.");
            }

            // Get a client
            VssConnection connection = Context.Connection;
            WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>();

            // Delete the work item (but don't destroy it completely)
            WorkItemDelete results = workItemTrackingClient.DeleteWorkItemAsync(workitem.Id.Value, destroy: false).Result;

            return(results);
        }
Ejemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="WIId">The specific work item Id need to delete</param>
        /// <returns></returns>
        public WorkItemDelete DeleteWITByID(int WIId)
        {
            WorkItemTrackingHttpClient witHttpClient = this.Connection.GetClient <WorkItemTrackingHttpClient>();

            try
            {
                WorkItemDelete result = witHttpClient.DeleteWorkItemAsync(WIId, destroy: false).Result;
                Console.WriteLine("Successfully Deleted Work Item: # {0}", result.Id);
                WriteLog.WriteLogLine("Successfully Deleted Work Item: # {0}", result.Id);
                return(result);
            }
            catch (AggregateException ex)
            {
                Console.WriteLine("Failed to delete Work Item: # {0} - Error Message: {1}", WIId, ex.InnerException.Message);
                WriteLog.WriteLogLine("Failed to delete Work Item: # {0} - Error Message: {1}", WIId, ex.InnerException.Message);
                return(null);
            }
        }
        public NotificationSubscription FollowWorkItem()
        {
            NotificationSubscription newFollowSubscription;

            // Get a work item to follow. For this sample, just create a temporary work item.
            WorkItem newWorkItem;

            using (new ClientSampleHttpLoggerOutputSuppression())
            {
                WorkItemsSample witSample = new WorkItemsSample();
                witSample.Context = this.Context;
                newWorkItem       = witSample.CreateWorkItem();
            }

            string workItemArtifactUri = "vstfs:///WorkItemTracking/WorkItem/" + newWorkItem.Id;

            NotificationSubscriptionCreateParameters createParams = new NotificationSubscriptionCreateParameters()
            {
                Filter  = new ArtifactFilter(workItemArtifactUri),
                Channel = new UserSubscriptionChannel()
            };

            VssConnection          connection         = Context.Connection;
            NotificationHttpClient notificationClient = Context.Connection.GetClient <NotificationHttpClient>();

            newFollowSubscription = notificationClient.CreateSubscriptionAsync(createParams).Result;

            LogSubscription(newFollowSubscription);

            // Cleanup the temporary work item
            using (new ClientSampleHttpLoggerOutputSuppression())
            {
                WorkItemTrackingHttpClient witClient = connection.GetClient <WorkItemTrackingHttpClient>();
                witClient.DeleteWorkItemAsync(newWorkItem.Id.Value, destroy: true);
            }

            return(newFollowSubscription);
        }