aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.TFS
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
committerMirta <mirta@twine-s.com>2020-12-30 16:39:52 +0200
commit00a491d93733d4625ad329b2ba8237f445364b3f (patch)
tree4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Tango.TFS
parent124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff)
downloadTango-00a491d9.tar.gz
Tango-00a491d9.zip
merge
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/ResolvedReason.cs2
-rw-r--r--Software/Visual_Studio/Tango.TFS/State.cs4
-rw-r--r--Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj3
-rw-r--r--Software/Visual_Studio/Tango.TFS/TeamFoundationServiceClient.cs162
-rw-r--r--Software/Visual_Studio/Tango.TFS/WorkItem.cs9
6 files changed, 4 insertions, 209 deletions
diff --git a/Software/Visual_Studio/Tango.TFS/AttachementHandler.cs b/Software/Visual_Studio/Tango.TFS/AttachementHandler.cs
deleted file mode 100644
index 4eb08d407..000000000
--- a/Software/Visual_Studio/Tango.TFS/AttachementHandler.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-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/ResolvedReason.cs b/Software/Visual_Studio/Tango.TFS/ResolvedReason.cs
index c48c64ef2..bdd1bf797 100644
--- a/Software/Visual_Studio/Tango.TFS/ResolvedReason.cs
+++ b/Software/Visual_Studio/Tango.TFS/ResolvedReason.cs
@@ -9,8 +9,6 @@ namespace Tango.TFS
{
public enum ResolvedReason
{
- [Description("Unknown")]
- Unknown,
[Description("As Designed")]
AsDesigned,
[Description("Cannot Reproduce")]
diff --git a/Software/Visual_Studio/Tango.TFS/State.cs b/Software/Visual_Studio/Tango.TFS/State.cs
index 511914832..dfa905846 100644
--- a/Software/Visual_Studio/Tango.TFS/State.cs
+++ b/Software/Visual_Studio/Tango.TFS/State.cs
@@ -11,8 +11,6 @@ namespace Tango.TFS
New,
Active,
Resolved,
- Closed,
- Analyze,
- Pending
+ Closed
}
}
diff --git a/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj b/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj
index 3e3e6f6fd..2e4bba2ad 100644
--- a/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj
+++ b/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj
@@ -202,7 +202,6 @@
<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" />
@@ -266,7 +265,7 @@
</Target>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</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 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;
diff --git a/Software/Visual_Studio/Tango.TFS/WorkItem.cs b/Software/Visual_Studio/Tango.TFS/WorkItem.cs
index 35c2f8669..230f4a5ef 100644
--- a/Software/Visual_Studio/Tango.TFS/WorkItem.cs
+++ b/Software/Visual_Studio/Tango.TFS/WorkItem.cs
@@ -183,13 +183,6 @@ namespace Tango.TFS
}
- private String _environment;
- public String Environment
- {
- get { return _environment; }
- set { _environment = value; RaisePropertyChangedAuto(); }
- }
-
private String _comment;
public String Comment
{
@@ -197,8 +190,6 @@ namespace Tango.TFS
set { _comment = value; RaisePropertyChangedAuto(); }
}
- public String LoggedInUser { get; set; }
-
public bool IsBuildVersionValid
{
get