[英]Rally Rest Api C# ToolKit
我正在嘗試將C#工具包用於RallyRest API。 我想顯示每個版本的用戶故事數量,以及團隊的任務數量。 分層需求請求不會返回所有數據。 此外,如何根據特定版本和用戶故事的所有者過濾數據? 下面是我的代碼。 你能建議我應該去哪里看嗎? 我看到了API。
RallyRestApi restApi = new RallyRestApi(username, password, "https://rally1.rallydev.com", "1.40");
bool projectScopingUp = false;
bool projectScopingDown = true;
try
{
Request storyRequest = new Request("HierarchicalRequirement");
storyRequest.Workspace = workspaceRef;
storyRequest.Project = projectRef;
storyRequest.ProjectScopeUp = projectScopingUp;
storyRequest.ProjectScopeDown = projectScopingDown;
storyRequest.Fetch = new List<string>()
{
"Name",
"FormattedID",
"Project",
"Release",
"ScheduleState",
"State",
"Owner",
"Tasks"
};
QueryResult queryStoryResults = restApi.Query(storyRequest);
int totalUS = 0;
foreach (var s in queryStoryResults.Results)
{
if (s["Release"] != null)
{
Release = s["Release"]["Name"];
string word = "July 2014";
if (Release.Equals(word))
{
string tempOwner = s["Owner"]["_refObjectName"];
if (tempOwner.Contains("development")
{
Owner = s["Owner"]["_refObjectName"];
paragraph.AddFormattedText("ID : " + Id + " Name : " + Name + " Owner : " + Owner + "Release :" + Release + "Number of Tasks : " + count, TextFormat.NotBold);
}
}
}
}
這是一個按特定發行版和故事所有者篩選故事的示例。 它還會獲取每個故事的Tasks集合,並通過單獨的請求添加它。
static void Main(string[] args)
{
int storyCount = 0;
int taskCount = 0;
RallyRestApi restApi;
restApi = new RallyRestApi("apiuser@co.com", "secret", "https://rally1.rallydev.com", "v2.0");
String workspaceRef = "/workspace/1234"; //replace this OID with an OID of your workspace
Request sRequest = new Request("HierarchicalRequirement");
sRequest.Workspace = workspaceRef;
sRequest.Fetch = new List<string>() { "FormattedID", "Name", "Tasks", "Release", "Project", "Owner" };
sRequest.Query = new Query("Release.Name", Query.Operator.Equals, "r1").And(new Query("Owner", Query.Operator.Equals, "user@co.com"));
QueryResult queryResults = restApi.Query(sRequest);
foreach (var s in queryResults.Results)
{
Console.WriteLine("FormattedID: " + s["FormattedID"] + " Name: " + s["Name"] + " Release: " + s["Release"]._refObjectName + " Project: " + s["Project"]._refObjectName + " Owner: " + s["Owner"]._refObjectName);
storyCount++;
Request tasksRequest = new Request(s["Tasks"]);
QueryResult queryTaskResult = restApi.Query(tasksRequest);
foreach (var t in queryTaskResult.Results)
{
Console.WriteLine("Task: " + t["FormattedID"] + " State: " + t["State"]);
taskCount++;
}
}
Console.WriteLine(storyCount + " stories, "+ taskCount + " tasks ");
}
我注意到您正在使用不再支持的WS API 1.40。 如果您有較舊的代碼,則必須將其重構以與v2.0一起使用。 在v2.0中,不可能在同一請求中對集合進行水合。 有關於這個問題的StackOverflow反彈標簽的例子很多,如這里下載最新的DLL的工具包在這里 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.