Skip to content

Commit d60048c

Browse files
Merge pull request #230 from TransactionProcessing/task/#229_net7upgrade
Upgrade to NET 7
2 parents 9f3ac0c + 12e583e commit d60048c

28 files changed

Lines changed: 120 additions & 99 deletions

File tree

.github/workflows/createrelease.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ jobs:
1919
id: get_version
2020
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
2121

22+
- name: Install NET 7
23+
uses: actions/setup-dotnet@v2
24+
with:
25+
dotnet-version: '7.0.x'
26+
2227
- name: Restore Nuget Packages
2328
run: dotnet restore FileProcessor.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
2429

.github/workflows/nightlybuild.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ jobs:
1919
- name: Set Up Variables
2020
run: echo "action_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
2121

22+
- name: Install NET 7
23+
uses: actions/setup-dotnet@v2
24+
with:
25+
dotnet-version: '7.0.x'
26+
2227
- name: Restore Nuget Packages
2328
run: dotnet restore FileProcessor.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
2429

.github/workflows/pullrequest.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ jobs:
2121
echo "CI is > ${CI}"
2222
echo "HOME is > ${HOME}"
2323
24+
- name: Install NET 7
25+
uses: actions/setup-dotnet@v2
26+
with:
27+
dotnet-version: '7.0.x'
28+
2429
- name: Restore Nuget Packages
2530
run: dotnet restore FileProcessor.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
2631

.github/workflows/pushtomain.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ jobs:
1818
- uses: actions/checkout@v2.3.4
1919
with:
2020
fetch-depth: 0
21+
22+
- name: Install NET 7
23+
uses: actions/setup-dotnet@v2
24+
with:
25+
dotnet-version: '7.0.x'
2126

2227
- name: Restore Nuget Packages
2328
run: dotnet restore FileProcessor.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json

FIleProcessor.Models/FIleProcessor.Models.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<DebugType>None</DebugType>
66
</PropertyGroup>
77

FileProcessor.BusinessLogic.Tests/FileProcessingManagerTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public async Task FileProcessingManager_GetFileImportLogs_NoMerchantId_ImportLog
6464
var fileProfiles = TestData.FileProfiles;
6565
var context = await this.GetContext(Guid.NewGuid().ToString("N"));
6666
var contextFactory = this.CreateMockContextFactory();
67-
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
67+
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<String>(),It.IsAny<CancellationToken>())).ReturnsAsync(context);
6868
IModelFactory modelFactory = new ModelFactory();
6969

7070
context.FileImportLogs.AddRange(TestData.FileImportLogs);
@@ -87,7 +87,7 @@ public async Task FileProcessingManager_GetFileImportLogs_WithMerchantId_ImportL
8787
var fileProfiles = TestData.FileProfiles;
8888
var context = await this.GetContext(Guid.NewGuid().ToString("N"));
8989
var contextFactory = this.CreateMockContextFactory();
90-
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
90+
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
9191
IModelFactory modelFactory = new ModelFactory();
9292

9393
context.FileImportLogs.AddRange(TestData.FileImportLogs);
@@ -110,7 +110,7 @@ public async Task FileProcessingManager_GetFileImportLog_NoMerchantId_ImportLogR
110110
var fileProfiles = TestData.FileProfiles;
111111
var context = await this.GetContext(Guid.NewGuid().ToString("N"));
112112
var contextFactory = this.CreateMockContextFactory();
113-
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
113+
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
114114
IModelFactory modelFactory = new ModelFactory();
115115

116116
context.FileImportLogs.AddRange(TestData.FileImportLogs);
@@ -133,7 +133,7 @@ public async Task FileProcessingManager_GetFileImportLog_WithMerchantId_ImportLo
133133
var fileProfiles = TestData.FileProfiles;
134134
var context = await this.GetContext(Guid.NewGuid().ToString("N"));
135135
var contextFactory = this.CreateMockContextFactory();
136-
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
136+
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
137137
IModelFactory modelFactory = new ModelFactory();
138138

139139
context.FileImportLogs.AddRange(TestData.FileImportLogs);
@@ -156,7 +156,7 @@ public async Task FileProcessingManager_GetFile_FileReturned()
156156
List<FileProfile> fileProfiles = new List<FileProfile>();
157157
var context = await this.GetContext(Guid.NewGuid().ToString("N"));
158158
var contextFactory = this.CreateMockContextFactory();
159-
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
159+
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
160160
IModelFactory modelFactory = new ModelFactory();
161161

162162
Mock<IAggregateRepository<FileAggregate, DomainEvent>> fileAggregateRepository =
@@ -185,7 +185,7 @@ public async Task FileProcessingManager_GetFile_FileReturnedWithMerchantName()
185185
});
186186
context.SaveChanges();
187187
var contextFactory = this.CreateMockContextFactory();
188-
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
188+
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
189189
IModelFactory modelFactory = new ModelFactory();
190190

191191
Mock<IAggregateRepository<FileAggregate, DomainEvent>> fileAggregateRepository =
@@ -212,7 +212,7 @@ public async Task FileProcessingManager_GetFile_FileReturnedWithUserEmailAddress
212212
});
213213
context.SaveChanges();
214214
var contextFactory = this.CreateMockContextFactory();
215-
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
215+
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
216216
IModelFactory modelFactory = new ModelFactory();
217217

218218
Mock<IAggregateRepository<FileAggregate, DomainEvent>> fileAggregateRepository =
@@ -248,7 +248,7 @@ public async Task FileProcessingManager_GetFile_FileReturnedWithFileProfileName(
248248
});
249249
context.SaveChanges();
250250
var contextFactory = this.CreateMockContextFactory();
251-
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
251+
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
252252
IModelFactory modelFactory = new ModelFactory();
253253

254254
Mock<IAggregateRepository<FileAggregate, DomainEvent>> fileAggregateRepository =
@@ -268,7 +268,7 @@ public async Task FileProcessingManager_GetFile_FileNotFound_ErrorThrown()
268268
var fileProfiles = TestData.FileProfiles;
269269
var context = await this.GetContext(Guid.NewGuid().ToString("N"));
270270
var contextFactory = this.CreateMockContextFactory();
271-
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
271+
contextFactory.Setup(c => c.GetContext(It.IsAny<Guid>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(context);
272272
IModelFactory modelFactory = new ModelFactory();
273273

274274
Mock<IAggregateRepository<FileAggregate, DomainEvent>> fileAggregateRepository =

FileProcessor.BusinessLogic.Tests/FileProcessor.BusinessLogic.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<DebugType>None</DebugType>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.5" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.5" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.0" />
1212
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
1313
<PackageReference Include="Moq" Version="4.18.1" />
1414
<PackageReference Include="Shouldly" Version="4.0.3" />

FileProcessor.BusinessLogic/Common/ConfigurationReaderConnectionStringRepository.cs

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace FileProcessor.BusinessLogic.Common
1010
using System.Diagnostics.CodeAnalysis;
1111
using System.Threading;
1212
using Microsoft.Data.SqlClient;
13+
using MySqlConnector;
1314
using Shared.General;
1415
using Shared.Repositories;
1516

@@ -18,61 +19,50 @@ public class ConfigurationReaderConnectionStringRepository : IConnectionStringCo
1819
{
1920
#region Methods
2021

21-
/// <summary>
22-
/// Creates the connection string.
23-
/// </summary>
24-
/// <param name="externalIdentifier">The external identifier.</param>
25-
/// <param name="connectionStringType">Type of the connection string.</param>
26-
/// <param name="connectionString">The connection string.</param>
27-
/// <param name="cancellationToken">The cancellation token.</param>
2822
public async Task CreateConnectionString(String externalIdentifier,
29-
ConnectionStringType connectionStringType,
23+
String connectionStringIdentifier,
3024
String connectionString,
3125
CancellationToken cancellationToken)
3226
{
3327
throw new NotImplementedException("This is only required to complete the interface");
3428
}
3529

36-
/// <summary>
37-
/// Deletes the connection string configuration.
38-
/// </summary>
39-
/// <param name="externalIdentifier">The external identifier.</param>
40-
/// <param name="connectionStringType">Type of the connection string.</param>
41-
/// <param name="cancellationToken">The cancellation token.</param>
4230
public async Task DeleteConnectionStringConfiguration(String externalIdentifier,
43-
ConnectionStringType connectionStringType,
31+
String connectionStringIdentifier,
4432
CancellationToken cancellationToken)
4533
{
4634
throw new NotImplementedException("This is only required to complete the interface");
4735
}
4836

49-
/// <summary>
50-
/// Gets the connection string.
51-
/// </summary>
52-
/// <param name="externalIdentifier">The external identifier.</param>
53-
/// <param name="connectionStringType">Type of the connection string.</param>
54-
/// <param name="cancellationToken">The cancellation token.</param>
55-
/// <returns></returns>
5637
public async Task<String> GetConnectionString(String externalIdentifier,
57-
ConnectionStringType connectionStringType,
38+
String connectionStringIdentifier,
5839
CancellationToken cancellationToken)
5940
{
6041
String connectionString = string.Empty;
6142
String databaseName = string.Empty;
62-
switch (connectionStringType)
43+
44+
String databaseEngine = ConfigurationReader.GetValue("AppSettings", "DatabaseEngine");
45+
46+
databaseName = $"{connectionStringIdentifier}{externalIdentifier}";
47+
connectionString = ConfigurationReader.GetConnectionString(connectionStringIdentifier);
48+
49+
DbConnectionStringBuilder builder = null;
50+
51+
if (databaseEngine == "MySql")
6352
{
64-
case ConnectionStringType.ReadModel:
65-
databaseName = "EstateReportingReadModel" + externalIdentifier;
66-
connectionString = ConfigurationReader.GetConnectionString("EstateReportingReadModel");
67-
break;
68-
default:
69-
throw new NotSupportedException($"Connection String type [{connectionStringType}] is not supported");
53+
builder = new MySqlConnectionStringBuilder(connectionString)
54+
{
55+
Database = databaseName
56+
};
7057
}
71-
72-
DbConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString)
58+
else
7359
{
74-
InitialCatalog = databaseName
75-
};
60+
// Default to SQL Server
61+
builder = new SqlConnectionStringBuilder(connectionString)
62+
{
63+
InitialCatalog = databaseName
64+
};
65+
}
7666

7767
return builder.ToString();
7868
}

FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.5" />
8+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
99
<PackageReference Include="EstateManagement.Client" Version="1.1.6-build16" />
1010
<PackageReference Include="EstateReporting.Database" Version="1.1.8-build15" />
1111
<PackageReference Include="SecurityService.Client" Version="1.1.2-build20" />
12-
<PackageReference Include="Shared" Version="1.4.2" />
13-
<PackageReference Include="Shared.DomainDrivenDesign" Version="1.4.2" />
12+
<PackageReference Include="Shared" Version="1.5.1" />
13+
<PackageReference Include="Shared.DomainDrivenDesign" Version="1.5.1" />
1414
<PackageReference Include="MediatR" Version="10.0.1" />
15-
<PackageReference Include="Shared.EventStore" Version="1.4.2" />
15+
<PackageReference Include="Shared.EventStore" Version="1.5.1" />
1616
<PackageReference Include="System.IO.Abstractions" Version="17.0.15" />
1717
<PackageReference Include="TransactionProcessor.Client" Version="1.1.13-build22" />
18-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.5" />
19-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.5" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
19+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

FileProcessor.BusinessLogic/Managers/FileProcessorManager.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class FileProcessorManager : IFileProcessorManager
3838

3939
private readonly IAggregateRepository<FileAggregate, DomainEvent> FileAggregateRepository;
4040

41+
private const String ConnectionStringIdentifier = "EstateReportingReadModel";
42+
4143
#endregion
4244

4345
#region Constructors
@@ -100,7 +102,7 @@ public async Task<List<FileImportLog>> GetFileImportLogs(Guid estateId,
100102
Guid? merchantId,
101103
CancellationToken cancellationToken)
102104
{
103-
EstateReportingGenericContext context = await this.DbContextFactory.GetContext(estateId, cancellationToken);
105+
EstateReportingGenericContext context = await this.DbContextFactory.GetContext(estateId, ConnectionStringIdentifier, cancellationToken);
104106

105107
List<EstateReporting.Database.Entities.FileImportLog> importLogQuery =
106108
await context.FileImportLogs.AsAsyncEnumerable().Where(f => f.ImportLogDateTime >= startDateTime).ToListAsync(cancellationToken);
@@ -130,7 +132,7 @@ public async Task<FileImportLog> GetFileImportLog(Guid fileImportLogId,
130132
Guid? merchantId,
131133
CancellationToken cancellationToken)
132134
{
133-
EstateReportingGenericContext context = await this.DbContextFactory.GetContext(estateId, cancellationToken);
135+
EstateReportingGenericContext context = await this.DbContextFactory.GetContext(estateId, ConnectionStringIdentifier, cancellationToken);
134136

135137
EstateReporting.Database.Entities.FileImportLog importLogQuery =
136138
await context.FileImportLogs.AsAsyncEnumerable().SingleOrDefaultAsync(f => f.FileImportLogId == fileImportLogId, cancellationToken);
@@ -168,7 +170,7 @@ public async Task<FileDetails> GetFile(Guid fileId,
168170

169171
FileDetails fileDetails = fileAggregate.GetFile();
170172

171-
EstateReportingGenericContext context = await this.DbContextFactory.GetContext(estateId, cancellationToken);
173+
EstateReportingGenericContext context = await this.DbContextFactory.GetContext(estateId, ConnectionStringIdentifier, cancellationToken);
172174

173175
Merchant merchant = await context.Merchants.AsAsyncEnumerable()
174176
.SingleOrDefaultAsync(m => m.MerchantId == fileDetails.MerchantId, cancellationToken);

0 commit comments

Comments
 (0)