Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public async Task FileProcessingManager_GetFile_FileReturnedWithMerchantName()
var context = await this.GetContext(Guid.NewGuid().ToString("N"));
context.Merchants.Add(new Merchant
{
EstateReportingId = TestData.EstateReportingId,
EstateId = TestData.EstateId,
MerchantReportingId = TestData.MerchantReportingId,
MerchantId = TestData.MerchantId,
Name = TestData.MerchantName
Expand Down Expand Up @@ -207,7 +207,7 @@ public async Task FileProcessingManager_GetFile_FileReturnedWithUserEmailAddress
var context = await this.GetContext(Guid.NewGuid().ToString("N"));
context.EstateSecurityUsers.Add(new EstateSecurityUser()
{
EstateReportingId = TestData.EstateReportingId,
EstateId = TestData.EstateId,
SecurityUserId = TestData.UserId,
EmailAddress = TestData.UserEmailAddress
});
Expand Down Expand Up @@ -243,7 +243,7 @@ public async Task FileProcessingManager_GetFile_FileReturnedWithFileProfileName(
var context = await this.GetContext(Guid.NewGuid().ToString("N"));
context.EstateSecurityUsers.Add(new EstateSecurityUser()
{
EstateReportingId = TestData.EstateReportingId,
EstateId = TestData.EstateId,
SecurityUserId = TestData.UserId,
EmailAddress = TestData.UserEmailAddress
});
Expand Down
2 changes: 1 addition & 1 deletion FileProcessor.BusinessLogic.Tests/ModelFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void VerifyImportLogs(List<FileImportLog> sourceImportLogs, List<(FileIm
importLogs.Count.ShouldBe(TestData.FileImportLogs.Count);
foreach (FileImportLog fileImportLog in sourceImportLogs){
FIleProcessor.Models.FileImportLog importLog = importLogs.SingleOrDefault(i => i.FileImportLogId == fileImportLog.FileImportLogId);
List<(FileImportLogFile, File, Merchant)> sourceFiles = sourceImportLogFiles.Where(s => s.Item1.FileImportLogReportingId == fileImportLog.FileImportLogReportingId).ToList();
List<(FileImportLogFile, File, Merchant)> sourceFiles = sourceImportLogFiles.Where(s => s.Item1.FileImportLogId == fileImportLog.FileImportLogId).ToList();
this.VerifyImportLog(fileImportLog, sourceFiles, importLog);
}
}
Expand Down
4 changes: 2 additions & 2 deletions FileProcessor.BusinessLogic/Common/ModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public List<FileImportLog> ConvertFrom(Guid estateId,
model.EstateId = estateId;
model.Files = new List<ImportLogFile>();

IEnumerable<(FileImportLogFile, File,Merchant)> currentImportLogFiles = importLogFilesList.Where(fi => fi.Item1.FileImportLogReportingId == fileImportLog.FileImportLogReportingId);
IEnumerable<(FileImportLogFile, File,Merchant)> currentImportLogFiles = importLogFilesList.Where(fi => fi.Item1.FileImportLogId == fileImportLog.FileImportLogId);

foreach ((FileImportLogFile, File, Merchant) importLogFile in currentImportLogFiles)
{
Expand Down Expand Up @@ -75,7 +75,7 @@ public FileImportLog ConvertFrom(Guid estateId,
model.EstateId = estateId;
model.Files = new List<ImportLogFile>();

IEnumerable<(FileImportLogFile, File,Merchant)> currentImportLogFiles = importLogFilesList.Where(fi => fi.Item1.FileImportLogReportingId == importLog.FileImportLogReportingId);
IEnumerable<(FileImportLogFile, File,Merchant)> currentImportLogFiles = importLogFilesList.Where(fi => fi.Item1.FileImportLogId == importLog.FileImportLogId);

foreach ((FileImportLogFile, File,Merchant) importLogFile in currentImportLogFiles)
{
Expand Down
14 changes: 7 additions & 7 deletions FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EstateManagement.Database" Version="2024.5.1" />
<PackageReference Include="EstateManagement.Database" Version="2024.6.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
<PackageReference Include="EstateManagement.Client" Version="2024.5.1" />
<PackageReference Include="SecurityService.Client" Version="2024.4.2" />
<PackageReference Include="Shared" Version="2024.4.3" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.4.3" />
<PackageReference Include="EstateManagement.Client" Version="2024.6.5" />
<PackageReference Include="SecurityService.Client" Version="2024.5.1" />
<PackageReference Include="Shared" Version="2024.7.1" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.7.1" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Shared.EventStore" Version="2024.4.3" />
<PackageReference Include="Shared.EventStore" Version="2024.7.1" />
<PackageReference Include="System.IO.Abstractions" Version="21.0.2" />
<PackageReference Include="TransactionProcessor.Client" Version="2024.5.1" />
<PackageReference Include="TransactionProcessor.Client" Version="2024.6.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
</ItemGroup>
Expand Down
24 changes: 12 additions & 12 deletions FileProcessor.BusinessLogic/Managers/FileProcessorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,26 @@ public async Task<List<FileImportLog>> GetFileImportLogs(Guid estateId,

var importLogFileQuery = await context.FileImportLogFiles
.Join(context.Files,
fileImportLogFile => fileImportLogFile.FileReportingId,
file => file.FileReportingId,
fileImportLogFile => fileImportLogFile.FileId,
file => file.FileId,
(fileImportLogFile, file) => new {
fileImportLogFile,
file
})
.Join(context.Merchants,
file => file.file.MerchantReportingId,
merchant => merchant.MerchantReportingId,
file => file.file.MerchantId,
merchant => merchant.MerchantId,
(file, merchant) => new {
file,
merchant
})
.AsAsyncEnumerable()
.Where(fi => importLogQuery.Select(f => f.FileImportLogReportingId).Contains(fi.file.fileImportLogFile.FileImportLogReportingId))
.Where(fi => importLogQuery.Select(f => f.FileImportLogId).Contains(fi.file.fileImportLogFile.FileImportLogId))
.ToListAsync(cancellationToken);

if (merchantId.HasValue){
Merchant merchant = await context.Merchants.SingleOrDefaultAsync(m => m.MerchantId == merchantId.Value, cancellationToken:cancellationToken);
importLogFileQuery = importLogFileQuery.Where(i => i.file.fileImportLogFile.MerchantReportingId == merchant.MerchantReportingId).ToList();
importLogFileQuery = importLogFileQuery.Where(i => i.file.fileImportLogFile.MerchantId == merchant.MerchantId).ToList();
}

List<(FileImportLogFile, File,Merchant)> entityData = new List<(FileImportLogFile, File, Merchant)>();
Expand Down Expand Up @@ -157,27 +157,27 @@ public async Task<FileImportLog> GetFileImportLog(Guid fileImportLogId,

var importLogFileQuery = await context.FileImportLogFiles
.Join(context.Files,
fileImportLogFile => fileImportLogFile.FileReportingId,
file => file.FileReportingId,
fileImportLogFile => fileImportLogFile.FileId,
file => file.FileId,
(fileImportLogFile, file) => new{
fileImportLogFile,
file
})
.Join(context.Merchants,
file => file.file.MerchantReportingId,
merchant => merchant.MerchantReportingId,
file => file.file.MerchantId,
merchant => merchant.MerchantId,
(file, merchant) => new{
file,
merchant
})
.AsAsyncEnumerable()
.Where(fi => fi.file.fileImportLogFile.FileImportLogReportingId == importLogQuery.FileImportLogReportingId)
.Where(fi => fi.file.fileImportLogFile.FileImportLogId == importLogQuery.FileImportLogId)
.ToListAsync(cancellationToken);

if (merchantId.HasValue)
{
Merchant merchant = await context.Merchants.SingleOrDefaultAsync(m => m.MerchantId == merchantId.Value, cancellationToken: cancellationToken);
importLogFileQuery = importLogFileQuery.Where(i => i.file.fileImportLogFile.MerchantReportingId == merchant.MerchantReportingId).ToList();
importLogFileQuery = importLogFileQuery.Where(i => i.file.fileImportLogFile.MerchantId == merchant.MerchantId).ToList();
}

List<(FileImportLogFile, File,Merchant)> entityData = new List<(FileImportLogFile, File, Merchant)>();
Expand Down
17 changes: 7 additions & 10 deletions FileProcessor.BusinessLogic/Services/FileProcessorDomainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public async Task ProcessTransactionForFileLine(ProcessTransactionForFileLineReq
})
};

Logger.LogInformation(serialisedRequestMessage.SerialisedData);
Logger.LogDebug(serialisedRequestMessage.SerialisedData);

// Send request to transaction processor
SerialisedMessage serialisedResponseMessage = await this.TransactionProcessorClient.PerformTransaction(this.TokenResponse.AccessToken, serialisedRequestMessage, cancellationToken);
Expand Down Expand Up @@ -365,13 +365,13 @@ private async Task ProcessFile(Guid fileId,
// Check the processed/failed directories exist
if (this.FileSystem.Directory.Exists(fileProfile.ProcessedDirectory) == false)
{
Logger.LogWarning($"Creating Directory {fileProfile.ProcessedDirectory} as not found");
Logger.LogInformation($"Creating Directory {fileProfile.ProcessedDirectory} as not found");
this.FileSystem.Directory.CreateDirectory(fileProfile.ProcessedDirectory);
}

if (this.FileSystem.Directory.Exists(fileProfile.FailedDirectory) == false)
{
Logger.LogWarning($"Creating Directory {fileProfile.FailedDirectory} as not found");
Logger.LogInformation($"Creating Directory {fileProfile.FailedDirectory} as not found");
this.FileSystem.Directory.CreateDirectory(fileProfile.FailedDirectory);
}

Expand Down Expand Up @@ -416,8 +416,7 @@ private async Task ProcessFile(Guid fileId,
await this.FileAggregateRepository.SaveChanges(fileAggregate, cancellationToken);
}

Logger.LogInformation(
$"About to move file {inProgressFile.Name} to [{fileProfile.ProcessedDirectory}]");
Logger.LogInformation($"About to move file {inProgressFile.Name} to [{fileProfile.ProcessedDirectory}]");

// TODO: Move file now
inProgressFile.MoveTo($"{fileProfile.ProcessedDirectory}/{inProgressFile.Name}");
Expand Down Expand Up @@ -483,21 +482,19 @@ private async Task<TokenResponse> GetToken(CancellationToken cancellationToken)
// Get a token to talk to the estate service
String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId");
String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret");
Logger.LogInformation($"Client Id is {clientId}");
Logger.LogInformation($"Client Secret is {clientSecret}");

if (this.TokenResponse == null)
{
TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken);
Logger.LogInformation($"Token is {token.AccessToken}");
Logger.LogDebug($"Token is {token.AccessToken}");
return token;
}

if (this.TokenResponse.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2))
{
Logger.LogInformation($"Token is about to expire at {this.TokenResponse.Expires.DateTime:O}");
Logger.LogDebug($"Token is about to expire at {this.TokenResponse.Expires.DateTime:O}");
TokenResponse token = await this.SecurityServiceClient.GetToken(clientId, clientSecret, cancellationToken);
Logger.LogInformation($"Token is {token.AccessToken}");
Logger.LogDebug($"Token is {token.AccessToken}");
return token;
}

Expand Down
2 changes: 1 addition & 1 deletion FileProcessor.Client/FileProcessor.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="2024.4.3" />
<PackageReference Include="ClientProxyBase" Version="2024.7.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.4.3" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.7.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.61.0" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.4.3" />
<PackageReference Include="Shared.EventStore" Version="2024.4.3" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.7.1" />
<PackageReference Include="Shared.EventStore" Version="2024.7.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.4.3" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.7.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.61.0" />
<PackageReference Include="Shared.EventStore" Version="2024.4.3" />
<PackageReference Include="Shared.EventStore" Version="2024.7.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2024.5.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2024.4.3" />
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2024.6.5" />
<PackageReference Include="Shared.IntegrationTesting" Version="2024.7.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2024.5.1" />
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2024.6.5" />
<PackageReference Include="EventStoreProjections" Version="2023.12.3" />
<PackageReference Include="MessagingService.IntegrationTesting.Helpers" Version="2024.4.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
<PackageReference Include="EstateManagement.Client" Version="2024.5.1" />
<PackageReference Include="EstateManagement.Client" Version="2024.6.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Reqnroll.Tools.MsBuild.Generation" Version="1.0.1" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Reqnroll" Version="1.0.1" />
<PackageReference Include="Reqnroll.NUnit" Version="1.0.1" />
<PackageReference Include="SecurityService.Client" Version="2024.4.2" />
<PackageReference Include="SecurityService.IntegrationTesting.Helpers" Version="2024.4.2" />
<PackageReference Include="Shared" Version="2024.4.3" />
<PackageReference Include="Shared.IntegrationTesting" Version="2024.4.3" />
<PackageReference Include="SecurityService.Client" Version="2024.5.1" />
<PackageReference Include="SecurityService.IntegrationTesting.Helpers" Version="2024.5.1" />
<PackageReference Include="Shared" Version="2024.7.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2024.7.1" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="TransactionProcessor.Client" Version="2024.5.1" />
<PackageReference Include="TransactionProcessor.IntegrationTesting.Helpers" Version="2024.5.1" />
<PackageReference Include="TransactionProcessor.Client" Version="2024.6.2" />
<PackageReference Include="TransactionProcessor.IntegrationTesting.Helpers" Version="2024.6.2" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Loading