1

我正在使用诸如US1, US4. 但是,当客户尝试使用字母查询功能F时,检索到具有相同编号的用户故事。

然后我测试了一个缺陷查询DE1检索US1。而且,查询任何字母XX1也会检索美国和给定的#。我的查询代码是:

public HierarchicalRequirement getUserStoryById(string _formattedID)
    {
        // I created this class with only the properties (bellow) I'm using
        HierarchicalRequirement userStory = null;

        Request storyRequest = new Request("hierarchicalrequirement")
        {
            ProjectScopeUp = false,
            ProjectScopeDown = true,
            Fetch = new List<string>() 
            {
                "Name",
                "ObjectID",
                "FormattedID",
                "LastUpdateDate", 
                "Owner", 
                "Children", 
                "Description", 
                "RevisionHistory", 
                "Revisions"
            },
            Query = new Query("FormattedID", Query.Operator.Equals, _formattedID)
        };

        try
        {
            QueryResult queryStoryResults = m_rallyApi.Query(storyRequest);
            if (queryStoryResults.Results.Count() > 0)
            {
                var myStory = queryStoryResults.Results.First();

                //Recursively gets a HierarchicalRequirement and its child by the reference value
                userStory = GetUserStoryByReference(myStory["_ref"]);
            }
        }
        catch (...){
        }

        return userStory;
    }

我在这里错过了一些非常明显的东西吗?为什么我不能查询除用户故事之外的任何内容?当我第一次创建Request对象时,它应该不同于new Request("hierarchicalrequirement")(可能是“缺陷”或“功能”)吗?

谢谢

4

1 回答 1

2

请求必须指定工作项类型。使用“分层需求”来查询缺陷、特性、测试用例、任务将不起作用。FormattedID 在同一个工作空间内是唯一的,但你可能在同一个工作空间内有 DE123、US123、TA123 和 TS123,工作项类型必须相应设置。

以下是查询缺陷的示例:

        class Program
        {
            static void Main(string[] args)
            {

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

                Request dRequest = new Request("Defect");
                dRequest.Workspace = workspaceRef;
                dRequest.Project = projectRef;

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

                var fid = "DE1";

                dRequest.Query = new Query("FormattedID", Query.Operator.Equals, fid);
                QueryResult queryResults = restApi.Query(dRequest);
                DynamicJsonObject defect = queryResults.Results.First();
                String defectRef = defect["_ref"];
                Console.WriteLine(defectRef);
                Console.WriteLine("FormattedID: " + defect["FormattedID"] + " Name: " + defect["Name"]);
//...........
于 2013-09-06T13:59:26.947 回答