Enumerating labels

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
Posts: 1
Joined: Wed Oct 03, 2007 8:48 am

Enumerating labels

Post by UglyDuckling » Wed Oct 03, 2007 9:21 am


Can you provide some advice on how to enumerate a list of labels after a ServerOperations connection has been made? I would like to obtain the same list of labels possible in the existing client to enumerate over them.


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

Post by jeremy_sg » Wed Oct 03, 2007 1:23 pm

This can be done, but it's a bit tricky. Here's some pseudo-code for how to loop over the labels.

Code: Select all

int numRowsInherited;
int numRowsRecursive;
string token = String.Empty;
VaultClientNetLib.ClientService.VaultLabelItemX[] items = null;
int foundID = -1;
VaultClientTreeObject obj = RepositoryUtil.FindVaultTreeObjectAtReposOrLocalPath("$/path");

ServerOperations.Client.ClientInstance.BeginLabelQuery(obj.FullPath, obj.ID, false, false, true, false, 1000, out numRowsInherited, out numRowsRecursive, out token);

if (token == null || token == String.Empty)
   return some error status;

ServerOperations.Client.ClientInstance.GetLabelQueryItems_Main(token, 0, numRowsInherited, out items);

if (items == null)
   return some error status;

foreach (VaultLabelItemX item in items)
//Here's your loop.

Please be patient, as I haven't put much time into the pseudo-code. Thank you for pointing this out, because we should definitely put something like this in ServerOperations for the future.

Post Reply