Page 1 of 1

How do I list the available labels of a Project?

Posted: Wed Jul 06, 2016 3:35 am
by Tanguy
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.

Re: How do I list the available labels of a Project?

Posted: Wed Jul 06, 2016 2:08 pm
by Beth
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);

Re: How do I list the available labels of a Project?

Posted: Thu Jul 07, 2016 1:39 am
by Tanguy
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...

Re: How do I list the available labels of a Project?

Posted: Thu Jul 07, 2016 3:21 am
by Tanguy
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

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 
}

Re: How do I list the available labels of a Project?

Posted: Thu Jul 07, 2016 7:30 am
by Beth
Thank you for the update.