TFS secondary development-baseline File Manager (4)-tag Creation

Source: Internet
Author: User

The source code file has been read in the previous section. If you want to save the selected file as a label ). In vs, we can only label one directory, which is very inconvenient. If you use the following method to save the selected file path as a list and tag it, It is very flexible.

The method of saving as list is very simple. You need to recursively Save the files in the selected book.

For ease of display, I saved it to a ListBox first,

listBox1.Items.Clear();for (int i = 0; i < treeView1.Nodes.Count; i++){TreeNode node = treeView1.Nodes[i];SetTreeViewList(node);}


Recursively select the node selected in the tree and place it in ListBox

Public void settreeviewlist (treenode nodes) {// prevents nodes from being ignored if (nodes. checked) {listbox1.items. add (nodes. text);} // subnode foreach (treenode newnode in nodes. nodes) {If (newnode. nodes. count> 0) {settreeviewlist (newnode);} // determines the child node else {If (newnode. checked) {// display the path and version listbox1.items. add (newnode. text );}}}}
 

Save the file path as a tag.

// Determine the number of files int filenum = listbox1.items. count; // This path seems useless, does not affect, so the write dead string Path = "$/test2-agile"; var versioncontrollabel = new versioncontrollabel (version, "label name", version. authorizeduser, path, "tag annotation"); // creates an array. Each file requires a var labelitemspec = new labelitemspec [filenum]; for (INT I = 0; I <filenum; I ++) {string fileurl = tfscommon. getfileurl (listbox1.items [I]. tostring (); // determines whether the object is a file. Because the path may be selected, If (! Tfscommon. isfile (fileurl) {MessageBox. show ("select file"); return;} // set the recursive type var itemspec = new itemspec (fileurl, recursiontype. full); labelitemspec [I] = new labelitemspec (itemspec, versionspec. latest, false) ;}/// create lable // labelchildoption three of the options, fail = failed, replace = replace, merge = merged var lB = version. createlabel (versioncontrollabel, labelitemspec, labelchildoption. replace); MessageBox. show (Lb [0]. status. tostring ());
 

Here we can see that the Tag Name and comment can be written by yourself, which is more flexible. Three options are available when saving the lable. They are failed, replaced, and merged.

If a tag with the same name fails to be selected, a message is displayed. If you select replace, the original tag will be replaced with the saved file. If the tag is merged, the two tags are merged.

TFS secondary development-baseline File Manager (4)-tag Creation

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.