using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Reflection; using System.Windows; using System.Windows.Media; using Comal.Classes; using Comal.Stores; using InABox.Clients; using InABox.Configuration; using InABox.Core; using InABox.DynamicGrid; using InABox.Logging; using InABox.Reports; using InABox.Scripting; using InABox.Wpf; using InABox.WPF; using InABox.WPF.Themes; using PRS.Shared; 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 { } } Progress.DisplayImage = Properties.Resources.appstore.AsBitmapImage(200, 200); Progress.ShowModal("Starting...", progress => { _settings = new LocalConfiguration().Load(); SyncfusionLicenseProvider.RegisterLicense(CoreUtils.SyncfusionLicense(SyncfusionVersion.v20_2)); StoreUtils.RegisterClasses(); CoreUtils.RegisterClasses(); ComalUtils.RegisterClasses(); ReportUtils.RegisterClasses(); ConfigurationUtils.RegisterClasses(); 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(); CheckForUpdates(); DatabaseEngine.MoveUpdateFiles(); Title = string.Format("PRS Server Manager (v{0})", CoreUtils.GetVersion()); 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 void CheckForUpdates() { Update.CheckForUpdates(GetUpdateLocation, GetLatestVersion, GetReleaseNotes, GetInstaller, BeforeUpdate, true, "PRSSetup.exe"); } #endregion private void Window_Closing(object sender, CancelEventArgs e) { //if (CoreUtils.GetVersion() == "???") // Servers.StopAll(); } } }