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 | |
| 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')
8 files changed, 277 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Tango.TFS/Email.cs b/Software/Visual_Studio/Tango.TFS/Email.cs new file mode 100644 index 000000000..8e87a5f02 --- /dev/null +++ b/Software/Visual_Studio/Tango.TFS/Email.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.TFS +{ + /// <summary> + /// Represents a simple email. + /// </summary> + public class Email + { + /// <summary> + /// Gets or sets the subject. + /// </summary> + public String Subject { get; set; } + + /// <summary> + /// Gets or sets the body. + /// </summary> + public String Body { get; set; } + + /// <summary> + /// Gets or sets the sender member. + /// </summary> + public TeamMember From { get; set; } + + /// <summary> + /// Gets or sets the recipient members. + /// </summary> + public List<TeamMember> To { get; set; } + + /// <summary> + /// Gets or sets the optional attachments. + /// </summary> + public List<Attachment> Attachments { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="Email"/> class. + /// </summary> + public Email() + { + To = new List<TeamMember>(); + Attachments = new List<Attachment>(); + } + } +} diff --git a/Software/Visual_Studio/Tango.TFS/ITeamFoundationEmailClient.cs b/Software/Visual_Studio/Tango.TFS/ITeamFoundationEmailClient.cs new file mode 100644 index 000000000..080d9fa93 --- /dev/null +++ b/Software/Visual_Studio/Tango.TFS/ITeamFoundationEmailClient.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.TFS +{ + /// <summary> + /// Represents an email client for sending emails to team members. + /// </summary> + public interface ITeamFoundationEmailClient + { + /// <summary> + /// Gets or sets the SMTP address. + /// </summary> + String SMTP { get; set; } + + /// <summary> + /// Gets or sets the SMTP port. + /// </summary> + int Port { get; set; } + + /// <summary> + /// Gets or sets the credentials used to authenticate against the SMTP server. + /// </summary> + NetworkCredential Credentials { get; set; } + + /// <summary> + /// Sends the specified email. + /// </summary> + /// <param name="email">The email.</param> + /// <returns></returns> + Task Send(Email email); + } +} diff --git a/Software/Visual_Studio/Tango.TFS/ITeamFoundationServiceClient.cs b/Software/Visual_Studio/Tango.TFS/ITeamFoundationServiceClient.cs index 1fe169218..ea6ed4a1e 100644 --- a/Software/Visual_Studio/Tango.TFS/ITeamFoundationServiceClient.cs +++ b/Software/Visual_Studio/Tango.TFS/ITeamFoundationServiceClient.cs @@ -35,6 +35,21 @@ namespace Tango.TFS Task<WorkItem> GetWorkItem(Project project, int id); /// <summary> + /// Gets all work items of the specified type + /// </summary> + /// <param name="project">The project.</param> + /// <param name="type">Work item type.</param> + /// <returns></returns> + Task<List<WorkItem>> GetWorkItemsByType(Project project, WorkItemType type); + + /// <summary> + /// Gets all work items of the specified project. + /// </summary> + /// <param name="project">The project.</param> + /// <returns></returns> + Task<List<WorkItem>> GetAllWorkItems(Project project); + + /// <summary> /// Gets all the work items created by the specified team member. /// </summary> /// <param name="project">The project.</param> diff --git a/Software/Visual_Studio/Tango.TFS/ResolvedReason.cs b/Software/Visual_Studio/Tango.TFS/ResolvedReason.cs index e1af689a2..bdd1bf797 100644 --- a/Software/Visual_Studio/Tango.TFS/ResolvedReason.cs +++ b/Software/Visual_Studio/Tango.TFS/ResolvedReason.cs @@ -21,6 +21,8 @@ namespace Tango.TFS Duplicate, [Description("Fixed")] Fixed, + [Description("Fixed and verified")] + FixedAndVerified, [Description("Obsolete")] Obsolete, } diff --git a/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj b/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj index cf15c2e9e..554636eba 100644 --- a/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj +++ b/Software/Visual_Studio/Tango.TFS/Tango.TFS.csproj @@ -201,6 +201,8 @@ </Compile> <Compile Include="Area.cs" /> <Compile Include="Attachment.cs" /> + <Compile Include="Email.cs" /> + <Compile Include="ITeamFoundationEmailClient.cs" /> <Compile Include="Iteration.cs" /> <Compile Include="Priority.cs" /> <Compile Include="Project.cs" /> @@ -208,6 +210,7 @@ <Compile Include="Severity.cs" /> <Compile Include="State.cs" /> <Compile Include="Tag.cs" /> + <Compile Include="TeamFoundationEmailClient.cs" /> <Compile Include="TeamFoundationServiceClient.cs" /> <Compile Include="TeamMember.cs" /> <Compile Include="WorkItem.cs" /> diff --git a/Software/Visual_Studio/Tango.TFS/TeamFoundationEmailClient.cs b/Software/Visual_Studio/Tango.TFS/TeamFoundationEmailClient.cs new file mode 100644 index 000000000..ac77cf470 --- /dev/null +++ b/Software/Visual_Studio/Tango.TFS/TeamFoundationEmailClient.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Mail; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.TFS +{ + /// <summary> + /// Represents an email client for sending emails to team members. + /// </summary> + /// <seealso cref="Tango.TFS.ITeamFoundationEmailClient" /> + public class TeamFoundationEmailClient : ITeamFoundationEmailClient + { + /// <summary> + /// Gets or sets the SMTP address. + /// </summary> + public String SMTP { get; set; } + + /// <summary> + /// Gets or sets the SMTP port. + /// </summary> + public int Port { get; set; } + + /// <summary> + /// Gets or sets the credentials used to authenticate against the SMTP server. + /// </summary> + public NetworkCredential Credentials { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="TeamFoundationEmailClient"/> class. + /// </summary> + public TeamFoundationEmailClient() + { + SMTP = "smtp-mail.outlook.com"; + Port = 587; + } + + /// <summary> + /// Initializes a new instance of the <see cref="TeamFoundationEmailClient"/> class. + /// </summary> + /// <param name="credentials">The credentials.</param> + public TeamFoundationEmailClient(NetworkCredential credentials) : this() + { + Credentials = credentials; + } + + /// <summary> + /// Initializes a new instance of the <see cref="TeamFoundationEmailClient"/> class. + /// </summary> + /// <param name="smtp">The SMTP.</param> + /// <param name="port">The port.</param> + /// <param name="credentials">The credentials.</param> + public TeamFoundationEmailClient(String smtp, int port, NetworkCredential credentials) : this(credentials) + { + SMTP = smtp; + Port = port; + } + + /// <summary> + /// Sends the specified email. + /// </summary> + /// <param name="email">The email.</param> + /// <returns></returns> + public Task Send(Email email) + { + return Task.Factory.StartNew(() => + { + SmtpClient client = new SmtpClient(SMTP); + + client.Port = Port; + client.DeliveryMethod = SmtpDeliveryMethod.Network; + client.UseDefaultCredentials = false; + NetworkCredential credentials = Credentials; + client.EnableSsl = true; + client.Credentials = credentials; + + var mail = new MailMessage(); + mail.From = new MailAddress(email.From.Email); + + foreach (var member in email.To) + { + mail.To.Add(new MailAddress(member.Email)); + } + + foreach (var file in email.Attachments) + { + mail.Attachments.Add(new System.Net.Mail.Attachment(new FileStream(file.FilePath, FileMode.Open), file.Name)); + } + + mail.Subject = email.Subject; + mail.Body = email.Body; + client.Send(mail); + }); + } + } +} 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(); diff --git a/Software/Visual_Studio/Tango.TFS/TeamMember.cs b/Software/Visual_Studio/Tango.TFS/TeamMember.cs index 747d550ca..bb4b8a21f 100644 --- a/Software/Visual_Studio/Tango.TFS/TeamMember.cs +++ b/Software/Visual_Studio/Tango.TFS/TeamMember.cs @@ -14,6 +14,11 @@ namespace Tango.TFS public String URL { get; set; } public String ImageURL { get; set; } + public String Email + { + get { return UniqueName; } + } + public String AssignName { get { return String.Format("{0} <{1}>", DisplayName, UniqueName); } |
