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
@@ -1,34 +1,5 @@
namespace TransactionProcessor.Mobile.BusinessLogic.Common
{
/*public class IdGenerationService
{
internal delegate Guid GenerateUniqueIdFromObject(Object payload);

internal delegate Guid GenerateUniqueIdFromString(String payload);


private static readonly JsonSerialiser JsonSerialiser = new(() => new JsonSerializerSettings
{
Formatting = Formatting.None
});

private static readonly GenerateUniqueIdFromObject GenerateUniqueId =
data => IdGenerationService.GenerateGuidFromString(IdGenerationService.JsonSerialiser.Serialise(data));

private static readonly GenerateUniqueIdFromString GenerateGuidFromString = uniqueKey => {
using SHA256 sha256Hash = SHA256.Create();
//Generate hash from the key
Byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(uniqueKey));

Byte[] j = bytes.Skip(Math.Max(0, bytes.Count() - 16)).ToArray(); //Take last 16

//Create our Guid.
return new Guid(j);
};

public static Guid GenerateGuid(Object o) => IdGenerationService.GenerateUniqueId(o);
}*/

public static class CorrelationIdProvider
{
private static readonly AsyncLocal<string?> _correlationId = new();
Expand All @@ -47,13 +18,6 @@ public static string CorrelationId
set => _correlationId.Value = value;
}

//public static string? CorrelationId
//{
// get => _correlationId.Value;
// set => _correlationId.Value = value;
//}

//public static void New() => CorrelationId = Guid.NewGuid().ToString();
public static void NewId() => CorrelationId = Guid.NewGuid().ToString();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using System.Diagnostics.CodeAnalysis;

namespace TransactionProcessor.Mobile.BusinessLogic.Models;
//using Microsoft.Maui.Graphics;

[ExcludeFromCodeCoverage]
public class LogMessageModel
{
#region Properties

public DateTime EntryDateTime { get; set; }

public Int32 Id { get; set; }
Expand All @@ -17,20 +14,4 @@ public class LogMessageModel
public String LogLevelString { get; set; }

public String Message { get; set; }

//public Color TextColor {
// get {
// return this.LogLevel switch {
// LogLevel.Debug => Colors.Gray,
// LogLevel.Trace => Colors.Gray,
// LogLevel.Info => Colors.Blue,
// LogLevel.Warn => Colors.Orange,
// LogLevel.Error => Colors.Red,
// LogLevel.Fatal => Colors.Red,
// _ => Colors.Gray
// };
// }
//}

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,7 @@ private String BuildRequestUrl(String route)

return requestUri;
}

//protected override async Task<String> HandleResponse(HttpResponseMessage responseMessage,
// CancellationToken cancellationToken)
//{
// String content = await responseMessage.Content.ReadAsStringAsync();

// if (responseMessage.StatusCode == HttpStatusCode.NotFound)
// {
// // No error as maybe running under CI (which has no internet)
// return content;
// }

// return await base.HandleResponse(responseMessage, cancellationToken);
//}


public async Task<Result<Configuration>> GetConfiguration(String deviceIdentifier,
CancellationToken cancellationToken)
{
Expand All @@ -66,17 +52,6 @@ public async Task<Result<Configuration>> GetConfiguration(String deviceIdentifie
if (apiResponse.IsFailed)
return ResultHelpers.CreateFailure(apiResponse);

//response = new Configuration
//{
// ApplicationUpdateUri = "",
// ClientId = "mobileAppClient",
// ClientSecret = "d192cbc46d834d0da90e8a9d50ded543",
// EnableAutoUpdates = false,
// LogLevel = LogLevel.Debug,
// SecurityServiceUri = "https://192.168.1.86:5001",
// TransactionProcessorAclUri = "http://192.168.1.86:5003",
//};
//return response;
Logger.LogDebug($"Configuration Response is {StringSerialiser.Serialise(apiResponse.Data)}");
Logger.LogDebug($"About to build Configuration");
response = new Configuration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,7 @@ public async Task<Result<Decimal>> GetMerchantBalance(CancellationToken cancella
Logger.LogInformation("About to request merchant balance");
Logger.LogDebug($"Merchant Balance Request details: Access Token {accessToken.AccessToken}");

//MerchantBalanceResponse merchantBalance = new MerchantBalanceResponse {
// AvailableBalance = 0,
// Balance = 0
// };
//await this.EstateClient.GetMerchantBalance(accessToken.AccessToken, estateId, merchantId, cancellationToken);

Logger.LogInformation("Balance for merchant requested successfully");
//Logger.LogDebug($"Merchant Balance Response: [{JsonConvert.SerializeObject(merchantBalance)}]");

return Result.Success(0.0m);
}
catch(Exception ex) {
Expand All @@ -135,24 +127,6 @@ public async Task<Result<MerchantDetailsModel>> GetMerchantDetails(CancellationT
Logger.LogInformation("About to request merchant details");
Logger.LogDebug($"Merchant Details Request details: Access Token {accessToken.AccessToken}");

//HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
//request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.AccessToken);
//var httpResponse = await this.HttpClient.SendAsync(request, cancellationToken);

//// Process the response
//Result<String> content = await this.HandleResponseX(httpResponse, cancellationToken);

//if (content.IsFailed)
//{
// Logger.LogInformation($"GetMerchantContracts failed {content.Status}");
// return Result.Failure(content.Message);
//}

//Logger.LogDebug($"Transaction Response details: Status {httpResponse.StatusCode} Payload {content.Data}");

////ResponseData<MerchantResponse> responseData = this.HandleResponseContent<MerchantResponse>(content.Data);
//MerchantResponse responseData = JsonConvert.DeserializeObject<MerchantResponse>(content.Data);

Result<MerchantResponse>? responseDataResult = await this.Get<MerchantResponse>(requestUri, accessToken.AccessToken, cancellationToken);

if (responseDataResult.IsFailed)
Expand All @@ -171,8 +145,6 @@ public async Task<Result<MerchantDetailsModel>> GetMerchantDetails(CancellationT
NextStatementDate = responseDataResult.Data.NextStatementDate,
LastStatementDate = new DateTime(),
SettlementSchedule = responseDataResult.Data.SettlementSchedule.ToString(),
//AvailableBalance = merchantResponse.AvailableBalance,
//Balance = merchantResponse.Balance,
Contact = new ContactModel {
Name = responseDataResult.Data.Contacts.First().ContactName,
EmailAddress = responseDataResult.Data.Contacts.First().ContactEmailAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ Task ShowInformationToast(String message,
TimeSpan? duration = null,
CancellationToken cancellationToken = default);

//Task<String> ShowPrompt(String title,
// String message,
// String acceptString,
// String cancelString,
// String placeHolder = "",
// Int32 maxLength = -1,
// Keyboard keyboard = null,
// String initialValue = "");

Task ShowWarningToast(String message,
Action? action = null,
String? actionButtonText = "OK",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,8 @@ private async Task Logon(){
Result<List<ContractProductModel>> getMerchantContractProductsResult = await this.GetMerchantContractProducts();
this.HandleResult(getMerchantContractProductsResult);

//await this.WriteTimingTrace(sw, "After GetMerchantContractProducts");
//Result<Decimal> getMerchantBalanceResult = await this.GetMerchantBalance();
//this.HandleResult(getMerchantBalanceResult);

//await this.WriteTimingTrace(sw, "After GetMerchantBalance");
await this.WriteTimingTrace(sw, "After GetMerchantContractProducts");

this.ApplicationCache.SetIsLoggedIn(true);

this.BalanceRefresher.StartRefreshing();
Expand Down
2 changes: 0 additions & 2 deletions TransactionProcessor.Mobile/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ public App(IApplicationThemeService applicationThemeService)
#endif
MainPage = new AppShell();

//RegisterRouteOnce("login", typeof(LoginPage));
//RegisterRouteOnce("home", typeof(HomePage));

RegisterRouteOnce(nameof(MobileTopupSelectOperatorPage), typeof(MobileTopupSelectOperatorPage));
RegisterRouteOnce(nameof(MobileTopupSelectProductPage), typeof(MobileTopupSelectProductPage));
Expand Down
2 changes: 0 additions & 2 deletions TransactionProcessor.Mobile/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public AppShell()
protected override async void OnNavigating(ShellNavigatingEventArgs args)
{
base.OnNavigating(args);

//Logger.LogDebug($"In OnNavigating - Source [{args.Source.ToString()}] {JsonConvert.SerializeObject(args)}");
if (args.Source == ShellNavigationSource.ShellSectionChanged)
{
List<Page> existingPages = Navigation.NavigationStack.ToList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Net.Security;
using banditoth.MAUI.DeviceId;
using SecurityService.Client;
using TransactionMobile.Maui.UIServices;
using TransactionProcessor.Mobile.BusinessLogic.Database;
using TransactionProcessor.Mobile.BusinessLogic.RequestHandlers;
using TransactionProcessor.Mobile.BusinessLogic.Services;
Expand Down Expand Up @@ -186,32 +185,8 @@ public static MauiAppBuilder ConfigureUIServices(this MauiAppBuilder builder) {
}

public static MauiAppBuilder ConfigureRequestHandlers(this MauiAppBuilder builder) {
//builder.Services.AddSingleton<MediatRServiceConfiguration>();
//builder.Services.AddSingleton<ISender, Mediator>();
//builder.Services.AddSingleton<IPublisher, Mediator>();
//builder.Services.AddSingleton<IMediator, Mediator>();
builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(LoginRequestHandler).Assembly));
//builder.Services.AddSingleton<IRequestHandler<GetConfigurationRequest, Result<Configuration>>, LoginRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<LoginRequest, Result<TokenResponseModel>>, LoginRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<RefreshTokenRequest, Result<TokenResponseModel>>, LoginRequestHandler>();

//builder.Services.AddSingleton<IRequestHandler<GetContractProductsRequest, Result<List<ContractProductModel>>>, MerchantRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<GetProductOperators, Result<List<ContractOperatorModel>>>, MerchantRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<GetMerchantBalanceRequest, Result<Decimal>>, MerchantRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<GetMerchantDetailsRequest, Result<MerchantDetailsModel>>, MerchantRequestHandler>();

//builder.Services.AddSingleton<IRequestHandler<PerformMobileTopupRequest, Result<PerformMobileTopupResponseModel>>, TransactionRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<LogonTransactionRequest, Result<PerformLogonResponseModel>>, TransactionRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<PerformVoucherIssueRequest, Result<PerformVoucherIssueResponseModel>>, TransactionRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<PerformReconciliationRequest, Result<PerformReconciliationResponseModel>>, TransactionRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<PerformBillPaymentGetAccountRequest, Result<PerformBillPaymentGetAccountResponseModel>>, TransactionRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<PerformBillPaymentGetMeterRequest, Result<PerformBillPaymentGetMeterResponseModel>>, TransactionRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<PerformBillPaymentMakePostPaymentRequest, Result<PerformBillPaymentMakePaymentResponseModel>>, TransactionRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<PerformBillPaymentMakePrePaymentRequest, Result<PerformBillPaymentMakePaymentResponseModel>>, TransactionRequestHandler>();

//builder.Services.AddSingleton<IRequestHandler<UploadLogsRequest, Boolean>, SupportRequestHandler>();
//builder.Services.AddSingleton<IRequestHandler<ViewLogsRequest, List<LogMessage>>, SupportRequestHandler>();


return builder;
}

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 @@
}).Services.AddTransient<IDeviceService, DeviceService>()
.AddMemoryCache();

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

Check notice on line 34 in TransactionProcessor.Mobile/MauiProgram.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

TransactionProcessor.Mobile/MauiProgram.cs#L34

Remove this empty statement.

Container = builder.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,5 @@ protected override async void OnAppearing()
{
base.OnAppearing();
await this.viewModel.Initialise(CancellationToken.None);

//this.AddressLine2.IsVisible = String.IsNullOrEmpty(viewModel.Address.AddressLine2) switch {
// true => false,
// false => true
//};
//this.AddressLine3.IsVisible = String.IsNullOrEmpty(viewModel.Address.AddressLine3) switch
//{
// true => false,
// false => true
//};
//this.AddressLine4.IsVisible = String.IsNullOrEmpty(viewModel.Address.AddressLine4) switch
//{
// true => false,
// false => true
//};
}
}
19 changes: 2 additions & 17 deletions TransactionProcessor.Mobile/UIServices/DialogService.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using Microsoft.Maui.Controls;
using CommunityToolkit.Maui.Alerts;
using TransactionProcessor.Mobile.BusinessLogic.UIServices;
using TransactionProcessor.Mobile.UIServices;

namespace TransactionMobile.Maui.UIServices
namespace TransactionProcessor.Mobile.UIServices
{
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;

public class DialogService : IDialogService
{
#region Methods
Expand Down Expand Up @@ -53,17 +49,6 @@ await Application.Current.MainPage.DisplaySnackbar(message,
cancellationToken);
}

//public async Task<String> ShowPrompt(String title,
// String message,
// String acceptString,
// String cancelString,
// String placeHolder = "",
// Int32 maxLength = -1,
// Keyboard keyboard = null,
// String initialValue = "") {
// return await Application.Current.MainPage.DisplayPromptAsync(title, message, acceptString, cancelString, placeHolder, maxLength, keyboard, initialValue);
//}

public async Task ShowWarningToast(String message,
Action? action = null,
String? actionButtonText = "OK",
Expand Down
Loading
Loading