From 02b31b87738df00d0c6323b8ea3b7d65659c62f0 Mon Sep 17 00:00:00 2001 From: Bert Cotton Date: Fri, 4 Aug 2017 09:03:58 -0600 Subject: [PATCH 1/4] stuff --- .../Repository/BuildDefinitionRepository.cs | 6 +- .../Repository/BuildRepository.cs | 12 +- .../Repository/JobRequestRepository.cs | 26 ++-- .../Repository/PolicyRepository.cs | 23 ---- .../Repository/PoolRepository.cs | 7 +- .../Repository/ProjectRepository.cs | 27 +--- .../Repository/PullRequestRepository.cs | 12 +- .../Repository/RepositoryRepository.cs | 11 +- .../Repository/UpdateStatusRepository.cs | 2 +- src/TfsAdvanced.Models/DTO/Build.cs | 27 ++++ src/TfsAdvanced.Models/DTO/BuildDefinition.cs | 23 ++++ .../DTO/BuildDefinitionPolicy.cs | 14 ++ src/TfsAdvanced.Models/DTO/BuildStatus.cs | 18 +++ src/TfsAdvanced.Models/DTO/JobType.cs | 12 ++ src/TfsAdvanced.Models/DTO/MergeStatus.cs | 12 ++ src/TfsAdvanced.Models/{Pools => DTO}/Pool.cs | 2 +- src/TfsAdvanced.Models/DTO/Project.cs | 15 +++ src/TfsAdvanced.Models/DTO/PullRequest.cs | 39 ++++++ src/TfsAdvanced.Models/DTO/QueueJob.cs | 29 +++++ src/TfsAdvanced.Models/DTO/QueueJobStatus.cs | 18 +++ .../DTO/ReleaseDefinition.cs | 15 +++ src/TfsAdvanced.Models/DTO/Repository.cs | 20 +++ src/TfsAdvanced.Models/DTO/ReviewStatus.cs | 15 +++ src/TfsAdvanced.Models/DTO/Reviewer.cs | 11 ++ src/TfsAdvanced.Models/DTO/User.cs | 13 ++ .../Policy/PolicyConfiguration.cs | 20 --- src/TfsAdvanced.Models/Policy/PolicyType.cs | 9 -- src/TfsAdvanced.Updater/GetAsync.cs | 6 +- .../Models}/Builds/Build.cs | 6 +- .../Models}/Builds/BuildDefinition.cs | 7 +- .../Models}/Builds/BuildDefinitionLinks.cs | 4 +- .../Models}/Builds/BuildLinks.cs | 4 +- .../Models}/Builds/BuildQueue.cs | 2 +- .../Models}/Builds/BuildQueueRequest.cs | 5 +- .../Models}/Builds/BuildResult.cs | 2 +- .../Models}/Builds/BuildRun.cs | 2 +- .../Models}/Builds/BuildStatus.cs | 2 +- .../Models}/Builds/BuildStepInput.cs | 2 +- .../Models}/Builds/BuildSteps.cs | 2 +- .../Models}/Builds/RequestedFor.cs | 2 +- .../Models}/Builds/TaskGroupItem.cs | 2 +- .../Models}/JobRequests/Agent.cs | 2 +- .../Models}/JobRequests/JobRequest.cs | 5 +- .../Models}/JobRequests/JobRequestStatus.cs | 2 +- .../Models}/JobRequests/PlanTypes.cs | 2 +- .../Models}/Policy/MatchKind.cs | 2 +- .../Models/Policy/PolicyConfiguration.cs | 12 ++ .../Models}/Policy/PolicyScope.cs | 2 +- .../Models}/Policy/PolicySetting.cs | 2 +- .../Models/Policy/PolicyType.cs | 7 + .../Models}/Projects/Project.cs | 2 +- .../Models}/Projects/ProjectGuid.cs | 2 +- .../Models}/Projects/ProjectLinks.cs | 4 +- .../Models}/PullRequests/CompletionOptions.cs | 6 +- .../Models}/PullRequests/PullRequest.cs | 9 +- .../Models}/PullRequests/PullRequestLinks.cs | 4 +- .../Models}/PullRequests/Reviewer.cs | 2 +- .../Models}/PullRequests/Vote.cs | 2 +- .../Models}/PullRequests/VotedFor.cs | 2 +- .../Models}/Repositories/Commit.cs | 4 +- .../Models}/Repositories/CommitLink.cs | 2 +- .../Models}/Repositories/Repository.cs | 6 +- .../Tasks/BuildDefinitionUpdater.cs | 22 +++- src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs | 71 +++++++++-- .../Tasks/JobRequestUpdater.cs | 80 ++++++------ .../Tasks/PolicyUpdater.cs | 61 --------- src/TfsAdvanced.Updater/Tasks/PoolUpdater.cs | 2 +- .../Tasks/ProjectUpdater.cs | 9 +- .../Tasks/PullRequestUpdater.cs | 120 +++++++++++++++--- .../Tasks/RepositoryUpdater.cs | 44 +++++-- src/TfsAdvanced.Updater/Tasks/Updater.cs | 5 +- .../Controllers/BuildDefinitionsController.cs | 4 +- .../Controllers/ProjectsController.cs | 2 +- .../Controllers/PullRequestsController.cs | 12 +- .../ServiceRequests/BuildDefinitionRequest.cs | 23 ++-- .../wwwroot/views/jobRequests.html | 68 +++++----- .../wwwroot/views/pullRequests.html | 63 ++++----- 77 files changed, 739 insertions(+), 414 deletions(-) delete mode 100644 src/TfsAdvanced.DataStore/Repository/PolicyRepository.cs create mode 100644 src/TfsAdvanced.Models/DTO/Build.cs create mode 100644 src/TfsAdvanced.Models/DTO/BuildDefinition.cs create mode 100644 src/TfsAdvanced.Models/DTO/BuildDefinitionPolicy.cs create mode 100644 src/TfsAdvanced.Models/DTO/BuildStatus.cs create mode 100644 src/TfsAdvanced.Models/DTO/JobType.cs create mode 100644 src/TfsAdvanced.Models/DTO/MergeStatus.cs rename src/TfsAdvanced.Models/{Pools => DTO}/Pool.cs (89%) create mode 100644 src/TfsAdvanced.Models/DTO/Project.cs create mode 100644 src/TfsAdvanced.Models/DTO/PullRequest.cs create mode 100644 src/TfsAdvanced.Models/DTO/QueueJob.cs create mode 100644 src/TfsAdvanced.Models/DTO/QueueJobStatus.cs create mode 100644 src/TfsAdvanced.Models/DTO/ReleaseDefinition.cs create mode 100644 src/TfsAdvanced.Models/DTO/Repository.cs create mode 100644 src/TfsAdvanced.Models/DTO/ReviewStatus.cs create mode 100644 src/TfsAdvanced.Models/DTO/Reviewer.cs create mode 100644 src/TfsAdvanced.Models/DTO/User.cs delete mode 100644 src/TfsAdvanced.Models/Policy/PolicyConfiguration.cs delete mode 100644 src/TfsAdvanced.Models/Policy/PolicyType.cs rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/Build.cs (82%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/BuildDefinition.cs (73%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/BuildDefinitionLinks.cs (68%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/BuildLinks.cs (61%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/BuildQueue.cs (72%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/BuildQueueRequest.cs (69%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/BuildResult.cs (77%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/BuildRun.cs (88%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/BuildStatus.cs (76%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/BuildStepInput.cs (67%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/BuildSteps.cs (89%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/RequestedFor.cs (79%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Builds/TaskGroupItem.cs (79%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/JobRequests/Agent.cs (82%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/JobRequests/JobRequest.cs (87%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/JobRequests/JobRequestStatus.cs (72%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/JobRequests/PlanTypes.cs (58%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Policy/MatchKind.cs (56%) create mode 100644 src/TfsAdvanced.Updater/Models/Policy/PolicyConfiguration.cs rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Policy/PolicyScope.cs (76%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Policy/PolicySetting.cs (91%) create mode 100644 src/TfsAdvanced.Updater/Models/Policy/PolicyType.cs rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Projects/Project.cs (80%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Projects/ProjectGuid.cs (62%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Projects/ProjectLinks.cs (84%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/PullRequests/CompletionOptions.cs (58%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/PullRequests/PullRequest.cs (86%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/PullRequests/PullRequestLinks.cs (84%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/PullRequests/Reviewer.cs (89%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/PullRequests/Vote.cs (76%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/PullRequests/VotedFor.cs (89%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Repositories/Commit.cs (77%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Repositories/CommitLink.cs (70%) rename src/{TfsAdvanced.Models => TfsAdvanced.Updater/Models}/Repositories/Repository.cs (79%) delete mode 100644 src/TfsAdvanced.Updater/Tasks/PolicyUpdater.cs diff --git a/src/TfsAdvanced.DataStore/Repository/BuildDefinitionRepository.cs b/src/TfsAdvanced.DataStore/Repository/BuildDefinitionRepository.cs index 9888aa4..8f7c90a 100644 --- a/src/TfsAdvanced.DataStore/Repository/BuildDefinitionRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/BuildDefinitionRepository.cs @@ -6,8 +6,8 @@ using System.Reflection; using System.Threading; using Microsoft.EntityFrameworkCore; -using TfsAdvanced.Models.Builds; using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.Models.DTO; namespace TfsAdvanced.DataStore.Repository { @@ -16,13 +16,13 @@ public class BuildDefinitionRepository : RepositoryBase public BuildDefinition GetBuildDefinition(int definitionId) { - return base.Get(definition => definition.id == definitionId); + return base.Get(definition => definition.Id == definitionId); } protected override int GetId(BuildDefinition item) { - return item.id; + return item.Id; } } diff --git a/src/TfsAdvanced.DataStore/Repository/BuildRepository.cs b/src/TfsAdvanced.DataStore/Repository/BuildRepository.cs index a0ddf51..c937654 100644 --- a/src/TfsAdvanced.DataStore/Repository/BuildRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/BuildRepository.cs @@ -1,10 +1,8 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using System.Threading; -using TfsAdvanced.Models.Builds; using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.Models.DTO; namespace TfsAdvanced.DataStore.Repository { @@ -13,24 +11,24 @@ public class BuildRepository : RepositoryBase public Build GetBuild(int buildId) { - return base.Get(b => b.id == buildId); + return base.Get(b => b.Id == buildId); } public Build GetBuildBySourceVersion(string commitId) { - return base.GetList(b => b.sourceVersion == commitId).OrderByDescending(b => b.id).FirstOrDefault(); + return base.GetList(b => b.SourceCommit == commitId).OrderByDescending(b => b.Id).FirstOrDefault(); } protected override int GetId(Build item) { - return item.id; + return item.Id; } public override void Update(IEnumerable updates) { base.Update(updates); DateTime yesterday = DateTime.Now.Date.AddDays(-2); - base.Cleanup(x => x.queueTime < yesterday); + base.Cleanup(x => x.QueuedDate < yesterday); } } diff --git a/src/TfsAdvanced.DataStore/Repository/JobRequestRepository.cs b/src/TfsAdvanced.DataStore/Repository/JobRequestRepository.cs index 7bc2608..a85f576 100644 --- a/src/TfsAdvanced.DataStore/Repository/JobRequestRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/JobRequestRepository.cs @@ -2,34 +2,28 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using TfsAdvanced.Models.JobRequests; +using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.Models.DTO; namespace TfsAdvanced.DataStore.Repository { - public class JobRequestRepository + public class JobRequestRepository : RepositoryBase { - private ConcurrentBag jobRequests; - - public JobRequestRepository() - { - this.jobRequests = new ConcurrentBag(); - } - - public IList GetJobRequests(DateTime? fromDate = null, DateTime? toDate = null) + public IEnumerable GetJobRequests(DateTime? fromDate = null, DateTime? toDate = null) { if(fromDate.HasValue && toDate.HasValue) - return jobRequests.Where(x => x.queueTime >= fromDate.Value && x.queueTime <= toDate.Value).ToList(); + return base.GetList(x => x.QueuedTime >= fromDate.Value && x.QueuedTime <= toDate.Value); if (fromDate.HasValue) - return jobRequests.Where(x => x.queueTime >= fromDate.Value).ToList(); + return base.GetList(x => x.QueuedTime >= fromDate.Value); if(toDate.HasValue) - return jobRequests.Where(x => x.queueTime <= toDate.Value).ToList(); + return base.GetList(x => x.QueuedTime <= toDate.Value); - return jobRequests.ToList(); + return GetAll(); } - public void UpdateJobRequests(IList jobRequests) + protected override int GetId(QueueJob item) { - this.jobRequests = new ConcurrentBag(jobRequests); + return item.RequestId; } } } diff --git a/src/TfsAdvanced.DataStore/Repository/PolicyRepository.cs b/src/TfsAdvanced.DataStore/Repository/PolicyRepository.cs deleted file mode 100644 index 6c5d1e2..0000000 --- a/src/TfsAdvanced.DataStore/Repository/PolicyRepository.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using TfsAdvanced.Models.Policy; -using TFSAdvanced.DataStore.Repository; - -namespace TfsAdvanced.DataStore.Repository -{ - public class PolicyRepository : RepositoryBase - { - - - public IEnumerable GetByRepository(string repositoryId) - { - return base.GetList(p => p.settings.scope != null && p.settings.scope.Any(s => s.repositoryId == repositoryId)); - } - - protected override int GetId(PolicyConfiguration item) - { - return item.id; - } - } -} diff --git a/src/TfsAdvanced.DataStore/Repository/PoolRepository.cs b/src/TfsAdvanced.DataStore/Repository/PoolRepository.cs index 463b258..e9656c3 100644 --- a/src/TfsAdvanced.DataStore/Repository/PoolRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/PoolRepository.cs @@ -1,8 +1,5 @@ -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using TfsAdvanced.Models.Pools; -using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.Models.DTO; namespace TfsAdvanced.DataStore.Repository { diff --git a/src/TfsAdvanced.DataStore/Repository/ProjectRepository.cs b/src/TfsAdvanced.DataStore/Repository/ProjectRepository.cs index 5c53ca6..a91617b 100644 --- a/src/TfsAdvanced.DataStore/Repository/ProjectRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/ProjectRepository.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using System.Threading; -using TfsAdvanced.Models.Projects; +using System.Collections.Generic; using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.Models.DTO; namespace TfsAdvanced.DataStore.Repository { @@ -14,25 +9,13 @@ public class ProjectRepository : RepositoryBase public Project GetProject(string projectId) { - return base.Get(p => p.id == projectId); + return base.Get(p => p.Id == projectId); } protected override int GetId(Project item) { - return item.id.GetHashCode(); - } - } - - class ProjectComparer : IEqualityComparer - { - public bool Equals(Project x, Project y) - { - return x.id == y.id; - } - - public int GetHashCode(Project obj) - { - return obj.id.GetHashCode(); + return item.Id.GetHashCode(); } } + } diff --git a/src/TfsAdvanced.DataStore/Repository/PullRequestRepository.cs b/src/TfsAdvanced.DataStore/Repository/PullRequestRepository.cs index 2752ce9..ce92e4a 100644 --- a/src/TfsAdvanced.DataStore/Repository/PullRequestRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/PullRequestRepository.cs @@ -1,8 +1,6 @@ -using System.Collections.Concurrent; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using Models.PullRequests; -using TfsAdvanced.Models.PullRequests; +using TFSAdvanced.Models.DTO; using TFSAdvanced.DataStore.Repository; namespace TfsAdvanced.DataStore.Repository @@ -12,19 +10,19 @@ public class PullRequestRepository : RepositoryBase public IEnumerable GetPullRequestsAfter(int id) { - return base.GetList(x => x.pullRequestId > id); + return base.GetList(x => x.Id > id); } protected override int GetId(PullRequest item) { - return item.pullRequestId; + return item.Id; } public override void Update(IEnumerable updates) { base.Update(updates); // If an update was not received, then remove it - var noUpdate = base.GetList(request => !updates.Select(x => x.pullRequestId).Contains(request.pullRequestId)); + var noUpdate = base.GetList(request => !updates.Select(x => x.Id).Contains(request.Id)); base.Remove(noUpdate); } diff --git a/src/TfsAdvanced.DataStore/Repository/RepositoryRepository.cs b/src/TfsAdvanced.DataStore/Repository/RepositoryRepository.cs index 3c9c618..5f3e006 100644 --- a/src/TfsAdvanced.DataStore/Repository/RepositoryRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/RepositoryRepository.cs @@ -5,11 +5,16 @@ namespace TfsAdvanced.DataStore.Repository { - public class RepositoryRepository : RepositoryBase + public class RepositoryRepository : RepositoryBase { - protected override int GetId(Models.Repositories.Repository item) + protected override int GetId(TFSAdvanced.Models.DTO.Repository item) { - return item.id.GetHashCode(); + return item.Id.GetHashCode(); + } + + public TFSAdvanced.Models.DTO.Repository GetById(string Id) + { + return Get(x => x.Id == Id); } } diff --git a/src/TfsAdvanced.DataStore/Repository/UpdateStatusRepository.cs b/src/TfsAdvanced.DataStore/Repository/UpdateStatusRepository.cs index 447708a..6d2107a 100644 --- a/src/TfsAdvanced.DataStore/Repository/UpdateStatusRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/UpdateStatusRepository.cs @@ -7,7 +7,7 @@ namespace TfsAdvanced.DataStore.Repository { public class UpdateStatusRepository { - private ConcurrentDictionary updateStatuses; + private readonly ConcurrentDictionary updateStatuses; public UpdateStatusRepository() { diff --git a/src/TfsAdvanced.Models/DTO/Build.cs b/src/TfsAdvanced.Models/DTO/Build.cs new file mode 100644 index 0000000..1c3d5fa --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/Build.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public class Build + { + public int Id { get; set; } + + public string Url { get; set; } + + public User Creator { get; set; } + + public Repository Repository { get; set; } + + public string SourceCommit { get; set; } + + public BuildStatus BuildStatus { get; set; } + + public DateTime QueuedDate { get; set; } + + public DateTime? StartedDate { get; set; } + + public DateTime? FinishedDate { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/DTO/BuildDefinition.cs b/src/TfsAdvanced.Models/DTO/BuildDefinition.cs new file mode 100644 index 0000000..18f5d9c --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/BuildDefinition.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public class BuildDefinition + { + public int Id { get; set; } + + public string Name { get; set; } + + public string Url { get; set; } + + public int QueueId { get; set; } + + public Repository Repository { get; set; } + + public string Folder { get; set; } + + public string DefaultBranch { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/DTO/BuildDefinitionPolicy.cs b/src/TfsAdvanced.Models/DTO/BuildDefinitionPolicy.cs new file mode 100644 index 0000000..066b493 --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/BuildDefinitionPolicy.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public class BuildDefinitionPolicy + { + public string Id { get; set; } + public int BuildDefinitionId { get; set; } + + public int MinimumApproverCount { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/DTO/BuildStatus.cs b/src/TfsAdvanced.Models/DTO/BuildStatus.cs new file mode 100644 index 0000000..9fb7bcc --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/BuildStatus.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public enum BuildStatus + { + NoBuild, + NotStarted, + Building, + Failed, + Succeeded, + Abandonded, + Cancelled, + Expired + } +} diff --git a/src/TfsAdvanced.Models/DTO/JobType.cs b/src/TfsAdvanced.Models/DTO/JobType.cs new file mode 100644 index 0000000..3444c5b --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/JobType.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public enum JobType + { + Build, + Release + } +} diff --git a/src/TfsAdvanced.Models/DTO/MergeStatus.cs b/src/TfsAdvanced.Models/DTO/MergeStatus.cs new file mode 100644 index 0000000..5736c11 --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/MergeStatus.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public enum MergeStatus + { + Failed, + Succeeded + } +} diff --git a/src/TfsAdvanced.Models/Pools/Pool.cs b/src/TfsAdvanced.Models/DTO/Pool.cs similarity index 89% rename from src/TfsAdvanced.Models/Pools/Pool.cs rename to src/TfsAdvanced.Models/DTO/Pool.cs index 4c32c72..e3f6627 100644 --- a/src/TfsAdvanced.Models/Pools/Pool.cs +++ b/src/TfsAdvanced.Models/DTO/Pool.cs @@ -1,6 +1,6 @@ using System; -namespace TfsAdvanced.Models.Pools +namespace TFSAdvanced.Models.DTO { public class Pool { diff --git a/src/TfsAdvanced.Models/DTO/Project.cs b/src/TfsAdvanced.Models/DTO/Project.cs new file mode 100644 index 0000000..158fbf4 --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/Project.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public class Project + { + public string Id { get; set; } + + public string Name { get; set; } + + public string Url { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/DTO/PullRequest.cs b/src/TfsAdvanced.Models/DTO/PullRequest.cs new file mode 100644 index 0000000..5336c2a --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/PullRequest.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public class PullRequest + { + public int Id { get; set; } + + public string Title { get; set; } + + public string Url { get; set; } + + public Repository Repository { get; set; } + + public BuildStatus BuildStatus { get; set; } + + public string BuildUrl { get; set; } + + public MergeStatus MergeStatus { get; set; } + + public int buildId { get; set; } + + public bool IsAutoCompleteSet { get; set; } + + public bool HasEnoughReviewers { get; set; } + + public User Creator { get; set; } + + public IList Reviewers { get; set; } + + public int RequiredReviewers { get; set; } + + public int AcceptedReviewers { get; set; } + + public DateTime CreatedDate { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/DTO/QueueJob.cs b/src/TfsAdvanced.Models/DTO/QueueJob.cs new file mode 100644 index 0000000..c7e9685 --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/QueueJob.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public class QueueJob + { + public int RequestId { get; set; } + + public string Url { get; set; } + + public JobType JobType { get; set; } + + public Project Project { get; set; } + + public User LaunchedBy { get; set; } + + public QueueJobStatus QueueJobStatus { get; set; } + + public DateTime QueuedTime { get; set; } + + public DateTime? AssignedTime { get; set; } + + public DateTime? StartedTime { get; set; } + + public DateTime? FinishedTime { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/DTO/QueueJobStatus.cs b/src/TfsAdvanced.Models/DTO/QueueJobStatus.cs new file mode 100644 index 0000000..7eb52e8 --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/QueueJobStatus.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public enum QueueJobStatus + { + Queued, + Assigned, + Building, + Deploying, + Succeeded, + Failed, + Abandonded, + Cancelled + } +} diff --git a/src/TfsAdvanced.Models/DTO/ReleaseDefinition.cs b/src/TfsAdvanced.Models/DTO/ReleaseDefinition.cs new file mode 100644 index 0000000..324d900 --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/ReleaseDefinition.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public class ReleaseDefinition + { + public int Id { get; set; } + + public string Name { get; set; } + + public Project Project { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/DTO/Repository.cs b/src/TfsAdvanced.Models/DTO/Repository.cs new file mode 100644 index 0000000..7f17442 --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/Repository.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public class Repository + { + public string Id { get; set; } + public string Name { get; set; } + + public string Url { get; set; } + + public Project Project { get; set; } + + public string PullRequestUrl { get; set; } + + public int MinimumApproverCount { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/DTO/ReviewStatus.cs b/src/TfsAdvanced.Models/DTO/ReviewStatus.cs new file mode 100644 index 0000000..da1184e --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/ReviewStatus.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public enum ReviewStatus + { + NoResponse, + Approved, + ApprovedWithSuggestions, + WaitingForAuthor, + Rejected + } +} diff --git a/src/TfsAdvanced.Models/DTO/Reviewer.cs b/src/TfsAdvanced.Models/DTO/Reviewer.cs new file mode 100644 index 0000000..a114873 --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/Reviewer.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public class Reviewer : User + { + public ReviewStatus ReviewStatus { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/DTO/User.cs b/src/TfsAdvanced.Models/DTO/User.cs new file mode 100644 index 0000000..924c4b9 --- /dev/null +++ b/src/TfsAdvanced.Models/DTO/User.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Models.DTO +{ + public class User + { + public string Name { get; set; } + + public string IconUrl { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/Policy/PolicyConfiguration.cs b/src/TfsAdvanced.Models/Policy/PolicyConfiguration.cs deleted file mode 100644 index 3f5a304..0000000 --- a/src/TfsAdvanced.Models/Policy/PolicyConfiguration.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace TfsAdvanced.Models.Policy -{ - public class PolicyConfiguration - { - public DateTime CreatedDate { get; set; } - public bool isEnabled { get; set; } - public bool isBlocking { get; set; } - public bool isDeleted { get; set; } - - public PolicySetting settings { get; set; } - - public int id { get; set; } - - public string url { get; set; } - - public PolicyType type { get; set; } - } -} diff --git a/src/TfsAdvanced.Models/Policy/PolicyType.cs b/src/TfsAdvanced.Models/Policy/PolicyType.cs deleted file mode 100644 index a44aefd..0000000 --- a/src/TfsAdvanced.Models/Policy/PolicyType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace TfsAdvanced.Models.Policy -{ - public class PolicyType - { - public string id { get; set; } - public string url { get; set; } - public string displayName { get; set; } - } -} diff --git a/src/TfsAdvanced.Updater/GetAsync.cs b/src/TfsAdvanced.Updater/GetAsync.cs index a831414..56770a6 100644 --- a/src/TfsAdvanced.Updater/GetAsync.cs +++ b/src/TfsAdvanced.Updater/GetAsync.cs @@ -11,8 +11,8 @@ public class GetAsync { public static async Task Fetch(RequestData requestData, string url) { - var response = await requestData.HttpClient.GetAsync(url); - if (!response.IsSuccessStatusCode) + var response = await requestData.HttpClient.GetAsync(url); + if (!response.IsSuccessStatusCode) throw new BadRequestException(url, response.StatusCode); return await JsonDeserializer.Deserialize(response); @@ -20,7 +20,7 @@ public static async Task Fetch(RequestData requestData, string url) public static async Task> FetchResponseList(RequestData requestData, string url) { - var response = await requestData.HttpClient.GetAsync(url); + var response = await requestData.HttpClient.GetAsync(url); if (!response.IsSuccessStatusCode) throw new BadRequestException(url, response.StatusCode); diff --git a/src/TfsAdvanced.Models/Builds/Build.cs b/src/TfsAdvanced.Updater/Models/Builds/Build.cs similarity index 82% rename from src/TfsAdvanced.Models/Builds/Build.cs rename to src/TfsAdvanced.Updater/Models/Builds/Build.cs index c4ccc90..2179fca 100644 --- a/src/TfsAdvanced.Models/Builds/Build.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/Build.cs @@ -1,12 +1,11 @@ using System; -using TfsAdvanced.Models.Projects; +using TFSAdvanced.Updater.Models.Projects; -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public class Build { public string buildNumber { get; set; } - public string buildUrl { get; set; } public BuildDefinition definition { get; set; } public DateTime? finishTime { get; set; } public int id { get; set; } @@ -18,7 +17,6 @@ public class Build public BuildStatus status { get; set; } public string sourceBranch { get; set; } public string sourceVersion { get; set; } - public string url { get; set; } public BuildLinks _links { get; set; } public RequestedFor requestedFor { get; set; } } diff --git a/src/TfsAdvanced.Models/Builds/BuildDefinition.cs b/src/TfsAdvanced.Updater/Models/Builds/BuildDefinition.cs similarity index 73% rename from src/TfsAdvanced.Models/Builds/BuildDefinition.cs rename to src/TfsAdvanced.Updater/Models/Builds/BuildDefinition.cs index 38da832..1e30b48 100644 --- a/src/TfsAdvanced.Models/Builds/BuildDefinition.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/BuildDefinition.cs @@ -1,8 +1,7 @@ -using System.Collections.Generic; -using TfsAdvanced.Models.Projects; -using TfsAdvanced.Models.Repositories; +using TFSAdvanced.Updater.Models.Projects; +using TFSAdvanced.Updater.Models.Repositories; -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public class BuildDefinition { diff --git a/src/TfsAdvanced.Models/Builds/BuildDefinitionLinks.cs b/src/TfsAdvanced.Updater/Models/Builds/BuildDefinitionLinks.cs similarity index 68% rename from src/TfsAdvanced.Models/Builds/BuildDefinitionLinks.cs rename to src/TfsAdvanced.Updater/Models/Builds/BuildDefinitionLinks.cs index 7ad0a4a..f843c16 100644 --- a/src/TfsAdvanced.Models/Builds/BuildDefinitionLinks.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/BuildDefinitionLinks.cs @@ -1,4 +1,6 @@ -namespace TfsAdvanced.Models.Builds +using TfsAdvanced.Models; + +namespace TFSAdvanced.Updater.Models.Builds { public class BuildDefinitionLinks { diff --git a/src/TfsAdvanced.Models/Builds/BuildLinks.cs b/src/TfsAdvanced.Updater/Models/Builds/BuildLinks.cs similarity index 61% rename from src/TfsAdvanced.Models/Builds/BuildLinks.cs rename to src/TfsAdvanced.Updater/Models/Builds/BuildLinks.cs index bba1c03..33ca109 100644 --- a/src/TfsAdvanced.Models/Builds/BuildLinks.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/BuildLinks.cs @@ -1,4 +1,6 @@ -namespace TfsAdvanced.Models.Builds +using TfsAdvanced.Models; + +namespace TFSAdvanced.Updater.Models.Builds { public class BuildLinks { diff --git a/src/TfsAdvanced.Models/Builds/BuildQueue.cs b/src/TfsAdvanced.Updater/Models/Builds/BuildQueue.cs similarity index 72% rename from src/TfsAdvanced.Models/Builds/BuildQueue.cs rename to src/TfsAdvanced.Updater/Models/Builds/BuildQueue.cs index bf4d629..a2b54e4 100644 --- a/src/TfsAdvanced.Models/Builds/BuildQueue.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/BuildQueue.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public class BuildQueue { diff --git a/src/TfsAdvanced.Models/Builds/BuildQueueRequest.cs b/src/TfsAdvanced.Updater/Models/Builds/BuildQueueRequest.cs similarity index 69% rename from src/TfsAdvanced.Models/Builds/BuildQueueRequest.cs rename to src/TfsAdvanced.Updater/Models/Builds/BuildQueueRequest.cs index 3ea8445..6e68b71 100644 --- a/src/TfsAdvanced.Models/Builds/BuildQueueRequest.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/BuildQueueRequest.cs @@ -1,6 +1,7 @@ -using TfsAdvanced.Models.Projects; +using TfsAdvanced.Models; +using TFSAdvanced.Updater.Models.Projects; -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public class BuildQueueRequest { diff --git a/src/TfsAdvanced.Models/Builds/BuildResult.cs b/src/TfsAdvanced.Updater/Models/Builds/BuildResult.cs similarity index 77% rename from src/TfsAdvanced.Models/Builds/BuildResult.cs rename to src/TfsAdvanced.Updater/Models/Builds/BuildResult.cs index 88e8d86..c9c1bdb 100644 --- a/src/TfsAdvanced.Models/Builds/BuildResult.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/BuildResult.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public enum BuildResult { diff --git a/src/TfsAdvanced.Models/Builds/BuildRun.cs b/src/TfsAdvanced.Updater/Models/Builds/BuildRun.cs similarity index 88% rename from src/TfsAdvanced.Models/Builds/BuildRun.cs rename to src/TfsAdvanced.Updater/Models/Builds/BuildRun.cs index 967fc0f..0f84eae 100644 --- a/src/TfsAdvanced.Models/Builds/BuildRun.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/BuildRun.cs @@ -1,6 +1,6 @@ using System; -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public class BuildRun { diff --git a/src/TfsAdvanced.Models/Builds/BuildStatus.cs b/src/TfsAdvanced.Updater/Models/Builds/BuildStatus.cs similarity index 76% rename from src/TfsAdvanced.Models/Builds/BuildStatus.cs rename to src/TfsAdvanced.Updater/Models/Builds/BuildStatus.cs index 394ec7d..e246e9f 100644 --- a/src/TfsAdvanced.Models/Builds/BuildStatus.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/BuildStatus.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public enum BuildStatus { diff --git a/src/TfsAdvanced.Models/Builds/BuildStepInput.cs b/src/TfsAdvanced.Updater/Models/Builds/BuildStepInput.cs similarity index 67% rename from src/TfsAdvanced.Models/Builds/BuildStepInput.cs rename to src/TfsAdvanced.Updater/Models/Builds/BuildStepInput.cs index 4528bc8..276445a 100644 --- a/src/TfsAdvanced.Models/Builds/BuildStepInput.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/BuildStepInput.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public class BuildStepInput { diff --git a/src/TfsAdvanced.Models/Builds/BuildSteps.cs b/src/TfsAdvanced.Updater/Models/Builds/BuildSteps.cs similarity index 89% rename from src/TfsAdvanced.Models/Builds/BuildSteps.cs rename to src/TfsAdvanced.Updater/Models/Builds/BuildSteps.cs index 7d8632c..8da0f58 100644 --- a/src/TfsAdvanced.Models/Builds/BuildSteps.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/BuildSteps.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public class BuildSteps { diff --git a/src/TfsAdvanced.Models/Builds/RequestedFor.cs b/src/TfsAdvanced.Updater/Models/Builds/RequestedFor.cs similarity index 79% rename from src/TfsAdvanced.Models/Builds/RequestedFor.cs rename to src/TfsAdvanced.Updater/Models/Builds/RequestedFor.cs index d57c8b5..e07b759 100644 --- a/src/TfsAdvanced.Models/Builds/RequestedFor.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/RequestedFor.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public class RequestedFor { diff --git a/src/TfsAdvanced.Models/Builds/TaskGroupItem.cs b/src/TfsAdvanced.Updater/Models/Builds/TaskGroupItem.cs similarity index 79% rename from src/TfsAdvanced.Models/Builds/TaskGroupItem.cs rename to src/TfsAdvanced.Updater/Models/Builds/TaskGroupItem.cs index efe7d44..277cd33 100644 --- a/src/TfsAdvanced.Models/Builds/TaskGroupItem.cs +++ b/src/TfsAdvanced.Updater/Models/Builds/TaskGroupItem.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Builds +namespace TFSAdvanced.Updater.Models.Builds { public class TaskGroupItem { diff --git a/src/TfsAdvanced.Models/JobRequests/Agent.cs b/src/TfsAdvanced.Updater/Models/JobRequests/Agent.cs similarity index 82% rename from src/TfsAdvanced.Models/JobRequests/Agent.cs rename to src/TfsAdvanced.Updater/Models/JobRequests/Agent.cs index b53fd17..dfd4076 100644 --- a/src/TfsAdvanced.Models/JobRequests/Agent.cs +++ b/src/TfsAdvanced.Updater/Models/JobRequests/Agent.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.JobRequests +namespace TFSAdvanced.Updater.Models.JobRequests { public class Agent { diff --git a/src/TfsAdvanced.Models/JobRequests/JobRequest.cs b/src/TfsAdvanced.Updater/Models/JobRequests/JobRequest.cs similarity index 87% rename from src/TfsAdvanced.Models/JobRequests/JobRequest.cs rename to src/TfsAdvanced.Updater/Models/JobRequests/JobRequest.cs index 0e87194..bc9e33f 100644 --- a/src/TfsAdvanced.Models/JobRequests/JobRequest.cs +++ b/src/TfsAdvanced.Updater/Models/JobRequests/JobRequest.cs @@ -1,7 +1,7 @@ using System; -using TfsAdvanced.Models.Builds; +using TFSAdvanced.Updater.Models.Builds; -namespace TfsAdvanced.Models.JobRequests +namespace TFSAdvanced.Updater.Models.JobRequests { public class JobRequest { @@ -9,7 +9,6 @@ public class JobRequest public DateTime queueTime { get; set; } public DateTime? assignTime { get; set; } public DateTime? receiveTime { get; set; } - public DateTime? startedTime { get; set; } public DateTime? finishTime { get; set; } public DateTime? lockedUntil { get; set; } public Guid serviceOwner { get; set; } diff --git a/src/TfsAdvanced.Models/JobRequests/JobRequestStatus.cs b/src/TfsAdvanced.Updater/Models/JobRequests/JobRequestStatus.cs similarity index 72% rename from src/TfsAdvanced.Models/JobRequests/JobRequestStatus.cs rename to src/TfsAdvanced.Updater/Models/JobRequests/JobRequestStatus.cs index b6f814b..4a59d23 100644 --- a/src/TfsAdvanced.Models/JobRequests/JobRequestStatus.cs +++ b/src/TfsAdvanced.Updater/Models/JobRequests/JobRequestStatus.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.JobRequests +namespace TFSAdvanced.Updater.Models.JobRequests { public enum JobRequestStatus { diff --git a/src/TfsAdvanced.Models/JobRequests/PlanTypes.cs b/src/TfsAdvanced.Updater/Models/JobRequests/PlanTypes.cs similarity index 58% rename from src/TfsAdvanced.Models/JobRequests/PlanTypes.cs rename to src/TfsAdvanced.Updater/Models/JobRequests/PlanTypes.cs index 1f08f6e..5caf9fc 100644 --- a/src/TfsAdvanced.Models/JobRequests/PlanTypes.cs +++ b/src/TfsAdvanced.Updater/Models/JobRequests/PlanTypes.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.JobRequests +namespace TFSAdvanced.Updater.Models.JobRequests { public enum PlanTypes { diff --git a/src/TfsAdvanced.Models/Policy/MatchKind.cs b/src/TfsAdvanced.Updater/Models/Policy/MatchKind.cs similarity index 56% rename from src/TfsAdvanced.Models/Policy/MatchKind.cs rename to src/TfsAdvanced.Updater/Models/Policy/MatchKind.cs index 431eae7..61d6475 100644 --- a/src/TfsAdvanced.Models/Policy/MatchKind.cs +++ b/src/TfsAdvanced.Updater/Models/Policy/MatchKind.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Policy +namespace TFSAdvanced.Updater.Models.Policy { public enum MatchKind { diff --git a/src/TfsAdvanced.Updater/Models/Policy/PolicyConfiguration.cs b/src/TfsAdvanced.Updater/Models/Policy/PolicyConfiguration.cs new file mode 100644 index 0000000..0d276fd --- /dev/null +++ b/src/TfsAdvanced.Updater/Models/Policy/PolicyConfiguration.cs @@ -0,0 +1,12 @@ +using System; + +namespace TFSAdvanced.Updater.Models.Policy +{ + public class PolicyConfiguration + { + public string id { get; set; } + public PolicySetting settings { get; set; } + + public PolicyType type { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/Policy/PolicyScope.cs b/src/TfsAdvanced.Updater/Models/Policy/PolicyScope.cs similarity index 76% rename from src/TfsAdvanced.Models/Policy/PolicyScope.cs rename to src/TfsAdvanced.Updater/Models/Policy/PolicyScope.cs index 2f96b67..7ec431b 100644 --- a/src/TfsAdvanced.Models/Policy/PolicyScope.cs +++ b/src/TfsAdvanced.Updater/Models/Policy/PolicyScope.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Policy +namespace TFSAdvanced.Updater.Models.Policy { public class PolicyScope { diff --git a/src/TfsAdvanced.Models/Policy/PolicySetting.cs b/src/TfsAdvanced.Updater/Models/Policy/PolicySetting.cs similarity index 91% rename from src/TfsAdvanced.Models/Policy/PolicySetting.cs rename to src/TfsAdvanced.Updater/Models/Policy/PolicySetting.cs index 26f7c07..9f26e4f 100644 --- a/src/TfsAdvanced.Models/Policy/PolicySetting.cs +++ b/src/TfsAdvanced.Updater/Models/Policy/PolicySetting.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Policy +namespace TFSAdvanced.Updater.Models.Policy { public class PolicySetting { diff --git a/src/TfsAdvanced.Updater/Models/Policy/PolicyType.cs b/src/TfsAdvanced.Updater/Models/Policy/PolicyType.cs new file mode 100644 index 0000000..cbefc7f --- /dev/null +++ b/src/TfsAdvanced.Updater/Models/Policy/PolicyType.cs @@ -0,0 +1,7 @@ +namespace TFSAdvanced.Updater.Models.Policy +{ + public class PolicyType + { + public string displayName { get; set; } + } +} diff --git a/src/TfsAdvanced.Models/Projects/Project.cs b/src/TfsAdvanced.Updater/Models/Projects/Project.cs similarity index 80% rename from src/TfsAdvanced.Models/Projects/Project.cs rename to src/TfsAdvanced.Updater/Models/Projects/Project.cs index c9b728e..654904c 100644 --- a/src/TfsAdvanced.Models/Projects/Project.cs +++ b/src/TfsAdvanced.Updater/Models/Projects/Project.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Projects +namespace TFSAdvanced.Updater.Models.Projects { public class Project { diff --git a/src/TfsAdvanced.Models/Projects/ProjectGuid.cs b/src/TfsAdvanced.Updater/Models/Projects/ProjectGuid.cs similarity index 62% rename from src/TfsAdvanced.Models/Projects/ProjectGuid.cs rename to src/TfsAdvanced.Updater/Models/Projects/ProjectGuid.cs index ab6976a..5f55e8f 100644 --- a/src/TfsAdvanced.Models/Projects/ProjectGuid.cs +++ b/src/TfsAdvanced.Updater/Models/Projects/ProjectGuid.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Projects +namespace TFSAdvanced.Updater.Models.Projects { public class ProjectGuid { diff --git a/src/TfsAdvanced.Models/Projects/ProjectLinks.cs b/src/TfsAdvanced.Updater/Models/Projects/ProjectLinks.cs similarity index 84% rename from src/TfsAdvanced.Models/Projects/ProjectLinks.cs rename to src/TfsAdvanced.Updater/Models/Projects/ProjectLinks.cs index 8a16b6c..f249d56 100644 --- a/src/TfsAdvanced.Models/Projects/ProjectLinks.cs +++ b/src/TfsAdvanced.Updater/Models/Projects/ProjectLinks.cs @@ -1,4 +1,6 @@ -namespace TfsAdvanced.Models.Projects +using TfsAdvanced.Models; + +namespace TFSAdvanced.Updater.Models.Projects { public class ProjectLinks { diff --git a/src/TfsAdvanced.Models/PullRequests/CompletionOptions.cs b/src/TfsAdvanced.Updater/Models/PullRequests/CompletionOptions.cs similarity index 58% rename from src/TfsAdvanced.Models/PullRequests/CompletionOptions.cs rename to src/TfsAdvanced.Updater/Models/PullRequests/CompletionOptions.cs index 3fbb814..e68c100 100644 --- a/src/TfsAdvanced.Models/PullRequests/CompletionOptions.cs +++ b/src/TfsAdvanced.Updater/Models/PullRequests/CompletionOptions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Models.PullRequests +namespace TFSAdvanced.Updater.Models.PullRequests { public class CompletionOptions { diff --git a/src/TfsAdvanced.Models/PullRequests/PullRequest.cs b/src/TfsAdvanced.Updater/Models/PullRequests/PullRequest.cs similarity index 86% rename from src/TfsAdvanced.Models/PullRequests/PullRequest.cs rename to src/TfsAdvanced.Updater/Models/PullRequests/PullRequest.cs index 6ded748..504ac92 100644 --- a/src/TfsAdvanced.Models/PullRequests/PullRequest.cs +++ b/src/TfsAdvanced.Updater/Models/PullRequests/PullRequest.cs @@ -1,9 +1,8 @@ using System; -using Models.PullRequests; -using TfsAdvanced.Models.Builds; -using TfsAdvanced.Models.Repositories; +using TfsAdvanced.Models; +using TFSAdvanced.Updater.Models.Repositories; -namespace TfsAdvanced.Models.PullRequests +namespace TFSAdvanced.Updater.Models.PullRequests { public class PullRequest { @@ -26,8 +25,6 @@ public class PullRequest public string title { get; set; } public string url { get; set; } - public Build build { get; set; } - public int requiredReviewers { get; set; } public int acceptedReviewers { get; set; } diff --git a/src/TfsAdvanced.Models/PullRequests/PullRequestLinks.cs b/src/TfsAdvanced.Updater/Models/PullRequests/PullRequestLinks.cs similarity index 84% rename from src/TfsAdvanced.Models/PullRequests/PullRequestLinks.cs rename to src/TfsAdvanced.Updater/Models/PullRequests/PullRequestLinks.cs index 38f9afa..8fa8864 100644 --- a/src/TfsAdvanced.Models/PullRequests/PullRequestLinks.cs +++ b/src/TfsAdvanced.Updater/Models/PullRequests/PullRequestLinks.cs @@ -1,4 +1,6 @@ -namespace TfsAdvanced.Models.PullRequests +using TfsAdvanced.Models; + +namespace TFSAdvanced.Updater.Models.PullRequests { public class PullRequestLinks { diff --git a/src/TfsAdvanced.Models/PullRequests/Reviewer.cs b/src/TfsAdvanced.Updater/Models/PullRequests/Reviewer.cs similarity index 89% rename from src/TfsAdvanced.Models/PullRequests/Reviewer.cs rename to src/TfsAdvanced.Updater/Models/PullRequests/Reviewer.cs index 736ae0c..02279b5 100644 --- a/src/TfsAdvanced.Models/PullRequests/Reviewer.cs +++ b/src/TfsAdvanced.Updater/Models/PullRequests/Reviewer.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.PullRequests +namespace TFSAdvanced.Updater.Models.PullRequests { public class Reviewer { diff --git a/src/TfsAdvanced.Models/PullRequests/Vote.cs b/src/TfsAdvanced.Updater/Models/PullRequests/Vote.cs similarity index 76% rename from src/TfsAdvanced.Models/PullRequests/Vote.cs rename to src/TfsAdvanced.Updater/Models/PullRequests/Vote.cs index 7b8de69..d187ed1 100644 --- a/src/TfsAdvanced.Models/PullRequests/Vote.cs +++ b/src/TfsAdvanced.Updater/Models/PullRequests/Vote.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.PullRequests +namespace TFSAdvanced.Updater.Models.PullRequests { public enum Vote { diff --git a/src/TfsAdvanced.Models/PullRequests/VotedFor.cs b/src/TfsAdvanced.Updater/Models/PullRequests/VotedFor.cs similarity index 89% rename from src/TfsAdvanced.Models/PullRequests/VotedFor.cs rename to src/TfsAdvanced.Updater/Models/PullRequests/VotedFor.cs index da86bc4..4c8e11e 100644 --- a/src/TfsAdvanced.Models/PullRequests/VotedFor.cs +++ b/src/TfsAdvanced.Updater/Models/PullRequests/VotedFor.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.PullRequests +namespace TFSAdvanced.Updater.Models.PullRequests { public class VotedFor { diff --git a/src/TfsAdvanced.Models/Repositories/Commit.cs b/src/TfsAdvanced.Updater/Models/Repositories/Commit.cs similarity index 77% rename from src/TfsAdvanced.Models/Repositories/Commit.cs rename to src/TfsAdvanced.Updater/Models/Repositories/Commit.cs index 16976b0..e458adb 100644 --- a/src/TfsAdvanced.Models/Repositories/Commit.cs +++ b/src/TfsAdvanced.Updater/Models/Repositories/Commit.cs @@ -1,4 +1,6 @@ -namespace TfsAdvanced.Models.Repositories +using TfsAdvanced.Models; + +namespace TFSAdvanced.Updater.Models.Repositories { public class Commit { diff --git a/src/TfsAdvanced.Models/Repositories/CommitLink.cs b/src/TfsAdvanced.Updater/Models/Repositories/CommitLink.cs similarity index 70% rename from src/TfsAdvanced.Models/Repositories/CommitLink.cs rename to src/TfsAdvanced.Updater/Models/Repositories/CommitLink.cs index eaff03a..e44a9c0 100644 --- a/src/TfsAdvanced.Models/Repositories/CommitLink.cs +++ b/src/TfsAdvanced.Updater/Models/Repositories/CommitLink.cs @@ -1,4 +1,4 @@ -namespace TfsAdvanced.Models.Repositories +namespace TFSAdvanced.Updater.Models.Repositories { public class CommitLink { diff --git a/src/TfsAdvanced.Models/Repositories/Repository.cs b/src/TfsAdvanced.Updater/Models/Repositories/Repository.cs similarity index 79% rename from src/TfsAdvanced.Models/Repositories/Repository.cs rename to src/TfsAdvanced.Updater/Models/Repositories/Repository.cs index 0dabad0..23fdf1e 100644 --- a/src/TfsAdvanced.Models/Repositories/Repository.cs +++ b/src/TfsAdvanced.Updater/Models/Repositories/Repository.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; -using TfsAdvanced.Models.Policy; -using TfsAdvanced.Models.Projects; +using TFSAdvanced.Updater.Models.Policy; +using TFSAdvanced.Updater.Models.Projects; -namespace TfsAdvanced.Models.Repositories +namespace TFSAdvanced.Updater.Models.Repositories { public class Repository { diff --git a/src/TfsAdvanced.Updater/Tasks/BuildDefinitionUpdater.cs b/src/TfsAdvanced.Updater/Tasks/BuildDefinitionUpdater.cs index 644fc38..95cc632 100644 --- a/src/TfsAdvanced.Updater/Tasks/BuildDefinitionUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/BuildDefinitionUpdater.cs @@ -6,8 +6,9 @@ using Hangfire; using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models; -using TfsAdvanced.Models.Builds; using TfsAdvanced.Models.Infrastructure; +using TFSAdvanced.Models.DTO; +using BuildDefinition = TFSAdvanced.Updater.Models.Builds.BuildDefinition; namespace TfsAdvanced.Updater.Tasks { @@ -16,15 +17,17 @@ public class BuildDefinitionUpdater private readonly BuildDefinitionRepository buildDefinitionRepository; private readonly UpdateStatusRepository updateStatusRepository; private readonly ProjectRepository projectRepository; + private readonly RepositoryRepository repositoryRepository; private readonly RequestData requestData; private bool IsRunning; - public BuildDefinitionUpdater(BuildDefinitionRepository buildDefinitionRepository, RequestData requestData, ProjectRepository projectRepository, UpdateStatusRepository updateStatusRepository) + public BuildDefinitionUpdater(BuildDefinitionRepository buildDefinitionRepository, RequestData requestData, ProjectRepository projectRepository, UpdateStatusRepository updateStatusRepository, RepositoryRepository repositoryRepository) { this.buildDefinitionRepository = buildDefinitionRepository; this.requestData = requestData; this.projectRepository = projectRepository; this.updateStatusRepository = updateStatusRepository; + this.repositoryRepository = repositoryRepository; } [AutomaticRetry(Attempts = 0)] @@ -36,16 +39,25 @@ public void Update() try { - var buildDefinitions = new ConcurrentBag(); + var buildDefinitions = new ConcurrentBag(); Parallel.ForEach(projectRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, project => { - var definitions = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.name}/_apis/build/definitions?api=2.2").Result; + var definitions = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/definitions?api=2.2").Result; if (definitions == null) return; Parallel.ForEach(definitions, new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, definition => { var populatedDefinition = GetAsync.Fetch(requestData, definition.url).Result; - buildDefinitions.Add(populatedDefinition); + + buildDefinitions.Add(new TFSAdvanced.Models.DTO.BuildDefinition + { + DefaultBranch = populatedDefinition.repository.defaultBranch, + Folder = populatedDefinition.path, + Id = populatedDefinition.id, + Name = populatedDefinition.name, + Url = populatedDefinition._links.web.href, + Repository = repositoryRepository.GetById(populatedDefinition.repository.id) + }); }); }); diff --git a/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs b/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs index 5926f5b..116f40f 100644 --- a/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs @@ -6,8 +6,11 @@ using Hangfire; using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models; -using TfsAdvanced.Models.Builds; using TfsAdvanced.Models.Infrastructure; +using TFSAdvanced.Models.DTO; +using TFSAdvanced.Updater.Models.Builds; +using Build = TFSAdvanced.Updater.Models.Builds.Build; +using BuildStatus = TFSAdvanced.Updater.Models.Builds.BuildStatus; namespace TfsAdvanced.Updater.Tasks { @@ -16,17 +19,15 @@ public class BuildUpdater private readonly BuildRepository buildRepository; private readonly UpdateStatusRepository updateStatusRepository; private readonly ProjectRepository projectRepository; - private readonly PullRequestRepository pullRequestRepository; private readonly RequestData requestData; private bool IsRunning; - public BuildUpdater(BuildRepository buildRepository, RequestData requestData, ProjectRepository projectRepository, UpdateStatusRepository updateStatusRepository, PullRequestRepository pullRequestRepository) + public BuildUpdater(BuildRepository buildRepository, RequestData requestData, ProjectRepository projectRepository, UpdateStatusRepository updateStatusRepository) { this.buildRepository = buildRepository; this.requestData = requestData; this.projectRepository = projectRepository; this.updateStatusRepository = updateStatusRepository; - this.pullRequestRepository = pullRequestRepository; } [AutomaticRetry(Attempts = 0)] @@ -43,7 +44,7 @@ public void Update() Parallel.ForEach(projectRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, project => { // Finished PR builds - var projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.name}/_apis/build/builds?api-version=2.2&reasonFilter=validateShelveset&minFinishTime={yesterday:O}").Result; + var projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/builds?api-version=2.2&reasonFilter=validateShelveset&minFinishTime={yesterday:O}").Result; if (projectBuilds != null && projectBuilds.Any()) { builds.PushRange(projectBuilds.ToArray()); @@ -51,7 +52,7 @@ public void Update() // Current active builds - projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.name}/_apis/build/builds?api-version=2.2&statusFilter=inProgress&inProgress=notStarted").Result; + projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/builds?api-version=2.2&statusFilter=inProgress&inProgress=notStarted").Result; if (projectBuilds != null && projectBuilds.Any()) { builds.PushRange(projectBuilds.ToArray()); @@ -61,7 +62,7 @@ public void Update() DateTime twoHoursAgo = DateTime.Now.AddHours(-2); // Because we want to capture the final state of any build that was running and just finished we are getting those too // Finished builds within the last 2 hours - projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.name}/_apis/build/builds?api-version=2.2&minFinishTime={twoHoursAgo:O}").Result; + projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/builds?api-version=2.2&minFinishTime={twoHoursAgo:O}").Result; if (projectBuilds != null && projectBuilds.Any()) { builds.PushRange(projectBuilds.ToArray()); @@ -72,7 +73,7 @@ public void Update() // The builds must be requested without the filter because the only filter available is minFinishTime, which will filter out those that haven't finished yet var buildLists = builds.ToList(); - buildRepository.Update(buildLists); + buildRepository.Update(buildLists.Select(CreateBuild)); updateStatusRepository.UpdateStatus(new UpdateStatus {LastUpdate = DateTime.Now, UpdatedRecords = buildLists.Count, UpdaterName = nameof(BuildUpdater)}); } @@ -85,5 +86,59 @@ public void Update() IsRunning = false; } } + + private TFSAdvanced.Models.DTO.Build CreateBuild(Build build) + { + TFSAdvanced.Models.DTO.Build buildDto = new TFSAdvanced.Models.DTO.Build + { + Id = build.id, + Url = build._links.web.href, + SourceCommit = build.sourceVersion, + QueuedDate = build.queueTime, + StartedDate = build.startTime, + FinishedDate = build.finishTime, + Creator = new User + { + Name = build.requestedFor.displayName, + IconUrl = build.requestedFor.imageUrl + } + }; + + switch (build.status) + { + case BuildStatus.notStarted: + buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.NotStarted; + break; + case BuildStatus.inProgress: + buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Building; + break; + default: + switch (build.result) + { + case BuildResult.abandoned: + buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Abandonded; + break; + case BuildResult.canceled: + buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Cancelled; + break; + case BuildResult.expired: + buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Expired; + break; + case BuildResult.failed: + case BuildResult.partiallySucceeded: + buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Failed; + break; + case BuildResult.succeeded: + buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Succeeded; + break; + default: + buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.NoBuild; + break; + } + break; + } + + return buildDto; + } } } diff --git a/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs b/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs index 72672ca..041f949 100644 --- a/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs @@ -6,9 +6,11 @@ using Hangfire; using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models; -using TfsAdvanced.Models.Builds; using TfsAdvanced.Models.Infrastructure; -using TfsAdvanced.Models.JobRequests; +using TFSAdvanced.Models.DTO; +using TFSAdvanced.Updater.Models.Builds; +using TFSAdvanced.Updater.Models.JobRequests; +using BuildStatus = TFSAdvanced.Updater.Models.Builds.BuildStatus; namespace TfsAdvanced.Updater.Tasks { @@ -40,7 +42,7 @@ public void Update() try { - ConcurrentBag jobRequests = new ConcurrentBag(); + ConcurrentBag jobRequests = new ConcurrentBag(); Parallel.ForEach(poolRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, pool => { @@ -50,41 +52,43 @@ public void Update() { foreach (var poolJobRequest in poolJobRequests) { + QueueJob queueJob = new QueueJob + { + RequestId = poolJobRequest.requestId, + QueuedTime = poolJobRequest.queueTime, + AssignedTime = poolJobRequest.assignTime, + FinishedTime = poolJobRequest.finishTime + }; if (poolJobRequest.planType == PlanTypes.Build) { var build = buildRepository.GetBuild(poolJobRequest.owner.id); if (build != null) { - poolJobRequest.owner = build; - poolJobRequest.startedTime = build.startTime; - poolJobRequest.definition = build.definition; - if (build.status == BuildStatus.completed) - { - switch (build.result) - { - case BuildResult.succeeded: - poolJobRequest.status = JobRequestStatus.succeeded; - break; - case BuildResult.abandoned: - poolJobRequest.status = JobRequestStatus.abandoned; - break; - case BuildResult.canceled: - poolJobRequest.status = JobRequestStatus.canceled; - break; - case BuildResult.failed: - case BuildResult.partiallySucceeded: - poolJobRequest.status = JobRequestStatus.failed; - break; - } - } - else if (build.status == BuildStatus.inProgress) + queueJob.LaunchedBy = build.Creator; + queueJob.StartedTime = build.StartedDate; + queueJob.FinishedTime = build.FinishedDate; + switch (build.BuildStatus) { - if (build.startTime.HasValue) - poolJobRequest.status = JobRequestStatus.started; - else - poolJobRequest.status = JobRequestStatus.queued; + case TFSAdvanced.Models.DTO.BuildStatus.NotStarted: + queueJob.QueueJobStatus = QueueJobStatus.Queued; + break; + case TFSAdvanced.Models.DTO.BuildStatus.Abandonded: + queueJob.QueueJobStatus = QueueJobStatus.Abandonded; + break; + case TFSAdvanced.Models.DTO.BuildStatus.Building: + queueJob.QueueJobStatus = QueueJobStatus.Building; + break; + case TFSAdvanced.Models.DTO.BuildStatus.Cancelled: + queueJob.QueueJobStatus = QueueJobStatus.Cancelled; + break; + case TFSAdvanced.Models.DTO.BuildStatus.Expired: + case TFSAdvanced.Models.DTO.BuildStatus.Failed: + queueJob.QueueJobStatus = QueueJobStatus.Failed; + break; + case TFSAdvanced.Models.DTO.BuildStatus.Succeeded: + queueJob.QueueJobStatus = QueueJobStatus.Succeeded; + break; } - } } @@ -95,17 +99,17 @@ public void Update() switch (poolJobRequest.result) { case BuildResult.succeeded: - poolJobRequest.status = JobRequestStatus.succeeded; + queueJob.QueueJobStatus = QueueJobStatus.Succeeded; break; case BuildResult.abandoned: - poolJobRequest.status = JobRequestStatus.abandoned; + queueJob.QueueJobStatus = QueueJobStatus.Abandonded; break; case BuildResult.canceled: - poolJobRequest.status = JobRequestStatus.canceled; + queueJob.QueueJobStatus = QueueJobStatus.Cancelled; break; case BuildResult.failed: case BuildResult.partiallySucceeded: - poolJobRequest.status = JobRequestStatus.failed; + queueJob.QueueJobStatus = QueueJobStatus.Failed; break; } } @@ -113,14 +117,14 @@ public void Update() - jobRequests.Add(poolJobRequest); + jobRequests.Add(queueJob); } } }); DateTime yesterday = DateTime.Now.Date.AddDays(-1); - var jobRequestsLists = jobRequests.Where(x => !x.startedTime.HasValue || x.startedTime.Value >= yesterday).ToList(); - jobRequestRepository.UpdateJobRequests(jobRequestsLists); + var jobRequestsLists = jobRequests.Where(x => !x.StartedTime.HasValue || x.StartedTime.Value >= yesterday).ToList(); + jobRequestRepository.Update(jobRequestsLists); updateStatusRepository.UpdateStatus(new UpdateStatus {LastUpdate = DateTime.Now, UpdatedRecords = jobRequestsLists.Count, UpdaterName = nameof(JobRequestUpdater)}); } diff --git a/src/TfsAdvanced.Updater/Tasks/PolicyUpdater.cs b/src/TfsAdvanced.Updater/Tasks/PolicyUpdater.cs deleted file mode 100644 index 6d5e6f1..0000000 --- a/src/TfsAdvanced.Updater/Tasks/PolicyUpdater.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Hangfire; -using TfsAdvanced.DataStore.Repository; -using TfsAdvanced.Models; -using TfsAdvanced.Models.Infrastructure; -using TfsAdvanced.Models.Policy; - -namespace TfsAdvanced.Updater.Tasks -{ - public class PolicyUpdater - { - - private readonly RequestData requestData; - private readonly ProjectRepository projectRepository; - private readonly PolicyRepository policyRepository; - private bool IsRunning = false; - - public PolicyUpdater(RequestData requestData, ProjectRepository projectRepository, PolicyRepository policyRepository) - { - this.requestData = requestData; - this.projectRepository = projectRepository; - this.policyRepository = policyRepository; - } - - [AutomaticRetry(Attempts = 0)] - public void Update() - { - if (IsRunning) - return; - IsRunning = true; - try - { - - ConcurrentBag policies = new ConcurrentBag(); - Parallel.ForEach(projectRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, project => - { - var policyConfigurations = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/defaultcollection/{project.id}/_apis/policy/configurations?api-version=2.0-preview.1").Result; - foreach (var configuration in policyConfigurations) - { - policies.Add(configuration); - } - - }); - policyRepository.Update(policies); - } - catch (Exception ex) - { - throw new InvalidOperationException("Error running policy updater.", ex); - } - finally - { - IsRunning = false; - } - - } - } -} diff --git a/src/TfsAdvanced.Updater/Tasks/PoolUpdater.cs b/src/TfsAdvanced.Updater/Tasks/PoolUpdater.cs index 54f53c1..0d6ff2d 100644 --- a/src/TfsAdvanced.Updater/Tasks/PoolUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/PoolUpdater.cs @@ -2,7 +2,7 @@ using Hangfire; using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models; -using TfsAdvanced.Models.Pools; +using TFSAdvanced.Models.DTO; namespace TfsAdvanced.Updater.Tasks { diff --git a/src/TfsAdvanced.Updater/Tasks/ProjectUpdater.cs b/src/TfsAdvanced.Updater/Tasks/ProjectUpdater.cs index 21fdf2c..414003e 100644 --- a/src/TfsAdvanced.Updater/Tasks/ProjectUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/ProjectUpdater.cs @@ -3,7 +3,7 @@ using Hangfire; using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models; -using TfsAdvanced.Models.Projects; +using TFSAdvanced.Updater.Models.Projects; namespace TfsAdvanced.Updater.Tasks { @@ -33,7 +33,12 @@ public void Update() var projects = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/_apis/projects?api-version=1.0").Result; if (projects != null) { - projectRepository.Update(projects.ToList()); + projectRepository.Update(projects.Select(x => new TFSAdvanced.Models.DTO.Project + { + Id = x.id, + Name = x.name, + Url = x.remoteUrl + })); updateStatusRepository.UpdateStatus(new UpdateStatus {LastUpdate = DateTime.Now, UpdatedRecords = projects.Count, UpdaterName = nameof(ProjectUpdater)}); } diff --git a/src/TfsAdvanced.Updater/Tasks/PullRequestUpdater.cs b/src/TfsAdvanced.Updater/Tasks/PullRequestUpdater.cs index 0135035..a984aec 100644 --- a/src/TfsAdvanced.Updater/Tasks/PullRequestUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/PullRequestUpdater.cs @@ -1,13 +1,18 @@ using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Hangfire; using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models; -using TfsAdvanced.Models.Builds; using TfsAdvanced.Models.Infrastructure; -using TfsAdvanced.Models.PullRequests; +using TFSAdvanced.Models.DTO; +using TFSAdvanced.Updater.Models.PullRequests; +using BuildStatus = TFSAdvanced.Updater.Models.Builds.BuildStatus; +using PullRequest = TFSAdvanced.Updater.Models.PullRequests.PullRequest; +using Reviewer = TFSAdvanced.Models.DTO.Reviewer; +using Repository = TFSAdvanced.Models.DTO.Repository; namespace TfsAdvanced.Updater.Tasks { @@ -20,7 +25,8 @@ public class PullRequestUpdater private readonly BuildRepository buildRepository; private bool IsRunning; - public PullRequestUpdater(PullRequestRepository pullRequestRepository, RequestData requestData, RepositoryRepository repositoryRepository, UpdateStatusRepository updateStatusRepository, BuildRepository buildRepository) + public PullRequestUpdater(PullRequestRepository pullRequestRepository, RequestData requestData, RepositoryRepository repositoryRepository, + UpdateStatusRepository updateStatusRepository, BuildRepository buildRepository) { this.requestData = requestData; this.repositoryRepository = repositoryRepository; @@ -38,38 +44,31 @@ public void Update() IsRunning = true; try { - ConcurrentBag allPullRequests = new ConcurrentBag(); + ConcurrentBag allPullRequests = new ConcurrentBag(); Parallel.ForEach(repositoryRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, repository => { - if (repository._links.pullRequests == null) + if (string.IsNullOrEmpty(repository.PullRequestUrl)) return; - var pullRequests = GetAsync.FetchResponseList(requestData, repository._links.pullRequests.href).Result; + var pullRequests = GetAsync.FetchResponseList(requestData, repository.PullRequestUrl).Result; if (pullRequests == null) return; Parallel.ForEach(pullRequests, new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, pullRequest => { - pullRequest.repository = repository; - pullRequest.remoteUrl = BuildPullRequestUrl(pullRequest, requestData.BaseAddress); - if (pullRequest.lastMergeCommit != null) - { - pullRequest.build = buildRepository.GetBuildBySourceVersion(pullRequest.lastMergeCommit.commitId); - } - foreach (var configuration in repository.policyConfigurations) - { - if (configuration.type.displayName == "Minimum number of reviewers") - { - pullRequest.requiredReviewers = configuration.settings.minimumApproverCount; - } - } + var build = buildRepository.GetBuildBySourceVersion(pullRequest.lastMergeCommit.commitId); + var pullRequestDto = BuildPullRequest(pullRequest, build); + pullRequestDto.Repository= repository; + pullRequestDto.Url = BuildPullRequestUrl(pullRequest, requestData.BaseAddress); + pullRequestDto.RequiredReviewers = repository.MinimumApproverCount; + foreach (var reviewer in pullRequest.reviewers) { // Container reviewers do not count if (reviewer.isContainer) continue; if (reviewer.vote == (int) Vote.Approved) - pullRequest.acceptedReviewers++; + pullRequestDto.AcceptedReviewers++; } - allPullRequests.Add(pullRequest); + allPullRequests.Add(pullRequestDto); }); }); var pullRequestsList = allPullRequests.ToList(); @@ -88,6 +87,85 @@ public void Update() } } + private TFSAdvanced.Models.DTO.PullRequest BuildPullRequest(PullRequest x, Build build) + { + TFSAdvanced.Models.DTO.PullRequest pullRequestDto = new TFSAdvanced.Models.DTO.PullRequest + { + Id = x.pullRequestId, + Title = x.title, + Url = x.remoteUrl, + CreatedDate = x.creationDate, + Creator = new User + { + Name = x.createdBy.displayName, + IconUrl = x.createdBy.imageUrl + }, + Repository = new Repository + { + Name = x.repository.name, + Url = x.repository.remoteUrl, + Project = new Project + { + Name = x.repository.project.name, + Url = x.repository.project.remoteUrl + } + }, + MergeStatus = x.mergeStatus == "conflicts" ? MergeStatus.Failed : MergeStatus.Succeeded, + IsAutoCompleteSet = x.completionOptions != null, + HasEnoughReviewers = x.hasEnoughReviewers, + AcceptedReviewers = x.acceptedReviewers, + RequiredReviewers = x.requiredReviewers, + Reviewers = new List() + }; + + if (x.reviewers != null) + { + foreach (var reviewer in x.reviewers) + { + if (reviewer.isContainer) + continue; + var reviewerDto = new Reviewer + { + Name = reviewer.displayName, + IconUrl = reviewer.imageUrl + + }; + switch ((Vote)reviewer.vote) + { + case Vote.Approved: + reviewerDto.ReviewStatus = ReviewStatus.Approved; + break; + case Vote.ApprovedWithSuggestions: + reviewerDto.ReviewStatus = ReviewStatus.ApprovedWithSuggestions; + break; + case Vote.NoResponse: + reviewerDto.ReviewStatus = ReviewStatus.NoResponse; + break; + case Vote.Rejected: + reviewerDto.ReviewStatus = ReviewStatus.Rejected; + break; + case Vote.WaitingForAuthor: + reviewerDto.ReviewStatus = ReviewStatus.WaitingForAuthor; + break; + } + pullRequestDto.Reviewers.Add(reviewerDto); + } + } + + if (build == null) + { + pullRequestDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.NoBuild; + } + else + { + pullRequestDto.buildId = build.Id; + pullRequestDto.BuildUrl = build.Url; + pullRequestDto.BuildStatus = build.BuildStatus; + } + + return pullRequestDto; + } + public string BuildPullRequestUrl(PullRequest pullRequest, string baseUrl) { return diff --git a/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs b/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs index 6b7973e..ab60305 100644 --- a/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs @@ -7,6 +7,9 @@ using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models; using TfsAdvanced.Models.Infrastructure; +using TFSAdvanced.Models.DTO; +using TFSAdvanced.Updater.Models.Policy; +using Repository = TFSAdvanced.Updater.Models.Repositories.Repository; namespace TfsAdvanced.Updater.Tasks { @@ -15,17 +18,16 @@ public class RepositoryUpdater private readonly ProjectRepository projectRepository; private readonly RepositoryRepository repositoryRepository; private readonly UpdateStatusRepository updateStatusRepository; - private readonly PolicyRepository policyRepository; private readonly RequestData requestData; private bool IsRunning; - public RepositoryUpdater(ProjectRepository projectRepository, RequestData requestData, RepositoryRepository repositoryRepository, UpdateStatusRepository updateStatusRepository, PolicyRepository policyRepository) + public RepositoryUpdater(ProjectRepository projectRepository, RequestData requestData, RepositoryRepository repositoryRepository, + UpdateStatusRepository updateStatusRepository) { this.projectRepository = projectRepository; this.requestData = requestData; this.repositoryRepository = repositoryRepository; this.updateStatusRepository = updateStatusRepository; - this.policyRepository = policyRepository; } [AutomaticRetry(Attempts = 0)] @@ -36,24 +38,42 @@ public void Update() IsRunning = true; try { - ConcurrentBag populatedRepositories = new ConcurrentBag(); + ConcurrentBag populatedRepositories = new ConcurrentBag(); Parallel.ForEach(projectRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, project => { - IList repositories = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.name}/_apis/git/repositories?api=1.0").Result; + IList repositories = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/git/repositories?api=1.0").Result; if (repositories == null) return; Parallel.ForEach(repositories, new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, repo => { try { - var populatedRepository = GetAsync.Fetch(requestData, $"{requestData.BaseAddress}/{project.name}/_apis/git/repositories/{repo.name}?api=1.0").Result; - populatedRepository.policyConfigurations = policyRepository.GetByRepository(populatedRepository.id); - populatedRepositories.Add(populatedRepository); - } - catch (Exception ex) - { - + var populatedRepository = GetAsync.Fetch(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/git/repositories/{repo.name}?api=1.0").Result; + + var repositoryDto = new TFSAdvanced.Models.DTO.Repository + { + Id = populatedRepository.id, + Name = populatedRepository.name, + PullRequestUrl = populatedRepository._links.pullRequests.href, + Url = populatedRepository.remoteUrl, + Project = new Project + { + Name = populatedRepository.project.name, + Url = populatedRepository.project.remoteUrl + } + }; + var policyConfigurations = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/defaultcollection/{project.Id}/_apis/policy/configurations?api-version=2.0-preview.1").Result; + + foreach (var configuration in policyConfigurations) + { + if (configuration.type.displayName == "Minimum number of reviewers") + { + repositoryDto.MinimumApproverCount = configuration.settings.minimumApproverCount; + } + } + populatedRepositories.Add(repositoryDto); } + catch (Exception){} }); }); var repositoryList = populatedRepositories.ToList(); diff --git a/src/TfsAdvanced.Updater/Tasks/Updater.cs b/src/TfsAdvanced.Updater/Tasks/Updater.cs index b1dd575..6a8ab16 100644 --- a/src/TfsAdvanced.Updater/Tasks/Updater.cs +++ b/src/TfsAdvanced.Updater/Tasks/Updater.cs @@ -20,13 +20,11 @@ public Updater(IServiceProvider serviceProvider) public void Start() { // Initialize the updaters in order - double stepSize = 1.0/8.0; + double stepSize = 1.0/7.0; double percentLoaded = 0.0; var hangFireStatusRepository = serviceProvider.GetService(); serviceProvider.GetService().Update(); percentLoaded += stepSize; - serviceProvider.GetService().Update(); - percentLoaded += stepSize; hangFireStatusRepository.SetPercentLoaded(percentLoaded); serviceProvider.GetService().Update(); percentLoaded += stepSize; @@ -53,7 +51,6 @@ public void Start() RecurringJob.AddOrUpdate(updater => updater.Update(), Cron.Hourly); RecurringJob.AddOrUpdate(updater => updater.Update(), Cron.Hourly); RecurringJob.AddOrUpdate(updater => updater.Update(), Cron.Hourly); - RecurringJob.AddOrUpdate(updater => updater.Update(), Cron.Hourly); thirtySecondTimer = new Timer(state => { diff --git a/src/TfsAdvanced/Controllers/BuildDefinitionsController.cs b/src/TfsAdvanced/Controllers/BuildDefinitionsController.cs index 0a627dc..112e185 100644 --- a/src/TfsAdvanced/Controllers/BuildDefinitionsController.cs +++ b/src/TfsAdvanced/Controllers/BuildDefinitionsController.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc; using TfsAdvanced.ServiceRequests; using TfsAdvanced.DataStore.Repository; -using TfsAdvanced.Models.Builds; +using TFSAdvanced.Models.DTO; namespace TfsAdvanced.Web.Controllers { @@ -38,7 +38,7 @@ public IActionResult BuildDefinitions([FromBody] List definitionIds) return NotFound(); var definitions = buildDefinitionRepository.GetAll() - .Where(x => definitionIds.Contains(x.id)) + .Where(x => definitionIds.Contains(x.Id)) .ToList(); var builds = buildDefinitionRequest.LaunchBuild(definitions); diff --git a/src/TfsAdvanced/Controllers/ProjectsController.cs b/src/TfsAdvanced/Controllers/ProjectsController.cs index 93e091a..01f8ec9 100644 --- a/src/TfsAdvanced/Controllers/ProjectsController.cs +++ b/src/TfsAdvanced/Controllers/ProjectsController.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using TfsAdvanced.DataStore.Repository; -using TfsAdvanced.Models.Projects; +using TFSAdvanced.Models.DTO; namespace TfsAdvanced.Web.Controllers { diff --git a/src/TfsAdvanced/Controllers/PullRequestsController.cs b/src/TfsAdvanced/Controllers/PullRequestsController.cs index 0c53591..ef7e763 100644 --- a/src/TfsAdvanced/Controllers/PullRequestsController.cs +++ b/src/TfsAdvanced/Controllers/PullRequestsController.cs @@ -2,7 +2,7 @@ using System.Linq; using Microsoft.AspNetCore.Mvc; using TfsAdvanced.DataStore.Repository; -using TfsAdvanced.Models.PullRequests; +using TFSAdvanced.Models.DTO; namespace TfsAdvanced.Web.Controllers { @@ -28,11 +28,11 @@ public IList> NewPullRequestSince([FromRoute] int sin var pullRequests = pullRequestRepository.GetPullRequestsAfter(sinceId); return pullRequests.Select(pullRequest => new Dictionary { - {"author", pullRequest.createdBy.displayName }, - {"id", pullRequest.pullRequestId.ToString()}, - {"repository", pullRequest.repository.name}, - {"title", pullRequest.title}, - {"url", pullRequest.remoteUrl} + {"author", pullRequest.Creator.Name }, + {"id", pullRequest.Id.ToString()}, + {"repository", pullRequest.Repository.Name}, + {"title", pullRequest.Title}, + {"url", pullRequest.BuildUrl} }).ToList(); } } diff --git a/src/TfsAdvanced/ServiceRequests/BuildDefinitionRequest.cs b/src/TfsAdvanced/ServiceRequests/BuildDefinitionRequest.cs index 3788a26..a4d25a6 100644 --- a/src/TfsAdvanced/ServiceRequests/BuildDefinitionRequest.cs +++ b/src/TfsAdvanced/ServiceRequests/BuildDefinitionRequest.cs @@ -6,8 +6,10 @@ using System.Text; using System.Threading.Tasks; using TfsAdvanced.Models; -using TfsAdvanced.Models.Builds; -using TfsAdvanced.Models.Projects; +using TFSAdvanced.Updater.Models.Builds; +using TFSAdvanced.Updater.Models.Projects; +using Build = TFSAdvanced.Models.DTO.Build; +using BuildDefinition = TFSAdvanced.Models.DTO.BuildDefinition; namespace TfsAdvanced.ServiceRequests { @@ -33,27 +35,22 @@ public IList LaunchBuild(IList definitions) public Build LaunchBuild(BuildDefinition definition) { var request = new HttpRequestMessage(HttpMethod.Post, - $"{requestData.BaseAddress}/{definition.project.name}/_apis/build/builds?api-version=2.2"); + $"{requestData.BaseAddress}/{definition.Repository.Project.Name}/_apis/build/builds?api-version=2.2"); request.Content = new StringContent( JsonConvert.SerializeObject(new BuildQueueRequest { - queue = new Id {id = definition.queue.id }, - definition = new Id { id = definition.id }, - project = new ProjectGuid { id = definition.project.id }, - sourceBranch = definition.repository.defaultBranch + queue = new Id {id = definition.QueueId}, + definition = new Id { id = definition.Id }, + project = new ProjectGuid { id = definition.Repository.Project.Id }, + sourceBranch = definition.DefaultBranch }), Encoding.UTF8, "application/json"); var buildResponse = requestData.HttpClient.SendAsync(request).Result; var responseString = buildResponse.Content.ReadAsStringAsync().Result; if(buildResponse.IsSuccessStatusCode) return JsonConvert.DeserializeObject(responseString); - return new Build - { - definition = definition, - project = definition.project, - buildNumber = "Failed To Start Build" - }; + return null; } } } \ No newline at end of file diff --git a/src/TfsAdvanced/wwwroot/views/jobRequests.html b/src/TfsAdvanced/wwwroot/views/jobRequests.html index ace08d3..e0abc5e 100644 --- a/src/TfsAdvanced/wwwroot/views/jobRequests.html +++ b/src/TfsAdvanced/wwwroot/views/jobRequests.html @@ -2,10 +2,11 @@
- - - - + + + + + @@ -29,79 +30,82 @@ "url": "/data/JobRequests", "dataSrc": function(json) { for (var i = 0, ien = json.length; i < ien; i++) { + var column = 0; var jobRequest = json[i]; - json[i][0] = "" + jobRequest.requestId + ""; + json[i][column++] = "" + jobRequest.requestId + ""; if (jobRequest.planType === 'release') - json[i][1] = '' + + json[i][column++] = '' + jobRequest.planType; else if (jobRequest.planType === 'build') - json[i][1] = '' + + json[i][column++] = '' + jobRequest.planType; + json[i][column++] = "" + jobRequest.project.name + ""; + if (jobRequest.planType === 'build') { // The path will always at least be "\" so the length needs to be more than one if (jobRequest.definition.path && jobRequest.definition.path.length > 1) - json[i][2] = "[" + jobRequest.definition.path.substring(1) + "] " + jobRequest.definition.name; + json[i][column++] = "[" + jobRequest.definition.path.substring(1) + "] " + jobRequest.definition.name; else - json[i][2] = jobRequest.definition.name; + json[i][column++] = jobRequest.definition.name; } else - json[i][2] = jobRequest.definition.name; + json[i][column++] = jobRequest.definition.name; if (jobRequest.planType === 'build' && jobRequest.owner.requestedFor) - json[i][3] = jobRequest.owner.requestedFor.displayName; + json[i][column++] = jobRequest.owner.requestedFor.displayName; else - json[i][3] = "---"; + json[i][column++] = "---"; if (jobRequest.status === 'succeeded') - json[i][4] = 'Succeeded'; + json[i][column++] = 'Succeeded'; else if (jobRequest.status === 'failed') - json[i][4] = 'Failed'; + json[i][column++] = 'Failed'; else if (jobRequest.status === 'queued') { if(jobRequest.planType === 'release') - json[i][4] = 'Releasing'; + json[i][column++] = 'Releasing'; else - json[i][4] = 'Queued'; + json[i][column++] = 'Queued'; } else if (jobRequest.status === 'assigned') - json[i][4] = 'Assigned'; + json[i][column++] = 'Assigned'; else if (jobRequest.status === 'started') { if(jobRequest.planType === 'release') - json[i][4] = 'Releasing'; + json[i][column++] = 'Releasing'; else - json[i][4] = 'Building'; + json[i][column++] = 'Building'; } else if (jobRequest.status === 'failed') - json[i][4] = 'Failed'; + json[i][column++] = 'Failed'; else if (jobRequest.status === 'abandoned') - json[i][4] = 'Abandoned'; + json[i][column++] = 'Abandoned'; else if (jobRequest.status === 'canceled') - json[i][4] = 'Cancelled'; + json[i][column++] = 'Cancelled'; else - json[i][4] = ' ${status} '; + json[i][column++] = ' ${status} '; if (jobRequest.queueTime) - json[i][5] = $.format.date(jobRequest.queueTime, longDateFormat); + json[i][column++] = $.format.date(jobRequest.queueTime, longDateFormat); else - json[i][5] = "---"; + json[i][column++] = "---"; if (jobRequest.assignTime) - json[i][6] = $.format.date(jobRequest.assignTime, longDateFormat); + json[i][column++] = $.format.date(jobRequest.assignTime, longDateFormat); else - json[i][6] = "---"; + json[i][column++] = "---"; if (jobRequest.planType === 'release') - json[i][7] = "---"; + json[i][column++] = "---"; else if (jobRequest.startedTime) - json[i][7] = $.format.date(jobRequest.startedTime, longDateFormat); + json[i][column++] = $.format.date(jobRequest.startedTime, longDateFormat); else - json[i][7] = "---"; + json[i][column++] = "---"; if (jobRequest.finishTime) - json[i][8] = $.format.date(jobRequest.finishTime, longDateFormat); + json[i][column++] = $.format.date(jobRequest.finishTime, longDateFormat); else - json[i][8] = "---"; + json[i][column++] = "---"; } return json; diff --git a/src/TfsAdvanced/wwwroot/views/pullRequests.html b/src/TfsAdvanced/wwwroot/views/pullRequests.html index deaa905..a6ed3d3 100644 --- a/src/TfsAdvanced/wwwroot/views/pullRequests.html +++ b/src/TfsAdvanced/wwwroot/views/pullRequests.html @@ -43,7 +43,8 @@

No Pull Requests

function fetchData() { $.get("data/PullRequests", - function (data) { + function (data) { + console.log(data); if (data.length === 0) { $("#pullRequestHeader").hide(); $("#pullRequests").hide(); @@ -76,12 +77,12 @@

No Pull Requests

- ${title} + ${title}

@@ -93,60 +94,52 @@
- {{if build == null}} - {{if mergeStatus == 'conflicts'}} - - {{else}} + + {{if buildStatus == 'NoBuild'}} - {{/if}} - {{/if}} - {{if build != null}} - - {{if build.status == 'notStarted'}} + {{else}} + + {{if buildStatus == 'notStarted'}} - {{else build.status == 'inProgress'}} + {{else buildStatus == 'building'}} - {{else build.result == 'expired'}} + {{else buildStatus == 'expired'}} - {{else build.result == 'succeeded'}} + {{else buildStatus == 'succeeded'}} - {{else build.result == 'failed'}} + {{else buildStatus == 'failed'}} - {{else mergeStatus == 'conflicts'}} - {{else}} - ${build.status}|${build.result} + ${buildStatus} {{/if}} {{/if}} - {{if requiredReviewers > 0}} | - {{if hasEnoughReviewers}} + {{if HasEnoughReviewers}} {{else}} {{/if}} - {{/if}}
Created By:
- User Photo + User Photo
- ${createdBy.displayName} -
() + ${creator.name} +
()
@@ -159,29 +152,27 @@
From 7dbe0f955780048ae31a60752443f3d429375373 Mon Sep 17 00:00:00 2001 From: Bert Cotton Date: Fri, 4 Aug 2017 11:47:40 -0600 Subject: [PATCH 2/4] Adding release management api --- .../Repository/ReleaseDefinitionRepository.cs | 20 ++++ src/TfsAdvanced.Models/DTO/Build.cs | 4 + src/TfsAdvanced.Models/DTO/QueueJob.cs | 4 + .../Infrastructure/AppSettings.cs | 4 +- src/TfsAdvanced.Models/RequestData.cs | 9 ++ src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs | 2 + .../Tasks/JobRequestUpdater.cs | 63 ++++++++++- .../Tasks/ReleaseDefinitionUpdater.cs | 93 ++++++++++++++++ .../Tasks/RepositoryUpdater.cs | 3 +- src/TfsAdvanced.Updater/Tasks/Updater.cs | 6 +- src/TfsAdvanced/wwwroot/css/site.css | 4 + .../wwwroot/views/jobRequests.html | 101 ++++++++++-------- 12 files changed, 263 insertions(+), 50 deletions(-) create mode 100644 src/TfsAdvanced.DataStore/Repository/ReleaseDefinitionRepository.cs create mode 100644 src/TfsAdvanced.Updater/Tasks/ReleaseDefinitionUpdater.cs diff --git a/src/TfsAdvanced.DataStore/Repository/ReleaseDefinitionRepository.cs b/src/TfsAdvanced.DataStore/Repository/ReleaseDefinitionRepository.cs new file mode 100644 index 0000000..fe37cb4 --- /dev/null +++ b/src/TfsAdvanced.DataStore/Repository/ReleaseDefinitionRepository.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; +using TFSAdvanced.Models.DTO; + +namespace TFSAdvanced.DataStore.Repository +{ + public class ReleaseDefinitionRepository : RepositoryBase + { + protected override int GetId(ReleaseDefinition item) + { + return item.Id; + } + + public ReleaseDefinition GetReleaseDefinition(int id) + { + return Get(definition => definition.Id == id); + } + } +} diff --git a/src/TfsAdvanced.Models/DTO/Build.cs b/src/TfsAdvanced.Models/DTO/Build.cs index 1c3d5fa..97b8729 100644 --- a/src/TfsAdvanced.Models/DTO/Build.cs +++ b/src/TfsAdvanced.Models/DTO/Build.cs @@ -8,6 +8,10 @@ public class Build { public int Id { get; set; } + public string Name { get; set; } + + public string Folder { get; set; } + public string Url { get; set; } public User Creator { get; set; } diff --git a/src/TfsAdvanced.Models/DTO/QueueJob.cs b/src/TfsAdvanced.Models/DTO/QueueJob.cs index c7e9685..387666b 100644 --- a/src/TfsAdvanced.Models/DTO/QueueJob.cs +++ b/src/TfsAdvanced.Models/DTO/QueueJob.cs @@ -25,5 +25,9 @@ public class QueueJob public DateTime? StartedTime { get; set; } public DateTime? FinishedTime { get; set; } + + public string Name { get; set; } + + public string BuildFolder { get; set; } } } diff --git a/src/TfsAdvanced.Models/Infrastructure/AppSettings.cs b/src/TfsAdvanced.Models/Infrastructure/AppSettings.cs index d9731ee..5a2e639 100644 --- a/src/TfsAdvanced.Models/Infrastructure/AppSettings.cs +++ b/src/TfsAdvanced.Models/Infrastructure/AppSettings.cs @@ -6,12 +6,14 @@ public class AppSettings { public string BaseAddress { get; set; } + public string BaseReleaseManagerAddress { get; set; } + public List Projects { get; set; } public Security Security { get; set; } public AuthorizationSettings authorization { get; set; } - public static int MAX_DEGREE_OF_PARALLELISM = 3; + public static int MAX_DEGREE_OF_PARALLELISM = 10; } } \ No newline at end of file diff --git a/src/TfsAdvanced.Models/RequestData.cs b/src/TfsAdvanced.Models/RequestData.cs index dab55b7..ca63adb 100644 --- a/src/TfsAdvanced.Models/RequestData.cs +++ b/src/TfsAdvanced.Models/RequestData.cs @@ -13,6 +13,8 @@ public class RequestData : IDisposable private readonly AppSettings appSettings; public string BaseAddress { get; } + + public string BaseReleaseManagerAddress { get; } public HttpClient HttpClient { get; } public RequestData(IOptions settings) @@ -23,6 +25,13 @@ public RequestData(IOptions settings) AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }; BaseAddress = appSettings.BaseAddress; + + var baseAddressParts = BaseAddress.Split('.'); + if (appSettings.BaseReleaseManagerAddress == null) + BaseReleaseManagerAddress = $"{baseAddressParts[0]}.vsrm.{baseAddressParts[1]}.{baseAddressParts[2]}"; + else + BaseReleaseManagerAddress = appSettings.BaseReleaseManagerAddress; + HttpClient = new HttpClient(handler); HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authenticationToken.base64_token); diff --git a/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs b/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs index 116f40f..d4f2e9e 100644 --- a/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs @@ -92,6 +92,8 @@ private TFSAdvanced.Models.DTO.Build CreateBuild(Build build) TFSAdvanced.Models.DTO.Build buildDto = new TFSAdvanced.Models.DTO.Build { Id = build.id, + Name = build.definition.name, + Folder = build.definition.path, Url = build._links.web.href, SourceCommit = build.sourceVersion, QueuedDate = build.queueTime, diff --git a/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs b/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs index 041f949..7c9af0d 100644 --- a/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs @@ -4,9 +4,11 @@ using System.Linq; using System.Threading.Tasks; using Hangfire; +using Microsoft.EntityFrameworkCore.Metadata.Internal; using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models; using TfsAdvanced.Models.Infrastructure; +using TFSAdvanced.DataStore.Repository; using TFSAdvanced.Models.DTO; using TFSAdvanced.Updater.Models.Builds; using TFSAdvanced.Updater.Models.JobRequests; @@ -20,17 +22,23 @@ public class JobRequestUpdater private readonly UpdateStatusRepository updateStatusRepository; private readonly PoolRepository poolRepository; private readonly BuildRepository buildRepository; + private readonly BuildDefinitionRepository buildDefinitionRepository; + private readonly ProjectRepository projectRepository; + private readonly ReleaseDefinitionRepository releaseDefinitionRepository; private readonly RequestData requestData; private bool IsRunning; - public JobRequestUpdater(JobRequestRepository jobRequestRepository, RequestData requestData, PoolRepository poolRepository, BuildRepository buildRepository, UpdateStatusRepository updateStatusRepository) + public JobRequestUpdater(JobRequestRepository jobRequestRepository, RequestData requestData, PoolRepository poolRepository, BuildRepository buildRepository, UpdateStatusRepository updateStatusRepository, BuildDefinitionRepository buildDefinitionRepository, ProjectRepository projectRepository, ReleaseDefinitionRepository releaseDefinitionRepository) { this.jobRequestRepository = jobRequestRepository; this.requestData = requestData; this.poolRepository = poolRepository; this.buildRepository = buildRepository; this.updateStatusRepository = updateStatusRepository; + this.buildDefinitionRepository = buildDefinitionRepository; + this.projectRepository = projectRepository; + this.releaseDefinitionRepository = releaseDefinitionRepository; } [AutomaticRetry(Attempts = 0)] @@ -52,13 +60,18 @@ public void Update() { foreach (var poolJobRequest in poolJobRequests) { + QueueJob queueJob = new QueueJob { + RequestId = poolJobRequest.requestId, QueuedTime = poolJobRequest.queueTime, AssignedTime = poolJobRequest.assignTime, - FinishedTime = poolJobRequest.finishTime + FinishedTime = poolJobRequest.finishTime, + Name = poolJobRequest.definition.name, + Url = poolJobRequest.definition._links.self.href }; + if (poolJobRequest.planType == PlanTypes.Build) { var build = buildRepository.GetBuild(poolJobRequest.owner.id); @@ -67,6 +80,8 @@ public void Update() queueJob.LaunchedBy = build.Creator; queueJob.StartedTime = build.StartedDate; queueJob.FinishedTime = build.FinishedDate; + queueJob.BuildFolder = build.Folder; + switch (build.BuildStatus) { case TFSAdvanced.Models.DTO.BuildStatus.NotStarted: @@ -91,6 +106,35 @@ public void Update() } } + var buildDefinition = buildDefinitionRepository.GetBuildDefinition(poolJobRequest.definition.id); + if (buildDefinition != null) + { + var project = projectRepository.GetProject(buildDefinition.Repository.Project.Id); + if (project != null) + { + queueJob.Project = new Project + { + Id = project.Id, + Name = project.Name, + Url = project.Url + }; + } + else + { + queueJob.Project = new Project + { + Name = "Unknown Project" + }; + } + } + else + { + queueJob.Project = new Project + { + Name = "Unknown Build Definition" + }; + } + } else if (poolJobRequest.planType == PlanTypes.Release) { @@ -113,6 +157,21 @@ public void Update() break; } } + + var releaseDefinition = releaseDefinitionRepository.GetReleaseDefinition(poolJobRequest.definition.id); + if (releaseDefinition != null) + { + queueJob.Project = releaseDefinition.Project; + } + else + { + queueJob.Project = new Project + { + Name = "Unknown Release Definition" + }; + } + + } diff --git a/src/TfsAdvanced.Updater/Tasks/ReleaseDefinitionUpdater.cs b/src/TfsAdvanced.Updater/Tasks/ReleaseDefinitionUpdater.cs new file mode 100644 index 0000000..674b7ee --- /dev/null +++ b/src/TfsAdvanced.Updater/Tasks/ReleaseDefinitionUpdater.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Hangfire; +using TfsAdvanced.DataStore.Repository; +using TfsAdvanced.Models; +using TfsAdvanced.Models.Infrastructure; +using TfsAdvanced.Updater; +using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.Updater.Models.JobRequests; +using TFSAdvanced.Updater.Models.Releases; + +namespace TFSAdvanced.Updater.Tasks +{ + public class ReleaseDefinitionUpdater + { + private readonly ReleaseDefinitionRepository releaseDefinitionRepository; + private readonly ProjectRepository projectRepository; + private readonly RequestData requestData; + private bool IsRunning; + + public ReleaseDefinitionUpdater(ReleaseDefinitionRepository releaseDefinitionRepository, ProjectRepository projectRepository, RequestData requestData) + { + this.releaseDefinitionRepository = releaseDefinitionRepository; + this.projectRepository = projectRepository; + this.requestData = requestData; + } + + [AutomaticRetry(Attempts = 0)] + public void Update() + { + if (IsRunning) + return; + IsRunning = true; + try + { + var releases = new ConcurrentStack(); + Parallel.ForEach(projectRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, project => + { + + var releaseDefinitions = GetAsync.FetchResponseList(requestData, $"{requestData.BaseReleaseManagerAddress}/{project.Id}/_apis/Release/definitions?api-version=3.0-preview.1").Result; + if (releaseDefinitions != null) + { + Parallel.ForEach(releaseDefinitions, new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, releaseDefinition => + { + var populatedReleaseDefinition = GetAsync.Fetch(requestData, releaseDefinition.url).Result; + releases.Push(CreateReleaseDefinition(populatedReleaseDefinition)); + }); + } + }); + + releaseDefinitionRepository.Update(releases); + + } + catch (Exception ex) + { + throw new InvalidOperationException("Error processing the release definition updater.", ex); + } + finally + + { + IsRunning = false; + } + + + } + + private TFSAdvanced.Models.DTO.ReleaseDefinition CreateReleaseDefinition(ReleaseDefinition releaseDefinition) + { + var dto = new TFSAdvanced.Models.DTO.ReleaseDefinition + { + Name = releaseDefinition.name, + Id = releaseDefinition.id + }; + + if (releaseDefinition.artifacts != null) + { + var artifact = releaseDefinition.artifacts.FirstOrDefault(x => x.isPrimary); + if (artifact != null && artifact.definitionReference != null && artifact.definitionReference.project != null) + { + var projectId = artifact.definitionReference.project; + dto.Project = projectRepository.GetProject(projectId.id); + } + } + + return dto; + + } + } +} diff --git a/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs b/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs index ab60305..673e498 100644 --- a/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs @@ -58,8 +58,9 @@ public void Update() Url = populatedRepository.remoteUrl, Project = new Project { + Id = populatedRepository.project.id, Name = populatedRepository.project.name, - Url = populatedRepository.project.remoteUrl + Url = populatedRepository.project.url } }; var policyConfigurations = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/defaultcollection/{project.Id}/_apis/policy/configurations?api-version=2.0-preview.1").Result; diff --git a/src/TfsAdvanced.Updater/Tasks/Updater.cs b/src/TfsAdvanced.Updater/Tasks/Updater.cs index 6a8ab16..1e13306 100644 --- a/src/TfsAdvanced.Updater/Tasks/Updater.cs +++ b/src/TfsAdvanced.Updater/Tasks/Updater.cs @@ -3,6 +3,7 @@ using Hangfire; using Microsoft.Extensions.DependencyInjection; using TfsAdvanced.DataStore.Repository; +using TFSAdvanced.Updater.Tasks; namespace TfsAdvanced.Updater.Tasks { @@ -41,6 +42,9 @@ public void Start() serviceProvider.GetService().Update(); percentLoaded += stepSize; hangFireStatusRepository.SetPercentLoaded(percentLoaded); + serviceProvider.GetService().Update(); + percentLoaded += stepSize; + hangFireStatusRepository.SetPercentLoaded(percentLoaded); serviceProvider.GetService().Update(); percentLoaded += stepSize; hangFireStatusRepository.SetPercentLoaded(1); @@ -56,12 +60,12 @@ public void Start() { BackgroundJob.Enqueue(updater => updater.Update()); BackgroundJob.Enqueue(updater => updater.Update()); + BackgroundJob.Enqueue(updater => updater.Update()); }, null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); fiveSecondTimer = new Timer(state => { BackgroundJob.Enqueue(updater => updater.Update()); BackgroundJob.Enqueue(updater => updater.Update()); - }, null, TimeSpan.Zero, TimeSpan.FromSeconds(5)); } diff --git a/src/TfsAdvanced/wwwroot/css/site.css b/src/TfsAdvanced/wwwroot/css/site.css index 14cf1a8..c5f38c5 100644 --- a/src/TfsAdvanced/wwwroot/css/site.css +++ b/src/TfsAdvanced/wwwroot/css/site.css @@ -166,4 +166,8 @@ div[ng-view] { .launching { background-color: lightblue; +} + +.datetime { + font-size: 75%; } \ No newline at end of file diff --git a/src/TfsAdvanced/wwwroot/views/jobRequests.html b/src/TfsAdvanced/wwwroot/views/jobRequests.html index e0abc5e..e9d2ab0 100644 --- a/src/TfsAdvanced/wwwroot/views/jobRequests.html +++ b/src/TfsAdvanced/wwwroot/views/jobRequests.html @@ -32,78 +32,89 @@ for (var i = 0, ien = json.length; i < ien; i++) { var column = 0; var jobRequest = json[i]; - json[i][column++] = "" + jobRequest.requestId + ""; - if (jobRequest.planType === 'release') + console.log(jobRequest); + json[i][column++] = "" + jobRequest.requestId + ""; + + if (jobRequest.jobType === 'release') json[i][column++] = '' + - jobRequest.planType; - else if (jobRequest.planType === 'build') + jobRequest.jobType; + else if (jobRequest.jobType === 'build') json[i][column++] = '' + - jobRequest.planType; + jobRequest.jobType; - json[i][column++] = "" + jobRequest.project.name + ""; + if (jobRequest.project != null) + json[i][column++] = "" + jobRequest.project.name + ""; + else + json[i][column++] = ""; - if (jobRequest.planType === 'build') { + if (jobRequest.jobType === 'build') { // The path will always at least be "\" so the length needs to be more than one - if (jobRequest.definition.path && jobRequest.definition.path.length > 1) - json[i][column++] = "[" + jobRequest.definition.path.substring(1) + "] " + jobRequest.definition.name; + if (jobRequest.buildFolder) + json[i][column++] = "[" + jobRequest.buildFolder.substring(1) + "] " + jobRequest.name; else - json[i][column++] = jobRequest.definition.name; + json[i][column++] = jobRequest.name; } else - json[i][column++] = jobRequest.definition.name; + json[i][column++] = jobRequest.name; - if (jobRequest.planType === 'build' && jobRequest.owner.requestedFor) - json[i][column++] = jobRequest.owner.requestedFor.displayName; + if (jobRequest.launchedBy) + json[i][column++] = " " + jobRequest.launchedBy.name; else json[i][column++] = "---"; - if (jobRequest.status === 'succeeded') - json[i][column++] = 'Succeeded'; - else if (jobRequest.status === 'failed') - json[i][column++] = 'Failed'; - else if (jobRequest.status === 'queued') { - if(jobRequest.planType === 'release') - json[i][column++] = 'Releasing'; - else - json[i][column++] = 'Queued'; - } - else if (jobRequest.status === 'assigned') - json[i][column++] = 'Assigned'; - else if (jobRequest.status === 'started') - { - if(jobRequest.planType === 'release') + switch (jobRequest.queueJobStatus) { + case "queued": + if (jobRequest.jobType === 'release') + json[i][column++] = 'Releasing'; + else + json[i][column++] = 'Queued'; + break; + case "assigned": + json[i][column++] = 'Assigned'; + break; + case "building": + json[i][column++] = 'Building'; + break; + case "deploying": json[i][column++] = 'Releasing'; - else - json[i][column++] = 'Building'; + break; + case "succeeded": + json[i][column++] = 'Succeeded'; + break; + case "failed": + json[i][column++] = 'Failed'; + break; + case "abandonded": + json[i][column++] = 'Abandoned'; + break; + case "cancelled": + json[i][column++] = 'Cancelled'; + break; + default: + json[i][column++] = '' + jobRequest.queueJobStatus + ''; + break; } - else if (jobRequest.status === 'failed') - json[i][column++] = 'Failed'; - else if (jobRequest.status === 'abandoned') - json[i][column++] = 'Abandoned'; - else if (jobRequest.status === 'canceled') - json[i][column++] = 'Cancelled'; - else - json[i][column++] = ' ${status} '; + - if (jobRequest.queueTime) - json[i][column++] = $.format.date(jobRequest.queueTime, longDateFormat); + if (jobRequest.queuedTime) + json[i][column++] = "" + $.format.date(jobRequest.queuedTime, longDateFormat) + ""; else json[i][column++] = "---"; - if (jobRequest.assignTime) - json[i][column++] = $.format.date(jobRequest.assignTime, longDateFormat); + if (jobRequest.assignedTime) + json[i][column++] = "" + $.format.date(jobRequest.assignedTime, longDateFormat) + ""; else json[i][column++] = "---"; - if (jobRequest.planType === 'release') + if (jobRequest.jobType === 'release') json[i][column++] = "---"; else if (jobRequest.startedTime) - json[i][column++] = $.format.date(jobRequest.startedTime, longDateFormat); + json[i][column++] = "" + $.format.date(jobRequest.startedTime, longDateFormat) + ""; else json[i][column++] = "---"; if (jobRequest.finishTime) - json[i][column++] = $.format.date(jobRequest.finishTime, longDateFormat); + json[i][column++] = "" + $.format.date(jobRequest.finishedTime, longDateFormat) + ""; else json[i][column++] = "---"; From 4c8e6741f486f0154163bf6170013ecfc7c6e7b8 Mon Sep 17 00:00:00 2001 From: Bert Cotton Date: Fri, 4 Aug 2017 12:14:02 -0600 Subject: [PATCH 3/4] Cleanup --- TfsAdvanced.sln | 10 +++-- .../Repository/BuildDefinitionRepository.cs | 10 +---- .../Repository/JobRequestRepository.cs | 2 - .../Repository/ProjectRepository.cs | 3 +- .../Repository/PullRequestRepository.cs | 2 +- .../Repository/ReleaseDefinitionRepository.cs | 5 +-- .../Repository/RepositoryBase.cs | 2 - .../Repository/RepositoryRepository.cs | 5 +-- .../TfsAdvancedDataContext.cs | 8 +--- src/TfsAdvanced.Models/DTO/Build.cs | 2 - src/TfsAdvanced.Models/DTO/BuildDefinition.cs | 6 +-- .../DTO/BuildDefinitionPolicy.cs | 6 +-- src/TfsAdvanced.Models/DTO/BuildStatus.cs | 6 +-- src/TfsAdvanced.Models/DTO/JobType.cs | 6 +-- src/TfsAdvanced.Models/DTO/MergeStatus.cs | 6 +-- src/TfsAdvanced.Models/DTO/Project.cs | 6 +-- src/TfsAdvanced.Models/DTO/PullRequest.cs | 1 - src/TfsAdvanced.Models/DTO/QueueJob.cs | 2 - src/TfsAdvanced.Models/DTO/QueueJobStatus.cs | 6 +-- .../DTO/ReleaseDefinition.cs | 6 +-- src/TfsAdvanced.Models/DTO/Repository.cs | 6 +-- src/TfsAdvanced.Models/DTO/ReviewStatus.cs | 6 +-- src/TfsAdvanced.Models/DTO/Reviewer.cs | 6 +-- src/TfsAdvanced.Models/DTO/User.cs | 6 +-- src/TfsAdvanced.Updater/JsonDeserializer.cs | 2 - .../Models/Policy/PolicyConfiguration.cs | 4 +- .../Tasks/BuildDefinitionUpdater.cs | 11 ++---- src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs | 37 +++++++++---------- .../Tasks/JobRequestUpdater.cs | 18 ++++----- .../Tasks/PullRequestUpdater.cs | 16 ++++---- .../Tasks/ReleaseDefinitionUpdater.cs | 15 +++----- .../Tasks/RepositoryUpdater.cs | 9 ++--- .../Controllers/BuildDefinitionsController.cs | 2 +- src/TfsAdvanced/HangfireJobFilter.cs | 3 -- .../AuthenticationMiddleware.cs | 3 +- .../AuthenticationMiddlewareExtension.cs | 6 +-- .../AuthenticationTokenProvider.cs | 4 -- .../Infrastructure/AuthorizationSettings.cs | 7 +--- .../HangfireAuthorizationFilter.cs | 7 +--- src/TfsAdvanced/Program.cs | 4 +- .../ServiceRequests/AuthorizationRequest.cs | 6 --- .../ServiceRequests/BuildDefinitionRequest.cs | 4 +- src/TfsAdvanced/Startup.cs | 28 +++++++------- src/TfsAdvanced/Utilities/GetAsync.cs | 3 +- src/TfsAdvanced/Utilities/JsonDeserializer.cs | 2 - 45 files changed, 97 insertions(+), 218 deletions(-) diff --git a/TfsAdvanced.sln b/TfsAdvanced.sln index 15f31d1..570fa67 100644 --- a/TfsAdvanced.sln +++ b/TfsAdvanced.sln @@ -1,23 +1,25 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26403.0 +VisualStudioVersion = 15.0.26430.15 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{28430696-29B7-46F4-9140-2EF000FB2D29}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BB3621F3-9DFF-49AD-9482-D325EC7DD410}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore + .travis.yml = .travis.yml + build.sh = build.sh nuget.config = nuget.config EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web", "src\TfsAdvanced\Web.csproj", "{5FFBC1A5-B8CE-44D5-99E7-64B9903E0BAD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataStore", "src\TfsAdvanced.DataStore\DataStore.csproj", "{B91AC19E-9D65-416C-8B4D-47C7D7F41C63}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataStore", "src\TfsAdvanced.DataStore\DataStore.csproj", "{B91AC19E-9D65-416C-8B4D-47C7D7F41C63}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "src\TfsAdvanced.Models\Models.csproj", "{23D45B3D-C188-48F3-9078-35B61B1F293D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Models", "src\TfsAdvanced.Models\Models.csproj", "{23D45B3D-C188-48F3-9078-35B61B1F293D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "src\TfsAdvanced.Updater\Updater.csproj", "{F88AE0D1-17B4-427E-8023-42A183EB05D3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Updater", "src\TfsAdvanced.Updater\Updater.csproj", "{F88AE0D1-17B4-427E-8023-42A183EB05D3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/TfsAdvanced.DataStore/Repository/BuildDefinitionRepository.cs b/src/TfsAdvanced.DataStore/Repository/BuildDefinitionRepository.cs index 8f7c90a..f1b01cd 100644 --- a/src/TfsAdvanced.DataStore/Repository/BuildDefinitionRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/BuildDefinitionRepository.cs @@ -1,12 +1,4 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using System.Reflection; -using System.Threading; -using Microsoft.EntityFrameworkCore; -using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.DataStore.Repository; using TFSAdvanced.Models.DTO; namespace TfsAdvanced.DataStore.Repository diff --git a/src/TfsAdvanced.DataStore/Repository/JobRequestRepository.cs b/src/TfsAdvanced.DataStore/Repository/JobRequestRepository.cs index a85f576..83bd718 100644 --- a/src/TfsAdvanced.DataStore/Repository/JobRequestRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/JobRequestRepository.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; -using System.Linq; using TFSAdvanced.DataStore.Repository; using TFSAdvanced.Models.DTO; diff --git a/src/TfsAdvanced.DataStore/Repository/ProjectRepository.cs b/src/TfsAdvanced.DataStore/Repository/ProjectRepository.cs index a91617b..daea40e 100644 --- a/src/TfsAdvanced.DataStore/Repository/ProjectRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/ProjectRepository.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.DataStore.Repository; using TFSAdvanced.Models.DTO; namespace TfsAdvanced.DataStore.Repository diff --git a/src/TfsAdvanced.DataStore/Repository/PullRequestRepository.cs b/src/TfsAdvanced.DataStore/Repository/PullRequestRepository.cs index ce92e4a..8117b44 100644 --- a/src/TfsAdvanced.DataStore/Repository/PullRequestRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/PullRequestRepository.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -using TFSAdvanced.Models.DTO; using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.Models.DTO; namespace TfsAdvanced.DataStore.Repository { diff --git a/src/TfsAdvanced.DataStore/Repository/ReleaseDefinitionRepository.cs b/src/TfsAdvanced.DataStore/Repository/ReleaseDefinitionRepository.cs index fe37cb4..f4ecb3b 100644 --- a/src/TfsAdvanced.DataStore/Repository/ReleaseDefinitionRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/ReleaseDefinitionRepository.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using TFSAdvanced.Models.DTO; +using TFSAdvanced.Models.DTO; namespace TFSAdvanced.DataStore.Repository { diff --git a/src/TfsAdvanced.DataStore/Repository/RepositoryBase.cs b/src/TfsAdvanced.DataStore/Repository/RepositoryBase.cs index c5a69ab..e6496b6 100644 --- a/src/TfsAdvanced.DataStore/Repository/RepositoryBase.cs +++ b/src/TfsAdvanced.DataStore/Repository/RepositoryBase.cs @@ -2,9 +2,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; -using System.Text; using System.Threading; -using Microsoft.EntityFrameworkCore; namespace TFSAdvanced.DataStore.Repository { diff --git a/src/TfsAdvanced.DataStore/Repository/RepositoryRepository.cs b/src/TfsAdvanced.DataStore/Repository/RepositoryRepository.cs index 5f3e006..8e74d60 100644 --- a/src/TfsAdvanced.DataStore/Repository/RepositoryRepository.cs +++ b/src/TfsAdvanced.DataStore/Repository/RepositoryRepository.cs @@ -1,7 +1,4 @@ -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Collections.Immutable; -using TFSAdvanced.DataStore.Repository; +using TFSAdvanced.DataStore.Repository; namespace TfsAdvanced.DataStore.Repository { diff --git a/src/TfsAdvanced.DataStore/TfsAdvancedDataContext.cs b/src/TfsAdvanced.DataStore/TfsAdvancedDataContext.cs index 2b0e5a3..e9f843a 100644 --- a/src/TfsAdvanced.DataStore/TfsAdvancedDataContext.cs +++ b/src/TfsAdvanced.DataStore/TfsAdvancedDataContext.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using TfsAdvanced.Data; -using Microsoft.EntityFrameworkCore.Storage.Internal; +using Microsoft.EntityFrameworkCore; using TfsAdvanced.Models.Infrastructure; namespace TfsAdvanced.Data diff --git a/src/TfsAdvanced.Models/DTO/Build.cs b/src/TfsAdvanced.Models/DTO/Build.cs index 97b8729..80e2da4 100644 --- a/src/TfsAdvanced.Models/DTO/Build.cs +++ b/src/TfsAdvanced.Models/DTO/Build.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace TFSAdvanced.Models.DTO { diff --git a/src/TfsAdvanced.Models/DTO/BuildDefinition.cs b/src/TfsAdvanced.Models/DTO/BuildDefinition.cs index 18f5d9c..3ab2164 100644 --- a/src/TfsAdvanced.Models/DTO/BuildDefinition.cs +++ b/src/TfsAdvanced.Models/DTO/BuildDefinition.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public class BuildDefinition { diff --git a/src/TfsAdvanced.Models/DTO/BuildDefinitionPolicy.cs b/src/TfsAdvanced.Models/DTO/BuildDefinitionPolicy.cs index 066b493..027523d 100644 --- a/src/TfsAdvanced.Models/DTO/BuildDefinitionPolicy.cs +++ b/src/TfsAdvanced.Models/DTO/BuildDefinitionPolicy.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public class BuildDefinitionPolicy { diff --git a/src/TfsAdvanced.Models/DTO/BuildStatus.cs b/src/TfsAdvanced.Models/DTO/BuildStatus.cs index 9fb7bcc..dae96b2 100644 --- a/src/TfsAdvanced.Models/DTO/BuildStatus.cs +++ b/src/TfsAdvanced.Models/DTO/BuildStatus.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public enum BuildStatus { diff --git a/src/TfsAdvanced.Models/DTO/JobType.cs b/src/TfsAdvanced.Models/DTO/JobType.cs index 3444c5b..3536b0f 100644 --- a/src/TfsAdvanced.Models/DTO/JobType.cs +++ b/src/TfsAdvanced.Models/DTO/JobType.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public enum JobType { diff --git a/src/TfsAdvanced.Models/DTO/MergeStatus.cs b/src/TfsAdvanced.Models/DTO/MergeStatus.cs index 5736c11..ff25381 100644 --- a/src/TfsAdvanced.Models/DTO/MergeStatus.cs +++ b/src/TfsAdvanced.Models/DTO/MergeStatus.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public enum MergeStatus { diff --git a/src/TfsAdvanced.Models/DTO/Project.cs b/src/TfsAdvanced.Models/DTO/Project.cs index 158fbf4..203b881 100644 --- a/src/TfsAdvanced.Models/DTO/Project.cs +++ b/src/TfsAdvanced.Models/DTO/Project.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public class Project { diff --git a/src/TfsAdvanced.Models/DTO/PullRequest.cs b/src/TfsAdvanced.Models/DTO/PullRequest.cs index 5336c2a..0d42fee 100644 --- a/src/TfsAdvanced.Models/DTO/PullRequest.cs +++ b/src/TfsAdvanced.Models/DTO/PullRequest.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; namespace TFSAdvanced.Models.DTO { diff --git a/src/TfsAdvanced.Models/DTO/QueueJob.cs b/src/TfsAdvanced.Models/DTO/QueueJob.cs index 387666b..6be1f84 100644 --- a/src/TfsAdvanced.Models/DTO/QueueJob.cs +++ b/src/TfsAdvanced.Models/DTO/QueueJob.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace TFSAdvanced.Models.DTO { diff --git a/src/TfsAdvanced.Models/DTO/QueueJobStatus.cs b/src/TfsAdvanced.Models/DTO/QueueJobStatus.cs index 7eb52e8..f1edfb9 100644 --- a/src/TfsAdvanced.Models/DTO/QueueJobStatus.cs +++ b/src/TfsAdvanced.Models/DTO/QueueJobStatus.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public enum QueueJobStatus { diff --git a/src/TfsAdvanced.Models/DTO/ReleaseDefinition.cs b/src/TfsAdvanced.Models/DTO/ReleaseDefinition.cs index 324d900..93a5f45 100644 --- a/src/TfsAdvanced.Models/DTO/ReleaseDefinition.cs +++ b/src/TfsAdvanced.Models/DTO/ReleaseDefinition.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public class ReleaseDefinition { diff --git a/src/TfsAdvanced.Models/DTO/Repository.cs b/src/TfsAdvanced.Models/DTO/Repository.cs index 7f17442..44fb853 100644 --- a/src/TfsAdvanced.Models/DTO/Repository.cs +++ b/src/TfsAdvanced.Models/DTO/Repository.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public class Repository { diff --git a/src/TfsAdvanced.Models/DTO/ReviewStatus.cs b/src/TfsAdvanced.Models/DTO/ReviewStatus.cs index da1184e..07535c9 100644 --- a/src/TfsAdvanced.Models/DTO/ReviewStatus.cs +++ b/src/TfsAdvanced.Models/DTO/ReviewStatus.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public enum ReviewStatus { diff --git a/src/TfsAdvanced.Models/DTO/Reviewer.cs b/src/TfsAdvanced.Models/DTO/Reviewer.cs index a114873..82dc839 100644 --- a/src/TfsAdvanced.Models/DTO/Reviewer.cs +++ b/src/TfsAdvanced.Models/DTO/Reviewer.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public class Reviewer : User { diff --git a/src/TfsAdvanced.Models/DTO/User.cs b/src/TfsAdvanced.Models/DTO/User.cs index 924c4b9..23bf5bc 100644 --- a/src/TfsAdvanced.Models/DTO/User.cs +++ b/src/TfsAdvanced.Models/DTO/User.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TFSAdvanced.Models.DTO +namespace TFSAdvanced.Models.DTO { public class User { diff --git a/src/TfsAdvanced.Updater/JsonDeserializer.cs b/src/TfsAdvanced.Updater/JsonDeserializer.cs index 08ed5e3..16c2adf 100644 --- a/src/TfsAdvanced.Updater/JsonDeserializer.cs +++ b/src/TfsAdvanced.Updater/JsonDeserializer.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Net.Http; using System.Threading.Tasks; using Newtonsoft.Json; diff --git a/src/TfsAdvanced.Updater/Models/Policy/PolicyConfiguration.cs b/src/TfsAdvanced.Updater/Models/Policy/PolicyConfiguration.cs index 0d276fd..93fc300 100644 --- a/src/TfsAdvanced.Updater/Models/Policy/PolicyConfiguration.cs +++ b/src/TfsAdvanced.Updater/Models/Policy/PolicyConfiguration.cs @@ -1,6 +1,4 @@ -using System; - -namespace TFSAdvanced.Updater.Models.Policy +namespace TFSAdvanced.Updater.Models.Policy { public class PolicyConfiguration { diff --git a/src/TfsAdvanced.Updater/Tasks/BuildDefinitionUpdater.cs b/src/TfsAdvanced.Updater/Tasks/BuildDefinitionUpdater.cs index 95cc632..825cdd2 100644 --- a/src/TfsAdvanced.Updater/Tasks/BuildDefinitionUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/BuildDefinitionUpdater.cs @@ -1,14 +1,11 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Hangfire; using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models; using TfsAdvanced.Models.Infrastructure; using TFSAdvanced.Models.DTO; -using BuildDefinition = TFSAdvanced.Updater.Models.Builds.BuildDefinition; namespace TfsAdvanced.Updater.Tasks { @@ -39,17 +36,17 @@ public void Update() try { - var buildDefinitions = new ConcurrentBag(); + var buildDefinitions = new ConcurrentBag(); Parallel.ForEach(projectRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, project => { - var definitions = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/definitions?api=2.2").Result; + var definitions = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/definitions?api=2.2").Result; if (definitions == null) return; Parallel.ForEach(definitions, new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, definition => { - var populatedDefinition = GetAsync.Fetch(requestData, definition.url).Result; + var populatedDefinition = GetAsync.Fetch(requestData, definition.url).Result; - buildDefinitions.Add(new TFSAdvanced.Models.DTO.BuildDefinition + buildDefinitions.Add(new BuildDefinition { DefaultBranch = populatedDefinition.repository.defaultBranch, Folder = populatedDefinition.path, diff --git a/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs b/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs index d4f2e9e..39c1ba4 100644 --- a/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/BuildUpdater.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Hangfire; @@ -9,8 +8,8 @@ using TfsAdvanced.Models.Infrastructure; using TFSAdvanced.Models.DTO; using TFSAdvanced.Updater.Models.Builds; -using Build = TFSAdvanced.Updater.Models.Builds.Build; -using BuildStatus = TFSAdvanced.Updater.Models.Builds.BuildStatus; +using Build = TFSAdvanced.Models.DTO.Build; +using BuildStatus = TFSAdvanced.Models.DTO.BuildStatus; namespace TfsAdvanced.Updater.Tasks { @@ -40,11 +39,11 @@ public void Update() { DateTime yesterday = DateTime.Now.Date.AddDays(-1); - var builds = new ConcurrentStack(); + var builds = new ConcurrentStack(); Parallel.ForEach(projectRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, project => { // Finished PR builds - var projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/builds?api-version=2.2&reasonFilter=validateShelveset&minFinishTime={yesterday:O}").Result; + var projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/builds?api-version=2.2&reasonFilter=validateShelveset&minFinishTime={yesterday:O}").Result; if (projectBuilds != null && projectBuilds.Any()) { builds.PushRange(projectBuilds.ToArray()); @@ -52,7 +51,7 @@ public void Update() // Current active builds - projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/builds?api-version=2.2&statusFilter=inProgress&inProgress=notStarted").Result; + projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/builds?api-version=2.2&statusFilter=inProgress&inProgress=notStarted").Result; if (projectBuilds != null && projectBuilds.Any()) { builds.PushRange(projectBuilds.ToArray()); @@ -62,7 +61,7 @@ public void Update() DateTime twoHoursAgo = DateTime.Now.AddHours(-2); // Because we want to capture the final state of any build that was running and just finished we are getting those too // Finished builds within the last 2 hours - projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/builds?api-version=2.2&minFinishTime={twoHoursAgo:O}").Result; + projectBuilds = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/build/builds?api-version=2.2&minFinishTime={twoHoursAgo:O}").Result; if (projectBuilds != null && projectBuilds.Any()) { builds.PushRange(projectBuilds.ToArray()); @@ -87,9 +86,9 @@ public void Update() } } - private TFSAdvanced.Models.DTO.Build CreateBuild(Build build) + private Build CreateBuild(TFSAdvanced.Updater.Models.Builds.Build build) { - TFSAdvanced.Models.DTO.Build buildDto = new TFSAdvanced.Models.DTO.Build + Build buildDto = new Build { Id = build.id, Name = build.definition.name, @@ -108,33 +107,33 @@ private TFSAdvanced.Models.DTO.Build CreateBuild(Build build) switch (build.status) { - case BuildStatus.notStarted: - buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.NotStarted; + case TFSAdvanced.Updater.Models.Builds.BuildStatus.notStarted: + buildDto.BuildStatus = BuildStatus.NotStarted; break; - case BuildStatus.inProgress: - buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Building; + case TFSAdvanced.Updater.Models.Builds.BuildStatus.inProgress: + buildDto.BuildStatus = BuildStatus.Building; break; default: switch (build.result) { case BuildResult.abandoned: - buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Abandonded; + buildDto.BuildStatus = BuildStatus.Abandonded; break; case BuildResult.canceled: - buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Cancelled; + buildDto.BuildStatus = BuildStatus.Cancelled; break; case BuildResult.expired: - buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Expired; + buildDto.BuildStatus = BuildStatus.Expired; break; case BuildResult.failed: case BuildResult.partiallySucceeded: - buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Failed; + buildDto.BuildStatus = BuildStatus.Failed; break; case BuildResult.succeeded: - buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.Succeeded; + buildDto.BuildStatus = BuildStatus.Succeeded; break; default: - buildDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.NoBuild; + buildDto.BuildStatus = BuildStatus.NoBuild; break; } break; diff --git a/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs b/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs index 7c9af0d..50656f5 100644 --- a/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/JobRequestUpdater.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Hangfire; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models; using TfsAdvanced.Models.Infrastructure; @@ -12,7 +10,7 @@ using TFSAdvanced.Models.DTO; using TFSAdvanced.Updater.Models.Builds; using TFSAdvanced.Updater.Models.JobRequests; -using BuildStatus = TFSAdvanced.Updater.Models.Builds.BuildStatus; +using BuildStatus = TFSAdvanced.Models.DTO.BuildStatus; namespace TfsAdvanced.Updater.Tasks { @@ -84,23 +82,23 @@ public void Update() switch (build.BuildStatus) { - case TFSAdvanced.Models.DTO.BuildStatus.NotStarted: + case BuildStatus.NotStarted: queueJob.QueueJobStatus = QueueJobStatus.Queued; break; - case TFSAdvanced.Models.DTO.BuildStatus.Abandonded: + case BuildStatus.Abandonded: queueJob.QueueJobStatus = QueueJobStatus.Abandonded; break; - case TFSAdvanced.Models.DTO.BuildStatus.Building: + case BuildStatus.Building: queueJob.QueueJobStatus = QueueJobStatus.Building; break; - case TFSAdvanced.Models.DTO.BuildStatus.Cancelled: + case BuildStatus.Cancelled: queueJob.QueueJobStatus = QueueJobStatus.Cancelled; break; - case TFSAdvanced.Models.DTO.BuildStatus.Expired: - case TFSAdvanced.Models.DTO.BuildStatus.Failed: + case BuildStatus.Expired: + case BuildStatus.Failed: queueJob.QueueJobStatus = QueueJobStatus.Failed; break; - case TFSAdvanced.Models.DTO.BuildStatus.Succeeded: + case BuildStatus.Succeeded: queueJob.QueueJobStatus = QueueJobStatus.Succeeded; break; } diff --git a/src/TfsAdvanced.Updater/Tasks/PullRequestUpdater.cs b/src/TfsAdvanced.Updater/Tasks/PullRequestUpdater.cs index a984aec..77df613 100644 --- a/src/TfsAdvanced.Updater/Tasks/PullRequestUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/PullRequestUpdater.cs @@ -9,10 +9,8 @@ using TfsAdvanced.Models.Infrastructure; using TFSAdvanced.Models.DTO; using TFSAdvanced.Updater.Models.PullRequests; -using BuildStatus = TFSAdvanced.Updater.Models.Builds.BuildStatus; -using PullRequest = TFSAdvanced.Updater.Models.PullRequests.PullRequest; +using PullRequest = TFSAdvanced.Models.DTO.PullRequest; using Reviewer = TFSAdvanced.Models.DTO.Reviewer; -using Repository = TFSAdvanced.Models.DTO.Repository; namespace TfsAdvanced.Updater.Tasks { @@ -44,12 +42,12 @@ public void Update() IsRunning = true; try { - ConcurrentBag allPullRequests = new ConcurrentBag(); + ConcurrentBag allPullRequests = new ConcurrentBag(); Parallel.ForEach(repositoryRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, repository => { if (string.IsNullOrEmpty(repository.PullRequestUrl)) return; - var pullRequests = GetAsync.FetchResponseList(requestData, repository.PullRequestUrl).Result; + var pullRequests = GetAsync.FetchResponseList(requestData, repository.PullRequestUrl).Result; if (pullRequests == null) return; Parallel.ForEach(pullRequests, new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, pullRequest => @@ -87,9 +85,9 @@ public void Update() } } - private TFSAdvanced.Models.DTO.PullRequest BuildPullRequest(PullRequest x, Build build) + private PullRequest BuildPullRequest(TFSAdvanced.Updater.Models.PullRequests.PullRequest x, Build build) { - TFSAdvanced.Models.DTO.PullRequest pullRequestDto = new TFSAdvanced.Models.DTO.PullRequest + PullRequest pullRequestDto = new PullRequest { Id = x.pullRequestId, Title = x.title, @@ -154,7 +152,7 @@ private TFSAdvanced.Models.DTO.PullRequest BuildPullRequest(PullRequest x, Build if (build == null) { - pullRequestDto.BuildStatus = TFSAdvanced.Models.DTO.BuildStatus.NoBuild; + pullRequestDto.BuildStatus = BuildStatus.NoBuild; } else { @@ -166,7 +164,7 @@ private TFSAdvanced.Models.DTO.PullRequest BuildPullRequest(PullRequest x, Build return pullRequestDto; } - public string BuildPullRequestUrl(PullRequest pullRequest, string baseUrl) + public string BuildPullRequestUrl(TFSAdvanced.Updater.Models.PullRequests.PullRequest pullRequest, string baseUrl) { return $"{baseUrl}/{pullRequest.repository.project.name}/_git/{pullRequest.repository.name}/pullrequest/{pullRequest.pullRequestId}?view=files"; diff --git a/src/TfsAdvanced.Updater/Tasks/ReleaseDefinitionUpdater.cs b/src/TfsAdvanced.Updater/Tasks/ReleaseDefinitionUpdater.cs index 674b7ee..8a74d4e 100644 --- a/src/TfsAdvanced.Updater/Tasks/ReleaseDefinitionUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/ReleaseDefinitionUpdater.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading.Tasks; using Hangfire; using TfsAdvanced.DataStore.Repository; @@ -10,8 +8,7 @@ using TfsAdvanced.Models.Infrastructure; using TfsAdvanced.Updater; using TFSAdvanced.DataStore.Repository; -using TFSAdvanced.Updater.Models.JobRequests; -using TFSAdvanced.Updater.Models.Releases; +using TFSAdvanced.Models.DTO; namespace TFSAdvanced.Updater.Tasks { @@ -37,16 +34,16 @@ public void Update() IsRunning = true; try { - var releases = new ConcurrentStack(); + var releases = new ConcurrentStack(); Parallel.ForEach(projectRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, project => { - var releaseDefinitions = GetAsync.FetchResponseList(requestData, $"{requestData.BaseReleaseManagerAddress}/{project.Id}/_apis/Release/definitions?api-version=3.0-preview.1").Result; + var releaseDefinitions = GetAsync.FetchResponseList(requestData, $"{requestData.BaseReleaseManagerAddress}/{project.Id}/_apis/Release/definitions?api-version=3.0-preview.1").Result; if (releaseDefinitions != null) { Parallel.ForEach(releaseDefinitions, new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, releaseDefinition => { - var populatedReleaseDefinition = GetAsync.Fetch(requestData, releaseDefinition.url).Result; + var populatedReleaseDefinition = GetAsync.Fetch(requestData, releaseDefinition.url).Result; releases.Push(CreateReleaseDefinition(populatedReleaseDefinition)); }); } @@ -68,9 +65,9 @@ public void Update() } - private TFSAdvanced.Models.DTO.ReleaseDefinition CreateReleaseDefinition(ReleaseDefinition releaseDefinition) + private ReleaseDefinition CreateReleaseDefinition(Models.Releases.ReleaseDefinition releaseDefinition) { - var dto = new TFSAdvanced.Models.DTO.ReleaseDefinition + var dto = new ReleaseDefinition { Name = releaseDefinition.name, Id = releaseDefinition.id diff --git a/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs b/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs index 673e498..41f2129 100644 --- a/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs @@ -9,7 +9,6 @@ using TfsAdvanced.Models.Infrastructure; using TFSAdvanced.Models.DTO; using TFSAdvanced.Updater.Models.Policy; -using Repository = TFSAdvanced.Updater.Models.Repositories.Repository; namespace TfsAdvanced.Updater.Tasks { @@ -38,19 +37,19 @@ public void Update() IsRunning = true; try { - ConcurrentBag populatedRepositories = new ConcurrentBag(); + ConcurrentBag populatedRepositories = new ConcurrentBag(); Parallel.ForEach(projectRepository.GetAll(), new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, project => { - IList repositories = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/git/repositories?api=1.0").Result; + IList repositories = GetAsync.FetchResponseList(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/git/repositories?api=1.0").Result; if (repositories == null) return; Parallel.ForEach(repositories, new ParallelOptions {MaxDegreeOfParallelism = AppSettings.MAX_DEGREE_OF_PARALLELISM}, repo => { try { - var populatedRepository = GetAsync.Fetch(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/git/repositories/{repo.name}?api=1.0").Result; + var populatedRepository = GetAsync.Fetch(requestData, $"{requestData.BaseAddress}/{project.Name}/_apis/git/repositories/{repo.name}?api=1.0").Result; - var repositoryDto = new TFSAdvanced.Models.DTO.Repository + var repositoryDto = new Repository { Id = populatedRepository.id, Name = populatedRepository.name, diff --git a/src/TfsAdvanced/Controllers/BuildDefinitionsController.cs b/src/TfsAdvanced/Controllers/BuildDefinitionsController.cs index 112e185..4096e20 100644 --- a/src/TfsAdvanced/Controllers/BuildDefinitionsController.cs +++ b/src/TfsAdvanced/Controllers/BuildDefinitionsController.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc; -using TfsAdvanced.ServiceRequests; using TfsAdvanced.DataStore.Repository; +using TfsAdvanced.ServiceRequests; using TFSAdvanced.Models.DTO; namespace TfsAdvanced.Web.Controllers diff --git a/src/TfsAdvanced/HangfireJobFilter.cs b/src/TfsAdvanced/HangfireJobFilter.cs index 2f86466..08bb9ab 100644 --- a/src/TfsAdvanced/HangfireJobFilter.cs +++ b/src/TfsAdvanced/HangfireJobFilter.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Hangfire.Common; using Hangfire.States; using Hangfire.Storage; diff --git a/src/TfsAdvanced/Infrastructure/AuthenticationMiddleware.cs b/src/TfsAdvanced/Infrastructure/AuthenticationMiddleware.cs index 453e928..193bfa0 100644 --- a/src/TfsAdvanced/Infrastructure/AuthenticationMiddleware.cs +++ b/src/TfsAdvanced/Infrastructure/AuthenticationMiddleware.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Newtonsoft.Json; +using TfsAdvanced.Models.Infrastructure; namespace TfsAdvanced.Infrastructure { @@ -35,7 +36,7 @@ public async Task Invoke(HttpContext context) byte[] value; if (context.Session.TryGetValue("AuthToken", out value)) { - var token = JsonConvert.DeserializeObject(ASCIIEncoding.ASCII.GetString(value)); + var token = JsonConvert.DeserializeObject(ASCIIEncoding.ASCII.GetString(value)); if (token?.access_token == null) { context.Response.StatusCode = (int) HttpStatusCode.Forbidden; diff --git a/src/TfsAdvanced/Infrastructure/AuthenticationMiddlewareExtension.cs b/src/TfsAdvanced/Infrastructure/AuthenticationMiddlewareExtension.cs index 758f508..d9e764d 100644 --- a/src/TfsAdvanced/Infrastructure/AuthenticationMiddlewareExtension.cs +++ b/src/TfsAdvanced/Infrastructure/AuthenticationMiddlewareExtension.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Options; using TfsAdvanced.Models.Infrastructure; diff --git a/src/TfsAdvanced/Infrastructure/AuthenticationTokenProvider.cs b/src/TfsAdvanced/Infrastructure/AuthenticationTokenProvider.cs index d26135d..3c46233 100644 --- a/src/TfsAdvanced/Infrastructure/AuthenticationTokenProvider.cs +++ b/src/TfsAdvanced/Infrastructure/AuthenticationTokenProvider.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Newtonsoft.Json; -using TfsAdvanced.Data; using TfsAdvanced.Models.Infrastructure; namespace TfsAdvanced.Infrastructure diff --git a/src/TfsAdvanced/Infrastructure/AuthorizationSettings.cs b/src/TfsAdvanced/Infrastructure/AuthorizationSettings.cs index 8e97ddd..2bff2e4 100644 --- a/src/TfsAdvanced/Infrastructure/AuthorizationSettings.cs +++ b/src/TfsAdvanced/Infrastructure/AuthorizationSettings.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace TfsAdvanced.Infrastructure +namespace TfsAdvanced.Infrastructure { public class AuthorizationSettings { diff --git a/src/TfsAdvanced/Infrastructure/HangfireAuthorizationFilter.cs b/src/TfsAdvanced/Infrastructure/HangfireAuthorizationFilter.cs index 8bd56e0..984c20e 100644 --- a/src/TfsAdvanced/Infrastructure/HangfireAuthorizationFilter.cs +++ b/src/TfsAdvanced/Infrastructure/HangfireAuthorizationFilter.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Hangfire.Dashboard; -using Microsoft.AspNetCore.Mvc.Filters; +using Hangfire.Dashboard; namespace TfsAdvanced.Infrastructure { diff --git a/src/TfsAdvanced/Program.cs b/src/TfsAdvanced/Program.cs index c134277..5c667ef 100644 --- a/src/TfsAdvanced/Program.cs +++ b/src/TfsAdvanced/Program.cs @@ -1,5 +1,5 @@ -using Microsoft.AspNetCore.Hosting; -using System.IO; +using System.IO; +using Microsoft.AspNetCore.Hosting; namespace TfsAdvanced { diff --git a/src/TfsAdvanced/ServiceRequests/AuthorizationRequest.cs b/src/TfsAdvanced/ServiceRequests/AuthorizationRequest.cs index 2960417..e3e101c 100644 --- a/src/TfsAdvanced/ServiceRequests/AuthorizationRequest.cs +++ b/src/TfsAdvanced/ServiceRequests/AuthorizationRequest.cs @@ -1,17 +1,11 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Text; -using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Primitives; using Newtonsoft.Json; -using TfsAdvanced.Data; -using TfsAdvanced.Infrastructure; using TfsAdvanced.Models.Infrastructure; namespace TfsAdvanced.ServiceRequests diff --git a/src/TfsAdvanced/ServiceRequests/BuildDefinitionRequest.cs b/src/TfsAdvanced/ServiceRequests/BuildDefinitionRequest.cs index a4d25a6..e1c7bac 100644 --- a/src/TfsAdvanced/ServiceRequests/BuildDefinitionRequest.cs +++ b/src/TfsAdvanced/ServiceRequests/BuildDefinitionRequest.cs @@ -1,10 +1,10 @@ -using Newtonsoft.Json; -using System.Collections.Concurrent; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; +using Newtonsoft.Json; using TfsAdvanced.Models; using TFSAdvanced.Updater.Models.Builds; using TFSAdvanced.Updater.Models.Projects; diff --git a/src/TfsAdvanced/Startup.cs b/src/TfsAdvanced/Startup.cs index 242105d..b4633d9 100644 --- a/src/TfsAdvanced/Startup.cs +++ b/src/TfsAdvanced/Startup.cs @@ -1,21 +1,21 @@ -using Autofac; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Autofac; using Autofac.Extensions.DependencyInjection; +using Hangfire; +using Hangfire.MemoryStorage; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Hangfire; -using Hangfire.MemoryStorage; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using TfsAdvanced.Data; using TfsAdvanced.Infrastructure; using TfsAdvanced.Models; @@ -28,7 +28,7 @@ namespace TfsAdvanced public class Startup { public static readonly int MAX_DEGREE_OF_PARALLELISM = -1; - private string siteName = Environment.GetEnvironmentVariable("SiteName") ?? "ius"; + private readonly string siteName = Environment.GetEnvironmentVariable("SiteName") ?? "ius"; public IConfigurationRoot Configuration { get; set; } public IList References; @@ -46,8 +46,8 @@ public Startup(IHostingEnvironment env) References = new List { - typeof(Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole), - typeof(Microsoft.Extensions.Options.Options) + typeof(IdentityRole), + typeof(Options) }; } @@ -128,7 +128,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF GlobalJobFilters.Filters.Add(new HangfireJobFilter()); - Hangfire.BackgroundJob.Enqueue(updater => updater.Start()); + BackgroundJob.Enqueue(updater => updater.Start()); } } } diff --git a/src/TfsAdvanced/Utilities/GetAsync.cs b/src/TfsAdvanced/Utilities/GetAsync.cs index c4ad282..fd01d30 100644 --- a/src/TfsAdvanced/Utilities/GetAsync.cs +++ b/src/TfsAdvanced/Utilities/GetAsync.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json; diff --git a/src/TfsAdvanced/Utilities/JsonDeserializer.cs b/src/TfsAdvanced/Utilities/JsonDeserializer.cs index c07a192..f1a2485 100644 --- a/src/TfsAdvanced/Utilities/JsonDeserializer.cs +++ b/src/TfsAdvanced/Utilities/JsonDeserializer.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Net.Http; using System.Threading.Tasks; using Newtonsoft.Json; From b6a56eb759b6911285b271b13442c0aa8e675691 Mon Sep 17 00:00:00 2001 From: Bert Cotton Date: Fri, 4 Aug 2017 13:36:31 -0600 Subject: [PATCH 4/4] Added missing models --- .gitignore | 1 + .../Models/Releases/Artifact.cs | 19 +++++++++++ .../Models/Releases/DefinitionReference.cs | 17 ++++++++++ .../Models/Releases/IdNameReference.cs | 13 +++++++ .../Models/Releases/ReleaseDefinition.cs | 34 +++++++++++++++++++ .../Models/Releases/ReleaseLink.cs | 14 ++++++++ .../Models/Releases/User.cs | 18 ++++++++++ .../Tasks/RepositoryUpdater.cs | 2 +- 8 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 src/TfsAdvanced.Updater/Models/Releases/Artifact.cs create mode 100644 src/TfsAdvanced.Updater/Models/Releases/DefinitionReference.cs create mode 100644 src/TfsAdvanced.Updater/Models/Releases/IdNameReference.cs create mode 100644 src/TfsAdvanced.Updater/Models/Releases/ReleaseDefinition.cs create mode 100644 src/TfsAdvanced.Updater/Models/Releases/ReleaseLink.cs create mode 100644 src/TfsAdvanced.Updater/Models/Releases/User.cs diff --git a/.gitignore b/.gitignore index bb5a43a..84bd6b6 100644 --- a/.gitignore +++ b/.gitignore @@ -236,6 +236,7 @@ src/*/wwwroot/lib/ src/*/wwwroot/fonts/ src/*/wwwroot/_references.js +!src/**/Models/Releases/ node_modules/ diff --git a/src/TfsAdvanced.Updater/Models/Releases/Artifact.cs b/src/TfsAdvanced.Updater/Models/Releases/Artifact.cs new file mode 100644 index 0000000..518ba49 --- /dev/null +++ b/src/TfsAdvanced.Updater/Models/Releases/Artifact.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Updater.Models.Releases +{ + public class Artifact + { + public string sourceId { get; set; } + + public string type { get; set; } + + public string alias { get; set; } + + public DefinitionReference definitionReference { get; set; } + + public bool isPrimary { get; set; } + } +} diff --git a/src/TfsAdvanced.Updater/Models/Releases/DefinitionReference.cs b/src/TfsAdvanced.Updater/Models/Releases/DefinitionReference.cs new file mode 100644 index 0000000..b6e34fc --- /dev/null +++ b/src/TfsAdvanced.Updater/Models/Releases/DefinitionReference.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Updater.Models.Releases +{ + public class DefinitionReference + { + public IdNameReference artifactSourceDefinitionUrl { get; set; } + + public IdNameReference definition { get; set; } + + public IdNameReference project { get; set; } + + public IdNameReference defaultVersionType { get; set; } + } +} diff --git a/src/TfsAdvanced.Updater/Models/Releases/IdNameReference.cs b/src/TfsAdvanced.Updater/Models/Releases/IdNameReference.cs new file mode 100644 index 0000000..8092cdb --- /dev/null +++ b/src/TfsAdvanced.Updater/Models/Releases/IdNameReference.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Updater.Models.Releases +{ + public class IdNameReference + { + public string id { get; set; } + + public string name { get; set; } + } +} diff --git a/src/TfsAdvanced.Updater/Models/Releases/ReleaseDefinition.cs b/src/TfsAdvanced.Updater/Models/Releases/ReleaseDefinition.cs new file mode 100644 index 0000000..51fbe12 --- /dev/null +++ b/src/TfsAdvanced.Updater/Models/Releases/ReleaseDefinition.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Updater.Models.Releases +{ + public class ReleaseDefinition + { + + public int id { get; set; } + + public string source { get; set; } + + public int revision { get; set; } + + public string name { get; set; } + + public User createdBy { get; set; } + + public DateTime createdOn { get; set; } + + public User modifiedBy { get; set; } + + public DateTime modifiedOn { get; set; } + + public Artifact[] artifacts { get; set; } + + public string releaseNameFormat { get; set; } + + public ReleaseLink _links { get; set; } + + public string url { get; set; } + } +} diff --git a/src/TfsAdvanced.Updater/Models/Releases/ReleaseLink.cs b/src/TfsAdvanced.Updater/Models/Releases/ReleaseLink.cs new file mode 100644 index 0000000..25878bd --- /dev/null +++ b/src/TfsAdvanced.Updater/Models/Releases/ReleaseLink.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using TfsAdvanced.Models; + +namespace TFSAdvanced.Updater.Models.Releases +{ + public class ReleaseLink + { + public HrefLink self { get; set; } + + public HrefLink web { get; set; } + } +} diff --git a/src/TfsAdvanced.Updater/Models/Releases/User.cs b/src/TfsAdvanced.Updater/Models/Releases/User.cs new file mode 100644 index 0000000..a8e4e25 --- /dev/null +++ b/src/TfsAdvanced.Updater/Models/Releases/User.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TFSAdvanced.Updater.Models.Releases +{ + public class User + { + public string id { get; set; } + + public string displayName { get; set; } + + public string uniqueuName { get; set; } + + public string imageUrl { get; set; } + + } +} diff --git a/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs b/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs index 41f2129..f0b0556 100644 --- a/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs +++ b/src/TfsAdvanced.Updater/Tasks/RepositoryUpdater.cs @@ -2,7 +2,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; +using System.Threading.Tasks; using Hangfire; using TfsAdvanced.DataStore.Repository; using TfsAdvanced.Models;
Request IDJob TypeProject Name
Request IDJob TypeProjectRepository Launched By Result Queued Time