(1) Database export, import and creation completed, TODO pwd, (2) Warning message with yes/no confirmation when aborting a cycle.
This commit is contained in:
parent
e61e5c59cb
commit
5dde27bad9
@ -85,7 +85,15 @@ namespace Config
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Extract and return a database name from a MySQL connection string.
|
||||
/// Extract and return a DB server from a MySQL connection string.
|
||||
/// </summary>
|
||||
public static string GetDBServer(string connectionString)
|
||||
{
|
||||
return GetFromConnectionString(connectionString, new string[] { "SERVER=" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract and return a DB name from a MySQL connection string.
|
||||
/// </summary>
|
||||
public static string GetDBName(string connectionString)
|
||||
{
|
||||
@ -105,7 +113,7 @@ namespace Config
|
||||
/// </summary>
|
||||
public static string GetDBPassword(string connectionString)
|
||||
{
|
||||
return GetFromConnectionString(connectionString, new string[] { "PASSWORD=" });
|
||||
return GetFromConnectionString(connectionString, new string[] { "PASSWORD=", "PWD=" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -17,6 +17,8 @@ namespace TBF
|
||||
// when 'OK' is pressed.
|
||||
LocalSettings localSettings;
|
||||
|
||||
public bool CurrentDBChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, initializes the dialog
|
||||
/// </summary>
|
||||
@ -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
|
||||
|
||||
7
TBF/Forms/DatabaseSettingsDlg.Designer.cs
generated
7
TBF/Forms/DatabaseSettingsDlg.Designer.cs
generated
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="bench">Test bench database settings</param>
|
||||
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);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Configuration database import (UI)
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -269,21 +284,31 @@ namespace TBF.Forms
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Execute a MySQL command line command without specifying a database
|
||||
/// </summary>
|
||||
/// <param name="command">MySQL command</param>
|
||||
/// <param name="userName">User name</param>
|
||||
void ExecuteMySqlCmd(string command, string userName)
|
||||
{
|
||||
ExecuteMySqlCmd(command, userName, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a MySQL command line command, specify database to be used
|
||||
/// </summary>
|
||||
/// <param name="command">MySQL command</param>
|
||||
/// <param name="userName">User name</param>
|
||||
/// <param name="databaseToBeUsed">Database name</param>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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(); }
|
||||
|
||||
/// <summary>
|
||||
/// 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,
|
||||
|
||||
66
TBF/Resources/Strings.Designer.cs
generated
66
TBF/Resources/Strings.Designer.cs
generated
@ -1023,6 +1023,15 @@ namespace TBF.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A currently used database was restored..
|
||||
/// </summary>
|
||||
internal static string Currently_used_database_was_restored {
|
||||
get {
|
||||
return ResourceManager.GetString("Currently_used_database_was_restored", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Data.
|
||||
/// </summary>
|
||||
@ -1203,6 +1212,15 @@ namespace TBF.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Do you really want to abort this session?.
|
||||
/// </summary>
|
||||
internal static string Do_you_really_want_to_abort_this_session {
|
||||
get {
|
||||
return ResourceManager.GetString("Do_you_really_want_to_abort_this_session", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Do you really want to delete sequence '{0}' ?.
|
||||
/// </summary>
|
||||
@ -1267,20 +1285,20 @@ namespace TBF.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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} ?.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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} ?.
|
||||
/// </summary>
|
||||
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 {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Program must be closed..
|
||||
/// </summary>
|
||||
internal static string Program_must_be_closed {
|
||||
get {
|
||||
return ResourceManager.GetString("Program_must_be_closed", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Program restart is required to apply some settings.
|
||||
/// </summary>
|
||||
@ -3912,6 +3939,24 @@ namespace TBF.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Remote database cannot be exported.
|
||||
/// </summary>
|
||||
internal static string Remote_database_cannot_be_exported {
|
||||
get {
|
||||
return ResourceManager.GetString("Remote_database_cannot_be_exported", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Remote database cannot be imported.
|
||||
/// </summary>
|
||||
internal static string Remote_database_cannot_be_imported {
|
||||
get {
|
||||
return ResourceManager.GetString("Remote_database_cannot_be_imported", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Remote database is not compatible..
|
||||
/// </summary>
|
||||
@ -5181,6 +5226,15 @@ namespace TBF.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Test results will be lost..
|
||||
/// </summary>
|
||||
internal static string Test_results_will_be_lost {
|
||||
get {
|
||||
return ResourceManager.GetString("Test_results_will_be_lost", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Test start ({0}: step {1}/{2}).
|
||||
/// </summary>
|
||||
|
||||
@ -1464,4 +1464,28 @@
|
||||
<data name="Show_disabled_positions" xml:space="preserve">
|
||||
<value>Zobrazit vypnuté pozice</value>
|
||||
</data>
|
||||
<data name="Do_you_really_want_to_abort_this_session" xml:space="preserve">
|
||||
<value>Skutečně chcete přerušit tento cyklus?</value>
|
||||
</data>
|
||||
<data name="Test_results_will_be_lost" xml:space="preserve">
|
||||
<value>Výsledky testů se stratí.</value>
|
||||
</data>
|
||||
<data name="Remote_database_cannot_be_exported" xml:space="preserve">
|
||||
<value>Vzdálená databáze nemůže být exportována</value>
|
||||
</data>
|
||||
<data name="Remote_database_cannot_be_imported" xml:space="preserve">
|
||||
<value>Vzdálená databáze nemůže být naimportována</value>
|
||||
</data>
|
||||
<data name="Do_you_want_to_restore_configuration_DB_from_file_0_qm" xml:space="preserve">
|
||||
<value>Chcete obnovit konfigurační databázi ze souboru {0} ?</value>
|
||||
</data>
|
||||
<data name="Do_you_want_to_restore_results_DB_from_file_0_qm" xml:space="preserve">
|
||||
<value>Chcete obnovit výsledkovou databázi ze souboru {0} ?</value>
|
||||
</data>
|
||||
<data name="Currently_used_database_was_restored" xml:space="preserve">
|
||||
<value>Databáze která se právě používá byla naimportována.</value>
|
||||
</data>
|
||||
<data name="Program_must_be_closed" xml:space="preserve">
|
||||
<value>Program musí být uzavřen.</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -2014,11 +2014,11 @@
|
||||
<data name="Do_you_want_to_back_up_results_qm" xml:space="preserve">
|
||||
<value>Do you want to back up results?</value>
|
||||
</data>
|
||||
<data name="Do_you_want_to_restore_configuration_qm" xml:space="preserve">
|
||||
<value>Do you want to restore configuration?</value>
|
||||
<data name="Do_you_want_to_restore_configuration_DB_from_file_0_qm" xml:space="preserve">
|
||||
<value>Do you want to restore configuration database from file {0} ?</value>
|
||||
</data>
|
||||
<data name="Do_you_want_to_restore_results_qm" xml:space="preserve">
|
||||
<value>Do you want to restore results?</value>
|
||||
<data name="Do_you_want_to_restore_results_DB_from_file_0_qm" xml:space="preserve">
|
||||
<value>Do you want to restore results database from file {0} ?</value>
|
||||
</data>
|
||||
<data name="Saving_all_results" xml:space="preserve">
|
||||
<value>Saving all results</value>
|
||||
@ -2035,4 +2035,22 @@
|
||||
<data name="Show_disabled_positions" xml:space="preserve">
|
||||
<value>Show disabled positions</value>
|
||||
</data>
|
||||
<data name="Do_you_really_want_to_abort_this_session" xml:space="preserve">
|
||||
<value>Do you really want to abort this session?</value>
|
||||
</data>
|
||||
<data name="Test_results_will_be_lost" xml:space="preserve">
|
||||
<value>Test results will be lost.</value>
|
||||
</data>
|
||||
<data name="Remote_database_cannot_be_exported" xml:space="preserve">
|
||||
<value>Remote database cannot be exported</value>
|
||||
</data>
|
||||
<data name="Remote_database_cannot_be_imported" xml:space="preserve">
|
||||
<value>Remote database cannot be imported</value>
|
||||
</data>
|
||||
<data name="Currently_used_database_was_restored" xml:space="preserve">
|
||||
<value>A currently used database was restored.</value>
|
||||
</data>
|
||||
<data name="Program_must_be_closed" xml:space="preserve">
|
||||
<value>Program must be closed.</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user