diff --git a/ElectronicObserver/Data/Bonodere/BonodereHttpClient.cs b/ElectronicObserver/Data/Bonodere/BonodereHttpClient.cs index 15a3a552d..01af4ab80 100644 --- a/ElectronicObserver/Data/Bonodere/BonodereHttpClient.cs +++ b/ElectronicObserver/Data/Bonodere/BonodereHttpClient.cs @@ -11,12 +11,14 @@ namespace ElectronicObserver.Data.Bonodere; -public class BonodereHttpClient +public class BonodereHttpClient(BonodereSubmissionTranslationViewModel translations) { private HttpClient? CurrentClient { get; set; } public bool IsReady => CurrentClient is not null; + private BonodereSubmissionTranslationViewModel Translations { get; } = translations; + private static HttpClient MakeHttpClient() => new() { BaseAddress = new("https://bonodere.famluro.es/api/"), @@ -119,7 +121,7 @@ public async Task SubmitData(List data) } else { - Logger.Add(2, "Bonodere submission : Success"); + Logger.Add(2, Translations.Success); } } @@ -131,8 +133,8 @@ private async Task HandleErrorResponse(HttpResponseMessage response) { Logger.Add(2, errorData switch { - { Code: >0 } => $"Bonodere error : {errorData.Message} ({errorData.Code})", - _ => $"Bonodere error : {errorData.Message}", + { Code: >0 } => $"{BonodereSubmissionResources.BonodereError} : {errorData.Message} ({errorData.Code})", + _ => $"{BonodereSubmissionResources.BonodereError} {errorData.Message}", }); } else diff --git a/ElectronicObserver/Data/Bonodere/BonodereSubmissionResources.en.resx b/ElectronicObserver/Data/Bonodere/BonodereSubmissionResources.en.resx index 241085f2d..bf64301f3 100644 --- a/ElectronicObserver/Data/Bonodere/BonodereSubmissionResources.en.resx +++ b/ElectronicObserver/Data/Bonodere/BonodereSubmissionResources.en.resx @@ -117,6 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Bonodere error + + + Bonodere submission : Success + Inconsistant data detected diff --git a/ElectronicObserver/Data/Bonodere/BonodereSubmissionResources.resx b/ElectronicObserver/Data/Bonodere/BonodereSubmissionResources.resx index e4bb1698c..8fb8ff503 100644 --- a/ElectronicObserver/Data/Bonodere/BonodereSubmissionResources.resx +++ b/ElectronicObserver/Data/Bonodere/BonodereSubmissionResources.resx @@ -117,6 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Bonodere エラー + + + ??? (Bonodere submission : Success) + ??? (Inconsistant data detected) diff --git a/ElectronicObserver/Data/Bonodere/BonodereSubmissionService.cs b/ElectronicObserver/Data/Bonodere/BonodereSubmissionService.cs index 656c3789b..ecc7aad60 100644 --- a/ElectronicObserver/Data/Bonodere/BonodereSubmissionService.cs +++ b/ElectronicObserver/Data/Bonodere/BonodereSubmissionService.cs @@ -12,13 +12,14 @@ public class BonodereSubmissionService { private BonodereSubmissionTranslationViewModel BonodereSubmission { get; } - private BonodereHttpClient BonodereClient { get; } = new(); + private BonodereHttpClient BonodereClient { get; } public string Username { get; set; } = ""; public BonodereSubmissionService(BonodereSubmissionTranslationViewModel translations) { BonodereSubmission = translations; + BonodereClient = new(BonodereSubmission); _ = LoginFromSavedToken(); @@ -71,7 +72,7 @@ public async Task SubmitData(List data) if (!IsDataValid(data)) { - Logger.Add(2, $"Bonodere error: {BonodereSubmission.InconsistantDataDetected}"); + Logger.Add(2, $"{BonodereSubmission.Error}: {BonodereSubmission.InconsistantDataDetected}"); return; } @@ -95,8 +96,8 @@ private bool IsDataValid(List data) return true; } - private static void LogError(Exception e) + private void LogError(Exception e) { - Logger.Add(2, "Bonodere error", e); + Logger.Add(2, BonodereSubmission.Error, e); } } diff --git a/ElectronicObserver/Data/Bonodere/BonodereSubmissionTranslationViewModel.cs b/ElectronicObserver/Data/Bonodere/BonodereSubmissionTranslationViewModel.cs index 92a6d5a20..dc2598e39 100644 --- a/ElectronicObserver/Data/Bonodere/BonodereSubmissionTranslationViewModel.cs +++ b/ElectronicObserver/Data/Bonodere/BonodereSubmissionTranslationViewModel.cs @@ -5,4 +5,6 @@ namespace ElectronicObserver.Data.Bonodere; public class BonodereSubmissionTranslationViewModel : TranslationBaseViewModel { public string InconsistantDataDetected => BonodereSubmissionResources.InconsistantDataDetected; + public string Error => BonodereSubmissionResources.BonodereError; + public string Success => BonodereSubmissionResources.BonodereSubmissionSuccess; } diff --git a/ElectronicObserver/Window/Settings/DataSubmission/ConfigurationDataSubmissionViewModel.cs b/ElectronicObserver/Window/Settings/DataSubmission/ConfigurationDataSubmissionViewModel.cs index d37b5e7e0..f6d8ae9bf 100644 --- a/ElectronicObserver/Window/Settings/DataSubmission/ConfigurationDataSubmissionViewModel.cs +++ b/ElectronicObserver/Window/Settings/DataSubmission/ConfigurationDataSubmissionViewModel.cs @@ -92,7 +92,7 @@ private async Task BonodereLogin(SecureString password) { LoginError = ex.Message; - Logger.Add(2, "Bonodere error", ex); + Logger.Add(2, BonodereSubmissionResources.BonodereError, ex); } } diff --git a/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardManager.cs b/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardManager.cs index d81f11093..026d3200c 100644 --- a/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardManager.cs +++ b/ElectronicObserver/Window/Wpf/SenkaLeaderboard/SenkaLeaderboardManager.cs @@ -70,7 +70,7 @@ private void HandleData(string apiname, dynamic data) } catch (Exception ex) { - Logger.Add(2, "Bonodere error", ex); + Logger.Add(2, BonodereSubmissionResources.BonodereError, ex); } finally {