Skip to content

Commit

Permalink
Change or statecode
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevJoy committed Jan 20, 2025
1 parent fc558b7 commit d788bd0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using CsvHelper.Configuration;
using CsvHelper;
using CsvHelper.Configuration.Attributes;
using CsvHelper.TypeConversion;

namespace TeachingRecordSystem.Core.Jobs.EWCWalesImport;

Expand Down Expand Up @@ -35,4 +38,3 @@ public record EwcWalesInductionImportData
public required string InductionStatusName { get; set; }
}


Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Globalization;
using System.Text;
using CsvHelper;
using CsvHelper.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
Expand All @@ -26,7 +27,11 @@ public InductionImporter(ICrmQueryDispatcher crmQueryDispatcher, ILogger<Inducti

public async Task<InductionImportResult> ImportAsync(StreamReader csvReaderStream, string fileName)
{
using (var csv = new CsvReader(csvReaderStream, CultureInfo.InvariantCulture))
var csvConfig = new CsvConfiguration(CultureInfo.InvariantCulture)
{
TrimOptions = TrimOptions.Trim
};
using (var csv = new CsvReader(csvReaderStream, csvConfig))
{
var integrationJob = new CreateIntegrationTransactionQuery()
{
Expand Down Expand Up @@ -164,7 +169,7 @@ public async Task<InductionImportResult> ImportAsync(StreamReader csvReaderStrea

//increase failurecount if row is processable or if there are validation failures
//else increase success counter
if (validationFailures.ValidationFailures.Any() || validationFailures.Errors.Any())
if (validationFailures.Errors.Any())
{
failureRowCount++;
}
Expand All @@ -186,7 +191,7 @@ public async Task<InductionImportResult> ImportAsync(StreamReader csvReaderStrea
InductionPeriodId = inductionPeriodId,
DuplicateStatus = null,
FailureMessage = itrFailureMessage.ToString(),
StatusCode = string.IsNullOrEmpty(itrFailureMessage.ToString()) ? dfeta_integrationtransactionrecord_StatusCode.Success : dfeta_integrationtransactionrecord_StatusCode.Fail,
StatusCode = validationFailures.Errors.Count == 0 ? dfeta_integrationtransactionrecord_StatusCode.Success : dfeta_integrationtransactionrecord_StatusCode.Fail,
RowData = ConvertToCSVString(row),
FileName = fileName
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Globalization;
using System.Text;
using CsvHelper;
using CsvHelper.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Xrm.Sdk.Query;
using TeachingRecordSystem.Core.DataStore.Postgres;
Expand All @@ -27,7 +28,11 @@ public QtsImporter(ICrmQueryDispatcher crmQueryDispatcher, ILogger<InductionImpo

public async Task<QtsImportResult> ImportAsync(StreamReader csvReaderStream, string fileName)
{
using var csv = new CsvReader(csvReaderStream, CultureInfo.InvariantCulture);
var csvConfig = new CsvConfiguration(CultureInfo.InvariantCulture)
{
TrimOptions = TrimOptions.Trim
};
using var csv = new CsvReader(csvReaderStream, csvConfig);
var records = csv.GetRecords<EwcWalesQtsFileImportData>().ToList();
var totalRowCount = 0;
var successCount = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using CsvHelper.Configuration;
using CsvHelper;
using CsvHelper.Configuration.Attributes;
using CsvHelper.TypeConversion;

namespace TeachingRecordSystem.Core.Jobs.EWCWalesImport;

Expand Down Expand Up @@ -35,4 +38,3 @@ public record EwcWalesInductionImportData
public required string InductionStatusName { get; set; }
}


Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Globalization;
using System.Text;
using CsvHelper;
using CsvHelper.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
Expand All @@ -26,7 +27,11 @@ public InductionImporter(ICrmQueryDispatcher crmQueryDispatcher, ILogger<Inducti

public async Task<InductionImportResult> ImportAsync(StreamReader csvReaderStream, string fileName)
{
using (var csv = new CsvReader(csvReaderStream, CultureInfo.InvariantCulture))
var csvConfig = new CsvConfiguration(CultureInfo.InvariantCulture)
{
TrimOptions = TrimOptions.Trim
};
using (var csv = new CsvReader(csvReaderStream, csvConfig))
{
var integrationJob = new CreateIntegrationTransactionQuery()
{
Expand Down Expand Up @@ -164,7 +169,7 @@ public async Task<InductionImportResult> ImportAsync(StreamReader csvReaderStrea

//increase failurecount if row is processable or if there are validation failures
//else increase success counter
if (validationFailures.ValidationFailures.Any() || validationFailures.Errors.Any())
if (validationFailures.Errors.Any())
{
failureRowCount++;
}
Expand All @@ -186,7 +191,7 @@ public async Task<InductionImportResult> ImportAsync(StreamReader csvReaderStrea
InductionPeriodId = inductionPeriodId,
DuplicateStatus = null,
FailureMessage = itrFailureMessage.ToString(),
StatusCode = string.IsNullOrEmpty(itrFailureMessage.ToString()) ? dfeta_integrationtransactionrecord_StatusCode.Success : dfeta_integrationtransactionrecord_StatusCode.Fail,
StatusCode = validationFailures.Errors.Count == 0 ? dfeta_integrationtransactionrecord_StatusCode.Success : dfeta_integrationtransactionrecord_StatusCode.Fail,
RowData = ConvertToCSVString(row),
FileName = fileName
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Globalization;
using System.Text;
using CsvHelper;
using CsvHelper.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Xrm.Sdk.Query;
using TeachingRecordSystem.Core.DataStore.Postgres;
Expand All @@ -27,7 +28,11 @@ public QtsImporter(ICrmQueryDispatcher crmQueryDispatcher, ILogger<InductionImpo

public async Task<QtsImportResult> ImportAsync(StreamReader csvReaderStream, string fileName)
{
using var csv = new CsvReader(csvReaderStream, CultureInfo.InvariantCulture);
var csvConfig = new CsvConfiguration(CultureInfo.InvariantCulture)
{
TrimOptions = TrimOptions.Trim
};
using var csv = new CsvReader(csvReaderStream, csvConfig);
var records = csv.GetRecords<EwcWalesQtsFileImportData>().ToList();
var totalRowCount = 0;
var successCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ public async Task EwcWalesImportJobInduction_WithInvalidEmployerCode_ReturnsExpe
{
// Arrange
var expectedTotalRowCount = 1;
var expectedSuccessCount = 0;
var expectedSuccessCount = 1;
var expectedDuplicateRowCount = 0;
var expectedFailureRowCount = 1;
var expectedFailureRowCount = 0;
var person = await TestData.CreatePersonAsync(x => x.WithTrn());
var trn1 = person.Trn;
var inductionStartDate = new DateTime(2024, 05, 01);
Expand All @@ -470,7 +470,7 @@ public async Task EwcWalesImportJobInduction_WithInvalidEmployerCode_ReturnsExpe
item1 =>
{
Assert.Contains($"Organisation with Induction Body Code {invalidEmployeCode} was not found.", item1.dfeta_FailureMessage);
Assert.Equal(dfeta_integrationtransactionrecord_StatusCode.Fail, item1.StatusCode);
Assert.Equal(dfeta_integrationtransactionrecord_StatusCode.Success, item1.StatusCode);
});
Assert.NotNull(induction);
Assert.Equal(expectedTotalRowCount, integrationTransaction.dfeta_TotalCount);
Expand Down

0 comments on commit d788bd0

Please sign in to comment.