【问题标题】:How do I list the available labels of a Project?如何列出项目的可用标签?
【发布时间】:2016-11-08 08:28:16
【问题描述】:

这是我第一次使用 Vault Client API 功能开发 .NET winforms 应用程序。 我想使用 Vault Client API 来获取每个项目的标签列表。

我在 VaultClientIntegrationLib.dll 中找到了方法 ServerOperations.ProcessCommandFindLabels(),但我不知道参数应该是什么样子才能获得成功的结果。

感谢任何帮助。

【问题讨论】:

    标签: c# winforms sourcegear-vault


    【解决方案1】:

    经过多次尝试,我可以通过运行下面的代码来获取项目的所有标签。

    我在 Visual Studio 项目的引用下添加了两个 dll(VaultLib.dll 和 VaultClientIntegrationLib.dll),并添加了 2 个 using 语句(在类中)

    using VaultLib;
    using VaultClientIntegrationLib;
    

    我在静态方法中添加了以下代码

    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 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-01
      • 1970-01-01
      • 2019-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多