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 @@ -40,6 +40,7 @@ public async Task SupportRequestHandlerTests_UploadLogsRequest_NoLogs_Handle_IsH
public async Task SupportRequestHandlerTests_UploadLogsRequest_LogsToUpload_Only10Messages_Handle_IsHandled()
{
Mock<IConfigurationService> configurationService = new Mock<IConfigurationService>();
configurationService.Setup(c => c.PostDiagnosticLogs(It.IsAny<String>(), It.IsAny<List<Models.LogMessage>>(), It.IsAny<CancellationToken>())).ReturnsAsync(Result.Success());
Func<Boolean, IConfigurationService> configurationServiceResolver = new Func<bool, IConfigurationService>((param) =>
{
return configurationService.Object;
Expand Down Expand Up @@ -76,6 +77,7 @@ public async Task SupportRequestHandlerTests_UploadLogsRequest_LogsToUpload_Only
public async Task SupportRequestHandlerTests_UploadLogsRequest_LogsToUpload_15Messages_Handle_IsHandled()
{
Mock<IConfigurationService> configurationService = new Mock<IConfigurationService>();
configurationService.Setup(c => c.PostDiagnosticLogs(It.IsAny<String>(), It.IsAny<List<Models.LogMessage>>(), It.IsAny<CancellationToken>())).ReturnsAsync(Result.Success());
Func<Boolean, IConfigurationService> configurationServiceResolver = new Func<bool, IConfigurationService>((param) =>
{
return configurationService.Object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public MyAccountPageViewModelTests() {
public async Task MyAccountPageViewModel_Initialise_IsInitialised() {
this.ApplicationThemeService.Setup(s => s.GetDarkThemeEnabled()).ReturnsAsync(true);
this.Mediator.Setup(m => m.Send(It.IsAny<MerchantQueries.GetMerchantDetailsQuery>(), It.IsAny<CancellationToken>())).ReturnsAsync(Result.Success( TestData.MerchantDetailsModel));

this.ApplicationCache.Setup(a => a.GetLastLoginDate()).Returns(DateTime.Now);
await this.ViewModel.Initialise(CancellationToken.None);

this.ViewModel.MerchantName.ShouldBe(TestData.MerchantDetailsModel.MerchantName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace TransactionProcessor.Mobile.BusinessLogic.Models;
[ExcludeFromCodeCoverage]
public class PerformVoucherIssueRequestModel
{
// TODO: should we have a base transaction request model ?

#region Properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ public async Task<Result> Handle(SupportCommands.UploadLogsCommand request, Canc
}));


await configurationService.PostDiagnosticLogs(request.DeviceIdentifier, logMessageModels, CancellationToken.None);
Result result = await configurationService.PostDiagnosticLogs(request.DeviceIdentifier, logMessageModels, CancellationToken.None);

if (result.IsFailed) {
// We have had a failure posting the logs so we will stop trying to upload any more logs
return result;
}

// Clear the logs that have been uploaded
await this.DatabaseContext.RemoveUploadedMessages(logEntries);

}

return Result.Success();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
String GetConfigHostUrl();

void SetConfigHostUrl(String value, MemoryCacheEntryOptions options = default);

Check warning on line 16 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.

Boolean GetUseTrainingMode();

Expand Down Expand Up @@ -42,6 +42,10 @@
Decimal GetMerchantBalance();

void SetMerchantBalance(Decimal value, MemoryCacheEntryOptions options = default);

DateTime GetLastLoginDate();

void SetLastLoginDate(DateTime value, MemoryCacheEntryOptions options = default);
}

[ExcludeFromCodeCoverage]
Expand Down Expand Up @@ -94,7 +98,7 @@
}

public void SetConfigHostUrl(String value,
MemoryCacheEntryOptions options = default)

Check warning on line 101 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.
{
this.Set("ConfigHostUrl", value, options);
}
Expand All @@ -105,25 +109,25 @@
}

public void SetAccessToken(TokenResponseModel value,
MemoryCacheEntryOptions options = default)

Check warning on line 112 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.
{
this.Set("AccessToken", value, options);
}

public void SetConfiguration(Configuration value,
MemoryCacheEntryOptions options = default)

Check warning on line 118 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.
{
this.Set("Configuration", value, options);
}

public void SetContractProducts(List<ContractProductModel> value,
MemoryCacheEntryOptions options = default)

Check warning on line 124 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.
{
this.Set("ContractProducts", value, options);
}

public void SetIsLoggedIn(Boolean value,
MemoryCacheEntryOptions options = default)

Check warning on line 130 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.
{
this.Set("isLoggedIn", value, options);
}
Expand All @@ -134,7 +138,7 @@
}

public void SetMerchantDetails(MerchantDetailsModel value,
MemoryCacheEntryOptions options = default)

Check warning on line 141 in TransactionProcessor.Mobile.BusinessLogic/Services/ApplicationCache.cs

View workflow job for this annotation

GitHub Actions / Verify version parsing + trial publish (Windows)

Cannot convert null literal to non-nullable reference type.
{
this.Set("MerchantDetails", value, options);
}
Expand All @@ -148,6 +152,15 @@
this.Set("MerchantBalance", value, options);
}

public DateTime GetLastLoginDate() {
return this.TryGetValue<DateTime>("LastLoginDate");
}

public void SetLastLoginDate(DateTime value,
MemoryCacheEntryOptions options = default) {
this.Set("LastLoginDate", value, options);
}

public void SetUseTrainingMode(Boolean value,
MemoryCacheEntryOptions options = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void StopRefreshing()

private async Task RefreshLoopAsync(CancellationToken token)
{
using PeriodicTimer timer = new PeriodicTimer(TimeSpan.FromSeconds(30));
using PeriodicTimer timer = new(TimeSpan.FromSeconds(30));

try
{
Expand All @@ -52,6 +52,7 @@ private async Task RefreshLoopAsync(CancellationToken token)
}
catch (OperationCanceledException)
{
// Nothing here but the task was cancelled, which is expected when stopping the refresher.
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface IConfigurationService
Task<Result<Configuration>> GetConfiguration(String deviceIdentifier,
CancellationToken cancellationToken);

Task PostDiagnosticLogs(String deviceIdentifier,
Task<Result> PostDiagnosticLogs(String deviceIdentifier,
List<LogMessage> logMessages,
CancellationToken cancellationToken);
}
Expand Down Expand Up @@ -92,7 +92,7 @@ public async Task<Result<Configuration>> GetConfiguration(String deviceIdentifie
}
}

public async Task PostDiagnosticLogs(String deviceIdentifier,
public async Task<Result> PostDiagnosticLogs(String deviceIdentifier,
List<LogMessage> logMessages,
CancellationToken cancellationToken)
{
Expand All @@ -105,8 +105,8 @@ public async Task PostDiagnosticLogs(String deviceIdentifier,
};
StringContent content = new(StringSerialiser.Serialise(container), Encoding.UTF8, "application/json");

Result? result = await this.Post(requestUri, content, cancellationToken);
Result result = await this.Post(requestUri, content, cancellationToken);

// TODO: return the result to the caller so that we can retry if it fails (and also log any errors that occur here)
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ public async Task<Result<Configuration>> GetConfiguration(String deviceIdentifie
});
}

public async Task PostDiagnosticLogs(String deviceIdentifier,
public async Task<Result> PostDiagnosticLogs(String deviceIdentifier,
List<LogMessage> logMessages,
CancellationToken cancellationToken) {
// Do nothing
return Result.Success();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ private async Task Logon(){

await this.WriteTimingTrace(sw, "After SetIsLoggedIn");
await this.NavigationService.GoToHome();

// Cache the last login date
this.ApplicationCache.SetLastLoginDate(DateTime.Now);
}
catch(ApplicationException aex) {
Logger.LogError("Error during logon", aex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async Task Initialise(CancellationToken cancellationToken) {

this.MerchantName = merchantDetailsResult.Data.MerchantName;

this.LastLogin = DateTime.Now; // TODO: might cache this in the application
this.LastLogin = this.ApplicationCache.GetLastLoginDate();
this.IsDarkThemeEnabled = await this.ApplicationThemeService.GetDarkThemeEnabled();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ private async Task RecipientEmailAddressEntryCompleted()
private async Task IssueVoucher()
{
Logger.LogInformation("IssueVoucher called");
// TODO: Create Command and Send
TransactionCommands.PerformVoucherIssueCommand command = new TransactionCommands.PerformVoucherIssueCommand(DateTime.Now,
this.ProductDetails.ContractId,
this.ProductDetails.ProductId,
Expand Down
2 changes: 1 addition & 1 deletion TransactionProcessor.Mobile/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static MauiApp CreateMauiApp()
}).Services.AddTransient<IDeviceService, DeviceService>()
.AddMemoryCache();

builder.Logging.SetMinimumLevel(LogLevel.Trace);;
builder.Logging.SetMinimumLevel(LogLevel.Trace);

Container = builder.Build();

Expand Down
Loading