RallyRestToolkitFor.NET - 缺陷重复

时间:2014-03-24 14:27:07

标签: .net api rally

我有一个MVC应用程序,我们用它来向客户显示缺陷。它使用RallyRestToolkitFor.NET来获取此信息。

但我需要列出一份缺陷的所有副本,我不知道如何实现这一点。

通常,我会通过查询

获得关联对象,例如测试用例
request = new Request("testcase")
                      {
                          Fetch =
                              new List<string>()
                              {
                                  "FormattedID",
                                  "Name",
                                  "LastRun",
                                  "LastVerdict"
                              },
                          Query =
                              new Query("WorkProduct.FormattedID", Query.Operator.Equals, "DE123")
                      };

但我无法看到我如何能够为重复做同样的事情,因为没有“父母”概念。

你能帮忙吗?

1 个答案:

答案 0 :(得分:1)

以下是访问缺陷上的Duplicates集合的代码:

namespace FindDefectDuplicates
{
    class Program
    {
        static void Main(string[] args)
        {
            RallyRestApi restApi;

            restApi = new RallyRestApi("user@co.com", "secret", "https://rally1.rallydev.com", "v2.0");
            String workspaceRef = "/workspace/1111";
            String projectRef = "/project/2222";
            bool projectScopingUp = false;
            bool projectScopingDown = false;

            Request defectRequest = new Request("defect");
            defectRequest.Workspace = workspaceRef;
            defectRequest.Project = projectRef;
            defectRequest.ProjectScopeUp = projectScopingUp;
            defectRequest.ProjectScopeDown = projectScopingDown;

            defectRequest.Fetch = new List<string>()
                {
                    "Name",
                    "FormattedID",
                    "Duplicates"
                };

            defectRequest.Query = new Query("FormattedID", Query.Operator.Equals, "DE123");
            QueryResult queryDefectResults = restApi.Query(defectRequest);
            foreach (var d in queryDefectResults.Results)
            {
                Console.WriteLine("FormattedID: " + d["FormattedID"] + " Name: " + d["Name"]);
                Console.WriteLine("Collection ref: " + d["Duplicates"]._ref);
                Request duplicatesRequest = new Request(d["Duplicates"]);
                QueryResult queryDuplicatesResult = restApi.Query(duplicatesRequest);
                foreach (var duplicate in queryDuplicatesResult.Results)
                {
                    Console.WriteLine("FormattedID: " + duplicate["FormattedID"] + " Name: " + duplicate["Name"]);
                }

            }
        }
    }
}