AddLabel Method in the API

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
MH

AddLabel Method in the API

Post by MH » Fri Apr 02, 2004 5:48 pm

I am having some difficulty fully understanding the addLabel method in the API.

public int AddLabel(string repositoryPath, long objVerID, string label, string comment, ref VaultLabelResult result)

Namely, I don't understand where objVerID or result is coming from. Wading through the CommandLineClient code isn't helping much either.

I would greatly appreciate any explanation and/or a sample code snippet.

Thanks,
Mark

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Fri Apr 02, 2004 9:04 pm

If you wish to add a label to an item at the version that is currently in the tree, you would do something kinda like this.

VaultClientFile myFile = myClientInstance.TreeCache.Repository.Root.FindFileRecursive("$/trunk/src/file"). (There is a corresponding FindFolderRecursive that returns a VaultClientFolder)

VaultClientNetLib.ClientService.VaultLabelResultresultOfLabelOperation = new VaultClientNetLib.ClientService.VaultLabelResult()


myClientInstance.AddLabel("$/trunk/src/file", myFile.ObjVerID, "Label Text", "Label Comment", ref resultOfLabelOperation);

As for your specific questions. ObjVerID is a number that is unique for every version of every file in Vault. Lots of items can have Version 4, but only one item can ever have ObjVerID 3756. Because VaultLabelResult is passed in with the ref qualifier, the AddLabel method will modify it and use it to return the results from the label operation. For more tips on programming the Vault Client API, check out http://weblogs.asp.net/Jeremy_Sheeley

MH

Post by MH » Fri Apr 02, 2004 10:24 pm

Great, thanks!

Mark

Post Reply