From a3a3c9f36c96a83af97c23ba65c11af736702642 Mon Sep 17 00:00:00 2001 From: Jos Demmers Date: Sun, 11 Dec 2022 14:30:03 +0100 Subject: [PATCH] Fixed price info for arrows. Fixed compatibility issue third party packages. Improved logging for price requests. Updated third party packages. --- .../NewWorldCompanion.Helpers.csproj | 6 +++--- NewWorldCompanion.Helpers/ScreenCapture.cs | 8 ++++---- .../NewWorldCompanion.Interfaces.csproj | 2 +- .../HttpClientHandler.cs | 20 +++++++++++++++---- .../NewWorldCompanion.Services.csproj | 12 +++++------ .../NewWorldDataStore.cs | 7 ++++++- NewWorldCompanion.Services/PriceManager.cs | 8 -------- .../RelatedPriceManager.cs | 2 +- NewWorldCompanion/NewWorldCompanion.csproj | 12 +++++------ NewWorldCompanion/common.props | 4 ++-- 10 files changed, 45 insertions(+), 36 deletions(-) diff --git a/NewWorldCompanion.Helpers/NewWorldCompanion.Helpers.csproj b/NewWorldCompanion.Helpers/NewWorldCompanion.Helpers.csproj index f56fba7..6392d36 100644 --- a/NewWorldCompanion.Helpers/NewWorldCompanion.Helpers.csproj +++ b/NewWorldCompanion.Helpers/NewWorldCompanion.Helpers.csproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/NewWorldCompanion.Helpers/ScreenCapture.cs b/NewWorldCompanion.Helpers/ScreenCapture.cs index d634539..ac8e03d 100644 --- a/NewWorldCompanion.Helpers/ScreenCapture.cs +++ b/NewWorldCompanion.Helpers/ScreenCapture.cs @@ -28,9 +28,9 @@ public Bitmap GetScreenCapture(IntPtr windowHandle) region.right - region.left, region.bottom - region.top); var bitmapOldHandle = PInvoke.Gdi32.SelectObject(memoryDCHandle, bitmapHandle); - bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle.DangerousGetHandle(), 0, 0, + bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle, 0, 0, region.right - region.left, region.bottom - region.top, - windowDCHandle.DangerousGetHandle(), region.left, region.top, SRCCOPY | CAPTUREBLT); + windowDCHandle, region.left, region.top, SRCCOPY | CAPTUREBLT); try { @@ -71,7 +71,7 @@ public Bitmap GetScreenCapture(IntPtr windowHandle) xPos = Math.Min(Math.Max(xPos - width / 2, region.left), region.right - width); yPos = Math.Min(Math.Max(yPos - height / 2, region.top), region.bottom - height); - bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle.DangerousGetHandle(), 0, 0, width, height, windowDCHandle.DangerousGetHandle(), xPos, yPos, SRCCOPY | CAPTUREBLT); + bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle, 0, 0, width, height, windowDCHandle, xPos, yPos, SRCCOPY | CAPTUREBLT); offsetX = xPos; offsetY = yPos; @@ -118,7 +118,7 @@ public Bitmap GetScreenCapture(IntPtr windowHandle) xPos = Math.Min(Math.Max(xPos - width / 2, region.left), region.right - width); yPos = Math.Min(Math.Max(yPos, region.top), region.bottom - height); - bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle.DangerousGetHandle(), 0, 0, width, height, windowDCHandle.DangerousGetHandle(), xPos, yPos, SRCCOPY | CAPTUREBLT); + bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle, 0, 0, width, height, windowDCHandle, xPos, yPos, SRCCOPY | CAPTUREBLT); try { diff --git a/NewWorldCompanion.Interfaces/NewWorldCompanion.Interfaces.csproj b/NewWorldCompanion.Interfaces/NewWorldCompanion.Interfaces.csproj index f7416f8..b1a30c9 100644 --- a/NewWorldCompanion.Interfaces/NewWorldCompanion.Interfaces.csproj +++ b/NewWorldCompanion.Interfaces/NewWorldCompanion.Interfaces.csproj @@ -9,7 +9,7 @@ - + diff --git a/NewWorldCompanion.Services/HttpClientHandler.cs b/NewWorldCompanion.Services/HttpClientHandler.cs index bcf3b4c..43ded2d 100644 --- a/NewWorldCompanion.Services/HttpClientHandler.cs +++ b/NewWorldCompanion.Services/HttpClientHandler.cs @@ -62,15 +62,27 @@ public HttpClientHandler(IEventAggregator eventAggregator, ILogger GetRequest(string uri) { + HttpResponseMessage? response = null; + string responseAsString = string.Empty; try { - return await _client.GetStringAsync(uri); + response = await _client.GetAsync(uri); + responseAsString = await response.Content.ReadAsStringAsync(); + response.EnsureSuccessStatusCode(); + return responseAsString; } catch (Exception ex) { - _logger.LogError(ex, $"GetRequest({uri})"); - - return string.Empty; + if (response != null) + { + _logger.LogError(ex, $"GetRequest({uri}). Response: {responseAsString}"); + } + else + { + _logger.LogError(ex, $"GetRequest({uri})."); + } + + return responseAsString; } } diff --git a/NewWorldCompanion.Services/NewWorldCompanion.Services.csproj b/NewWorldCompanion.Services/NewWorldCompanion.Services.csproj index 5029fb9..e1c578d 100644 --- a/NewWorldCompanion.Services/NewWorldCompanion.Services.csproj +++ b/NewWorldCompanion.Services/NewWorldCompanion.Services.csproj @@ -20,14 +20,14 @@ - - + + - + - - - + + + diff --git a/NewWorldCompanion.Services/NewWorldDataStore.cs b/NewWorldCompanion.Services/NewWorldDataStore.cs index 4fadd33..c6bd7aa 100644 --- a/NewWorldCompanion.Services/NewWorldDataStore.cs +++ b/NewWorldCompanion.Services/NewWorldDataStore.cs @@ -177,7 +177,7 @@ private void UpdateStoreData() } } - // ItemDefinitionsLocalisation + // ItemDefinitionsLocalisation - Itemdefinitions _itemDefinitionsLocalisation.Clear(); resourcePath = "javelindata_itemdefinitions_master.loc.xml"; resourcePath = assembly.GetManifestResourceNames().Single(str => str.EndsWith(resourcePath)); @@ -208,6 +208,11 @@ private void UpdateStoreData() } } + // ItemDefinitionsLocalisation - Itemdefinitions - Cleanup duplicates + _itemDefinitionsLocalisation.Remove("ArrowBT2_MasterName".ToLower()); + _itemDefinitionsLocalisation.Remove("ArrowBT4_MasterName".ToLower()); + _itemDefinitionsLocalisation.Remove("ArrowBT5_MasterName".ToLower()); + // ItemDefinitionsLocalisation - HouseItems resourcePath = "javelindata_housingitems.loc.xml"; resourcePath = assembly.GetManifestResourceNames().Single(str => str.EndsWith(resourcePath)); diff --git a/NewWorldCompanion.Services/PriceManager.cs b/NewWorldCompanion.Services/PriceManager.cs index 9f7ca42..f40ef20 100644 --- a/NewWorldCompanion.Services/PriceManager.cs +++ b/NewWorldCompanion.Services/PriceManager.cs @@ -294,8 +294,6 @@ public void UpdatePriceData(string itemName) last_checked = DateTime.MinValue, }; } - - //Thread.Sleep(100); } catch (Exception ex) { @@ -307,13 +305,7 @@ public void UpdatePriceData(string itemName) _priceRequestQueue.RemoveAll(item => item.Equals(itemName)); _priceRequestQueueBusy = false; - - var sw = new Stopwatch(); - sw.Start(); - //Task delay = Task.Delay(100); - //await delay; Task.Delay(250).Wait(); - Debug.WriteLine($"async: Running for {sw.Elapsed.TotalSeconds} seconds"); if (_priceRequestQueue.Any()) { diff --git a/NewWorldCompanion.Services/RelatedPriceManager.cs b/NewWorldCompanion.Services/RelatedPriceManager.cs index d715371..9c206d1 100644 --- a/NewWorldCompanion.Services/RelatedPriceManager.cs +++ b/NewWorldCompanion.Services/RelatedPriceManager.cs @@ -75,7 +75,7 @@ public void SetRawResourceRecipeVisibility(string itemIDRawResource, string item { // RawResource exists var rawResource = PersistableOverlayResources.FirstOrDefault(resource => resource.ItemId.Equals(itemIDRawResource)); - if (rawResource.PersistableOverlayResourceRecipes.Any(resource => resource.ItemId.Equals(itemID))) + if (rawResource?.PersistableOverlayResourceRecipes.Any(resource => resource.ItemId.Equals(itemID)) ?? false) { // Recipe resource exists var recipe = rawResource.PersistableOverlayResourceRecipes.FirstOrDefault(resource => resource.ItemId.Equals(itemID)); diff --git a/NewWorldCompanion/NewWorldCompanion.csproj b/NewWorldCompanion/NewWorldCompanion.csproj index 17c77d5..ca7e303 100644 --- a/NewWorldCompanion/NewWorldCompanion.csproj +++ b/NewWorldCompanion/NewWorldCompanion.csproj @@ -35,15 +35,15 @@ - + - - - - + + + + - + diff --git a/NewWorldCompanion/common.props b/NewWorldCompanion/common.props index f38b21d..6c666b4 100644 --- a/NewWorldCompanion/common.props +++ b/NewWorldCompanion/common.props @@ -1,7 +1,7 @@ - 1.0.9.2 - 1.0.9.2 + 1.0.9.3 + 1.0.9.3 Copyright © 2022 net6.0-windows