diff --git a/ElectronicObserver/Data/PoiDbSubmission/PoiDbSubmissionResources.en.resx b/ElectronicObserver/Data/PoiDbSubmission/PoiDbSubmissionResources.en.resx
new file mode 100644
index 000000000..15ad8210f
--- /dev/null
+++ b/ElectronicObserver/Data/PoiDbSubmission/PoiDbSubmissionResources.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
+
+
+ PoiDB error
+
+
\ No newline at end of file
diff --git a/ElectronicObserver/Data/PoiDbSubmission/PoiDbSubmissionResources.resx b/ElectronicObserver/Data/PoiDbSubmission/PoiDbSubmissionResources.resx
new file mode 100644
index 000000000..29ebcf45f
--- /dev/null
+++ b/ElectronicObserver/Data/PoiDbSubmission/PoiDbSubmissionResources.resx
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ PoiDBエラー
+
+
\ No newline at end of file
diff --git a/ElectronicObserver/Data/PoiDbSubmission/PoiDbSubmissionService.cs b/ElectronicObserver/Data/PoiDbSubmission/PoiDbSubmissionService.cs
index 6ba8e1db9..57bc0c0ab 100644
--- a/ElectronicObserver/Data/PoiDbSubmission/PoiDbSubmissionService.cs
+++ b/ElectronicObserver/Data/PoiDbSubmission/PoiDbSubmissionService.cs
@@ -37,9 +37,6 @@ public PoiDbSubmissionService(KCDatabase kcDatabase)
private void OnConfigurationChanged()
{
- // disable poi till we can make it work
- return;
-
if (Configuration.Config.DataSubmission.SendDataToPoiPreview)
{
SubscribeToApis();
@@ -291,6 +288,6 @@ private static void UnsubscribeFromRouteApis(PoiDbRouteSubmissionService routeSu
private static void LogError(Exception e)
{
- Logger.Add(2, "PoiDB error", e);
+ Logger.Add(2, PoiDbSubmissionResources.Error, e);
}
}
diff --git a/ElectronicObserver/Data/PoiDbSubmission/PoiHttpClient.cs b/ElectronicObserver/Data/PoiDbSubmission/PoiHttpClient.cs
index 3e28122b2..4262656bd 100644
--- a/ElectronicObserver/Data/PoiDbSubmission/PoiHttpClient.cs
+++ b/ElectronicObserver/Data/PoiDbSubmission/PoiHttpClient.cs
@@ -16,12 +16,30 @@ public class PoiHttpClient
BaseAddress = new("http://report2.kcwiki.org:17027/api/report/"),
};
+ private static async Task EnsureSuccessStatusCode(HttpResponseMessage response)
+ {
+#if DEBUG
+ if (response.RequestMessage?.Content is HttpContent content)
+ {
+ string requestBody = await content.ReadAsStringAsync();
+ Utility.Logger.Add(3, requestBody);
+ }
+#endif
+
+ if (response.IsSuccessStatusCode) return;
+
+ string responseMessage = await response.Content.ReadAsStringAsync();
+ string errorMessage = $"{response.ReasonPhrase} {responseMessage}";
+
+ throw new HttpRequestException(errorMessage);
+ }
+
public async Task Quest(PoiDbQuestSubmissionData submission)
{
using HttpClient client = MakeHttpClient();
HttpResponseMessage response = await client.PostAsJsonAsync("quest", submission);
- response.EnsureSuccessStatusCode();
+ await EnsureSuccessStatusCode(response);
}
public async Task Battle(PoiDbBattleSubmissionData submission)
@@ -29,7 +47,7 @@ public async Task Battle(PoiDbBattleSubmissionData submission)
using HttpClient client = MakeHttpClient();
HttpResponseMessage response = await client.PostAsJsonAsync("battle", submission);
- response.EnsureSuccessStatusCode();
+ await EnsureSuccessStatusCode(response);
}
public async Task FriendFleet(Dictionary> submission)
@@ -37,15 +55,20 @@ public async Task FriendFleet(Dictionary>
using HttpClient client = MakeHttpClient();
HttpResponseMessage response = await client.PostAsJsonAsync("friendly_info", submission);
- response.EnsureSuccessStatusCode();
+ await EnsureSuccessStatusCode(response);
}
public async Task AirDefense(Dictionary submission)
{
using HttpClient client = MakeHttpClient();
- HttpResponseMessage response = await client.PostAsJsonAsync("air_base_attack", submission);
- response.EnsureSuccessStatusCode();
+ MultipartFormDataContent formData = new()
+ {
+ JsonContent.Create(submission),
+ };
+
+ HttpResponseMessage response = await client.PostAsync("air_base_attack", formData);
+ await EnsureSuccessStatusCode(response);
}
public async Task Route(PoiDbRouteSubmissionData submission)
@@ -53,6 +76,6 @@ public async Task Route(PoiDbRouteSubmissionData submission)
using HttpClient client = MakeHttpClient();
HttpResponseMessage response = await client.PostAsJsonAsync("next_way_v2", submission);
- response.EnsureSuccessStatusCode();
+ await EnsureSuccessStatusCode(response);
}
}
diff --git a/ElectronicObserver/Window/Settings/DataSubmission/ConfigurationDataSubmissionUserControl.xaml b/ElectronicObserver/Window/Settings/DataSubmission/ConfigurationDataSubmissionUserControl.xaml
index fc2f5435f..f093e9cc2 100644
--- a/ElectronicObserver/Window/Settings/DataSubmission/ConfigurationDataSubmissionUserControl.xaml
+++ b/ElectronicObserver/Window/Settings/DataSubmission/ConfigurationDataSubmissionUserControl.xaml
@@ -38,11 +38,7 @@
-
+