diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-05-08 17:01:22 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-05-08 17:01:22 +0300 |
| commit | 113eaf4d8a37e212b8528d41e400b346ce9f51d2 (patch) | |
| tree | 757df6c19de09061fad3b5a0b3954f0bbc98747b /Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs | |
| parent | cdba3267d2a47b3bff8cf3ec0219223e36e234ff (diff) | |
| download | Tango-113eaf4d8a37e212b8528d41e400b346ce9f51d2.tar.gz Tango-113eaf4d8a37e212b8528d41e400b346ce9f51d2.zip | |
Added improvements to stubs UI.
Implemented Bug Reporter engine!
Diffstat (limited to 'Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs b/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs index 6eef1ef92..5665caf3c 100644 --- a/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs +++ b/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs @@ -395,6 +395,61 @@ namespace Tango.TFS } /// <summary> + /// Gets the type of the work items by. + /// </summary> + /// <param name="project">The project.</param> + /// <param name="type">The type.</param> + /// <returns></returns> + public Task<List<WorkItem>> GetWorkItemsByType(Project project, WorkItemType type) + { + return Task.Factory.StartNew<List<WorkItem>>(() => + { + var connection = CreateConnection(); + + var projCollection = new TfsTeamProjectCollection(new Uri(CollectionURL), connection.Credentials); + var store = projCollection.GetService<WorkItemStore>(); + + WorkItemCollection queryResults = store.Query(String.Format("Select [Id]" + "From WorkItems " + "Where [Work Item Type] = '{0}'", type.ToString())); + var ids = queryResults.OfType<Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem>().Where(x => x.Project.Name == project.Name).ToList().Select(x => x.Id).ToList(); + + if (ids.Count == 0) return new List<WorkItem>(); + + WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>(); + + var items = witClient.GetWorkItemsAsync(ids).Result; + + return items.Select(x => ConvertToWorkItem(project, x)).ToList(); + }); + } + + /// <summary> + /// Gets all work items of the specified project. + /// </summary> + /// <param name="project">The project.</param> + /// <returns></returns> + public Task<List<WorkItem>> GetAllWorkItems(Project project) + { + return Task.Factory.StartNew<List<WorkItem>>(() => + { + var connection = CreateConnection(); + + var projCollection = new TfsTeamProjectCollection(new Uri(CollectionURL), connection.Credentials); + var store = projCollection.GetService<WorkItemStore>(); + + WorkItemCollection queryResults = store.Query("Select [Id]" + "From WorkItems " + "Where [Work Item Type] = 'Bug' Or [Work Item Type] = 'Task'"); + var ids = queryResults.OfType<Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem>().Where(x => x.Project.Name == project.Name).ToList().Select(x => x.Id).ToList(); + + if (ids.Count == 0) return new List<WorkItem>(); + + WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>(); + + var items = witClient.GetWorkItemsAsync(ids).Result; + + return items.Select(x => ConvertToWorkItem(project, x)).ToList(); + }); + } + + /// <summary> /// Deletes the specified work item. /// </summary> /// <param name="project">The project.</param> @@ -667,13 +722,22 @@ namespace Tango.TFS workItem.State = (State)Enum.Parse(typeof(State), item.Fields[GetFieldNameForRead(CoreField.State)].ToString()); - workItem.Severity = ParseEnumByDescription<Severity>(item.Fields[ExtensionFields.SEVERITY].ToString()); + if (item.Fields.ContainsKey(ExtensionFields.SEVERITY)) + { + workItem.Severity = ParseEnumByDescription<Severity>(item.Fields[ExtensionFields.SEVERITY].ToString()); + } workItem.Priority = (Priority)int.Parse(item.Fields[ExtensionFields.PRIORITY].ToString()); - workItem.StepsToReproduce = TryGetField(item.Fields, ExtensionFields.STEPS_TO_REP).ToString(); + if (item.Fields.ContainsKey(ExtensionFields.STEPS_TO_REP)) + { + workItem.StepsToReproduce = TryGetField(item.Fields, ExtensionFields.STEPS_TO_REP).ToString(); + } - workItem.SystemInformation = TryGetField(item.Fields, ExtensionFields.SYSTEM_INFO).ToString(); + if (item.Fields.ContainsKey(ExtensionFields.SYSTEM_INFO)) + { + workItem.SystemInformation = TryGetField(item.Fields, ExtensionFields.SYSTEM_INFO).ToString(); + } workItem.Comment = TryGetField(item.Fields, GetFieldNameForRead(CoreField.History)).ToString(); |
