//latest task closed time public string latestTaskClosedTime(WorkItem wi) { string ltcTime = string.Empty; Revision rev = WorkItemInfo.getWorkItemRevision(wi); DateTime latestTask = DateTime.Parse(rev.Fields["Created Date"].Value.ToString(), CultureInfo.InvariantCulture); string usState = rev.Fields["State"].Value.ToString(); if ("Closed".Equals(usState) | "Resolved".Equals(usState)) { List <WorkItem> childItems = WorkItemInfo.getWorkItemChild(workItemStore, wi); if (childItems.Count() != 0) { foreach (WorkItem child in childItems) { Revision revChild = WorkItemInfo.getWorkItemRevision(child); if ("Closed".Equals(revChild.Fields["State"].Value)) { DateTime taskClosed = DateTime.Parse(revChild.Fields["Closed Date"].Value.ToString(), CultureInfo.InvariantCulture); latestTask = latestTask > taskClosed ? latestTask : taskClosed; } } ltcTime = latestTask.ToString(); } } return(ltcTime); }
public Dictionary <string, List <string> > allUserStory() { WorkItemCollection wcStory = workItemStore.Query( "SELECT * FROM WorkItems WHERE [System.WorkItemType] = 'User Story' AND [System.State] != 'Removed'"); Dictionary <string, List <string> > user_story = new Dictionary <string, List <string> >(); foreach (WorkItem wi in wcStory) { List <string> story_Info = new List <string>(); Revision rev = WorkItemInfo.getWorkItemRevision(wi); story_Info.Add(rev.Fields["Assigned To"].Value.ToString()); story_Info.Add(rev.Fields["State"].Value.ToString()); story_Info.Add(rev.Fields["Iteration Path"].Value.ToString()); story_Info.Add(rev.Fields["Area Path"].Value.ToString()); if (rev.Fields["Story Points"].Value != null) { story_Info.Add(rev.Fields["Story Points"].Value.ToString()); } else { story_Info.Add("null"); } double totalCompletedEffort = 0; List <WorkItem> childItems = WorkItemInfo.getWorkItemChild(workItemStore, wi); foreach (WorkItem child in childItems) { Revision revChild = WorkItemInfo.getWorkItemRevision(child); double comp = Convert.ToDouble(revChild.Fields["Completed work"].Value); totalCompletedEffort = totalCompletedEffort + comp; } story_Info.Add((totalCompletedEffort / 8).ToString()); story_Info.Add(rev.Fields["Title"].Value.ToString().Replace(",", ".")); story_Info.Add(rev.Fields["Created Date"].Value.ToString()); if (rev.Fields["Resolved Date"].Value != null) { story_Info.Add(rev.Fields["Resolved Date"].Value.ToString()); } else { story_Info.Add(string.Empty); } if (rev.Fields["Closed Date"].Value != null) { story_Info.Add(rev.Fields["Closed Date"].Value.ToString()); } else { story_Info.Add(string.Empty); } story_Info.Add(startTime(wi)); story_Info.Add(usClosedTime(wi)); story_Info.Add(latestTaskClosedTime(wi)); story_Info.Add(leadTime(wi)); string storyId = rev.Fields["Id"].Value.ToString(); user_story.Add(storyId, story_Info); } return(user_story); }
//user story start time public string startTime(WorkItem wi) { string stTime = null; DateTime earliestTask = DateTime.Now; List <WorkItem> childItems = WorkItemInfo.getWorkItemChild(workItemStore, wi); if (childItems.Count() == 0) { return(stTime); } else { foreach (WorkItem child in childItems) { Revision revChild = WorkItemInfo.getWorkItemRevision(child); DateTime taskCreate = DateTime.Parse(revChild.Fields["Created Date"].Value.ToString(), CultureInfo.InvariantCulture); earliestTask = earliestTask < taskCreate ? earliestTask : taskCreate; } return(earliestTask.ToString()); } }