public MainWindow() { InitializeComponent(); lastBackup = DateTime.Now; jsonHandler = new JSONHandler(Directory.GetCurrentDirectory()); jsonHandler.SQLBackupUpdate(); jsonHandler.RestartDataUpdate(); jsonHandler.NodeCMDUpdate(); sqlBackup = jsonHandler.SQLBackup; restartInformation = jsonHandler.RestartInformation; nodeCMDInformation = jsonHandler.NodeCMDInformation; mySQLHandler = new MySQLHandler(sqlBackup.Host, sqlBackup.DatabaseName, sqlBackup.User, sqlBackup.Password); if ((jsonHandler.GetServerDirectory() == null || jsonHandler.GetServerDirectory() == "") || (jsonHandler.GetServerConfigDirectory() == null || jsonHandler.GetServerConfigDirectory() == "")) { ServerDirConfig serverDirConfig = new ServerDirConfig(this, jsonHandler); serverDirConfig.ShowDialog(); } CreateSQLBackupControl(); CreateRestartControls(); CreateNodeCMDControls(); Scheduler.Interval = TimeSpan.FromSeconds(60); Scheduler.Tick += Scheduler_Tick; Scheduler.Start(); startServer.Visibility = Visibility.Visible; stopServer.Visibility = Visibility.Collapsed; restartServer.Visibility = Visibility.Collapsed; inputText.Visibility = Visibility.Collapsed; submitInput.Visibility = Visibility.Collapsed; labelConsole.Visibility = Visibility.Collapsed; //Stop(); versionLabel.Content = "Version " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
public MainWindow() { InitializeComponent(); jsonHandler = new JSONHandler(Directory.GetCurrentDirectory()); jsonHandler.SQLBackupUpdate(); jsonHandler.RestartDataUpdate(); jsonHandler.NodeCMDUpdate(); sqlBackup = jsonHandler.SQLBackup; restartInformation = jsonHandler.RestartInformation; nodeCMDInformation = jsonHandler.NodeCMDInformation; mySQLHandler = new MySQLHandler(sqlBackup.Host, sqlBackup.DatabaseName, sqlBackup.User, sqlBackup.Password); while (jsonHandler.GetServerDirectory() == null || jsonHandler.GetServerDirectory() == "") { MessageBoxResult msgResult = System.Windows.MessageBox.Show("Please Select The Server Directory", "FiveM Server Launcher", MessageBoxButton.OKCancel, (MessageBoxImage)MessageBoxIcon.Error); if (msgResult == MessageBoxResult.Cancel) { closing = true; Close(); break; } using (var dialog = new FolderBrowserDialog()) { DialogResult result = dialog.ShowDialog(); jsonHandler.SetServerDirectory(dialog.SelectedPath); } } if (!closing) { while (jsonHandler.GetServerConfigDirectory() == null || jsonHandler.GetServerConfigDirectory() == "") { MessageBoxResult msgResult = System.Windows.MessageBox.Show("Please Select The Server Config Directory", "FiveM Server Launcher", MessageBoxButton.OKCancel, (MessageBoxImage)MessageBoxIcon.Error); if (msgResult == MessageBoxResult.Cancel) { closing = true; Close(); break; } using (var dialog = new OpenFileDialog()) { DialogResult result = dialog.ShowDialog(); jsonHandler.SetServerConfigDirectory(dialog.FileName); } } CreateSQLBackupControl(); CreateRestartControls(); CreateNodeCMDControls(); UIUpdater.Interval = TimeSpan.FromSeconds(0.5); UIUpdater.Tick += UIUpdater_Tick; UIUpdater.Start(); RestartScheduler.Interval = TimeSpan.FromSeconds(60); RestartScheduler.Tick += RestartScheduler_Tick; RestartScheduler.Start(); Stop(); } }