aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-23 12:18:00 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-23 12:18:00 +0300
commit374ac997c64b23984e37bd887db03743c2a744d4 (patch)
treedb1719bcca27efabfba104ba1f61cc58aaa95583 /Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs
parent3e6e666cc3ef5ed1ac1aafa19c8abd3bc35b4c67 (diff)
downloadTango-374ac997c64b23984e37bd887db03743c2a744d4.tar.gz
Tango-374ac997c64b23984e37bd887db03743c2a744d4.zip
Added Custom Protocol (Web Open) for Tango FSE installer.
Added support for "Action" on System Information template VSTS. Implemented VSTS download attachments. Implemented Tango FSE custom protocol startup args support.
Diffstat (limited to 'Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs')
-rw-r--r--Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs b/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs
index 27e92b740..a47b109b0 100644
--- a/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs
+++ b/Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs
@@ -1,6 +1,7 @@
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;
@@ -555,6 +556,68 @@ 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)
{
return Task.Factory.StartNew<List<WorkItem>>(() =>