Skip to content

Commit 28153f7

Browse files
authored
Merge pull request #6 from typinghard/feature/43
Feature/43
2 parents d90d0b7 + c07183f commit 28153f7

22 files changed

+585
-61
lines changed

AzureDevopsTracker/Adapters/WorkItemAdapter.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal class WorkItemAdapter : IWorkItemAdapter
1212
{
1313
public WorkItemDTO ToWorkItemDTO(WorkItem workItem)
1414
{
15-
if (workItem == null) return null;
15+
if (workItem is null) return null;
1616

1717
return new WorkItemDTO()
1818
{
@@ -31,7 +31,7 @@ public WorkItemDTO ToWorkItemDTO(WorkItem workItem)
3131
OriginalEstimate = workItem.OriginalEstimate,
3232
WorkItemParentId = workItem.WorkItemParentId,
3333
Activity = workItem.Activity,
34-
Tags = workItem.Tags == null ? new List<string>() : workItem.Tags.Split(';').ToList(),
34+
Tags = workItem.Tags is null ? new List<string>() : workItem.Tags.Split(';').ToList(),
3535
WorkItemsChangesDTO = ToWorkItemsChangeDTO(workItem.WorkItemsChanges.OrderBy(x => x.CreatedAt).ToList()),
3636
TimesByStateDTO = ToTimeByStatesDTO(workItem.CalculateTotalTimeByState().ToList()),
3737
};
@@ -41,7 +41,7 @@ public List<WorkItemDTO> ToWorkItemsDTO(List<WorkItem> workItems)
4141
{
4242
var workItemsDTO = new List<WorkItemDTO>();
4343

44-
if (workItems == null) return workItemsDTO;
44+
if (workItems is null) return workItemsDTO;
4545

4646
workItems.ForEach(
4747
workItem =>
@@ -53,7 +53,7 @@ public List<WorkItemDTO> ToWorkItemsDTO(List<WorkItem> workItems)
5353

5454
public WorkItemChangeDTO ToWorkItemChangeDTO(WorkItemChange workIteChange)
5555
{
56-
if (workIteChange == null) return null;
56+
if (workIteChange is null) return null;
5757

5858
return new WorkItemChangeDTO()
5959
{
@@ -69,20 +69,20 @@ public List<WorkItemChangeDTO> ToWorkItemsChangeDTO(List<WorkItemChange> workIte
6969
{
7070
var workItemsChangeDTO = new List<WorkItemChangeDTO>();
7171

72-
if (workItemsChanges == null) return workItemsChangeDTO;
72+
if (workItemsChanges is null) return workItemsChangeDTO;
7373

7474
workItemsChanges.ForEach(
7575
workItemsChange =>
7676
workItemsChangeDTO.Add(ToWorkItemChangeDTO(workItemsChange)));
7777

7878
return workItemsChangeDTO
79-
.Where(w => w != null)
79+
.Where(w => w is not null)
8080
.ToList();
8181
}
8282

8383
public TimeByStateDTO ToTimeByStateDTO(TimeByState workItemStatusTime)
8484
{
85-
if (workItemStatusTime == null) return null;
85+
if (workItemStatusTime is null) return null;
8686

8787
return new TimeByStateDTO()
8888
{
@@ -97,14 +97,14 @@ public List<TimeByStateDTO> ToTimeByStatesDTO(List<TimeByState> workItemStatusTi
9797
{
9898
var workItemStatusTimeDTO = new List<TimeByStateDTO>();
9999

100-
if (workItemStatusTimes == null) return workItemStatusTimeDTO;
100+
if (workItemStatusTimes is null) return workItemStatusTimeDTO;
101101

102102
workItemStatusTimes.ForEach(
103103
workItemStatusTime =>
104104
workItemStatusTimeDTO.Add(ToTimeByStateDTO(workItemStatusTime)));
105105

106106
return workItemStatusTimeDTO
107-
.Where(w => w != null)
107+
.Where(w => w is not null)
108108
.ToList();
109109
}
110110
}

AzureDevopsTracker/AzureDevopsTracker.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
<PackageLicenseFile>LICENSE.md.txt</PackageLicenseFile>
1919
<Description>A NuGet that allows you to use a Azure DevOps Service Hook to track workitems changes in a simply and detailed way.</Description>
2020
<AssemblyVersion>5.0.0.0</AssemblyVersion>
21-
<FileVersion>5.0.3</FileVersion>
22-
<Version>5.0.3</Version>
21+
<FileVersion>5.0.4</FileVersion>
22+
<Version>5.0.4</Version>
2323
<PackageReleaseNotes>Add ChangeLog Feature</PackageReleaseNotes>
2424
</PropertyGroup>
2525

2626
<ItemGroup>
27+
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
2728
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
28-
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.0.0" />
29+
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
2930
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
3031
</ItemGroup>
3132

AzureDevopsTracker/Configurations/Configuration.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using AzureDevopsTracker.Interfaces.Internals;
77
using AzureDevopsTracker.Services;
88
using Microsoft.AspNetCore.Builder;
9+
using Microsoft.AspNetCore.Http;
910
using Microsoft.EntityFrameworkCore;
1011
using Microsoft.Extensions.DependencyInjection;
1112
using System;
@@ -21,6 +22,8 @@ public static IServiceCollection AddAzureDevopsTracker(this IServiceCollection s
2122

2223
services.AddMessageIntegrations();
2324

25+
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
26+
2427
services.AddScoped<AzureDevopsTrackerContext>();
2528
services.AddScoped<IWorkItemAdapter, WorkItemAdapter>();
2629
services.AddScoped<IWorkItemRepository, WorkItemRepository>();
@@ -44,7 +47,7 @@ private static IServiceCollection AddMessageIntegrations(this IServiceCollection
4447
case EMessengers.MICROSOFT_TEAMS:
4548
services.AddScoped<MessageIntegration, MicrosoftTeamsIntegration>();
4649
break;
47-
default:
50+
default:
4851
services.AddScoped<MessageIntegration, FakeIntegration>();
4952
break;
5053
}

AzureDevopsTracker/DTOs/Fields.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ public class Fields
7474
[JsonProperty("Microsoft.VSTS.Common.Activity")]
7575
public string Activity { get; set; }
7676

77-
[JsonProperty("Custom.01f51eeb-416d-49b1-b7f9-b92f3a675de1")]
78-
public string Lancado { get; set; }
79-
8077
[JsonProperty("Custom.ChangeLogDescription")]
8178
public string ChangeLogDescription { get; set; }
8279
}

AzureDevopsTracker/Data/Context/AzureDevopsTrackerContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public AzureDevopsTrackerContext(DbContextOptions options) : base(options)
1515
public DbSet<TimeByState> TimeByStates { get; set; }
1616
public DbSet<ChangeLogItem> ChangeLogItems { get; set; }
1717
public DbSet<ChangeLog> ChangeLogs { get; set; }
18+
public DbSet<WorkItemCustomField> CustomFields { get; set; }
1819

1920
protected override void OnModelCreating(ModelBuilder modelBuilder)
2021
{

AzureDevopsTracker/Data/DataBaseConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public DataBaseConfig(string connectionsString, string schemaName = "dbo", TimeZ
1111
if (connectionsString.IsNullOrEmpty())
1212
throw new ArgumentException("The ConnectionsString is required");
1313

14-
if (timeZoneInfo == null)
14+
if (timeZoneInfo is null)
1515
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
1616
timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time");
1717
else

AzureDevopsTracker/Data/Mapping/ChangeLogMapping.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ public void Configure(EntityTypeBuilder<ChangeLog> builder)
1212
.HasColumnType("varchar(max)");
1313
}
1414
}
15-
}
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using AzureDevopsTracker.Entities;
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
4+
5+
namespace AzureDevopsTracker.Data.Mapping
6+
{
7+
public class CustomFieldMapping : IEntityTypeConfiguration<WorkItemCustomField>
8+
{
9+
public void Configure(EntityTypeBuilder<WorkItemCustomField> builder)
10+
{
11+
builder.HasKey(k => new { k.WorkItemId, k.Key });
12+
13+
builder.Property(p => p.Key)
14+
.HasColumnType("varchar(1000)");
15+
16+
builder.Property(p => p.Value)
17+
.HasColumnType("varchar(max)");
18+
}
19+
}
20+
}

AzureDevopsTracker/Data/WorkItemRepository.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public async Task<WorkItem> GetByWorkItemId(string workItemId)
1818
.Include(x => x.WorkItemsChanges)
1919
.Include(x => x.TimeByStates)
2020
.Include(x => x.ChangeLogItem)
21+
.Include(x => x.CustomFields)
2122
.FirstOrDefaultAsync(x => x.Id == workItemId);
2223
}
2324

@@ -27,6 +28,7 @@ public async Task<IEnumerable<WorkItem>> ListByWorkItemId(IEnumerable<string> wo
2728
.Include(x => x.WorkItemsChanges)
2829
.Include(x => x.TimeByStates)
2930
.Include(x => x.ChangeLogItem)
31+
.Include(x => x.CustomFields)
3032
.Where(x => workItemsId.Contains(x.Id))
3133
.ToListAsync();
3234
}
@@ -37,6 +39,7 @@ public async Task<IEnumerable<WorkItem>> ListByIterationPath(string iterationPat
3739
.Include(x => x.WorkItemsChanges)
3840
.Include(x => x.TimeByStates)
3941
.Include(x => x.ChangeLogItem)
42+
.Include(x => x.CustomFields)
4043
.Where(x => x.IterationPath == iterationPath)
4144
.ToListAsync();
4245
}

AzureDevopsTracker/Entities/ChangeLog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void ClearResponse()
3737

3838
public void AddChangeLogItem(ChangeLogItem changeLogItem)
3939
{
40-
if (changeLogItem == null)
40+
if (changeLogItem is null)
4141
throw new Exception("ChangeLogItem is required");
4242

4343
if (CheckChangeLogItem(changeLogItem))
@@ -49,7 +49,7 @@ public void AddChangeLogItem(ChangeLogItem changeLogItem)
4949

5050
public void AddChangeLogItems(IEnumerable<ChangeLogItem> changeLogItems)
5151
{
52-
if (changeLogItems == null)
52+
if (changeLogItems is null)
5353
throw new Exception("ChangeLogItems is required");
5454

5555
foreach (var changeLogItem in changeLogItems)

0 commit comments

Comments
 (0)