From 5dde27bad9e4e274e8a48ba976d6fb513fb1dcd5 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 27 Aug 2019 11:00:30 +0200 Subject: [PATCH] (1) Database export, import and creation completed, TODO pwd, (2) Warning message with yes/no confirmation when aborting a cycle. --- Config/Utils.cs | 12 +- TBF/BenchesDlg.cs | 18 +- TBF/Forms/DatabaseSettingsDlg.Designer.cs | 7 - TBF/Forms/DatabaseSettingsDlg.cs | 225 ++++++++++++++-------- TBF/MainWnd.cs | 38 +++- TBF/Resources/Strings.Designer.cs | 66 ++++++- TBF/Resources/Strings.cs.resx | 24 +++ TBF/Resources/Strings.resx | 26 ++- TBF/UiControls/BenchControlPanel.cs | 16 +- 9 files changed, 322 insertions(+), 110 deletions(-) diff --git a/Config/Utils.cs b/Config/Utils.cs index a8840f40d..51b5562c4 100644 --- a/Config/Utils.cs +++ b/Config/Utils.cs @@ -85,7 +85,15 @@ namespace Config /// - /// Extract and return a database name from a MySQL connection string. + /// Extract and return a DB server from a MySQL connection string. + /// + public static string GetDBServer(string connectionString) + { + return GetFromConnectionString(connectionString, new string[] { "SERVER=" }); + } + + /// + /// Extract and return a DB name from a MySQL connection string. /// public static string GetDBName(string connectionString) { @@ -105,7 +113,7 @@ namespace Config /// public static string GetDBPassword(string connectionString) { - return GetFromConnectionString(connectionString, new string[] { "PASSWORD=" }); + return GetFromConnectionString(connectionString, new string[] { "PASSWORD=", "PWD=" }); } /// diff --git a/TBF/BenchesDlg.cs b/TBF/BenchesDlg.cs index b2cc2389c..15e20d028 100644 --- a/TBF/BenchesDlg.cs +++ b/TBF/BenchesDlg.cs @@ -17,6 +17,8 @@ namespace TBF // when 'OK' is pressed. LocalSettings localSettings; + public bool CurrentDBChanged; + /// /// Constructor, initializes the dialog /// @@ -28,6 +30,7 @@ namespace TBF InitializeComponent(); RedrawTestBenchesListBox(); + CurrentDBChanged = false; } private void BenchesDlg_Load(object sender, EventArgs e) @@ -61,8 +64,11 @@ namespace TBF private void addButton_Click(object sender, EventArgs e) { Config.DatabaseSettings bench = new Config.DatabaseSettings(); - Forms.DatabaseSettingsDlg dlg = new Forms.DatabaseSettingsDlg(bench); + Forms.DatabaseSettingsDlg dlg = new Forms.DatabaseSettingsDlg(bench, + Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString, + Config.Data.CurrentBench.WaterMetersDBSettings.ConnectionString); DialogResult dr = dlg.ShowDialog(); + CurrentDBChanged |= dlg.CurrentDBChanged; if (dr == DialogResult.OK) { int nrBenches = @@ -99,8 +105,11 @@ namespace TBF Config.DatabaseSettings ori = localSettings.TestBenches[testBenchesListBox.SelectedIndex]; Config.DatabaseSettings bench = (Config.DatabaseSettings)ori.Clone(); - Forms.DatabaseSettingsDlg dlg = new Forms.DatabaseSettingsDlg(bench); + Forms.DatabaseSettingsDlg dlg = new Forms.DatabaseSettingsDlg(bench, + Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString, + Config.Data.CurrentBench.WaterMetersDBSettings.ConnectionString); DialogResult dr = dlg.ShowDialog(); + CurrentDBChanged |= dlg.CurrentDBChanged; if (dr == DialogResult.OK) { int nrBenches = @@ -126,8 +135,11 @@ namespace TBF { if (testBenchesListBox.SelectedIndex >= 0) { - Forms.DatabaseSettingsDlg dlg = new Forms.DatabaseSettingsDlg(localSettings.TestBenches[testBenchesListBox.SelectedIndex]); + Forms.DatabaseSettingsDlg dlg = new Forms.DatabaseSettingsDlg(localSettings.TestBenches[testBenchesListBox.SelectedIndex], + Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString, + Config.Data.CurrentBench.WaterMetersDBSettings.ConnectionString); DialogResult dr = dlg.ShowDialog(); + CurrentDBChanged |= dlg.CurrentDBChanged; if (dr == DialogResult.OK) { // Update the item name diff --git a/TBF/Forms/DatabaseSettingsDlg.Designer.cs b/TBF/Forms/DatabaseSettingsDlg.Designer.cs index bae975c1c..23da3df25 100644 --- a/TBF/Forms/DatabaseSettingsDlg.Designer.cs +++ b/TBF/Forms/DatabaseSettingsDlg.Designer.cs @@ -134,7 +134,6 @@ namespace TBF.Forms // testConnConfigDbBtn // resources.ApplyResources(this.testConnConfigDbBtn, "testConnConfigDbBtn"); - this.testConnConfigDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.testConnConfigDbBtn.Name = "testConnConfigDbBtn"; this.testConnConfigDbBtn.UseVisualStyleBackColor = true; this.testConnConfigDbBtn.Click += new System.EventHandler(this.testConnConfigDbBtn_Click); @@ -142,7 +141,6 @@ namespace TBF.Forms // testConnResultsDbBtn // resources.ApplyResources(this.testConnResultsDbBtn, "testConnResultsDbBtn"); - this.testConnResultsDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.testConnResultsDbBtn.Name = "testConnResultsDbBtn"; this.testConnResultsDbBtn.UseVisualStyleBackColor = true; this.testConnResultsDbBtn.Click += new System.EventHandler(this.testConnResultsDbBtn_Click); @@ -150,7 +148,6 @@ namespace TBF.Forms // createConfigDbBtn // resources.ApplyResources(this.createConfigDbBtn, "createConfigDbBtn"); - this.createConfigDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.createConfigDbBtn.Name = "createConfigDbBtn"; this.createConfigDbBtn.UseVisualStyleBackColor = true; this.createConfigDbBtn.Click += new System.EventHandler(this.createConfigDbBtn_Click); @@ -158,7 +155,6 @@ namespace TBF.Forms // createResultsDbBtn // resources.ApplyResources(this.createResultsDbBtn, "createResultsDbBtn"); - this.createResultsDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.createResultsDbBtn.Name = "createResultsDbBtn"; this.createResultsDbBtn.UseVisualStyleBackColor = true; this.createResultsDbBtn.Click += new System.EventHandler(this.createResultsDbBtn_Click); @@ -166,7 +162,6 @@ namespace TBF.Forms // testConnUsersDbBtn // resources.ApplyResources(this.testConnUsersDbBtn, "testConnUsersDbBtn"); - this.testConnUsersDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.testConnUsersDbBtn.Name = "testConnUsersDbBtn"; this.testConnUsersDbBtn.UseVisualStyleBackColor = true; this.testConnUsersDbBtn.Click += new System.EventHandler(this.testConnUsersDbBtn_Click); @@ -190,7 +185,6 @@ namespace TBF.Forms // importResultsDbBtn // resources.ApplyResources(this.importResultsDbBtn, "importResultsDbBtn"); - this.importResultsDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.importResultsDbBtn.Name = "importResultsDbBtn"; this.importResultsDbBtn.UseVisualStyleBackColor = true; this.importResultsDbBtn.Click += new System.EventHandler(this.importResultsDbBtn_Click); @@ -198,7 +192,6 @@ namespace TBF.Forms // importConfigDbBtn // resources.ApplyResources(this.importConfigDbBtn, "importConfigDbBtn"); - this.importConfigDbBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.importConfigDbBtn.Name = "importConfigDbBtn"; this.importConfigDbBtn.UseVisualStyleBackColor = true; this.importConfigDbBtn.Click += new System.EventHandler(this.importConfigDbBtn_Click); diff --git a/TBF/Forms/DatabaseSettingsDlg.cs b/TBF/Forms/DatabaseSettingsDlg.cs index f958f142f..81627d3da 100644 --- a/TBF/Forms/DatabaseSettingsDlg.cs +++ b/TBF/Forms/DatabaseSettingsDlg.cs @@ -2,10 +2,9 @@ /// Copyright (c) 2013-2019 Sensus Metering Systems /// using System; -using System.Windows.Forms; -using System.Drawing; -using System.IO; using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms; using log4net; using TBF.Resources; @@ -21,13 +20,21 @@ namespace TBF.Forms // Reference to bench DB settins (not a local copy) Config.DatabaseSettings bench; + string currentConfigDBConnStr; /// Initialized in constructor by the parent + string currentResultsDBConnStr; /// Initialized in constructor by the parent + public bool CurrentDBChanged; /// Set when a current database is modified (erased or imported) + + /// /// Constructor /// /// Test bench database settings - public DatabaseSettingsDlg(Config.DatabaseSettings bench) + public DatabaseSettingsDlg(Config.DatabaseSettings bench, string currentConfigDBConnStr, string currentResultsDBConnStr) { this.bench = bench; + this.currentConfigDBConnStr = currentConfigDBConnStr; + this.currentResultsDBConnStr = currentResultsDBConnStr; + CurrentDBChanged = false; InitializeComponent(); } @@ -161,8 +168,24 @@ namespace TBF.Forms { try { + string connectionString = bench.ProceduresDBSettings.ConnectionString; + string databaseName = Config.Utils.GetDBName(connectionString); + string userName = Config.Utils.GetDBUser(connectionString); + string password = Config.Utils.GetDBPassword(connectionString); /// TODO: Use password + + if (connectionString == currentConfigDBConnStr || connectionString == currentResultsDBConnStr) + { + CurrentDBChanged = true; + } + Cursor.Current = Cursors.WaitCursor; - Config.FluentCommon.CreateEmptyConfigDB(bench.ProceduresDBSettings.DbType, bench.ProceduresDBSettings.ConnectionString); + + log.ErrorFormat("Going to create an empty configuration database '{0}'", databaseName); + ExecuteMySqlCmd(string.Format("DROP DATABASE `{0}`;", databaseName), userName); + ExecuteMySqlCmd(string.Format("CREATE DATABASE `{0}`;", databaseName), userName); + Config.FluentCommon.CreateEmptyConfigDB(bench.ProceduresDBSettings.DbType, connectionString); + log.ErrorFormat("An empty configuration database '{0}' was created", databaseName); + MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification); Cursor.Current = Cursors.Default; DialogResult = DialogResult.None; @@ -186,10 +209,26 @@ namespace TBF.Forms { try { + string connectionString = bench.WaterMetersDBSettings.ConnectionString; + string databaseName = Config.Utils.GetDBName(connectionString); + string userName = Config.Utils.GetDBUser(connectionString); + string password = Config.Utils.GetDBPassword(connectionString); /// TODO: Use password + + if (connectionString == currentConfigDBConnStr || connectionString == currentResultsDBConnStr) + { + CurrentDBChanged = true; + } + Cursor.Current = Cursors.WaitCursor; + + log.ErrorFormat("Going to create an empty results database '{0}'", databaseName); + ExecuteMySqlCmd(string.Format("DROP DATABASE `{0}`;", databaseName), userName); + ExecuteMySqlCmd(string.Format("CREATE DATABASE `{0}`;", databaseName), userName); Results.DB.DbType = bench.WaterMetersDBSettings.DbType; - Results.DB.ConnectionString = bench.WaterMetersDBSettings.ConnectionString; + Results.DB.ConnectionString = connectionString; Results.DB.CreateEmptyDB(); + log.ErrorFormat("An empty results database '{0}' was created", databaseName); + MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification); Cursor.Current = Cursors.Default; DialogResult = DialogResult.None; @@ -207,61 +246,37 @@ namespace TBF.Forms } } - //private void createUsersDbBtn_Click(object sender, EventArgs e) - //{ - // /// Update database connection strings - // if (!UpdateBenchFromUIControls()) return; - - // if (DialogResult.OK == MessageBox.Show(Strings.DB_will_be_overwritten + Environment.NewLine + - // Strings.Do_you_want_to_proceed, Strings.Warning, - // MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)) - // { - // try - // { - // Cursor.Current = Cursors.WaitCursor; - // Users.DB.DbType = bench.UsersDBSettings.DbType; - // Users.DB.ConnectionString = bench.UsersDBSettings.ConnectionString; - // Users.DB.CreateEmptyDB(); - // MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification); - // Cursor.Current = Cursors.Default; - // DialogResult = DialogResult.None; - // } - // catch (Exception exception) - // { - // Cursor.Current = Cursors.Default; - // string msg = Strings.Error_while_creating_DB_Reason + Environment.NewLine + exception.Message; - // if (exception.InnerException != null) - // { - // msg += Environment.NewLine + exception.InnerException.Message; - // } - // MessageBox.Show(msg, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); - // } - // } - //} - - /// /// Configuration database import (UI) /// private void importConfigDbBtn_Click(object sender, EventArgs e) { - /// Update database connection strings + /// Update database connection strings from UI if (!UpdateBenchFromUIControls()) return; - if (MessageBox.Show(Strings.Do_you_want_to_restore_configuration_qm, - string.Empty, - MessageBoxButtons.YesNo, - MessageBoxIcon.Question) == DialogResult.Yes) - { - OpenFileDialog dlg = new OpenFileDialog(); - dlg.InitialDirectory = string.Format(@"C:\TBF\DbBackups\"); - if (dlg.ShowDialog() != DialogResult.OK) return; + string connectionString = bench.ProceduresDBSettings.ConnectionString; - DBImportMessageStart("Importing database with configuration"); - ImportDatabase(Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString, dlg.FileName); - DBImportMessageEnd(); + string server = Config.Utils.GetDBServer(connectionString); + if ((server != "localhost") && (server != "127.0.0.1")) + { + MessageBox.Show(Strings.Remote_database_cannot_be_imported, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information); + return; } + OpenFileDialog dlg = new OpenFileDialog(); + dlg.InitialDirectory = string.Format(@"C:\TBF\DbBackups\"); + if (dlg.ShowDialog() == DialogResult.OK) + { + if (MessageBox.Show(string.Format(Strings.Do_you_want_to_restore_configuration_DB_from_file_0_qm, dlg.FileName), + string.Empty, + MessageBoxButtons.YesNo, + MessageBoxIcon.Question) == DialogResult.Yes) + { + DBImportMessageStart("Importing database with configuration"); + ImportDatabase(connectionString, dlg.FileName); + DBImportMessageEnd(); + } + } } /// @@ -269,21 +284,31 @@ namespace TBF.Forms /// private void importResultsDbBtn_Click(object sender, EventArgs e) { - /// Update database connection strings + /// Update database connection strings from UI if (!UpdateBenchFromUIControls()) return; - if (MessageBox.Show(Strings.Do_you_want_to_restore_results_qm, - string.Empty, - MessageBoxButtons.YesNo, - MessageBoxIcon.Question) == DialogResult.Yes) - { - OpenFileDialog dlg = new OpenFileDialog(); - dlg.InitialDirectory = string.Format(@"C:\TBF\DbBackups\"); - if (dlg.ShowDialog() != DialogResult.OK) return; + string connectionString = bench.WaterMetersDBSettings.ConnectionString; - DBImportMessageStart("Importing database with results"); - ImportDatabase(Config.Data.CurrentBench.WaterMetersDBSettings.ConnectionString, dlg.FileName); - DBImportMessageEnd(); + string server = Config.Utils.GetDBServer(connectionString); + if ((server != "localhost") && (server != "127.0.0.1")) + { + MessageBox.Show(Strings.Remote_database_cannot_be_imported, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.InitialDirectory = string.Format(@"C:\TBF\DbBackups\"); + if (dlg.ShowDialog() == DialogResult.OK) + { + if (MessageBox.Show(string.Format(Strings.Do_you_want_to_restore_results_DB_from_file_0_qm, dlg.FileName), + string.Empty, + MessageBoxButtons.YesNo, + MessageBoxIcon.Question) == DialogResult.Yes) + { + DBImportMessageStart("Importing database with results"); + ImportDatabase(connectionString, dlg.FileName); + DBImportMessageEnd(); + } } } @@ -332,31 +357,65 @@ namespace TBF.Forms try { - Process proc = new Process(); - proc.StartInfo.FileName = @"C:\xampp\mysql\bin\mysql.exe"; - proc.StartInfo.Arguments = string.Format("--user={0} --default-character-set=utf8 --database={2}", userName, password, databaseName); - proc.StartInfo.UseShellExecute = false; /// Must be false to redirect standard input or standard output - proc.StartInfo.RedirectStandardOutput = false; - proc.StartInfo.RedirectStandardInput = true; - proc.StartInfo.CreateNoWindow = false; - //proc.StartInfo.Verb = "runas"; /// To run mysql.exe as administrator - Debug.WriteLine("Ideme na to."); - proc.Start(); + if (connectionString == currentConfigDBConnStr || connectionString == currentResultsDBConnStr) + { + CurrentDBChanged = true; + } - string command = string.Format("SOURCE {0}{1}", inputFileName, Environment.NewLine); - proc.StandardInput.Write(command); - Debug.Write(command); - - proc.StandardInput.Write(string.Format("exit{0}", Environment.NewLine)); - Debug.WriteLine("exit"); - - proc.WaitForExit(); - log.ErrorFormat("Database {0} imported from file {1}", databaseName, inputFileName); + log.ErrorFormat("Going to import database '{0}' from file {1}", databaseName, inputFileName); + ExecuteMySqlCmd(string.Format("DROP DATABASE `{0}`;", databaseName), userName); + ExecuteMySqlCmd(string.Format("CREATE DATABASE `{0}`;", databaseName), userName); + ExecuteMySqlCmd(string.Format("SOURCE {0}", inputFileName), userName, databaseName); + log.ErrorFormat("Database {0} was imported from file {1}", databaseName, inputFileName); } catch (Exception exc) { - log.FatalFormat("Failed to import database {0} from file {1}: {2}", databaseName, inputFileName, exc.Message); + log.FatalFormat("Failed to import database '{0}' from file {1}: {2}", databaseName, inputFileName, exc.Message); } } + + + /// + /// Execute a MySQL command line command without specifying a database + /// + /// MySQL command + /// User name + void ExecuteMySqlCmd(string command, string userName) + { + ExecuteMySqlCmd(command, userName, null); + } + + /// + /// Execute a MySQL command line command, specify database to be used + /// + /// MySQL command + /// User name + /// Database name + void ExecuteMySqlCmd(string command, string userName, string databaseToBeUsed) + { + Process proc = new Process(); + + proc.StartInfo.FileName = @"C:\xampp\mysql\bin\mysql.exe"; + if (string.IsNullOrEmpty(databaseToBeUsed)) + { + proc.StartInfo.Arguments = string.Format("--user={0} --default-character-set=utf8", userName); + } + else + { + proc.StartInfo.Arguments = string.Format("--user={0} --database={1} --default-character-set=utf8", userName, databaseToBeUsed); + } + proc.StartInfo.UseShellExecute = false; /// Must be false to redirect standard input or standard output + proc.StartInfo.RedirectStandardOutput = false; + proc.StartInfo.RedirectStandardInput = true; + proc.StartInfo.CreateNoWindow = false; + //proc.StartInfo.Verb = "runas"; /// To run mysql.exe as administrator + + proc.Start(); + proc.StandardInput.WriteLine(command); + Debug.WriteLine(command); + log.Warn(command); + proc.StandardInput.WriteLine("exit"); + proc.WaitForExit(); + } } } \ No newline at end of file diff --git a/TBF/MainWnd.cs b/TBF/MainWnd.cs index 7e41fe69d..eea6733ed 100644 --- a/TBF/MainWnd.cs +++ b/TBF/MainWnd.cs @@ -494,7 +494,28 @@ namespace TBF private void benchMetrologyTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new MetrologyDlg().ShowDialog(); Cursor = Cursors.Default; } private void proceduresTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new ProceduresDlg().ShowDialog(); Cursor = Cursors.Default; } private void localSettingsTSMItem_Click(object s, EventArgs e) { new PreferencesDlg().ShowDialog(); } - private void databaseSettingsTSMItem_Click(object s, EventArgs e) { new BenchesDlg().ShowDialog(); } + private void aboutTSMItem_Click(object s, EventArgs e) { new Forms.AboutDlg().ShowDialog(); } + + private void databaseSettingsTSMItem_Click(object s, EventArgs e) + { + BenchesDlg dlg = new BenchesDlg(); + dlg.ShowDialog(); + if (dlg.CurrentDBChanged) + { + MessageBox.Show(Strings.Currently_used_database_was_restored + Environment.NewLine + Strings.Program_must_be_closed, + string.Empty, + MessageBoxButtons.OK, + MessageBoxIcon.Information); + + if (TryShutdownTBF()) + { + /// Save settings and exit TBF + UI2Settings(); + Close(); + } + } + } + private void usersTSMItem_Click(object s, EventArgs e) { Users.DB.ConnectionString = Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString; @@ -510,7 +531,6 @@ namespace TBF #endif dlg.ShowDialog(); } - private void aboutTSMItem_Click(object s, EventArgs e) { new Forms.AboutDlg().ShowDialog(); } /// /// Read the database and re-initialize procedureComboBox items. @@ -840,6 +860,13 @@ namespace TBF { string connectionString = Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString; + string server = Config.Utils.GetDBServer(connectionString); + if ((server != "localhost") && (server != "127.0.0.1")) + { + MessageBox.Show(Strings.Remote_database_cannot_be_exported, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + if (MessageBox.Show(Strings.Do_you_want_to_back_up_configuration_qm, string.Empty, MessageBoxButtons.YesNo, @@ -865,6 +892,13 @@ namespace TBF { string connectionString = Config.Data.CurrentBench.WaterMetersDBSettings.ConnectionString; + string server = Config.Utils.GetDBServer(connectionString); + if ((server != "localhost") && (server != "127.0.0.1")) + { + MessageBox.Show(Strings.Remote_database_cannot_be_exported, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + if (MessageBox.Show(Strings.Do_you_want_to_back_up_results_qm, string.Empty, MessageBoxButtons.YesNo, diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs index 75a8fb477..6c5da009a 100644 --- a/TBF/Resources/Strings.Designer.cs +++ b/TBF/Resources/Strings.Designer.cs @@ -1023,6 +1023,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to A currently used database was restored.. + /// + internal static string Currently_used_database_was_restored { + get { + return ResourceManager.GetString("Currently_used_database_was_restored", resourceCulture); + } + } + /// /// Looks up a localized string similar to Data. /// @@ -1203,6 +1212,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Do you really want to abort this session?. + /// + internal static string Do_you_really_want_to_abort_this_session { + get { + return ResourceManager.GetString("Do_you_really_want_to_abort_this_session", resourceCulture); + } + } + /// /// Looks up a localized string similar to Do you really want to delete sequence '{0}' ?. /// @@ -1267,20 +1285,20 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Do you want to restore configuration?. + /// Looks up a localized string similar to Do you want to restore configuration database from file {0} ?. /// - internal static string Do_you_want_to_restore_configuration_qm { + internal static string Do_you_want_to_restore_configuration_DB_from_file_0_qm { get { - return ResourceManager.GetString("Do_you_want_to_restore_configuration_qm", resourceCulture); + return ResourceManager.GetString("Do_you_want_to_restore_configuration_DB_from_file_0_qm", resourceCulture); } } /// - /// Looks up a localized string similar to Do you want to restore results?. + /// Looks up a localized string similar to Do you want to restore results database from file {0} ?. /// - internal static string Do_you_want_to_restore_results_qm { + internal static string Do_you_want_to_restore_results_DB_from_file_0_qm { get { - return ResourceManager.GetString("Do_you_want_to_restore_results_qm", resourceCulture); + return ResourceManager.GetString("Do_you_want_to_restore_results_DB_from_file_0_qm", resourceCulture); } } @@ -3417,6 +3435,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Program must be closed.. + /// + internal static string Program_must_be_closed { + get { + return ResourceManager.GetString("Program_must_be_closed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Program restart is required to apply some settings. /// @@ -3912,6 +3939,24 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Remote database cannot be exported. + /// + internal static string Remote_database_cannot_be_exported { + get { + return ResourceManager.GetString("Remote_database_cannot_be_exported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Remote database cannot be imported. + /// + internal static string Remote_database_cannot_be_imported { + get { + return ResourceManager.GetString("Remote_database_cannot_be_imported", resourceCulture); + } + } + /// /// Looks up a localized string similar to Remote database is not compatible.. /// @@ -5181,6 +5226,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Test results will be lost.. + /// + internal static string Test_results_will_be_lost { + get { + return ResourceManager.GetString("Test_results_will_be_lost", resourceCulture); + } + } + /// /// Looks up a localized string similar to Test start ({0}: step {1}/{2}). /// diff --git a/TBF/Resources/Strings.cs.resx b/TBF/Resources/Strings.cs.resx index 3d983a451..874fd9766 100644 --- a/TBF/Resources/Strings.cs.resx +++ b/TBF/Resources/Strings.cs.resx @@ -1464,4 +1464,28 @@ Zobrazit vypnuté pozice + + Skutečně chcete přerušit tento cyklus? + + + Výsledky testů se stratí. + + + Vzdálená databáze nemůže být exportována + + + Vzdálená databáze nemůže být naimportována + + + Chcete obnovit konfigurační databázi ze souboru {0} ? + + + Chcete obnovit výsledkovou databázi ze souboru {0} ? + + + Databáze která se právě používá byla naimportována. + + + Program musí být uzavřen. + \ No newline at end of file diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx index e9ff632e3..3423f00f7 100644 --- a/TBF/Resources/Strings.resx +++ b/TBF/Resources/Strings.resx @@ -2014,11 +2014,11 @@ Do you want to back up results? - - Do you want to restore configuration? + + Do you want to restore configuration database from file {0} ? - - Do you want to restore results? + + Do you want to restore results database from file {0} ? Saving all results @@ -2035,4 +2035,22 @@ Show disabled positions + + Do you really want to abort this session? + + + Test results will be lost. + + + Remote database cannot be exported + + + Remote database cannot be imported + + + A currently used database was restored. + + + Program must be closed. + \ No newline at end of file diff --git a/TBF/UiControls/BenchControlPanel.cs b/TBF/UiControls/BenchControlPanel.cs index c0618b2ee..2b1a18fde 100644 --- a/TBF/UiControls/BenchControlPanel.cs +++ b/TBF/UiControls/BenchControlPanel.cs @@ -235,9 +235,8 @@ namespace TBF.UiControls private void startCycleBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.StartCycle); } private void stopBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.Stop); } private void purgeBeginBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.PurgeBegin); } - private void purgeEndBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.PurgeEnd); } - private void breakBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.Break); } - private void resetResultsBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.ResetResults); } + private void purgeEndBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.PurgeEnd); } + private void resetResultsBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.ResetResults); } private void acceptResultsBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.AcceptResults); } private void cameraTestBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.CameraTest); } private void sensitivityTestBtn_Click(object sender, EventArgs e){ Bridge.Ui2Bench(UI2BenchCmd.SensitivityTest); } @@ -245,6 +244,17 @@ namespace TBF.UiControls private void button2_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.B2); } private void nextButton_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.Next); } private void customButton_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.Custom); } + + private void breakBtn_Click(object sender, EventArgs e) + { + if (MessageBox.Show(Strings.Do_you_really_want_to_abort_this_session + Environment.NewLine + Strings.Test_results_will_be_lost, + Strings.Warning, + MessageBoxButtons.YesNo, + MessageBoxIcon.Exclamation) == DialogResult.Yes) + { + Bridge.Ui2Bench(UI2BenchCmd.Break); + } + } private void emptyTank1Btn_Click(object sender, EventArgs e) {