From 07cf2e1ed30f8ca1d68fd0081d2053ab67858c6f Mon Sep 17 00:00:00 2001 From: Telmo Rodrigues <660776+query-wow@users.noreply.github.com> Date: Fri, 28 Jan 2022 15:07:43 +0000 Subject: [PATCH] Fixed price alert + directory checks --- TauriTSMAppDataFetcher/MainForm.cs | 20 ++++++++++++++--- .../PriceTracking/PriceTrackerUtils.cs | 22 ++++++++++++++++++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/TauriTSMAppDataFetcher/MainForm.cs b/TauriTSMAppDataFetcher/MainForm.cs index cf088a0..5dc99cd 100644 --- a/TauriTSMAppDataFetcher/MainForm.cs +++ b/TauriTSMAppDataFetcher/MainForm.cs @@ -62,7 +62,7 @@ public MainForm() serverSelectorCombo.DropDownStyle = ComboBoxStyle.DropDownList; TrayIcon.MouseDoubleClick += TrayIcon_MouseDoubleClick; - //FetchAppData(); + FetchAppData(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; @@ -165,6 +165,20 @@ private void FetchAppData() if (Settings.Default.WoWLocation + "" == "") return; + + string folderPath = Path.Combine(Settings.Default.WoWLocation, "Interface", "AddOns", "TradeSkillMaster_AuctionDB"); + try + { + if (!Directory.Exists(folderPath)) + { + Directory.CreateDirectory(folderPath); + } + } + catch + { + MessageBox.Show($"Unable to create path {folderPath}. Try to run this app as admin."); + return; + } try { string baseUrl = "https://tsm.topsoft4u.com/get-tsm-appdata?realms[tauri]={0}&realms[mistblade]={1}"; @@ -196,9 +210,9 @@ private void FetchAppData() wc.DownloadFile(string.Format(calculatedUrl), Path.Combine(Settings.Default.WoWLocation, "Interface", "AddOns", "TradeSkillMaster_AuctionDB", "AppData.lua")); } } - catch (Exception) + catch (Exception ex) { - MessageBox.Show(Path.Combine(Settings.Default.WoWLocation, "Interface", "AddOns", "TradeSkillMaster_AuctionDB") + " folder not found. Please install TSM"); + MessageBox.Show(ex.Message); } } diff --git a/TauriTSMAppDataFetcher/PriceTracking/PriceTrackerUtils.cs b/TauriTSMAppDataFetcher/PriceTracking/PriceTrackerUtils.cs index 375551a..c73ca7a 100644 --- a/TauriTSMAppDataFetcher/PriceTracking/PriceTrackerUtils.cs +++ b/TauriTSMAppDataFetcher/PriceTracking/PriceTrackerUtils.cs @@ -67,7 +67,27 @@ public static void PriceTrackerRequest() lastNotify = DateTime.Now; } }; - wc.UploadStringAsync(new Uri("https://tsm.topsoft4u.com/check-prices"), "POST", json); + + string baseUrl = "https://tsm.topsoft4u.com/check-prices?realms[tauri]={0}&realms[mistblade]={1}"; + string calculatedUrl = null; + Servers selectedRealm = (Servers)Settings.Default.SelectedServer; + switch (selectedRealm) + { + case Servers.Both: + MessageBox.Show("You cannot track items for both realms"); + return; + case Servers.Tauri: + calculatedUrl = string.Format(baseUrl, 1, 0); + break; + case Servers.Stormforge: + calculatedUrl = string.Format(baseUrl, 0, 1); + break; + default: + break; + } + + + wc.UploadStringAsync(new Uri(calculatedUrl), "POST", json); } } catch (Exception ex)