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
AddLabel Method in the API
Moderator: SourceGear
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
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