aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs')
-rw-r--r--Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs162
1 files changed, 2 insertions, 160 deletions
diff --git a/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs b/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs
index 92c56187b..11bdf2f2f 100644
--- a/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs
+++ b/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs
@@ -1,7 +1,6 @@
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
-using Microsoft.TeamFoundation.WorkItemTracking.Proxy;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;
@@ -9,7 +8,6 @@ using Microsoft.VisualStudio.Services.WebApi.Patch;
using Microsoft.VisualStudio.Services.WebApi.Patch.Json;
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
@@ -38,8 +36,6 @@ namespace Tango.TFS
public const String RESOLVED_REASON = "Microsoft.VSTS.Common.ResolvedReason";
public const String EMBEDDED_VERSION = "Custom.EmbeddedVersion";
public const String MACHINE_SN = "Custom.MachineSN";
- public const String ENVIRONMENT = "Custom.Environment";
- public const String LOGGED_IN_USER = "Custom.LoggedInUser";
}
#endregion
@@ -398,16 +394,6 @@ namespace Tango.TFS
});
}
- if (workItem.Environment != null)
- {
- patchDocument.Add(new JsonPatchOperation
- {
- Operation = Operation.Add,
- Path = GetExtensionFieldNameForWrite(ExtensionFields.ENVIRONMENT),
- Value = workItem.Environment,
- });
- }
-
if (workItem.MachineSerialNumber != null)
{
patchDocument.Add(new JsonPatchOperation
@@ -418,16 +404,6 @@ namespace Tango.TFS
});
}
- if (workItem.LoggedInUser != null)
- {
- patchDocument.Add(new JsonPatchOperation
- {
- Operation = Operation.Add,
- Path = GetExtensionFieldNameForWrite(ExtensionFields.LOGGED_IN_USER),
- Value = workItem.LoggedInUser,
- });
- }
-
var resultWorkItem = witClient.CreateWorkItemAsync(patchDocument, project.Name, workItem.Type.ToString(), bypassRules: true).Result;
workItem.ID = resultWorkItem.Id.Value;
@@ -557,90 +533,6 @@ namespace Tango.TFS
});
}
- public Task<List<AttachementHandler>> GetWorkItemAttachements(int id)
- {
- return Task.Factory.StartNew<List<AttachementHandler>>(() =>
- {
- List<AttachementHandler> handlers = new List<AttachementHandler>();
-
- var connection = CreateConnection();
- var projCollection = new TfsTeamProjectCollection(new Uri(CollectionURL), connection.Credentials);
- projCollection.EnsureAuthenticated();
- WorkItemStore wistore = projCollection.GetService<WorkItemStore>();
- Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem wi = wistore.GetWorkItem(id);
- //WorkItemServer wiserver = projCollection.GetService<WorkItemServer>();
-
- foreach (Microsoft.TeamFoundation.WorkItemTracking.Client.Attachment attachement in wi.Attachments)
- {
- AttachementHandler handler = new AttachementHandler((targetPath) =>
- {
- WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>();
-
- //Method 1. Use for progress...
- //Stream st = witClient.GetAttachmentContentAsync(Guid.Parse(attachement.FileGuid)).Result;
-
- //var tempFile = TemporaryManager.CreateFile();
-
- //using (var fileStream = File.Open(tempFile, FileMode.Create))
- //{
- // byte[] buffer = new byte[2048]; // read in chunks of 2KB
- // int bytesRead;
- // while ((bytesRead = st.Read(buffer, 0, buffer.Length)) > 0)
- // {
- // fileStream.Write(buffer, 0, bytesRead);
- // }
- //}
-
- //File.Copy(tempFile, targetPath, true);
- //tempFile.Delete();
-
- //Method 2. More basic...
- WorkItemServer wiserver = projCollection.GetService<WorkItemServer>();
- string tempPath = wiserver.DownloadFile(attachement.Id);
- File.Copy(tempPath, targetPath, true);
-
- try
- {
- File.Delete(tempPath);
- }
- catch { }
- });
-
- handler.Name = attachement.Name;
- handler.Comment = attachement.Comment;
- handler.AttachedTimeUtc = attachement.AttachedTimeUtc;
- handler.Extension = attachement.Extension;
- handler.FileGuid = attachement.FileGuid;
- handler.Length = attachement.Length;
- handlers.Add(handler);
- }
-
- return handlers;
- });
- }
-
- public Task<List<WorkItem>> GetWorkItemsForMachine(Project project, String serialNumber, DateTime startUtc, DateTime endUtc)
- {
- 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 {ExtensionFields.MACHINE_SN} = '{serialNumber}' And [Work Item Type] = 'Bug' AND [Created Date] >= '{startUtc.ToString("MM/dd/yyyy")}' AND [Created Date] <= '{endUtc.ToString("MM/dd/yyyy")}'");
- 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>
/// Sets the state of the work item.
/// </summary>
@@ -671,29 +563,6 @@ namespace Tango.TFS
});
}
- public Task<WorkItem> UpdateWorkItemSystemInfo(Project project, WorkItem item, String systemInfo)
- {
- return Task.Factory.StartNew<WorkItem>(() =>
- {
- var connection = CreateConnection();
-
- WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>();
-
- var patchDocument = new JsonPatchDocument();
-
- patchDocument.Add(new JsonPatchOperation
- {
- Operation = Operation.Replace,
- Path = GetExtensionFieldNameForWrite(ExtensionFields.SYSTEM_INFO),
- Value = systemInfo,
- });
-
- var updatedItem = witClient.UpdateWorkItemAsync(patchDocument, item.ID).Result;
-
- return ConvertToWorkItem(project, updatedItem);
- });
- }
-
/// <summary>
/// Adds a comment to the work item discussion.
/// </summary>
@@ -875,20 +744,8 @@ namespace Tango.TFS
if (item.Fields.ContainsKey(ExtensionFields.RESOLVED_REASON))
{
- try
- {
- workItem.ResolvedReason = ParseEnumByDescription<ResolvedReason>(item.Fields[ExtensionFields.RESOLVED_REASON].ToString());
-
- if (item.Fields.ContainsKey(ExtensionFields.RESOLVED_DATE))
- {
- workItem.ResolvedDate = DateTime.Parse(item.Fields[ExtensionFields.RESOLVED_DATE].ToString());
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine($"Error parsing TFS work item resolved reason.\n{ex.ToString()}");
- LogManager.Log(ex, "Error parsing TFS work item resolved reason.");
- }
+ workItem.ResolvedReason = ParseEnumByDescription<ResolvedReason>(item.Fields[ExtensionFields.RESOLVED_REASON].ToString());
+ workItem.ResolvedDate = DateTime.Parse(item.Fields[ExtensionFields.RESOLVED_DATE].ToString());
}
workItem.Type = (WorkItemType)Enum.Parse(typeof(WorkItemType), item.Fields[GetFieldNameForRead(CoreField.WorkItemType)].ToString());
@@ -921,21 +778,6 @@ namespace Tango.TFS
workItem.SystemInformation = TryGetField(item.Fields, ExtensionFields.SYSTEM_INFO).ToString();
}
- if (item.Fields.ContainsKey(ExtensionFields.LOGGED_IN_USER))
- {
- workItem.LoggedInUser = TryGetField(item.Fields, ExtensionFields.LOGGED_IN_USER).ToString();
- }
-
- if (item.Fields.ContainsKey(ExtensionFields.MACHINE_SN))
- {
- workItem.MachineSerialNumber = TryGetField(item.Fields, ExtensionFields.MACHINE_SN).ToString();
- }
-
- if (item.Fields.ContainsKey(ExtensionFields.ENVIRONMENT))
- {
- workItem.Environment = TryGetField(item.Fields, ExtensionFields.ENVIRONMENT).ToString();
- }
-
workItem.Comment = TryGetField(item.Fields, GetFieldNameForRead(CoreField.History)).ToString();
return workItem;