Team System: Work items and undo support

Source: Internet
Author: User
Tags valid visual studio

In the January 2007 installment of this column (Msdn.microsoft.com/msdnmag/issues/07/01/teamsystem), I introduced how to create a Microsoft®word 2003 add-in to work with Team Foundatio The N Server version control subsystem works together. In the April 2007 issue column (Msdn.microsoft.com/msdnmag/issues/07/04/teamsystem), I explored the work item tracking subsystem in depth. In this month's column, I'll show you how to add Work item support to an add-in. In addition, you will learn how to add features that should have occurred in the first version of the add-in-undo support.

Change

In the first installment of the introduction to add-ins, I used the beta version of Microsoft Visual Studio®2005 tools for the 2007 Microsoft Office System (visual Studio, tools For Office Second Edition, or short for VSTO. Since then, Microsoft has released a final version that supports the creation of application add-ins for Office 2003 and 2007 Office system. Therefore, if you plan to follow the instructions in the column, you will need to upgrade the first version of the add-in to the RTM version. To do this, simply open the solution and recompile it on a computer that has the VSTO (SE) installed. Once you've confirmed that the new version works, the next step is to add undo pending change Support. This feature requires that you modify the Tfsvcutil class and the ThisAddin class.

In Tfsvcutil, add a new shared method Undopendingchanges (which accepts the full path of the document currently being modified) and returns a Boolean value. It turns out that the core function of the new method is much like the existing Checkindocument method. The method checks to make sure that a valid connection has been established with team Foundation Server and that a valid workspace has been loaded. When this step is complete, it gets an array of Pendingchanges objects for the incoming document. Suppose you return a pending change, and then call the Undo method of the user's workspace and pass in the pendingchanges array. This method should return an integer value of 1. If it does, the method returns True, otherwise the tfsutilexception is thrown using the newly defined Msg_undo_not_zero constant. Figure 1 provides a complete list of methods.

The Undopendingchanges method in Figure 1 tfsvcutil

 public Shared Function undopendingchanges (_ ByVal Docpath as String) as Boolean If servervalidated Then If M_us Erworkspace is nothing Then Dim userworkstation As Workstation = Workstation.current Dim docwsinfo As Workspaceinfo = _ Userworkstation.getlocalworkspaceinfo (docpath) m_userworkspace = M_tfsvcs.getworkspace (docWSInfo) End If Di M PC as Pendingchange () = _ M_userworkspace.getpendingchanges (docpath) If pc IsNot nothing AndAlso pc. Length > 0 Then Dim retval as Integer = M_userworkspace.undo (PC) ' retval should equal the number of items ' Undon E ' If retval = 1 Then return True Else Throw New tfsutilexception (String.Format (_ Msg_undo_not_zero, D Ocpath, retval))) End If else return False End If Else Throw New tfsutilexception (msg_server_not_validated) E nd If End Function 

The changes you need to make to the ThisAddIn class are simple. As before, because of space limitations, I no longer detail the Word add-in Special code (you can compare the downloads of this column with the previous version to see what happens). There is no doubt that you must modify the class, add a new undo Pending Change button for the toolbar, add a click handler for the New button, and add additional code to handle state changes to control whether the button is enabled. Basically, the enable status of the Undo Pending Changes button should reflect the status of the existing Check-in button.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.