It's my first time I develop a .NET winforms application using Vault Client functionalities.
I want to use Vault Client API to get a list of the labels per project.
I found the method ServerOperations.ProcessCommandFindLabels() in VaultClientIntegrationLib.dll but I don't have any clue how the parameters should look like to get a successful result.
Any help is appreciated.
How do I list the available labels of a Project?
Moderator: SourceGear
Re: How do I list the available labels of a Project?
You could try using the command-line client in a script and the FindLabels command. There is a -patternmath option where you can use wildcards.
Or, in the API download is the code used for the CLC, so you can see exactly how we used ProcessCommandFindLabels in the CLC. It should look like:
int nRetCode = ServerOperations.ProcessCommandFindLabels(strSearchString, strReposPath, _args.Recursive, _args.HistoryRowLimit, _args.MatchCase, _args.MatchWord, pm, out arLabelItems);
Here's a basic example...
VaultLabelItemX[] arLabelItems = null;
int nRetCode = ServerOperations.ProcessCommandFindLabels("myLabel", "$/folder1", true, 1000, true, true, false, out arLabelItems);
Or, in the API download is the code used for the CLC, so you can see exactly how we used ProcessCommandFindLabels in the CLC. It should look like:
int nRetCode = ServerOperations.ProcessCommandFindLabels(strSearchString, strReposPath, _args.Recursive, _args.HistoryRowLimit, _args.MatchCase, _args.MatchWord, pm, out arLabelItems);
Here's a basic example...
VaultLabelItemX[] arLabelItems = null;
int nRetCode = ServerOperations.ProcessCommandFindLabels("myLabel", "$/folder1", true, 1000, true, true, false, out arLabelItems);
Beth Kieler
SourceGear Technical Support
SourceGear Technical Support
Re: How do I list the available labels of a Project?
Thank you Beth for the example. But is there a simple way to list all available Labels of a project?
Something like:
GetAllLabelsOfProject(strProjectPath) --> which returns a list of all Labels...
Something like:
GetAllLabelsOfProject(strProjectPath) --> which returns a list of all Labels...
Re: How do I list the available labels of a Project?
After many attempts I was able to get all labels of a project by running the code below.
I added two dll's (VaultLib.dll and VaultClientIntegrationLib.dll) in the References in Visual Studio Project and added
I added two dll's (VaultLib.dll and VaultClientIntegrationLib.dll) in the References in Visual Studio Project and added
Code: Select all
using VaultLib;
using VaultClientIntegrationLib;
Code: Select all
ServerOperations.client.LoginOptions.URL = url;
ServerOperations.client.LoginOptions.User = user;
ServerOperations.client.LoginOptions.Password = pass;
ServerOperations.client.LoginOptions.Repository = rep;
ServerOperations.Login();
ServerOperations.client.AutoCommit = true;
string prjPath = "$/projectpath";
VaultLabelItemX[] arLabelItems = null;
int nRetCode = ServerOperations.ProcessCommandFindLabels("*", prjPath, false, 1000, true, true, VaultFindInFilesDefine.PatternMatch.Wildcard, out arLabelItems);
MessageBox.Show(arLabelItems.Count().ToString()); // Print how much labels found
foreach (var item in arLabelItems)
{
MessageBox.Show(arLabelItems[i].Label.ToString()); // Show Label
}
Last edited by Tanguy on Fri Jul 08, 2016 12:55 am, edited 1 time in total.
Re: How do I list the available labels of a Project?
Thank you for the update.
Beth Kieler
SourceGear Technical Support
SourceGear Technical Support