From 6d3bd0c9908672ac8b0289a8a0e0d5ec6d73fc15 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Fri, 23 Jun 2023 13:05:50 +0200 Subject: [PATCH 01/18] Report wrong upgrade data to app center --- .../Translation/DataAndTranslationManager.cs | 5 ++ .../DataAndTranslationIssueReporter.cs | 22 +++++ .../DataIssueLogs/DataIssueAnalytic.cs | 16 ++++ .../DataIssueLogs/WrongUpgradesAnalytic.cs | 15 ++++ .../WrongUpgradesIssueReporter.cs | 87 +++++++++++++++++++ .../Data/EquipmentUpgradeExtensions.cs | 17 ++++ 6 files changed, 162 insertions(+) create mode 100644 ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataAndTranslationIssueReporter.cs create mode 100644 ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataIssueAnalytic.cs create mode 100644 ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesAnalytic.cs create mode 100644 ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs create mode 100644 ElectronicObserver/Utility/Data/EquipmentUpgradeExtensions.cs diff --git a/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs b/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs index df3b5395f..3ee998658 100644 --- a/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs +++ b/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs @@ -1,5 +1,6 @@ using System.IO; using ElectronicObserver.Utility; +using ElectronicObserver.Utility.AppCenter.DataIssueLogs; namespace ElectronicObserver.Data.Translation; @@ -22,9 +23,13 @@ public class DataAndTranslationManager public FitBonusData FitBonus { get; private set; } public EquipmentUpgradeData EquipmentUpgrade { get; private set; } + public DataAndTranslationIssueReporter DataAndTranslationIssueReporter { get; } + public DataAndTranslationManager() { Initialize(); + + DataAndTranslationIssueReporter = new DataAndTranslationIssueReporter(); } public void Initialize() diff --git a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataAndTranslationIssueReporter.cs b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataAndTranslationIssueReporter.cs new file mode 100644 index 000000000..97294f9e6 --- /dev/null +++ b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataAndTranslationIssueReporter.cs @@ -0,0 +1,22 @@ +using ElectronicObserver.Observer; + +namespace ElectronicObserver.Utility.AppCenter.DataIssueLogs; + +public class DataAndTranslationIssueReporter +{ + private WrongUpgradesIssueReporter WrongUpgradesIssueReporter { get; } + + public DataAndTranslationIssueReporter() + { + WrongUpgradesIssueReporter = new(); + + SubscribeToAPI(); + } + + private void SubscribeToAPI() + { + APIObserver api = APIObserver.Instance; + + api.ApiReqKousyou_RemodelSlotList.ResponseReceived += WrongUpgradesIssueReporter.ProcessUpgradeList; + } +} diff --git a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataIssueAnalytic.cs b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataIssueAnalytic.cs new file mode 100644 index 000000000..5f47fe68b --- /dev/null +++ b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataIssueAnalytic.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using Microsoft.AppCenter.Analytics; + +namespace ElectronicObserver.Utility.AppCenter.DataIssueLogs; + +public abstract record DataIssueAnalytic(int DataVersion) +{ + public abstract string Key { get; } + + public abstract Dictionary GetValues(); + + public void ReportIssue() + { + Analytics.TrackEvent(Key, GetValues()); + } +} diff --git a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesAnalytic.cs b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesAnalytic.cs new file mode 100644 index 000000000..207f87800 --- /dev/null +++ b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesAnalytic.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using System.Text.Json; + +namespace ElectronicObserver.Utility.AppCenter.DataIssueLogs; +public record WrongUpgradesAnalytic(int DataVersion, int ShipId, byte Day, List ExpectedUpgrades, List ActualUpgrades) : DataIssueAnalytic(DataVersion) +{ + public override string Key => "WRONGUPGRADES"; + + public override Dictionary GetValues() + { + List data = new() { ShipId.ToString(), Day.ToString(), string.Join(",", ExpectedUpgrades), string.Join(",", ActualUpgrades), DataVersion.ToString() }; + + return new Dictionary { { "data", JsonSerializer.Serialize(data) } }; + } +} diff --git a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs new file mode 100644 index 000000000..f0dead90f --- /dev/null +++ b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -0,0 +1,87 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using ElectronicObserver.Data; +using ElectronicObserver.KancolleApi.Types.ApiReqKousyou.RemodelSlotlist; +using ElectronicObserver.Utility.Data; +using ElectronicObserver.Utility.Mathematics; +using ElectronicObserverTypes; +using ElectronicObserverTypes.Serialization.EquipmentUpgrade; + +namespace ElectronicObserver.Utility.AppCenter.DataIssueLogs; + +public class WrongUpgradesIssueReporter +{ + public void ProcessUpgradeList(string _, dynamic data) + { + // if no helper => ignore + int helperId = KCDatabase.Instance.Fleet.Fleets[1].Members[2]; + if (helperId <= 0) return; + IShipData helper = KCDatabase.Instance.Ships[helperId]; + + List? parsedResponse = ParseResponse(data); + + List expectedUpgrades = EquipmentsThatCanBeUpgradedByCurrentHelper(helper.MasterShip); + + if (CheckForIssue(parsedResponse, expectedUpgrades)) + { + WrongUpgradesAnalytic report = new(SoftwareUpdater.CurrentVersion.EquipmentUpgrades, (int)helper.MasterShip.ShipId, (byte)DateTimeHelper.GetJapanStandardTimeNow().DayOfWeek, + expectedUpgrades.Select(upgrade => upgrade.EquipmentId).ToList(), + parsedResponse.Select(apiData => apiData.ApiSlotId).ToList()); + + report.ReportIssue(); + } + } + + /// + /// Checks for issues + /// + /// true if an issue is detected + private bool CheckForIssue(List actualUpgrades, List expectedUpgrades) + { + // Check data + foreach (APIReqKousyouRemodelSlotlistResponse actualUpgrade in actualUpgrades) + { + if (expectedUpgrades.All(upgSaved => upgSaved.EquipmentId != actualUpgrade.ApiSlotId) && !IsBaseUpgradeEquipment((EquipmentId)actualUpgrade.ApiSlotId)) + { + return true; + } + } + + foreach (EquipmentUpgradeDataModel expectedUpgrade in expectedUpgrades) + { + if (actualUpgrades.All(upgApi => expectedUpgrade.EquipmentId != upgApi.ApiSlotId)) + { + return true; + } + } + + return false; + } + + private List? ParseResponse(dynamic data) + { + if (!data.IsArray) return null; + + return JsonSerializer.Deserialize>(data.ToString()); + } + + private List EquipmentsThatCanBeUpgradedByCurrentHelper(IShipDataMaster helper) + { + KCDatabase db = KCDatabase.Instance; + + return helper.CanUpgradeEquipments(DateTimeHelper.GetJapanStandardTimeNow().DayOfWeek, + db.Translation.EquipmentUpgrade.UpgradeList) + .ToList(); + } + + private bool IsBaseUpgradeEquipment(EquipmentId equipmentId) => equipmentId switch + { + EquipmentId.MainGunSmall_12_7cmTwinGun + or EquipmentId.MainGunMedium_14cmSingleGun + or EquipmentId.Torpedo_61cmQuadrupleTorpedo + or EquipmentId.DepthCharge_Type94DepthChargeProjector + => true, + _ => false + }; +} diff --git a/ElectronicObserver/Utility/Data/EquipmentUpgradeExtensions.cs b/ElectronicObserver/Utility/Data/EquipmentUpgradeExtensions.cs new file mode 100644 index 000000000..086c1d530 --- /dev/null +++ b/ElectronicObserver/Utility/Data/EquipmentUpgradeExtensions.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ElectronicObserverTypes; +using ElectronicObserverTypes.Serialization.EquipmentUpgrade; + +namespace ElectronicObserver.Utility.Data; +public static class EquipmentUpgradeExtensions +{ + public static List CanUpgradeEquipments(this IShipDataMaster ship, DayOfWeek day, List upgradesData) + => upgradesData.Where(upgrade => upgrade.Improvement + .Any(improvement => improvement.Helpers + .Any(helpers => helpers.ShipIds.Contains(ship.ShipID)) + ) + ) + .ToList(); +} From 12a99fe1401be4370516ac477e3f6ebdf75a7106 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Fri, 23 Jun 2023 13:11:09 +0200 Subject: [PATCH 02/18] target type --- .../Data/Translation/DataAndTranslationManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs b/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs index 3ee998658..2dad8d4d3 100644 --- a/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs +++ b/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs @@ -29,7 +29,7 @@ public DataAndTranslationManager() { Initialize(); - DataAndTranslationIssueReporter = new DataAndTranslationIssueReporter(); + DataAndTranslationIssueReporter = new(); } public void Initialize() From 6ae7fad97cc57c10fd9635c8382a136a01f6902c Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Fri, 23 Jun 2023 13:20:14 +0200 Subject: [PATCH 03/18] Sonar --- .../DataIssueLogs/WrongUpgradesIssueReporter.cs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs index f0dead90f..a1cbe4be4 100644 --- a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs +++ b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -40,23 +40,12 @@ public void ProcessUpgradeList(string _, dynamic data) private bool CheckForIssue(List actualUpgrades, List expectedUpgrades) { // Check data - foreach (APIReqKousyouRemodelSlotlistResponse actualUpgrade in actualUpgrades) + if (actualUpgrades.Any(actualUpgrade => expectedUpgrades.All(upgSaved => upgSaved.EquipmentId != actualUpgrade.ApiSlotId) && !IsBaseUpgradeEquipment((EquipmentId)actualUpgrade.ApiSlotId))) { - if (expectedUpgrades.All(upgSaved => upgSaved.EquipmentId != actualUpgrade.ApiSlotId) && !IsBaseUpgradeEquipment((EquipmentId)actualUpgrade.ApiSlotId)) - { - return true; - } + return true; } - foreach (EquipmentUpgradeDataModel expectedUpgrade in expectedUpgrades) - { - if (actualUpgrades.All(upgApi => expectedUpgrade.EquipmentId != upgApi.ApiSlotId)) - { - return true; - } - } - - return false; + return expectedUpgrades.Any(expectedUpgrade => actualUpgrades.All(upgApi => expectedUpgrade.EquipmentId != upgApi.ApiSlotId)); } private List? ParseResponse(dynamic data) From 7505fda866289cca1a47e0146b3efd0031ce0eea Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Sat, 21 Oct 2023 08:29:30 +0200 Subject: [PATCH 04/18] Add url --- ElectronicObserver/App.xaml.cs | 2 ++ .../Translation/DataAndTranslationManager.cs | 2 +- .../DataIssueLogs/DataIssueAnalytic.cs | 16 --------------- .../DataIssueLogs/WrongUpgradesAnalytic.cs | 15 -------------- ElectronicObserver/Utility/Configuration.cs | 5 +++++ .../DataAndTranslationIssueReporter.cs | 2 +- .../DataIssueLogs/WrongUpgradesAnalytic.cs | 20 +++++++++++++++++++ .../WrongUpgradesIssueReporter.cs | 16 +++++++++------ .../ElectronicObserverApiService.cs | 20 +++++++++++++++++++ .../ConfigurationDebugTranslationViewModel.cs | 4 +++- .../ConfigurationDebugUserControl.xaml | 10 ++++++++++ .../Debugging/ConfigurationDebugViewModel.cs | 4 ++++ 12 files changed, 76 insertions(+), 40 deletions(-) delete mode 100644 ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataIssueAnalytic.cs delete mode 100644 ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesAnalytic.cs rename ElectronicObserver/Utility/{AppCenter => ElectronicObserverApi}/DataIssueLogs/DataAndTranslationIssueReporter.cs (85%) create mode 100644 ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesAnalytic.cs rename ElectronicObserver/Utility/{AppCenter => ElectronicObserverApi}/DataIssueLogs/WrongUpgradesIssueReporter.cs (81%) create mode 100644 ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs diff --git a/ElectronicObserver/App.xaml.cs b/ElectronicObserver/App.xaml.cs index 04bbe815d..dcece3e86 100644 --- a/ElectronicObserver/App.xaml.cs +++ b/ElectronicObserver/App.xaml.cs @@ -14,6 +14,7 @@ using ElectronicObserver.Database; using ElectronicObserver.Services; using ElectronicObserver.Utility; +using ElectronicObserver.Utility.ElectronicObserverApi; using ElectronicObserver.ViewModels.Translations; using ElectronicObserver.Window.Control.ShipFilter; using ElectronicObserver.Window.Dialog.EquipmentPicker; @@ -297,6 +298,7 @@ private void ConfigureServices() .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton() // external .AddSingleton(JotTracker()) diff --git a/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs b/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs index 2dad8d4d3..9e824fde9 100644 --- a/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs +++ b/ElectronicObserver/Data/Translation/DataAndTranslationManager.cs @@ -1,6 +1,6 @@ using System.IO; using ElectronicObserver.Utility; -using ElectronicObserver.Utility.AppCenter.DataIssueLogs; +using ElectronicObserver.Utility.ElectronicObserverApi.DataIssueLogs; namespace ElectronicObserver.Data.Translation; diff --git a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataIssueAnalytic.cs b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataIssueAnalytic.cs deleted file mode 100644 index 5f47fe68b..000000000 --- a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataIssueAnalytic.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using Microsoft.AppCenter.Analytics; - -namespace ElectronicObserver.Utility.AppCenter.DataIssueLogs; - -public abstract record DataIssueAnalytic(int DataVersion) -{ - public abstract string Key { get; } - - public abstract Dictionary GetValues(); - - public void ReportIssue() - { - Analytics.TrackEvent(Key, GetValues()); - } -} diff --git a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesAnalytic.cs b/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesAnalytic.cs deleted file mode 100644 index 207f87800..000000000 --- a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesAnalytic.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using System.Text.Json; - -namespace ElectronicObserver.Utility.AppCenter.DataIssueLogs; -public record WrongUpgradesAnalytic(int DataVersion, int ShipId, byte Day, List ExpectedUpgrades, List ActualUpgrades) : DataIssueAnalytic(DataVersion) -{ - public override string Key => "WRONGUPGRADES"; - - public override Dictionary GetValues() - { - List data = new() { ShipId.ToString(), Day.ToString(), string.Join(",", ExpectedUpgrades), string.Join(",", ActualUpgrades), DataVersion.ToString() }; - - return new Dictionary { { "data", JsonSerializer.Serialize(data) } }; - } -} diff --git a/ElectronicObserver/Utility/Configuration.cs b/ElectronicObserver/Utility/Configuration.cs index dc1de462d..4dd9e22e7 100644 --- a/ElectronicObserver/Utility/Configuration.cs +++ b/ElectronicObserver/Utility/Configuration.cs @@ -748,6 +748,11 @@ public class ConfigDebug : ConfigPartBase /// APIリストのパス /// public string APIListPath { get; set; } + + /// + /// Electronic Observer API URL + /// + public string ElectronicObserverApiUrl { get; set; } /// /// エラー発生時に警告音を鳴らすか diff --git a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataAndTranslationIssueReporter.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/DataAndTranslationIssueReporter.cs similarity index 85% rename from ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataAndTranslationIssueReporter.cs rename to ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/DataAndTranslationIssueReporter.cs index 97294f9e6..96857ace5 100644 --- a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/DataAndTranslationIssueReporter.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/DataAndTranslationIssueReporter.cs @@ -1,6 +1,6 @@ using ElectronicObserver.Observer; -namespace ElectronicObserver.Utility.AppCenter.DataIssueLogs; +namespace ElectronicObserver.Utility.ElectronicObserverApi.DataIssueLogs; public class DataAndTranslationIssueReporter { diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesAnalytic.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesAnalytic.cs new file mode 100644 index 000000000..ff040ae23 --- /dev/null +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesAnalytic.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace ElectronicObserver.Utility.ElectronicObserverApi.DataIssueLogs; + +public record EquipmentUpgradeIssueModel +{ + [JsonPropertyName("software_version")] public string SoftwareVersion { get; set; } = ""; + + [JsonPropertyName("data_version")] public int DataVersion { get; set; } + + [JsonPropertyName("expected")] public List ExpectedUpgrades { get; set; } = new(); + + [JsonPropertyName("actual")] public List ActualUpgrades { get; set; } = new(); + + [JsonPropertyName("day")] public DayOfWeek Day { get; set; } + + [JsonPropertyName("helperId")] public int HelperId { get; set; } +} diff --git a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs similarity index 81% rename from ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs rename to ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs index a1cbe4be4..5ba71297a 100644 --- a/ElectronicObserver/Utility/AppCenter/DataIssueLogs/WrongUpgradesIssueReporter.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -8,7 +8,7 @@ using ElectronicObserverTypes; using ElectronicObserverTypes.Serialization.EquipmentUpgrade; -namespace ElectronicObserver.Utility.AppCenter.DataIssueLogs; +namespace ElectronicObserver.Utility.ElectronicObserverApi.DataIssueLogs; public class WrongUpgradesIssueReporter { @@ -25,11 +25,15 @@ public void ProcessUpgradeList(string _, dynamic data) if (CheckForIssue(parsedResponse, expectedUpgrades)) { - WrongUpgradesAnalytic report = new(SoftwareUpdater.CurrentVersion.EquipmentUpgrades, (int)helper.MasterShip.ShipId, (byte)DateTimeHelper.GetJapanStandardTimeNow().DayOfWeek, - expectedUpgrades.Select(upgrade => upgrade.EquipmentId).ToList(), - parsedResponse.Select(apiData => apiData.ApiSlotId).ToList()); - - report.ReportIssue(); + EquipmentUpgradeIssueModel report = new() + { + DataVersion = SoftwareUpdater.CurrentVersion.EquipmentUpgrades, + ActualUpgrades = parsedResponse.Select(apiData => apiData.ApiSlotId).ToList(), + ExpectedUpgrades = expectedUpgrades.Select(upgrade => upgrade.EquipmentId).ToList(), + Day = DateTimeHelper.GetJapanStandardTimeNow().DayOfWeek, + SoftwareVersion = SoftwareInformation.VersionEnglish, + HelperId = (int)helper.MasterShip.ShipId + }; } } diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs new file mode 100644 index 000000000..fb3b1b4b7 --- /dev/null +++ b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs @@ -0,0 +1,20 @@ +using System.IO; +using System.Net.Http; +using System.Net.Http.Json; +using System.Threading.Tasks; + +namespace ElectronicObserver.Utility.ElectronicObserverApi; + +public class ElectronicObserverApiService +{ + private HttpClient Client { get; } = new(); + + private string Url => Configuration.Config.Debug.ElectronicObserverApiUrl; + + public async Task PostJson(string route, T data) + { + if (string.IsNullOrEmpty(Url)) return; + + await Client.PostAsJsonAsync(Path.Combine(Url, route), data); + } +} diff --git a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugTranslationViewModel.cs b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugTranslationViewModel.cs index 26c9f5deb..ce4980333 100644 --- a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugTranslationViewModel.cs +++ b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugTranslationViewModel.cs @@ -9,7 +9,9 @@ public class ConfigurationDebugTranslationViewModel : TranslationBaseViewModel public string Debug_LoadAPIListOnLoad => Properties.Window.Dialog.DialogConfiguration.Debug_LoadAPIListOnLoad; public string Debug_LoadAPIListOnLoadToolTip => Properties.Window.Dialog.DialogConfiguration.Debug_LoadAPIListOnLoadToolTip; - + + public string Debug_ElectronicObserverApiUrl => Properties.Window.Dialog.DialogConfiguration.Debug_ElectronicObserverApiUrl; + public string Debug_EnableDebugMenu => Properties.Window.Dialog.DialogConfiguration.Debug_EnableDebugMenu; public string Debug_EnableDebugMenuToolTip => Properties.Window.Dialog.DialogConfiguration.Debug_EnableDebugMenuToolTip; } diff --git a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml index ea29c36eb..87914c58d 100644 --- a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml +++ b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml @@ -39,5 +39,15 @@ Content="..." /> + + + + + + + + + + diff --git a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugViewModel.cs b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugViewModel.cs index e2ce1cda1..c61b80a6f 100644 --- a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugViewModel.cs +++ b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugViewModel.cs @@ -23,6 +23,8 @@ public partial class ConfigurationDebugViewModel : ConfigurationViewModelBase public string APIListPath { get; set; } + public string ElectronicObserverApiUrl { get; set; } + public bool AlertOnError { get; set; } public ConfigurationDebugViewModel(Configuration.ConfigurationData.ConfigDebug config) @@ -40,6 +42,7 @@ private void Load(Configuration.ConfigurationData.ConfigDebug config) LoadAPIListOnLoad = config.LoadAPIListOnLoad; APIListPath = config.APIListPath; AlertOnError = config.AlertOnError; + ElectronicObserverApiUrl = config.ElectronicObserverApiUrl; } public override void Save() @@ -48,6 +51,7 @@ public override void Save() Config.LoadAPIListOnLoad = LoadAPIListOnLoad; Config.APIListPath = APIListPath; Config.AlertOnError = AlertOnError; + Config.ElectronicObserverApiUrl = ElectronicObserverApiUrl; } [RelayCommand] From b9f1a322263e32469675027d3b3b5ba1c510b909 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Sat, 21 Oct 2023 09:00:52 +0200 Subject: [PATCH 05/18] Post issue --- .../DataIssueLogs/WrongUpgradesIssueReporter.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs index 5ba71297a..106b539a1 100644 --- a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json; +using System.Threading.Tasks; +using CommunityToolkit.Mvvm.DependencyInjection; using ElectronicObserver.Data; using ElectronicObserver.KancolleApi.Types.ApiReqKousyou.RemodelSlotlist; using ElectronicObserver.Utility.Data; @@ -12,8 +14,16 @@ namespace ElectronicObserver.Utility.ElectronicObserverApi.DataIssueLogs; public class WrongUpgradesIssueReporter { + private ElectronicObserverApiService? Api { get; set; } + + public WrongUpgradesIssueReporter() + { + } + public void ProcessUpgradeList(string _, dynamic data) { + ElectronicObserverApiService api = Ioc.Default.GetRequiredService(); + // if no helper => ignore int helperId = KCDatabase.Instance.Fleet.Fleets[1].Members[2]; if (helperId <= 0) return; @@ -34,6 +44,8 @@ public void ProcessUpgradeList(string _, dynamic data) SoftwareVersion = SoftwareInformation.VersionEnglish, HelperId = (int)helper.MasterShip.ShipId }; + + api.PostJson("EquipmentUpgradeIssues", report); } } From 637695d0d7b845c15e9e5dd2c4203d43246d304d Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Sat, 21 Oct 2023 09:22:45 +0200 Subject: [PATCH 06/18] Fixes --- .../DataIssueLogs/WrongUpgradesIssueReporter.cs | 1 - .../Settings/Debugging/ConfigurationDebugUserControl.xaml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs index 106b539a1..d37b20893 100644 --- a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json; -using System.Threading.Tasks; using CommunityToolkit.Mvvm.DependencyInjection; using ElectronicObserver.Data; using ElectronicObserver.KancolleApi.Types.ApiReqKousyou.RemodelSlotlist; diff --git a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml index 87914c58d..6c94374a4 100644 --- a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml +++ b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml @@ -40,10 +40,10 @@ /> - + - + From ca136c16fb87bdf8549916b526c749de3713cde1 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:19:00 +0200 Subject: [PATCH 07/18] Removed useless code and add log --- .../DataIssueLogs/WrongUpgradesIssueReporter.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs index d37b20893..bd9ee5323 100644 --- a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -12,14 +12,7 @@ namespace ElectronicObserver.Utility.ElectronicObserverApi.DataIssueLogs; public class WrongUpgradesIssueReporter -{ - private ElectronicObserverApiService? Api { get; set; } - - public WrongUpgradesIssueReporter() - { - } - - public void ProcessUpgradeList(string _, dynamic data) +{ public void ProcessUpgradeList(string _, dynamic data) { ElectronicObserverApiService api = Ioc.Default.GetRequiredService(); @@ -44,6 +37,7 @@ public void ProcessUpgradeList(string _, dynamic data) HelperId = (int)helper.MasterShip.ShipId }; + Logger.Add(2, "Reported equipment upgrade issue"); api.PostJson("EquipmentUpgradeIssues", report); } } From 1b3bfbc4cf40ead95042f426be5dcb775e366a69 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:23:42 +0200 Subject: [PATCH 08/18] Sonar --- .../DataIssueLogs/WrongUpgradesIssueReporter.cs | 14 +++++--------- .../Debugging/ConfigurationDebugViewModel.cs | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs index bd9ee5323..96719bc0b 100644 --- a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -73,13 +73,9 @@ private List EquipmentsThatCanBeUpgradedByCurrentHelp .ToList(); } - private bool IsBaseUpgradeEquipment(EquipmentId equipmentId) => equipmentId switch - { - EquipmentId.MainGunSmall_12_7cmTwinGun - or EquipmentId.MainGunMedium_14cmSingleGun - or EquipmentId.Torpedo_61cmQuadrupleTorpedo - or EquipmentId.DepthCharge_Type94DepthChargeProjector - => true, - _ => false - }; + private bool IsBaseUpgradeEquipment(EquipmentId equipmentId) => equipmentId is + EquipmentId.MainGunSmall_12_7cmTwinGun or + EquipmentId.MainGunMedium_14cmSingleGun or + EquipmentId.Torpedo_61cmQuadrupleTorpedo or + EquipmentId.DepthCharge_Type94DepthChargeProjector; } diff --git a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugViewModel.cs b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugViewModel.cs index c61b80a6f..205053ca9 100644 --- a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugViewModel.cs +++ b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugViewModel.cs @@ -23,7 +23,7 @@ public partial class ConfigurationDebugViewModel : ConfigurationViewModelBase public string APIListPath { get; set; } - public string ElectronicObserverApiUrl { get; set; } + public string ElectronicObserverApiUrl { get; set; } = ""; public bool AlertOnError { get; set; } From a1ff89e8ab65939f667059402ce71d8a007d288a Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:27:45 +0200 Subject: [PATCH 09/18] Removed log --- .../DataIssueLogs/WrongUpgradesIssueReporter.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs index 96719bc0b..2a5810008 100644 --- a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -37,7 +37,6 @@ public class WrongUpgradesIssueReporter HelperId = (int)helper.MasterShip.ShipId }; - Logger.Add(2, "Reported equipment upgrade issue"); api.PostJson("EquipmentUpgradeIssues", report); } } From b62dbf5e2d04eb27f9286a4332c27cd7292f9fd9 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:31:48 +0200 Subject: [PATCH 10/18] Removed warning on async post --- .../DataIssueLogs/WrongUpgradesIssueReporter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs index 2a5810008..e16f90724 100644 --- a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -37,7 +37,9 @@ public class WrongUpgradesIssueReporter HelperId = (int)helper.MasterShip.ShipId }; +#pragma warning disable CS4014 api.PostJson("EquipmentUpgradeIssues", report); +#pragma warning restore CS4014 } } From e33628da66c521cf81a4b3e06b913475d5bf5e92 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Tue, 24 Oct 2023 19:28:11 +0200 Subject: [PATCH 11/18] weird --- .../DataIssueLogs/WrongUpgradesIssueReporter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs index e16f90724..4e4686c02 100644 --- a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -12,7 +12,8 @@ namespace ElectronicObserver.Utility.ElectronicObserverApi.DataIssueLogs; public class WrongUpgradesIssueReporter -{ public void ProcessUpgradeList(string _, dynamic data) +{ + public void ProcessUpgradeList(string _, dynamic data) { ElectronicObserverApiService api = Ioc.Default.GetRequiredService(); From e8764fbba7882a02ba5f8b698290632f00368b0a Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Tue, 24 Oct 2023 20:19:32 +0200 Subject: [PATCH 12/18] wrong ship index --- .../DataIssueLogs/WrongUpgradesIssueReporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs index 4e4686c02..e11fdf35e 100644 --- a/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/DataIssueLogs/WrongUpgradesIssueReporter.cs @@ -18,7 +18,7 @@ public void ProcessUpgradeList(string _, dynamic data) ElectronicObserverApiService api = Ioc.Default.GetRequiredService(); // if no helper => ignore - int helperId = KCDatabase.Instance.Fleet.Fleets[1].Members[2]; + int helperId = KCDatabase.Instance.Fleet.Fleets[1].Members[1]; if (helperId <= 0) return; IShipData helper = KCDatabase.Instance.Ships[helperId]; From 643fb90c4f507f0fd03417c2bbee6e4662745429 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:15:38 +0200 Subject: [PATCH 13/18] Equipment upgrade per ship aren't filtered by days --- ElectronicObserver/Utility/Data/EquipmentUpgradeExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ElectronicObserver/Utility/Data/EquipmentUpgradeExtensions.cs b/ElectronicObserver/Utility/Data/EquipmentUpgradeExtensions.cs index 086c1d530..73f9ee562 100644 --- a/ElectronicObserver/Utility/Data/EquipmentUpgradeExtensions.cs +++ b/ElectronicObserver/Utility/Data/EquipmentUpgradeExtensions.cs @@ -10,7 +10,7 @@ public static class EquipmentUpgradeExtensions public static List CanUpgradeEquipments(this IShipDataMaster ship, DayOfWeek day, List upgradesData) => upgradesData.Where(upgrade => upgrade.Improvement .Any(improvement => improvement.Helpers - .Any(helpers => helpers.ShipIds.Contains(ship.ShipID)) + .Any(helpers => helpers.ShipIds.Contains(ship.ShipID) && helpers.CanHelpOnDays.Contains(day)) ) ) .ToList(); From 90a45b591f4d16856e43911b48a5b8cdf1fe96b1 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:14:32 +0200 Subject: [PATCH 14/18] Sonar --- ElectronicObserver/Utility/Configuration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ElectronicObserver/Utility/Configuration.cs b/ElectronicObserver/Utility/Configuration.cs index f5cdb6194..2ebecd682 100644 --- a/ElectronicObserver/Utility/Configuration.cs +++ b/ElectronicObserver/Utility/Configuration.cs @@ -756,11 +756,11 @@ public class ConfigDebug : ConfigPartBase /// APIリストのパス /// public string APIListPath { get; set; } - + /// /// Electronic Observer API URL /// - public string ElectronicObserverApiUrl { get; set; } + public string ElectronicObserverApiUrl { get; set; } = ""; /// /// エラー発生時に警告音を鳴らすか From 0c3b019b0058e78cdbb203e67f1fc8706cb46293 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:19:46 +0200 Subject: [PATCH 15/18] Added tooltip --- .../Properties/Window/Dialog/ConfigurationResources.en.resx | 4 ++++ .../Properties/Window/Dialog/ConfigurationResources.resx | 3 +++ .../Debugging/ConfigurationDebugTranslationViewModel.cs | 3 ++- .../Settings/Debugging/ConfigurationDebugUserControl.xaml | 6 +++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.en.resx b/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.en.resx index c98945cd0..356afdb1d 100644 --- a/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.en.resx +++ b/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.en.resx @@ -759,4 +759,8 @@ When enabled, the preview will be ignored and all compositions will be shown. Electronic Observer API URL + + URL for the Electronic Observer API used to repport data issues. +For more information : https://github.com/ElectronicObserverEN/ElectronicObserverDataAPI + \ No newline at end of file diff --git a/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.resx b/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.resx index 7c06b480d..77d3828da 100644 --- a/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.resx +++ b/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.resx @@ -775,6 +775,9 @@ APIリストの書式や用法はオンラインヘルプを参照してくだ 韓国語 + 七四式EN API URL + + ??? \ No newline at end of file diff --git a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugTranslationViewModel.cs b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugTranslationViewModel.cs index efe79d0fe..17a4be0cb 100644 --- a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugTranslationViewModel.cs +++ b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugTranslationViewModel.cs @@ -9,7 +9,8 @@ public class ConfigurationDebugTranslationViewModel : TranslationBaseViewModel public string Debug_LoadAPIListOnLoad => ConfigurationResources.Debug_LoadAPIListOnLoad; public string Debug_LoadAPIListOnLoadToolTip => ConfigurationResources.Debug_LoadAPIListOnLoadToolTip; - public string Debug_ElectronicObserverApiUrl => ConfigurationResources.Debug_ElectronicObserverApiUrl; + public string Debug_ElectronicObserverApiUrl => ConfigurationResources.Debug_ElectronicObserverApiUrl; + public string Debug_ElectronicObserverApiUrlToolTip => ConfigurationResources.Debug_ElectronicObserverApiUrlToolTip; public string Debug_EnableDebugMenu => ConfigurationResources.Debug_EnableDebugMenu; public string Debug_EnableDebugMenuToolTip => ConfigurationResources.Debug_EnableDebugMenuToolTip; diff --git a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml index 6c94374a4..c6c46115d 100644 --- a/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml +++ b/ElectronicObserver/Window/Settings/Debugging/ConfigurationDebugUserControl.xaml @@ -47,7 +47,11 @@ - + From 82a946957c1307638527e805205a1448b7521acf Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Wed, 25 Oct 2023 21:58:24 +0200 Subject: [PATCH 16/18] Error logging --- ElectronicObserver/App.xaml.cs | 1 + ElectronicObserver/ElectronicObserver.csproj | 6 + .../ElectronicObserverApiResources.en.resx | 123 ++++++++++++++++++ .../ElectronicObserverApiResources.resx | 123 ++++++++++++++++++ .../ElectronicObserverApiService.cs | 24 +++- ...ectronicObserverApiTranslationViewModel.cs | 8 ++ 6 files changed, 283 insertions(+), 2 deletions(-) create mode 100644 ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiResources.en.resx create mode 100644 ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiResources.resx create mode 100644 ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiTranslationViewModel.cs diff --git a/ElectronicObserver/App.xaml.cs b/ElectronicObserver/App.xaml.cs index 4d5a7e992..7447e34d4 100644 --- a/ElectronicObserver/App.xaml.cs +++ b/ElectronicObserver/App.xaml.cs @@ -290,6 +290,7 @@ private void ConfigureServices() .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton() // tools .AddSingleton() .AddSingleton() diff --git a/ElectronicObserver/ElectronicObserver.csproj b/ElectronicObserver/ElectronicObserver.csproj index a761d9296..86ffac622 100644 --- a/ElectronicObserver/ElectronicObserver.csproj +++ b/ElectronicObserver/ElectronicObserver.csproj @@ -184,6 +184,12 @@ + + + Designer + + + true true diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiResources.en.resx b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiResources.en.resx new file mode 100644 index 000000000..4e7be45f4 --- /dev/null +++ b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiResources.en.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Electronic Observer API + + \ No newline at end of file diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiResources.resx b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiResources.resx new file mode 100644 index 000000000..b147ad31b --- /dev/null +++ b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiResources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 七四式EN API + + \ No newline at end of file diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs index fb3b1b4b7..014321f9d 100644 --- a/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Net.Http; using System.Net.Http.Json; using System.Threading.Tasks; @@ -11,10 +12,29 @@ public class ElectronicObserverApiService private string Url => Configuration.Config.Debug.ElectronicObserverApiUrl; + private ElectronicObserverApiTranslationViewModel Translations { get; } + + public ElectronicObserverApiService(ElectronicObserverApiTranslationViewModel translations) + { + Translations = translations; + } + public async Task PostJson(string route, T data) { if (string.IsNullOrEmpty(Url)) return; - await Client.PostAsJsonAsync(Path.Combine(Url, route), data); + try + { + HttpResponseMessage response = await Client.PostAsJsonAsync(Path.Combine(Url, route), data); + + if (!response.IsSuccessStatusCode) + { + throw new Exception($"Error {(int)response.StatusCode} {response.StatusCode}: {response}"); + } + } + catch (Exception ex) + { + Utility.ErrorReporter.SendErrorReport(ex, Translations.ElectronicObserverApi); + } } } diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiTranslationViewModel.cs b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiTranslationViewModel.cs new file mode 100644 index 000000000..7674532b9 --- /dev/null +++ b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiTranslationViewModel.cs @@ -0,0 +1,8 @@ +using ElectronicObserver.ViewModels.Translations; + +namespace ElectronicObserver.Utility.ElectronicObserverApi; + +public class ElectronicObserverApiTranslationViewModel : TranslationBaseViewModel +{ + public string ElectronicObserverApi => ElectronicObserverApiResources.ElectronicObserverApi; +} From c027f45fd5c61532512de6273d430fdae18303df Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Wed, 25 Oct 2023 22:00:40 +0200 Subject: [PATCH 17/18] Removed useless autogenerated code in csproj --- ElectronicObserver/ElectronicObserver.csproj | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ElectronicObserver/ElectronicObserver.csproj b/ElectronicObserver/ElectronicObserver.csproj index 86ffac622..a761d9296 100644 --- a/ElectronicObserver/ElectronicObserver.csproj +++ b/ElectronicObserver/ElectronicObserver.csproj @@ -184,12 +184,6 @@ - - - Designer - - - true true From f7d8d99a0eed5f219baf9f2240d9a91e3f916b32 Mon Sep 17 00:00:00 2001 From: Jebzou <22751386+Jebzou@users.noreply.github.com> Date: Thu, 26 Oct 2023 06:56:49 +0200 Subject: [PATCH 18/18] Sonar & Tooltip --- .../Properties/Window/Dialog/ConfigurationResources.en.resx | 3 +-- .../Properties/Window/Dialog/ConfigurationResources.resx | 2 +- .../ElectronicObserverApi/ElectronicObserverApiService.cs | 5 +---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.en.resx b/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.en.resx index 356afdb1d..9e8923a62 100644 --- a/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.en.resx +++ b/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.en.resx @@ -760,7 +760,6 @@ When enabled, the preview will be ignored and all compositions will be shown.Electronic Observer API URL - URL for the Electronic Observer API used to repport data issues. -For more information : https://github.com/ElectronicObserverEN/ElectronicObserverDataAPI + URL for the Electronic Observer API used to repport data issues. \ No newline at end of file diff --git a/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.resx b/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.resx index 77d3828da..11d24f2bf 100644 --- a/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.resx +++ b/ElectronicObserver/Properties/Window/Dialog/ConfigurationResources.resx @@ -778,6 +778,6 @@ APIリストの書式や用法はオンラインヘルプを参照してくだ 七四式EN API URL - ??? + データ問題を報告するために使用される七四式EN APIのURL \ No newline at end of file diff --git a/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs index 014321f9d..0a8b61d8b 100644 --- a/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs +++ b/ElectronicObserver/Utility/ElectronicObserverApi/ElectronicObserverApiService.cs @@ -27,10 +27,7 @@ public async Task PostJson(string route, T data) { HttpResponseMessage response = await Client.PostAsJsonAsync(Path.Combine(Url, route), data); - if (!response.IsSuccessStatusCode) - { - throw new Exception($"Error {(int)response.StatusCode} {response.StatusCode}: {response}"); - } + response.EnsureSuccessStatusCode(); } catch (Exception ex) {