經過多次嘗試,我可以通過運行下面的代碼來獲取項目的所有標籤。
我添加了兩個using語句(在課堂上)
using VaultLib;
using VaultClientIntegrationLib;
我已經添加下面的代碼在DLL中的(VaultLib.dll和VaultClientIntegrationLib.dll)在Visual Studio項目引用下,並添加2靜態方法
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
}