diff --git a/.vscode/launch.json b/.vscode/launch.json index e77e0e3..6de13ce 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "VS build PTMagic", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/PTMagic/bin/Debug/netcoreapp2.1/PTMagic.dll", + "program": "${workspaceFolder}/PTMagic/bin/Debug/netcoreapp3.1/PTMagic.dll", "args": [], "cwd": "${workspaceFolder}/PTMagic", "stopAtEntry": false, @@ -28,7 +28,7 @@ "request": "launch", "preLaunchTask": "VS build Monitor", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/Monitor/bin/Debug/netcoreapp2.1/Monitor.dll", + "program": "${workspaceFolder}/Monitor/bin/Debug/netcoreapp3.1/Monitor.dll", "args": [], "cwd": "${workspaceFolder}/Monitor", "stopAtEntry": false, diff --git a/Core/Core.csproj b/Core/Core.csproj index d9476f1..ab8a35b 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -1,23 +1,20 @@ - netcoreapp2.1 + netcoreapp3.1 - - - - - - - - + + + + + + + + - - - diff --git a/Core/Main/PTMagic.cs b/Core/Main/PTMagic.cs index fc5c7ce..181d7e7 100644 --- a/Core/Main/PTMagic.cs +++ b/Core/Main/PTMagic.cs @@ -36,7 +36,6 @@ namespace Core.Main private DateTime _lastSettingFileCheck = Constants.confMinDate; private DateTime _lastVersionCheck = Constants.confMinDate; private DateTime _lastFiatCurrencyCheck = Constants.confMinDate; - private string _lastSetting = ""; private string _activeSettingName = ""; private GlobalSetting _activeSetting = null; private string _defaultSettingName = ""; diff --git a/Core/MarketAnalyzer/BaseAnalyzer.cs b/Core/MarketAnalyzer/BaseAnalyzer.cs index b007201..9cc61c4 100644 --- a/Core/MarketAnalyzer/BaseAnalyzer.cs +++ b/Core/MarketAnalyzer/BaseAnalyzer.cs @@ -26,13 +26,14 @@ namespace Core.MarketAnalyzer request.ContentType = "application/json"; request.UserAgent = "PTMagic.Import"; request.KeepAlive = true; - request.Timeout = 60000; + request.Timeout = 10000; HttpWebResponse httpResponse = null; string jsonString = string.Empty; try { + log.DoLogInfo("Calling URL: " + url); httpResponse = (HttpWebResponse)request.GetResponse(); using (StreamReader jsonReader = new StreamReader(httpResponse.GetResponseStream())) @@ -73,6 +74,11 @@ namespace Core.MarketAnalyzer throw; } + finally + { + // Do any necessary clean up. + if (httpResponse != null) httpResponse.Dispose(); + } } public static Newtonsoft.Json.Linq.JObject GetSimpleJsonObjectFromURL(string url, LogHelper log, bool swallowException) diff --git a/Monitor/Monitor.csproj b/Monitor/Monitor.csproj index b118416..6213b2b 100644 --- a/Monitor/Monitor.csproj +++ b/Monitor/Monitor.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp3.1 @@ -23,10 +23,8 @@ - - - - + + diff --git a/Monitor/Pages/_get/DashboardTop.cshtml.cs b/Monitor/Pages/_get/DashboardTop.cshtml.cs index d01629a..06a63ca 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml.cs +++ b/Monitor/Pages/_get/DashboardTop.cshtml.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Http; using Core.Main; using Core.Main.DataObjects; -using Core.Main.DataObjects.PTMagicData; -using Core.MarketAnalyzer; namespace Monitor.Pages { public class DashboardTopModel : _Internal.BasePageModelSecureAJAX { diff --git a/Monitor/Program.cs b/Monitor/Program.cs index 3e73f7d..4d9066d 100644 --- a/Monitor/Program.cs +++ b/Monitor/Program.cs @@ -4,8 +4,6 @@ using System.Security.Permissions; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Core.Main; -using Core.Helper; -using Microsoft.Extensions.DependencyInjection; namespace Monitor { diff --git a/Monitor/Startup.cs b/Monitor/Startup.cs index 2afd563..b50797d 100644 --- a/Monitor/Startup.cs +++ b/Monitor/Startup.cs @@ -3,9 +3,9 @@ using System.IO; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Diagnostics; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Server.Kestrel.Core; using Core.Main; using System.Runtime.InteropServices; using System.Diagnostics; @@ -41,16 +41,9 @@ namespace Monitor ptMagicBasePath += Path.DirectorySeparatorChar; } - try - { - systemConfiguration = new PTMagicConfiguration(ptMagicBasePath); - } - catch (Exception ex) - { - throw ex; - } + systemConfiguration = new PTMagicConfiguration(ptMagicBasePath); - services.AddMvc(); + services.AddMvc(option => option.EnableEndpointRouting = false); services.AddAntiforgery(o => o.HeaderName = "XSRF-TOKEN"); services.AddSingleton(); services.AddDistributedMemoryCache(); @@ -60,13 +53,18 @@ namespace Monitor options.Cookie.HttpOnly = true; options.Cookie.Name = "PTMagicMonitor" + systemConfiguration.GeneralSettings.Monitor.Port.ToString(); }); + + services.Configure(options => + { + options.AllowSynchronousIO = true; + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { // Register global exception handler - if (env.IsDevelopment()) + if (env.EnvironmentName == "Development") { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); @@ -79,7 +77,7 @@ namespace Monitor // Configure request pipeline app.UseStaticFiles(); app.UseSession(); - app.UseMvc(); + app.UseMvcWithDefaultRoute(); // Open the browser if (systemConfiguration.GeneralSettings.Monitor.OpenBrowserOnStart) OpenBrowser("http://localhost:" + systemConfiguration.GeneralSettings.Monitor.Port.ToString()); diff --git a/PTMagic/PTMagic.csproj b/PTMagic/PTMagic.csproj index 7daa1f1..10054ea 100644 --- a/PTMagic/PTMagic.csproj +++ b/PTMagic/PTMagic.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp3.1 diff --git a/PTMagic/Program.cs b/PTMagic/Program.cs index e6ba5ec..a1c5f3c 100644 --- a/PTMagic/Program.cs +++ b/PTMagic/Program.cs @@ -5,7 +5,7 @@ using System.Security.Permissions; using Core.Helper; using Microsoft.Extensions.DependencyInjection; -[assembly: AssemblyVersion("2.2.10")] +[assembly: AssemblyVersion("3.0.0")] [assembly: AssemblyProduct("PT Magic")] namespace PTMagic