1. DB creation and import via Settings/Profiles menu item fixed, 2. Each scale must have a drain valve.
This commit is contained in:
parent
ee69631d38
commit
329ffeca8f
@ -77,6 +77,8 @@ namespace TBF.BenchControl.MettlerToledo
|
||||
drainValve = TbfComponents.FindComponent(tankDrainingCfg.DrainValve) as IValve;
|
||||
evaporationCmpnt = TbfComponents.FindComponent(tankDrainingCfg.Evaporation) as IEvaporation;
|
||||
|
||||
if (drainValve == null) throw new Exception(string.Format("{0} is missing a drain valve", Name));
|
||||
|
||||
openTheDrainValveOp = new Elde.SetValvesOp(StateMachine.ControlBoard, drainValve, null);
|
||||
closeTheDrainValveOp = new Elde.SetValvesOp(StateMachine.ControlBoard, null, drainValve);
|
||||
waitTankIsEmptyOp = new WaitTankEmptyOp(this);
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using Results;
|
||||
using TBF.Resources;
|
||||
using System.IO;
|
||||
|
||||
namespace TBF.UI.Settings
|
||||
{
|
||||
@ -18,6 +18,8 @@ namespace TBF.UI.Settings
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(DatabaseSettingsDlg));
|
||||
|
||||
const string CredFileName = "tempfile";
|
||||
|
||||
// Reference to bench DB settins (not a local copy)
|
||||
Config.DatabaseSettings bench;
|
||||
|
||||
@ -193,8 +195,14 @@ namespace TBF.UI.Settings
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (File.Exists(CredFileName)) File.Delete(CredFileName);
|
||||
Cursor.Current = Cursors.Default;
|
||||
MessageBox.Show(Strings.Error_while_creating_DB_Reason + exception.Message, Strings.Error);
|
||||
string msg = string.Format("{0}{1}{2}", 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,8 +244,9 @@ namespace TBF.UI.Settings
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (File.Exists(CredFileName)) File.Delete(CredFileName);
|
||||
Cursor.Current = Cursors.Default;
|
||||
string msg = Strings.Error_while_creating_DB_Reason + Environment.NewLine + exception.Message;
|
||||
string msg = string.Format("{0}{1}{2}", Strings.Error_while_creating_DB_Reason, Environment.NewLine, exception.Message);
|
||||
if (exception.InnerException != null)
|
||||
{
|
||||
msg += Environment.NewLine + exception.InnerException.Message;
|
||||
@ -371,6 +380,7 @@ namespace TBF.UI.Settings
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
if (File.Exists(CredFileName)) File.Delete(CredFileName);
|
||||
log.FatalFormat("Failed to import database '{0}' from file {1}: {2}", databaseName, inputFileName, exc.Message);
|
||||
}
|
||||
}
|
||||
@ -394,8 +404,7 @@ namespace TBF.UI.Settings
|
||||
/// <param name="databaseToBeUsed">Database name</param>
|
||||
void ExecuteMySqlCmd(string command, string userName, string password, string databaseToBeUsed)
|
||||
{
|
||||
string credFileName = "tempfile";
|
||||
using (TextWriter writer = new StreamWriter(credFileName))
|
||||
using (TextWriter writer = new StreamWriter(CredFileName))
|
||||
{
|
||||
writer.WriteLine("[mysql]");
|
||||
writer.WriteLine(string.Format("user={0}", userName));
|
||||
@ -409,11 +418,11 @@ namespace TBF.UI.Settings
|
||||
proc.StartInfo.FileName = @"C:\xampp\mysql\bin\mysql.exe";
|
||||
if (string.IsNullOrEmpty(databaseToBeUsed))
|
||||
{
|
||||
proc.StartInfo.Arguments = string.Format("--defaults-file={0}", credFileName);
|
||||
proc.StartInfo.Arguments = string.Format("--defaults-file={0}", CredFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
proc.StartInfo.Arguments = string.Format("--defaults-file={0} --database={1}", credFileName, databaseToBeUsed);
|
||||
proc.StartInfo.Arguments = string.Format("--defaults-file={0} --database={1}", CredFileName, databaseToBeUsed);
|
||||
}
|
||||
proc.StartInfo.UseShellExecute = false; /// Must be false to redirect standard input or standard output
|
||||
proc.StartInfo.RedirectStandardOutput = false;
|
||||
@ -426,14 +435,9 @@ namespace TBF.UI.Settings
|
||||
System.Diagnostics.Debug.WriteLine(command);
|
||||
log.Warn(command);
|
||||
proc.StandardInput.WriteLine("exit");
|
||||
while (!proc.StandardOutput.EndOfStream)
|
||||
{
|
||||
string line = proc.StandardOutput.ReadLine();
|
||||
Console.WriteLine(line);
|
||||
}
|
||||
proc.WaitForExit();
|
||||
|
||||
File.Delete(credFileName);
|
||||
File.Delete(CredFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user