UpgradeSelectionDlg implements 3.1 -> 3.2 and 3.2 -> 3.3
This commit is contained in:
@@ -181,18 +181,13 @@ namespace TBF.UI.Settings
|
||||
|
||||
private void upgradeDb_301_302_Button_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Not implemented");
|
||||
return;
|
||||
|
||||
string[] configDbCommands = new string[]
|
||||
{
|
||||
/// TODO
|
||||
"ALTER TABLE `test` ADD `TempControl` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER `TempLimHi`;",
|
||||
"ALTER TABLE `test` DROP `DoControlWaterTemp`;",
|
||||
};
|
||||
|
||||
string[] resultsDbCommands = new string[]
|
||||
{
|
||||
/// TODO
|
||||
};
|
||||
string[] resultsDbCommands = new string[] { };
|
||||
|
||||
if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
|
||||
{
|
||||
@@ -215,18 +210,18 @@ namespace TBF.UI.Settings
|
||||
|
||||
private void upgradeDb_302_303_Button_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Not implemented");
|
||||
return;
|
||||
|
||||
string[] configDbCommands = new string[]
|
||||
{
|
||||
/// TODO
|
||||
"ALTER TABLE `test` CHANGE `Qtg` `Qtg` DOUBLE NOT NULL DEFAULT '0';",
|
||||
"ALTER TABLE `test` CHANGE `Qfrom` `Qfrom` DOUBLE NOT NULL DEFAULT '0';",
|
||||
"ALTER TABLE `test` CHANGE `Qto` `Qto` DOUBLE NOT NULL DEFAULT '0';",
|
||||
"ALTER TABLE `test` CHANGE `Volume` `Volume` DOUBLE NOT NULL DEFAULT '0';",
|
||||
"ALTER TABLE `test` CHANGE `TestTime` `TestTime` DOUBLE NOT NULL DEFAULT '0';",
|
||||
"ALTER TABLE `measurementcorrection` CHANGE `Measurement` `Measurement` DOUBLE NOT NULL DEFAULT '0';",
|
||||
"ALTER TABLE `measurementcorrection` CHANGE `Correction` `Correction` DOUBLE NOT NULL DEFAULT '0';",
|
||||
};
|
||||
|
||||
string[] resultsDbCommands = new string[]
|
||||
{
|
||||
/// TODO
|
||||
};
|
||||
string[] resultsDbCommands = new string[] { };
|
||||
|
||||
if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
|
||||
{
|
||||
@@ -241,6 +236,60 @@ namespace TBF.UI.Settings
|
||||
(!upgradeResultsDBCheckBox.Checked || resultsDbCommands.Length == 0 ||
|
||||
ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands)))
|
||||
{
|
||||
if (upgradeConfigDBCheckBox.Checked)
|
||||
{
|
||||
ISession session = null;
|
||||
try
|
||||
{
|
||||
session = TBF.DB.CreateSession(DBKind.Config);
|
||||
|
||||
var tests = session.QueryOver<Config.Entities.Test>().List();
|
||||
foreach (var t in tests)
|
||||
{
|
||||
string singlePrecStr = Convert.ToSingle(t.Qtg).ToString();
|
||||
if (t.Qtg.ToString().Length > 2 * singlePrecStr.Length) t.Qtg = double.Parse(singlePrecStr);
|
||||
|
||||
singlePrecStr = Convert.ToSingle(t.Qfrom).ToString();
|
||||
if (t.Qfrom.ToString().Length > 2 * singlePrecStr.Length) t.Qfrom = double.Parse(singlePrecStr);
|
||||
|
||||
singlePrecStr = Convert.ToSingle(t.Qto).ToString();
|
||||
if (t.Qto.ToString().Length > 2 * singlePrecStr.Length) t.Qto = double.Parse(singlePrecStr);
|
||||
|
||||
singlePrecStr = Convert.ToSingle(t.Volume).ToString();
|
||||
if (t.Volume.ToString().Length > 2 * singlePrecStr.Length) t.Volume = double.Parse(singlePrecStr);
|
||||
|
||||
singlePrecStr = Convert.ToSingle(t.TestTime).ToString();
|
||||
if (t.TestTime.ToString().Length > 2 * singlePrecStr.Length) t.TestTime = double.Parse(singlePrecStr);
|
||||
|
||||
session.SaveOrUpdate(t);
|
||||
}
|
||||
|
||||
var mcorrections = session.QueryOver<Config.Entities.MeasurementCorrection>().List();
|
||||
foreach (var mc in mcorrections)
|
||||
{
|
||||
string singlePrecStr = Convert.ToSingle(mc.Measurement).ToString();
|
||||
if (mc.Measurement.ToString().Length > 2 * singlePrecStr.Length) mc.Measurement = double.Parse(singlePrecStr);
|
||||
|
||||
singlePrecStr = Convert.ToSingle(mc.Correction).ToString();
|
||||
if (mc.Correction.ToString().Length > 2 * singlePrecStr.Length) mc.Correction = double.Parse(singlePrecStr);
|
||||
|
||||
session.SaveOrUpdate(mc);
|
||||
}
|
||||
|
||||
session.Flush();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
ActivityEnd();
|
||||
MessageBox.Show(string.Format("Test flow rounding after a conversion to double failed:\r\n{0}", exc.Message),
|
||||
"Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (session != null && session.IsOpen) session.Close();
|
||||
}
|
||||
}
|
||||
|
||||
ActivityEnd();
|
||||
MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
upgradeDb_302_303_Button.Enabled = false;
|
||||
@@ -251,7 +300,7 @@ namespace TBF.UI.Settings
|
||||
{
|
||||
string[] configDbCommands = new string[]
|
||||
{
|
||||
"ALTER TABLE `outputpath` ADD `RegVPositions` VARCHAR(255) NULL DEFAULT NULL AFTER `Scale`;"
|
||||
"ALTER TABLE `outputpath` ADD `RegVPositions` VARCHAR(255) NULL DEFAULT NULL AFTER `Scale`;",
|
||||
};
|
||||
|
||||
string[] resultsDbCommands = new string[] { };
|
||||
@@ -279,7 +328,7 @@ namespace TBF.UI.Settings
|
||||
{
|
||||
string[] configDbCommands = new string[]
|
||||
{
|
||||
"ALTER TABLE `ptest` ADD `Method` VARCHAR(255) NULL DEFAULT NULL AFTER `Evaluate`;"
|
||||
"ALTER TABLE `ptest` ADD `Method` VARCHAR(255) NULL DEFAULT NULL AFTER `Evaluate`;",
|
||||
};
|
||||
|
||||
string[] resultsDbCommands = new string[] { };
|
||||
@@ -316,7 +365,7 @@ namespace TBF.UI.Settings
|
||||
"ALTER TABLE `watermeterdata` ADD `Qnames` TINYINT(4) NOT NULL DEFAULT '1' AFTER `Mounting`;",
|
||||
#endif
|
||||
"ALTER TABLE `watermeterdata` ADD `ErrLimHiQ` DOUBLE NOT NULL DEFAULT '2' AFTER `Q1_Qmin`," +
|
||||
" ADD `ErrLimLoQ` DOUBLE NOT NULL DEFAULT '5' AFTER `ErrLimHiQ`;"
|
||||
" ADD `ErrLimLoQ` DOUBLE NOT NULL DEFAULT '5' AFTER `ErrLimHiQ`;",
|
||||
};
|
||||
|
||||
if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
|
||||
|
||||
Reference in New Issue
Block a user