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 @@ -65,8 +65,6 @@ public async Task<Result> Handle(IDomainEvent domainEvent,
return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
}

//private static Int32 TransactionNumber = 0;

/// <summary>
/// Handles the specific domain event.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
// need to now parse the line (based on the file format), this builds the metadata
Dictionary<String, String> transactionMetadata = this.ParseFileLine(fileLine.LineData, fileProfile.FileFormatHandler);

if (transactionMetadata == null)
if (transactionMetadata.Any() == false)
{
// Line failed to parse so record this
fileAggregate.RecordFileLineAsRejected(fileLine.LineNumber, "Invalid Format");
Expand Down Expand Up @@ -360,7 +360,7 @@
return Result.NotFound($"No contracts found for Merchant Id {fileDetails.MerchantId} on estate Id {fileDetails.EstateId}");
}

ContractResponse? contract = null;

Check warning on line 363 in FileProcessor.BusinessLogic/Services/FileProcessorDomainService.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
if (fileProfile.OperatorName == "Voucher")
{
contract = contracts.SingleOrDefault(c => c.Description.Contains(operatorName));
Expand All @@ -375,7 +375,7 @@
return Result.NotFound($"No merchant contract for operator Id {operatorName} found for Merchant Id {merchant.MerchantId}");
}

ContractProduct? product = contract.Products.SingleOrDefault(p => p.Value == null); // TODO: Is this enough or should the name be used and stored in file profile??

Check warning on line 378 in FileProcessor.BusinessLogic/Services/FileProcessorDomainService.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

if (product == null)
{
Expand Down Expand Up @@ -566,7 +566,7 @@
catch (InvalidDataException iex)
{
Logger.LogWarning(iex.Message);
return null;
return new Dictionary<String, String>();
}
}

Expand Down
23 changes: 4 additions & 19 deletions FileProcessor.Client/FileProcessorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public async Task<Result<FileDetails>> GetFile(String accessToken,
Guid estateId,
Guid fileId,
CancellationToken cancellationToken) {
FileDetails response = null;

String requestUri = this.BuildRequestUrl($"/api/files/{fileId}?estateId={estateId}");

try {
Expand All @@ -81,16 +79,14 @@ public async Task<Result<FileDetails>> GetFile(String accessToken,
HandleResponseContent<FileDetails>(result.Data);

// call was successful so now deserialise the body to the response object
response = responseData.Data;
return Result.Success(responseData.Data);
}
catch (Exception ex) {
// An exception has occurred, add some additional information to the message
Exception exception = new Exception($"Error getting file with Id {fileId}.", ex);

throw exception;
}

return Result.Success(response);
}

/// <summary>
Expand All @@ -107,8 +103,6 @@ public async Task<Result<FileImportLog>> GetFileImportLog(String accessToken,
Guid estateId,
Guid? merchantId,
CancellationToken cancellationToken) {
FileImportLog response = null;

String requestUri = this.BuildRequestUrl($"/api/fileImportLogs/{fileImportLogId}?estateId={estateId}");

if (merchantId.HasValue) {
Expand All @@ -133,16 +127,14 @@ public async Task<Result<FileImportLog>> GetFileImportLog(String accessToken,
HandleResponseContent<FileImportLog>(result.Data);

// call was successful so now deserialise the body to the response object
response = responseData.Data;
return Result.Success(responseData.Data);
}
catch (Exception ex) {
// An exception has occurred, add some additional information to the message
Exception exception = new Exception("Error getting file import log.", ex);

throw exception;
}

return Result.Success(response);
}

/// <summary>
Expand All @@ -161,8 +153,6 @@ public async Task<Result<FileImportLogList>> GetFileImportLogs(String accessToke
DateTime endDateTime,
Guid? merchantId,
CancellationToken cancellationToken) {
FileImportLogList response = null;

String requestUri =
this.BuildRequestUrl(
$"/api/fileImportLogs?estateId={estateId}&startDateTime={startDateTime.Date:yyyy-MM-dd}&endDateTime={endDateTime.Date:yyyy-MM-dd}");
Expand All @@ -188,16 +178,14 @@ public async Task<Result<FileImportLogList>> GetFileImportLogs(String accessToke
HandleResponseContent<FileImportLogList>(result.Data);

// call was successful so now deserialise the body to the response object
response = responseData.Data;
return Result.Success(responseData.Data);
}
catch (Exception ex) {
// An exception has occurred, add some additional information to the message
Exception exception = new Exception("Error getting list of file import logs.", ex);

throw exception;
}

return Result.Success(response);
}

/// <summary>
Expand All @@ -214,7 +202,6 @@ public async Task<Result<Guid>> UploadFile(String accessToken,
Byte[] fileData,
UploadFileRequest uploadFileRequest,
CancellationToken cancellationToken) {
Guid response = Guid.Empty;
try {
String requestUri = this.BuildRequestUrl("/api/files");

Expand Down Expand Up @@ -246,16 +233,14 @@ public async Task<Result<Guid>> UploadFile(String accessToken,
HandleResponseContent<Guid>(result.Data);

// call was successful so now deserialise the body to the response object
response = responseData.Data;
return Result.Success(responseData.Data);
}
catch (Exception ex) {
// An exception has occurred, add some additional information to the message
Exception exception = new Exception($"Error uploading file {fileName}.", ex);

throw exception;
}

return Result.Success(response);
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion FileProcessor/Bootstrapper/ClientRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public ClientRegistry() {
this.RegisterHttpClient<ISecurityServiceClient, SecurityServiceClient>();
this.RegisterHttpClient<ITransactionProcessorClient, TransactionProcessorClient>();

//this.AddSingleton<Func<String, String>>(container => serviceName => { return ConfigurationReader.GetBaseServerUri(serviceName).OriginalString; });
Func<String, String> resolver(IServiceProvider container) => serviceName => { return ConfigurationReader.GetBaseServerUri(serviceName).OriginalString; };

this.AddSingleton<Func<String, String>>(resolver);
Expand Down
5 changes: 1 addition & 4 deletions FileProcessor/Bootstrapper/MiddlewareRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public MiddlewareRegistry()
}
});
// add a custom operation filter which sets default values
//c.OperationFilter<SwaggerDefaultValues>();
//c.ExampleFilters();


//Locate the XML files being generated by ASP.NET...
var directory = new DirectoryInfo(AppContext.BaseDirectory);
var xmlFiles = directory.GetFiles("*.xml");
Expand All @@ -69,7 +67,6 @@ public MiddlewareRegistry()
}
});

//services.AddSwaggerExamplesFromAssemblyOf<SwaggerJsonConverter>();

this.AddAuthentication(options =>
{
Expand Down
7 changes: 4 additions & 3 deletions FileProcessor/Common/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public static IServiceCollection AddInSecureEventStoreClient(
this IServiceCollection services,
Uri address,
Func<HttpMessageHandler>? createHttpMessageHandler = null)

Check warning on line 32 in FileProcessor/Common/Extensions.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
return services.AddEventStoreClient((Action<EventStoreClientSettings>)(options =>
{
Expand Down Expand Up @@ -58,6 +58,9 @@
case TraceEventType.Verbose:
Logger.LogDebug(logMessage);
break;
default:
Logger.LogInformation(logMessage);
break;
}
};

Expand Down Expand Up @@ -102,9 +105,7 @@
};

Func<String, Int32, ISubscriptionRepository> subscriptionRepositoryResolver = Startup.Container.GetInstance<Func<String, Int32, ISubscriptionRepository>>();

EventStoreClientSettings eventStoreClientSettings = EventStoreClientSettings.Create(eventStoreConnectionString);


applicationBuilder.ConfigureSubscriptionService(subscriptionWorkersRoot,
eventStoreConnectionString,
eventHandlerResolvers,
Expand Down
Loading