aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.TFS
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
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')
-rw-r--r--Software/Visual_Studio/Tango.TFS/AttachementHandler.cs33
-rw-r--r--Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj3
-rw-r--r--Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs63
3 files changed, 98 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.TFS/AttachementHandler.cs b/Software/Visual_Studio/Tango.TFS/AttachementHandler.cs
new file mode 100644
index 000000000..4eb08d407
--- /dev/null
+++ b/Software/Visual_Studio/Tango.TFS/AttachementHandler.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.TFS
+{
+ public class AttachementHandler
+ {
+ private Action<String> _downloadAction;
+
+ public String Name { get; set; }
+ public string Comment { get; set; }
+ public DateTime AttachedTimeUtc { get; set; }
+ public string Extension { get; set; }
+ public string FileGuid { get; set; }
+ public long Length { get; set; }
+
+ internal AttachementHandler(Action<String> downloadAction)
+ {
+ _downloadAction = downloadAction;
+ }
+
+ public Task Download(String targetFile)
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ _downloadAction(targetFile);
+ });
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj b/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj
index 2e4bba2ad..3e3e6f6fd 100644
--- a/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj
+++ b/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj
@@ -202,6 +202,7 @@
<Link>GlobalVersionInfo.cs</Link>
</Compile>
<Compile Include="Area.cs" />
+ <Compile Include="AttachementHandler.cs" />
<Compile Include="Attachment.cs" />
<Compile Include="Email.cs" />
<Compile Include="ITeamFoundationEmailClient.cs" />
@@ -265,7 +266,7 @@
</Target>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
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>>(() =>