Page 1 of 1

Enumerating labels

Posted: Wed Oct 03, 2007 9:21 am
by UglyDuckling
Hello,

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.

UD

Posted: Wed Oct 03, 2007 1:23 pm
by jeremy_sg
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.
}

ServerOperations.Client.ClientInstance.EndLabelQuery(token); 
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.