|
|
@@ -14,6 +14,7 @@ using InABox.Wpf.Reports;
|
|
|
using InABox.WPF;
|
|
|
using InABox.WPF.Themes;
|
|
|
using PRS.Shared;
|
|
|
+using PRSServer.Forms.Version9Update;
|
|
|
using PRSServices;
|
|
|
using Syncfusion.Licensing;
|
|
|
using Color = System.Windows.Media.Color;
|
|
|
@@ -26,7 +27,7 @@ namespace PRSServer;
|
|
|
/// </summary>
|
|
|
public partial class Configuration : ThemableWindow
|
|
|
{
|
|
|
- private AutoUpdateSettings _settings;
|
|
|
+ private AutoUpdateSettings _autoUpdateSettings;
|
|
|
|
|
|
public Configuration()
|
|
|
{
|
|
|
@@ -52,7 +53,7 @@ public partial class Configuration : ThemableWindow
|
|
|
|
|
|
Progress.ShowModal("Starting...", progress =>
|
|
|
{
|
|
|
- _settings = new LocalConfiguration<AutoUpdateSettings>().Load();
|
|
|
+ _autoUpdateSettings = new LocalConfiguration<AutoUpdateSettings>().Load();
|
|
|
|
|
|
StoreUtils.RegisterClasses();
|
|
|
CoreUtils.RegisterClasses();
|
|
|
@@ -64,7 +65,7 @@ public partial class Configuration : ThemableWindow
|
|
|
CoreUtils.RegisterClasses(typeof(Configuration).Assembly);
|
|
|
|
|
|
Logger.OnLog += MainLogger.Send;
|
|
|
- MainLogger.AddLogger(new LogFileLogger(CoreUtils.GetPath(), false));
|
|
|
+ MainLogger.AddLogger(new LogFileLogger(CoreUtils.GetPath()));
|
|
|
|
|
|
Logger.Send(LogType.Information, "", string.Format("Config Path: {0}", CoreUtils.GetPath()));
|
|
|
|
|
|
@@ -83,6 +84,11 @@ public partial class Configuration : ThemableWindow
|
|
|
Close();
|
|
|
return;
|
|
|
}
|
|
|
+ else if (CheckForVersion9Update())
|
|
|
+ {
|
|
|
+ Close();
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
DatabaseEngine.MoveUpdateFiles();
|
|
|
|
|
|
@@ -91,20 +97,91 @@ public partial class Configuration : ThemableWindow
|
|
|
Servers.Refresh(true, true);
|
|
|
}
|
|
|
|
|
|
+ #region Version 9 Update
|
|
|
+
|
|
|
+ private bool CheckForVersion9Update()
|
|
|
+ {
|
|
|
+ var location = $"{_autoUpdateSettings.Location}/v9";
|
|
|
+ var result = Update.GetRemoteFile($"{GetChannelLocation(location, allowAlpha: true)}/version.txt");
|
|
|
+ if(result.StatusCode == System.Net.HttpStatusCode.NotFound)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var res = MessageWindow.New()
|
|
|
+ .Title("PRS Version 9")
|
|
|
+ .Message("PRS Version 9 is available!")
|
|
|
+ .AddOKButton("Proceed")
|
|
|
+ .AddCancelButton()
|
|
|
+ .Display()
|
|
|
+ .Result;
|
|
|
+ if(res != MessageWindowResult.OK)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var updateDBWindow = new UpdateDatabaseFiles();
|
|
|
+ if(updateDBWindow.ShowDialog() != true)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!MessageWindow.ShowYesNo("Proceed with update to version 9?", "Update?"))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ bool? bOK = null;
|
|
|
+ Progress.ShowModal("Retrieving Update", progress =>
|
|
|
+ {
|
|
|
+ bOK = Update.DownloadAndRunInstaller(
|
|
|
+ location => Update.GetRemoteFile($"{GetChannelLocation(location, allowAlpha: true)}/PRSSetup.exe").RawBytes,
|
|
|
+ BeforeUpdate,
|
|
|
+ true,
|
|
|
+ location,
|
|
|
+ "PRSSetup.exe",
|
|
|
+ progress);
|
|
|
+ });
|
|
|
+ if (bOK is null || bOK == true)
|
|
|
+ {
|
|
|
+ // In this case, the Progress window was closed by the installer, and so we must close our current window.
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageWindow.ShowMessage("Unable to retrieve installer!", "Error");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region Update
|
|
|
|
|
|
- private string GetChannelLocation(string location)
|
|
|
+ private string GetChannelLocation(string location, bool allowAlpha = false)
|
|
|
{
|
|
|
- return _settings.Channel switch
|
|
|
+ if (allowAlpha)
|
|
|
+ {
|
|
|
+ return _autoUpdateSettings.Channel switch
|
|
|
+ {
|
|
|
+ AutoUpdateChannel.Unstable => $"{location}/Alpha",
|
|
|
+ AutoUpdateChannel.PreRelease => $"{location}/PreRelease",
|
|
|
+ AutoUpdateChannel.Stable or _ => $"{location}/Stable",
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- AutoUpdateChannel.PreRelease or AutoUpdateChannel.Unstable => $"{location}/PreRelease",
|
|
|
- AutoUpdateChannel.Stable or _ => $"{location}/Stable",
|
|
|
- };
|
|
|
+ return _autoUpdateSettings.Channel switch
|
|
|
+ {
|
|
|
+ AutoUpdateChannel.PreRelease or AutoUpdateChannel.Unstable => $"{location}/PreRelease",
|
|
|
+ AutoUpdateChannel.Stable or _ => $"{location}/Stable",
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private string GetUpdateLocation()
|
|
|
{
|
|
|
- return _settings?.Location;
|
|
|
+ return _autoUpdateSettings.Location;
|
|
|
}
|
|
|
private string GetLatestVersion(string location)
|
|
|
{
|