using System.ComponentModel; using System.Linq; using System.Reflection; using System.Windows.Media; using Comal.Classes; using Comal.Stores; using InABox.Configuration; using InABox.Core; using InABox.DynamicGrid; using InABox.Logging; using InABox.Scripting; using InABox.Wpf; using InABox.Wpf.Reports; using InABox.WPF; using InABox.WPF.Themes; using PRS.Shared; using PRSServices; using Syncfusion.Licensing; using Color = System.Windows.Media.Color; using ColorConverter = System.Windows.Media.ColorConverter; namespace PRSServer; /// /// Interaction logic for MainWindow.xaml /// public partial class Configuration : ThemableWindow { private AutoUpdateSettings _settings; public Configuration() { ThemeManager.BaseColor = Colors.CornflowerBlue; var database = PRSService.GetConfiguration().LoadAll().FirstOrDefault(x => x.Value.Type == ServerType.Database).Value; if(database is not null) { var properties = (database.DeserializeServerProperties() as DatabaseServerProperties)!; try { ThemeManager.BaseColor = (Color)ColorConverter.ConvertFromString(properties.ColorScheme); } catch { } } DynamicGridUtils.SelectionBackground = ThemeManager.SelectionBackgroundBrush; DynamicGridUtils.SelectionForeground = ThemeManager.SelectionForegroundBrush; Progress.DisplayImage = Properties.Resources.appstore.AsBitmapImage(200, 200); Progress.ShowModal("Starting...", progress => { _settings = new LocalConfiguration().Load(); StoreUtils.RegisterClasses(); CoreUtils.RegisterClasses(); ComalUtils.RegisterClasses(); PRSSharedUtils.RegisterClasses(); ReportUtils.RegisterClasses(); WPFUtils.RegisterClasses(); ConfigurationUtils.RegisterClasses(); CoreUtils.RegisterClasses(typeof(Configuration).Assembly); Logger.OnLog += MainLogger.Send; MainLogger.AddLogger(new LogFileLogger(CoreUtils.GetPath())); Logger.Send(LogType.Information, "", string.Format("Config Path: {0}", CoreUtils.GetPath())); ScriptDocument.DefaultAssemblies.AddRange( Assembly.Load("RoslynPad.Roslyn.Windows"), Assembly.Load("RoslynPad.Editor.Windows") ); ScriptDocument.Initialize(); }); InitializeComponent(); if (CheckForUpdates()) { Close(); return; } DatabaseEngine.MoveUpdateFiles(); Title = string.Format("PRS Server Manager (v{0})", CoreUtils.GetVersion()); Logger.Send(LogType.Information, "", "Doing refresh"); Servers.Refresh(true, true); } #region Update private string GetChannelLocation(string location) { return _settings.Channel switch { AutoUpdateChannel.PreRelease or AutoUpdateChannel.Unstable => $"{location}/PreRelease", AutoUpdateChannel.Stable or _ => $"{location}/Stable", }; } private string GetUpdateLocation() { return _settings?.Location; } private string GetLatestVersion(string location) { return Update.GetRemoteFile($"{GetChannelLocation(location)}/version.txt").Content; } private string GetReleaseNotes(string location) { return Update.GetRemoteFile($"{location}/Release Notes.txt").Content; } private byte[]? GetInstaller(string location) { return Update.GetRemoteFile($"{GetChannelLocation(location)}/PRSSetup.exe").RawBytes; } private void BeforeUpdate() { Servers.BeforeUpdate(); } private bool CheckForUpdates() { return Update.CheckForUpdates(GetUpdateLocation, GetLatestVersion, GetReleaseNotes, GetInstaller, BeforeUpdate, true, "PRSSetup.exe", true); } #endregion private void Window_Closing(object sender, CancelEventArgs e) { //if (CoreUtils.GetVersion() == "???") // Servers.StopAll(); } }