diff --git a/TBF/UI/Settings/DatabaseSettingsDlg.cs b/TBF/UI/Settings/DatabaseSettingsDlg.cs
index 7087ff5b0..c5f836bdf 100644
--- a/TBF/UI/Settings/DatabaseSettingsDlg.cs
+++ b/TBF/UI/Settings/DatabaseSettingsDlg.cs
@@ -21,7 +21,7 @@ namespace TBF.UI.Settings
const string CredFileName = "tempfile";
// Reference to bench DB settins (not a local copy)
- Common.DatabaseSettings bench;
+ DatabaseSettings bench;
string currentConfigDBConnStr; /// Initialized in constructor by the parent
string currentResultsDBConnStr; /// Initialized in constructor by the parent
@@ -177,9 +177,9 @@ namespace TBF.UI.Settings
try
{
string connectionString = bench.ProceduresDBSettings.ConnectionString;
- string databaseName = Common.DatabaseSettings.GetDBName(connectionString);
- string userName = Common.DatabaseSettings.GetDBUser(connectionString);
- string password = Common.DatabaseSettings.GetDBPassword(connectionString); /// TODO: Use password
+ string databaseName = DatabaseSettings.GetDBName(connectionString);
+ string userName = DatabaseSettings.GetDBUser(connectionString);
+ string password = DatabaseSettings.GetDBPassword(connectionString); /// TODO: Use password
if (connectionString == currentConfigDBConnStr || connectionString == currentResultsDBConnStr || connectionString == currentEventsDBConnStr)
{
@@ -224,9 +224,9 @@ namespace TBF.UI.Settings
try
{
string connectionString = bench.WaterMetersDBSettings.ConnectionString;
- string databaseName = Common.DatabaseSettings.GetDBName(connectionString);
- string userName = Common.DatabaseSettings.GetDBUser(connectionString);
- string password = Common.DatabaseSettings.GetDBPassword(connectionString); /// TODO: Use password
+ string databaseName = DatabaseSettings.GetDBName(connectionString);
+ string userName = DatabaseSettings.GetDBUser(connectionString);
+ string password = DatabaseSettings.GetDBPassword(connectionString); /// TODO: Use password
if (connectionString == currentConfigDBConnStr || connectionString == currentResultsDBConnStr || connectionString == currentEventsDBConnStr)
{
@@ -273,9 +273,9 @@ namespace TBF.UI.Settings
try
{
string connectionString = bench.EventsDBSettings.ConnectionString;
- string databaseName = Common.DatabaseSettings.GetDBName(connectionString);
- string userName = Common.DatabaseSettings.GetDBUser(connectionString);
- string password = Common.DatabaseSettings.GetDBPassword(connectionString); /// TODO: Use password
+ string databaseName = DatabaseSettings.GetDBName(connectionString);
+ string userName = DatabaseSettings.GetDBUser(connectionString);
+ string password = DatabaseSettings.GetDBPassword(connectionString); /// TODO: Use password
if (connectionString == currentConfigDBConnStr || connectionString == currentResultsDBConnStr || connectionString == currentEventsDBConnStr)
{
@@ -320,7 +320,7 @@ namespace TBF.UI.Settings
string connectionString = bench.ProceduresDBSettings.ConnectionString;
- string server = Common.DatabaseSettings.GetDBServer(connectionString);
+ string server = DatabaseSettings.GetDBServer(connectionString);
if ((server != "localhost") && (server != "127.0.0.1"))
{
MessageBox.Show(Strings.Remote_database_cannot_be_imported, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
@@ -353,7 +353,7 @@ namespace TBF.UI.Settings
string connectionString = bench.WaterMetersDBSettings.ConnectionString;
- string server = Common.DatabaseSettings.GetDBServer(connectionString);
+ string server = DatabaseSettings.GetDBServer(connectionString);
if ((server != "localhost") && (server != "127.0.0.1"))
{
MessageBox.Show(Strings.Remote_database_cannot_be_imported, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
@@ -383,7 +383,7 @@ namespace TBF.UI.Settings
string connectionString = bench.EventsDBSettings.ConnectionString;
- string server = Common.DatabaseSettings.GetDBServer(connectionString);
+ string server = DatabaseSettings.GetDBServer(connectionString);
if ((server != "localhost") && (server != "127.0.0.1"))
{
MessageBox.Show(Strings.Remote_database_cannot_be_imported, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
@@ -445,9 +445,9 @@ namespace TBF.UI.Settings
/// Output file name
void ImportDatabase(string connectionString, string inputFileName)
{
- string databaseName = Common.DatabaseSettings.GetDBName(connectionString);
- string userName = Common.DatabaseSettings.GetDBUser(connectionString);
- string password = Common.DatabaseSettings.GetDBPassword(connectionString); /// TODO: Use password
+ string databaseName = DatabaseSettings.GetDBName(connectionString);
+ string userName = DatabaseSettings.GetDBUser(connectionString);
+ string password = DatabaseSettings.GetDBPassword(connectionString); /// TODO: Use password
try
{
diff --git a/TBF/UI/Settings/UpgradeSelectionDlg.Designer.cs b/TBF/UI/Settings/UpgradeSelectionDlg.Designer.cs
index d8f291930..4c4b825fb 100644
--- a/TBF/UI/Settings/UpgradeSelectionDlg.Designer.cs
+++ b/TBF/UI/Settings/UpgradeSelectionDlg.Designer.cs
@@ -28,79 +28,16 @@
///
private void InitializeComponent()
{
- this.upgradeDb_215_216_Button = new System.Windows.Forms.Button();
- this.upgradeDb_216_217_Button = new System.Windows.Forms.Button();
- this.upgradeDb_212_215_Button = new System.Windows.Forms.Button();
- this.upgradeDb_217_218_Button = new System.Windows.Forms.Button();
- this.upgradeDb_29_212_Button = new System.Windows.Forms.Button();
this.upgradeConfigDBCheckBox = new System.Windows.Forms.CheckBox();
this.upgradeResultsDBCheckBox = new System.Windows.Forms.CheckBox();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.pressureRepresentationButton = new System.Windows.Forms.Button();
- this.upgradeDb_24_29_Button = new System.Windows.Forms.Button();
- this.upgradeDb_218_222_Button = new System.Windows.Forms.Button();
- this.upgradeDb_NFC_button = new System.Windows.Forms.Button();
- this.upgradeDb_222_224_Button = new System.Windows.Forms.Button();
- this.upgradeDb_224_225_Button = new System.Windows.Forms.Button();
- this.errorFlagsComponentsTextBox = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.upgradeDb_225_226_Button = new System.Windows.Forms.Button();
this.upgradePipesButton = new System.Windows.Forms.Button();
+ this.upgradeDb_301_302_Button = new System.Windows.Forms.Button();
+ this.upgradeDb_302_303_Button = new System.Windows.Forms.Button();
+ this.upgradeDb_303_304_Button = new System.Windows.Forms.Button();
+ this.upgradeDb_304_305_Button = new System.Windows.Forms.Button();
+ this.upgradeDb_305_306_Button = new System.Windows.Forms.Button();
this.SuspendLayout();
//
- // upgradeDb_215_216_Button
- //
- this.upgradeDb_215_216_Button.Location = new System.Drawing.Point(12, 217);
- this.upgradeDb_215_216_Button.Name = "upgradeDb_215_216_Button";
- this.upgradeDb_215_216_Button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_215_216_Button.TabIndex = 6;
- this.upgradeDb_215_216_Button.Text = "Upgrade DB from v.2.15 to v.2.16";
- this.upgradeDb_215_216_Button.UseVisualStyleBackColor = true;
- this.upgradeDb_215_216_Button.Click += new System.EventHandler(this.upgradeDb_215_216_Button_Click);
- //
- // upgradeDb_216_217_Button
- //
- this.upgradeDb_216_217_Button.Location = new System.Drawing.Point(12, 257);
- this.upgradeDb_216_217_Button.Name = "upgradeDb_216_217_Button";
- this.upgradeDb_216_217_Button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_216_217_Button.TabIndex = 7;
- this.upgradeDb_216_217_Button.Text = "Upgrade DB from v.2.16 to v.2.17";
- this.upgradeDb_216_217_Button.UseVisualStyleBackColor = true;
- this.upgradeDb_216_217_Button.Click += new System.EventHandler(this.upgradeDb_216_217_Button_Click);
- //
- // upgradeDb_212_215_Button
- //
- this.upgradeDb_212_215_Button.Location = new System.Drawing.Point(12, 177);
- this.upgradeDb_212_215_Button.Name = "upgradeDb_212_215_Button";
- this.upgradeDb_212_215_Button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_212_215_Button.TabIndex = 5;
- this.upgradeDb_212_215_Button.Text = "Upgrade DB from v.2.12 to v.2.15";
- this.upgradeDb_212_215_Button.UseVisualStyleBackColor = true;
- this.upgradeDb_212_215_Button.Click += new System.EventHandler(this.upgradeDb_212_215_Button_Click);
- //
- // upgradeDb_217_218_Button
- //
- this.upgradeDb_217_218_Button.Location = new System.Drawing.Point(12, 297);
- this.upgradeDb_217_218_Button.Name = "upgradeDb_217_218_Button";
- this.upgradeDb_217_218_Button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_217_218_Button.TabIndex = 8;
- this.upgradeDb_217_218_Button.Text = "Upgrade DB from v.2.17 to v.2.18";
- this.upgradeDb_217_218_Button.UseVisualStyleBackColor = true;
- this.upgradeDb_217_218_Button.Click += new System.EventHandler(this.upgradeDb_217_218_Button_Click);
- //
- // upgradeDb_29_212_Button
- //
- this.upgradeDb_29_212_Button.Location = new System.Drawing.Point(12, 137);
- this.upgradeDb_29_212_Button.Name = "upgradeDb_29_212_Button";
- this.upgradeDb_29_212_Button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_29_212_Button.TabIndex = 4;
- this.upgradeDb_29_212_Button.Text = "Upgrade DB from v.2.9 to v.2.12";
- this.upgradeDb_29_212_Button.UseVisualStyleBackColor = true;
- this.upgradeDb_29_212_Button.Click += new System.EventHandler(this.upgradeDb_29_212_Button_Click);
- //
// upgradeConfigDBCheckBox
//
this.upgradeConfigDBCheckBox.AutoSize = true;
@@ -121,138 +58,10 @@
this.upgradeResultsDBCheckBox.Text = "Upgrade Results database";
this.upgradeResultsDBCheckBox.UseVisualStyleBackColor = true;
//
- // textBox1
- //
- this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.textBox1.Enabled = false;
- this.textBox1.Location = new System.Drawing.Point(94, 535);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(100, 20);
- this.textBox1.TabIndex = 11;
- //
- // textBox2
- //
- this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.textBox2.Enabled = false;
- this.textBox2.Location = new System.Drawing.Point(94, 561);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(100, 20);
- this.textBox2.TabIndex = 13;
- //
- // label1
- //
- this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.label1.AutoSize = true;
- this.label1.Enabled = false;
- this.label1.Location = new System.Drawing.Point(12, 538);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(70, 13);
- this.label1.TabIndex = 10;
- this.label1.Text = "From batch #";
- //
- // label2
- //
- this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.label2.AutoSize = true;
- this.label2.Enabled = false;
- this.label2.Location = new System.Drawing.Point(12, 564);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(60, 13);
- this.label2.TabIndex = 12;
- this.label2.Text = "To batch #";
- //
- // pressureRepresentationButton
- //
- this.pressureRepresentationButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.pressureRepresentationButton.Enabled = false;
- this.pressureRepresentationButton.Location = new System.Drawing.Point(207, 535);
- this.pressureRepresentationButton.Name = "pressureRepresentationButton";
- this.pressureRepresentationButton.Size = new System.Drawing.Size(65, 42);
- this.pressureRepresentationButton.TabIndex = 14;
- this.pressureRepresentationButton.Text = "Upgrade pressure";
- this.pressureRepresentationButton.UseVisualStyleBackColor = true;
- this.pressureRepresentationButton.Click += new System.EventHandler(this.pressureRepresentationButton_Click);
- //
- // upgradeDb_24_29_Button
- //
- this.upgradeDb_24_29_Button.Location = new System.Drawing.Point(12, 97);
- this.upgradeDb_24_29_Button.Name = "upgradeDb_24_29_Button";
- this.upgradeDb_24_29_Button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_24_29_Button.TabIndex = 3;
- this.upgradeDb_24_29_Button.Text = "Upgrade DB from v.2.4 to v.2.9";
- this.upgradeDb_24_29_Button.UseVisualStyleBackColor = true;
- this.upgradeDb_24_29_Button.Click += new System.EventHandler(this.upgradeDb_24_29_Button_Click);
- //
- // upgradeDb_218_222_Button
- //
- this.upgradeDb_218_222_Button.Location = new System.Drawing.Point(12, 337);
- this.upgradeDb_218_222_Button.Name = "upgradeDb_218_222_Button";
- this.upgradeDb_218_222_Button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_218_222_Button.TabIndex = 9;
- this.upgradeDb_218_222_Button.Text = "Upgrade DB from v.2.18 to v.2.22";
- this.upgradeDb_218_222_Button.UseVisualStyleBackColor = true;
- this.upgradeDb_218_222_Button.Click += new System.EventHandler(this.upgradeDb_218_222_Button_Click);
- //
- // upgradeDb_NFC_button
- //
- this.upgradeDb_NFC_button.Location = new System.Drawing.Point(12, 57);
- this.upgradeDb_NFC_button.Name = "upgradeDb_NFC_button";
- this.upgradeDb_NFC_button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_NFC_button.TabIndex = 2;
- this.upgradeDb_NFC_button.Text = "Upgrade database for NFC tags";
- this.upgradeDb_NFC_button.UseVisualStyleBackColor = true;
- this.upgradeDb_NFC_button.Click += new System.EventHandler(this.upgradeDb_NFC_button_Click);
- //
- // upgradeDb_222_224_Button
- //
- this.upgradeDb_222_224_Button.Location = new System.Drawing.Point(12, 404);
- this.upgradeDb_222_224_Button.Name = "upgradeDb_222_224_Button";
- this.upgradeDb_222_224_Button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_222_224_Button.TabIndex = 15;
- this.upgradeDb_222_224_Button.Text = "Upgrade DB from v.2.22 to v.2.24";
- this.upgradeDb_222_224_Button.UseVisualStyleBackColor = true;
- this.upgradeDb_222_224_Button.Click += new System.EventHandler(this.upgradeDb_222_224_Button_Click);
- //
- // upgradeDb_224_225_Button
- //
- this.upgradeDb_224_225_Button.Location = new System.Drawing.Point(12, 444);
- this.upgradeDb_224_225_Button.Name = "upgradeDb_224_225_Button";
- this.upgradeDb_224_225_Button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_224_225_Button.TabIndex = 16;
- this.upgradeDb_224_225_Button.Text = "Upgrade DB from v.2.24 to v.2.25 (users)";
- this.upgradeDb_224_225_Button.UseVisualStyleBackColor = true;
- this.upgradeDb_224_225_Button.Click += new System.EventHandler(this.upgradeDb_224_225_Button_Click);
- //
- // errorFlagsComponentsTextBox
- //
- this.errorFlagsComponentsTextBox.Location = new System.Drawing.Point(94, 378);
- this.errorFlagsComponentsTextBox.Name = "errorFlagsComponentsTextBox";
- this.errorFlagsComponentsTextBox.Size = new System.Drawing.Size(178, 20);
- this.errorFlagsComponentsTextBox.TabIndex = 17;
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(12, 381);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(71, 13);
- this.label3.TabIndex = 18;
- this.label3.Text = "ErrFlags1~E..";
- //
- // upgradeDb_225_226_Button
- //
- this.upgradeDb_225_226_Button.Location = new System.Drawing.Point(13, 484);
- this.upgradeDb_225_226_Button.Name = "upgradeDb_225_226_Button";
- this.upgradeDb_225_226_Button.Size = new System.Drawing.Size(260, 34);
- this.upgradeDb_225_226_Button.TabIndex = 19;
- this.upgradeDb_225_226_Button.Text = "Upgrade DB from v.2.25 to v.2.26 (calendar)";
- this.upgradeDb_225_226_Button.UseVisualStyleBackColor = true;
- this.upgradeDb_225_226_Button.Click += new System.EventHandler(this.upgradeDb_225_226_Button_Click);
- //
// upgradePipesButton
//
this.upgradePipesButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.upgradePipesButton.Location = new System.Drawing.Point(206, 9);
+ this.upgradePipesButton.Location = new System.Drawing.Point(207, 10);
this.upgradePipesButton.Name = "upgradePipesButton";
this.upgradePipesButton.Size = new System.Drawing.Size(65, 42);
this.upgradePipesButton.TabIndex = 20;
@@ -260,32 +69,69 @@
this.upgradePipesButton.UseVisualStyleBackColor = true;
this.upgradePipesButton.Click += new System.EventHandler(this.upgradePipesButton_Click);
//
+ // upgradeDb_301_302_Button
+ //
+ this.upgradeDb_301_302_Button.Location = new System.Drawing.Point(12, 63);
+ this.upgradeDb_301_302_Button.Name = "upgradeDb_301_302_Button";
+ this.upgradeDb_301_302_Button.Size = new System.Drawing.Size(260, 22);
+ this.upgradeDb_301_302_Button.TabIndex = 23;
+ this.upgradeDb_301_302_Button.Text = "Upgrade DB from v.3.1 to v.3.2";
+ this.upgradeDb_301_302_Button.UseVisualStyleBackColor = true;
+ this.upgradeDb_301_302_Button.Click += new System.EventHandler(this.upgradeDb_301_302_Button_Click);
+ //
+ // upgradeDb_302_303_Button
+ //
+ this.upgradeDb_302_303_Button.Location = new System.Drawing.Point(12, 88);
+ this.upgradeDb_302_303_Button.Name = "upgradeDb_302_303_Button";
+ this.upgradeDb_302_303_Button.Size = new System.Drawing.Size(260, 22);
+ this.upgradeDb_302_303_Button.TabIndex = 24;
+ this.upgradeDb_302_303_Button.Text = "Upgrade DB from v.3.2 to v.3.3";
+ this.upgradeDb_302_303_Button.UseVisualStyleBackColor = true;
+ this.upgradeDb_302_303_Button.Click += new System.EventHandler(this.upgradeDb_302_303_Button_Click);
+ //
+ // upgradeDb_303_304_Button
+ //
+ this.upgradeDb_303_304_Button.Location = new System.Drawing.Point(12, 114);
+ this.upgradeDb_303_304_Button.Name = "upgradeDb_303_304_Button";
+ this.upgradeDb_303_304_Button.Size = new System.Drawing.Size(260, 22);
+ this.upgradeDb_303_304_Button.TabIndex = 25;
+ this.upgradeDb_303_304_Button.Text = "Upgrade DB from v.3.3 to v.3.4";
+ this.upgradeDb_303_304_Button.UseVisualStyleBackColor = true;
+ this.upgradeDb_303_304_Button.Click += new System.EventHandler(this.upgradeDb_303_304_Button_Click);
+ //
+ // upgradeDb_304_305_Button
+ //
+ this.upgradeDb_304_305_Button.Location = new System.Drawing.Point(12, 139);
+ this.upgradeDb_304_305_Button.Name = "upgradeDb_304_305_Button";
+ this.upgradeDb_304_305_Button.Size = new System.Drawing.Size(260, 22);
+ this.upgradeDb_304_305_Button.TabIndex = 26;
+ this.upgradeDb_304_305_Button.Text = "Upgrade DB from v.3.4 to v.3.5";
+ this.upgradeDb_304_305_Button.UseVisualStyleBackColor = true;
+ this.upgradeDb_304_305_Button.Click += new System.EventHandler(this.upgradeDb_304_305_Button_Click);
+ //
+ // upgradeDb_305_306_Button
+ //
+ this.upgradeDb_305_306_Button.Location = new System.Drawing.Point(12, 164);
+ this.upgradeDb_305_306_Button.Name = "upgradeDb_305_306_Button";
+ this.upgradeDb_305_306_Button.Size = new System.Drawing.Size(260, 22);
+ this.upgradeDb_305_306_Button.TabIndex = 27;
+ this.upgradeDb_305_306_Button.Text = "Upgrade DB from v.3.5 to v.3.6";
+ this.upgradeDb_305_306_Button.UseVisualStyleBackColor = true;
+ this.upgradeDb_305_306_Button.Click += new System.EventHandler(this.upgradeDb_305_306_Button_Click);
+ //
// UpgradeSelectionDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 597);
this.Controls.Add(this.upgradePipesButton);
- this.Controls.Add(this.upgradeDb_225_226_Button);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.errorFlagsComponentsTextBox);
- this.Controls.Add(this.upgradeDb_224_225_Button);
- this.Controls.Add(this.upgradeDb_222_224_Button);
- this.Controls.Add(this.upgradeDb_NFC_button);
- this.Controls.Add(this.upgradeDb_218_222_Button);
- this.Controls.Add(this.upgradeDb_24_29_Button);
- this.Controls.Add(this.pressureRepresentationButton);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.textBox1);
+ this.Controls.Add(this.upgradeDb_305_306_Button);
+ this.Controls.Add(this.upgradeDb_304_305_Button);
+ this.Controls.Add(this.upgradeDb_303_304_Button);
+ this.Controls.Add(this.upgradeDb_302_303_Button);
+ this.Controls.Add(this.upgradeDb_301_302_Button);
this.Controls.Add(this.upgradeResultsDBCheckBox);
this.Controls.Add(this.upgradeConfigDBCheckBox);
- this.Controls.Add(this.upgradeDb_29_212_Button);
- this.Controls.Add(this.upgradeDb_217_218_Button);
- this.Controls.Add(this.upgradeDb_212_215_Button);
- this.Controls.Add(this.upgradeDb_216_217_Button);
- this.Controls.Add(this.upgradeDb_215_216_Button);
this.Name = "UpgradeSelectionDlg";
this.Text = "Upgrade selection";
this.ResumeLayout(false);
@@ -295,27 +141,14 @@
#endregion
- private System.Windows.Forms.Button upgradeDb_215_216_Button;
- private System.Windows.Forms.Button upgradeDb_216_217_Button;
- private System.Windows.Forms.Button upgradeDb_212_215_Button;
- private System.Windows.Forms.Button upgradeDb_217_218_Button;
- private System.Windows.Forms.Button upgradeDb_29_212_Button;
private System.Windows.Forms.CheckBox upgradeConfigDBCheckBox;
private System.Windows.Forms.CheckBox upgradeResultsDBCheckBox;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.TextBox textBox2;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Button pressureRepresentationButton;
- private System.Windows.Forms.Button upgradeDb_24_29_Button;
- private System.Windows.Forms.Button upgradeDb_218_222_Button;
- private System.Windows.Forms.Button upgradeDb_NFC_button;
- private System.Windows.Forms.Button upgradeDb_222_224_Button;
- private System.Windows.Forms.Button upgradeDb_224_225_Button;
- private System.Windows.Forms.TextBox errorFlagsComponentsTextBox;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Button upgradeDb_225_226_Button;
private System.Windows.Forms.Button upgradePipesButton;
+ private System.Windows.Forms.Button upgradeDb_301_302_Button;
+ private System.Windows.Forms.Button upgradeDb_302_303_Button;
+ private System.Windows.Forms.Button upgradeDb_303_304_Button;
+ private System.Windows.Forms.Button upgradeDb_304_305_Button;
+ private System.Windows.Forms.Button upgradeDb_305_306_Button;
}
}
\ No newline at end of file
diff --git a/TBF/UI/Settings/UpgradeSelectionDlg.cs b/TBF/UI/Settings/UpgradeSelectionDlg.cs
index 99abbf283..62f8e4e97 100644
--- a/TBF/UI/Settings/UpgradeSelectionDlg.cs
+++ b/TBF/UI/Settings/UpgradeSelectionDlg.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2016-2020 Sensus slovensko a.s.
+/// Copyright (c) 2016-2023 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
@@ -32,12 +32,6 @@ namespace TBF.UI.Settings
upgradeConfigDBCheckBox.Checked = true;
upgradeResultsDBCheckBox.Checked = true;
-
- batchFrom = 1;
- batchTo = Program.LocalSettings.BatchNr - 1;
-
- textBox1.Text = batchFrom.ToString();
- textBox2.Text = batchTo.ToString();
}
void ActivityStart()
@@ -104,946 +98,6 @@ namespace TBF.UI.Settings
return success;
}
- ///
- /// Common part of database upgrade code
- ///
- /// Database connection
- /// Array of SQL commands to be executed
- /// true = successful
- bool ChangeErrorFlags(string errorFlagsCmpntName)
- {
- bool success = false;
- ISession session = null;
-
- try
- {
- session = TBF.DB.CreateSession(DBKind.Config);
-
- var testParams = session.QueryOver()
- .Where(x => (x.CmpntName == errorFlagsCmpntName))
- .List();
-
- foreach (var tp in testParams)
- {
- string temp;
- if (tp.Parameters.Contains("Info"))
- {
- temp = tp.Parameters.Replace("true", "1");
- }
- else if (tp.Parameters.Contains("On"))
- {
- temp = tp.Parameters.Replace("true", "2");
- }
- else
- {
- temp = tp.Parameters.Replace("true", "0");
- }
-
- tp.Parameters = temp.Replace("false", "0");
-
- session.SaveOrUpdate(tp);
- }
-
- session.Flush();
- success = true;
- }
- catch (Exception exc)
- {
- ActivityEnd();
- MessageBox.Show(string.Format("Upgrade failed:\r\n{0}", exc.Message),
- "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- finally
- {
- if (session != null) session.Close();
- }
-
- return success;
- }
-
- ///---------------------------------------------------------------------
- private void upgradeDb_NFC_button_Click(object sender, EventArgs e)
- {
- if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
- {
- MessageBox.Show("No database selected");
- return;
- }
-
- string[] commands = new string[]
- {
- "ALTER TABLE `user` ADD `Tag` VARCHAR(255) NULL DEFAULT NULL AFTER `Number`;",
- };
-
- ActivityStart();
-
- if (!upgradeConfigDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), commands))
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_NFC_button.Enabled = false;
- }
- }
-
- ///---------------------------------------------------------------------
- private void upgradeDb_24_29_Button_Click(object sender, EventArgs e)
- {
- if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
- {
- MessageBox.Show("No database selected");
- return;
- }
-
- string[] configDbCommands = new string[]
- {
- /// 2.4 -> 2.5
- "ALTER TABLE `test` ADD `MassRepeats` INT NOT NULL DEFAULT '5' AFTER `PumpPower`, ADD `MassSpread` FLOAT NOT NULL DEFAULT '0' AFTER `MassRepeats`, ADD `MassMethod` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `MassSpread`",
-
- /// 2.5 -> 2.6 ---
- /// 2.6 -> 2.7 ---
- /// 2.7 -> 2.8 ---
-
- /// 2.8 -> 2.9
- "ALTER TABLE `meterspath` DROP `Qfrom`, DROP `Qto`;",
- };
-
- string[] resultsDbCommands = new string[]
- {
- /// 2.4 -> 2.5 ---
-
- /// 2.5 -> 2.6
- "ALTER TABLE `watermeterdata` DROP `Q3`, CHANGE `Qn` `Q3_Qn` DOUBLE NULL DEFAULT NULL ",
- "ALTER TABLE `watermeterdata` ADD `DN` DOUBLE NOT NULL DEFAULT '0' AFTER `Producer`, ADD `L` DOUBLE NOT NULL DEFAULT '0' AFTER `DN`, ADD `Mounting` VARCHAR(255) NULL DEFAULT NULL AFTER `L`, ADD `TemperatureClass` VARCHAR(255) NULL DEFAULT NULL AFTER `Q1_Qmin`, ADD `PressureLossClass` VARCHAR(255) NULL DEFAULT NULL AFTER `TemperatureClass`",
- "ALTER TABLE `watermeterdata` ADD `MaxAdmissiblePressure` VARCHAR(255) NULL DEFAULT NULL AFTER `PressureLossClass`, ADD `FlowProfileSensitivityClass` VARCHAR(255) NULL DEFAULT NULL AFTER `MaxAdmissiblePressure`, ADD `Certificate` VARCHAR(255) NULL DEFAULT NULL AFTER `FlowProfileSensitivityClass`, ADD `PulsesPerLtr` DOUBLE NOT NULL DEFAULT '1' AFTER `Certificate`",
- "ALTER TABLE `watermeterdata` ADD `Text1` VARCHAR(255) NULL DEFAULT NULL AFTER `PulsesPerLtr`, ADD `Text2` VARCHAR(255) NULL DEFAULT NULL AFTER `Text1`, ADD `Text3` VARCHAR(255) NULL DEFAULT NULL AFTER `Text2`, ADD `Text4` VARCHAR(255) NULL DEFAULT NULL AFTER `Text3`, ADD `Text5` VARCHAR(255) NULL DEFAULT NULL AFTER `Text4`",
- /// 2.6 -> 2.7
- "ALTER TABLE `watermeterdata` ADD `ProducerAux` VARCHAR(255) NULL DEFAULT NULL AFTER `PulsesPerLtr`, ADD `Q3_Qn_Aux` DOUBLE NOT NULL DEFAULT '0' AFTER `ProducerAux`, ADD `MetrologicalClassAux` VARCHAR(255) NULL DEFAULT NULL AFTER `Q3_Qn_Aux`, ADD `ApprovalInfoAux` VARCHAR(255) NULL DEFAULT NULL AFTER `MetrologicalClassAux`",
- /// 2.7 -> 2.8
- "ALTER TABLE `watermeter` ADD `ResultCode` INT NOT NULL DEFAULT '0' AFTER `Passed`",
- "ALTER TABLE `batch` ADD `Remark` VARCHAR( 2000 ) NULL DEFAULT NULL AFTER `ProtocolTitle`",
-
- /// 2.8 -> 2.9 ---
- };
-
- ActivityStart();
-
- if ((!upgradeConfigDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
- (!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands)))
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_24_29_Button.Enabled = false;
- }
- }
-
- ///---------------------------------------------------------------------
- private void upgradeDb_29_212_Button_Click(object sender, EventArgs e)
- {
- if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
- {
- MessageBox.Show("No database selected");
- return;
- }
-
- string[] configDbCommands = new string[]
- {
- /// 2.9 -> 2.10
-
- /// 2.10 -> 2.11
- "ALTER TABLE `feedingpath` ADD `RegulValvesPct` VARCHAR(255) NULL DEFAULT NULL AFTER `Pump;",
-
- /// 2.11 -> 2.12
- "ALTER TABLE `benchpath` ADD `PressMtrDelta` VARCHAR(255) NULL DEFAULT NULL AFTER `PressOut;",
- };
-
- string[] resultsDbCommands = new string[]
- {
- /// 2.9 -> 2.10
- "ALTER TABLE `testrslt` ADD `AmbTempStart` FLOAT NOT NULL DEFAULT '0' AFTER `AmbientTempAve`",
- "ALTER TABLE `testrslt` ADD `AmbTempEnd` FLOAT NOT NULL DEFAULT '0' AFTER `AmbTempStart`",
- "ALTER TABLE `testrslt` ADD `AmbTempMin` FLOAT NOT NULL DEFAULT '0' AFTER `AmbTempEnd`",
- "ALTER TABLE `testrslt` ADD `AmbTempMax` FLOAT NOT NULL DEFAULT '0' AFTER `AmbTempMin`",
- "ALTER TABLE `testrslt` ADD `AmbPressStart` FLOAT NOT NULL DEFAULT '0' AFTER `AmbientPressAve`",
- "ALTER TABLE `testrslt` ADD `AmbPressEnd` FLOAT NOT NULL DEFAULT '0' AFTER `AmbPressStart`",
- "ALTER TABLE `testrslt` ADD `AmbPressMin` FLOAT NOT NULL DEFAULT '0' AFTER `AmbPressEnd`",
- "ALTER TABLE `testrslt` ADD `AmbPressMax` FLOAT NOT NULL DEFAULT '0' AFTER `AmbPressMin`",
- "ALTER TABLE `testrslt` ADD `AmbHumiStart` FLOAT NOT NULL DEFAULT '0' AFTER `AmbientHumiAve`",
- "ALTER TABLE `testrslt` ADD `AmbHumiEnd` FLOAT NOT NULL DEFAULT '0' AFTER `AmbHumiStart`",
- "ALTER TABLE `testrslt` ADD `AmbHumiMin` FLOAT NOT NULL DEFAULT '0' AFTER `AmbHumiEnd`",
- "ALTER TABLE `testrslt` ADD `AmbHumiMax` FLOAT NOT NULL DEFAULT '0' AFTER `AmbHumiMin`",
-
- /// 2.10 -> 2.11
-
- /// 2.11 -> 2.12
- "ALTER TABLE `testrslt` ADD `PressDeltaMean` FLOAT NOT NULL DEFAULT '0' AFTER `PressDownMax`",
- "ALTER TABLE `testrslt` ADD `PressDeltaStart` FLOAT NOT NULL DEFAULT '0' AFTER `PressDeltaMean`",
- "ALTER TABLE `testrslt` ADD `PressDeltaEnd` FLOAT NOT NULL DEFAULT '0' AFTER `PressDeltaStart`",
- "ALTER TABLE `testrslt` ADD `PressDeltaMin` FLOAT NOT NULL DEFAULT '0' AFTER `PressDeltaEnd`",
- "ALTER TABLE `testrslt` ADD `PressDeltaMax` FLOAT NOT NULL DEFAULT '0' AFTER `PressDeltaMin`",
- "ALTER TABLE `testrslt` ADD `FlowStart` FLOAT NOT NULL DEFAULT '0' AFTER `TempDivMax`",
- "ALTER TABLE `testrslt` ADD `FlowEnd` FLOAT NOT NULL DEFAULT '0' AFTER `FlowStart`",
- };
-
- ActivityStart();
-
- if ((!upgradeConfigDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
- (!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands)))
- {
- if (upgradeConfigDBCheckBox.Checked)
- {
- MySqlConnection dbConn = new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString);
- try
- {
- dbConn.Open();
-
- MySqlCommand cmd;
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'TestMethods.Adjustment.Single' WHERE ClassName = 'Adjustment'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'TestMethods.FlyingStartMassCollection.Compound' WHERE ClassName = 'CombinedMeters'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'TestMethods.CombinedWithDetection.Compound' WHERE ClassName = 'CombinedWithDetection'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'TestMethods.FixedStartMassCollection.Single' WHERE ClassName = 'FixedStartMassCollection'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'TestMethods.FixedStartMassCollection.Compound' WHERE ClassName = 'FixedStartCombinedMeters'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'TestMethods.FlyingStart.Single' WHERE ClassName = 'FlyingStart'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'TestMethods.FlyingStartMassCollection.Single' WHERE ClassName = 'Flying-Start-Collection'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'TestMethods.LeakTest' WHERE ClassName = 'Leak-Test'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'TestMethods.PMaxTest' WHERE ClassName = 'PMax-Test'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'Output.Printers.Enhanced.Single' WHERE ClassName = 'BasicResultsPrinter'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_29_212_Button.Enabled = false;
- }
- catch (Exception exc)
- {
- log.ErrorFormat(string.Format("Exception when upgrading DB: {0}", exc.Message));
- if (exc.InnerException != null) log.ErrorFormat(string.Format("Inner exception: {0}", exc.InnerException.Message));
- ActivityEnd();
- MessageBox.Show(string.Format("Exception {0}", exc.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- finally
- {
- dbConn.Close();
- }
- }
- else
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_29_212_Button.Enabled = false;
- }
- }
- }
-
- ///---------------------------------------------------------------------
- private void upgradeDb_212_215_Button_Click(object sender, EventArgs e)
- {
- if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
- {
- MessageBox.Show("No database selected");
- return;
- }
-
- string[] configDbCommands = new string[]
- {
- /// 2.12 -> 2.13
- "ALTER TABLE `procedure` ADD `Protected` BOOLEAN NOT NULL DEFAULT '0' AFTER `ProtocolTitle`, ADD `MustBeComplete` BOOLEAN NOT NULL DEFAULT '0' AFTER `Protected`, ADD `ManualCtrlDisabled` BOOLEAN NOT NULL DEFAULT '0' AFTER `MustBeComplete`",
- /// 2.13 -> 2.14
- "ALTER TABLE `test` ADD `DoControlWaterTemp` BOOLEAN NOT NULL DEFAULT '0' AFTER `Zeroing`, ADD `TempLimLo` FLOAT NOT NULL DEFAULT '15' AFTER `DoControlWaterTemp`, ADD `TempLimHi` FLOAT NOT NULL DEFAULT '25' AFTER `TempLimLo`",
- /// 2.14 -> 2.15
- "ALTER TABLE `procedure` ADD `AltProcName` VARCHAR(255) NULL DEFAULT NULL , ADD `AltProcPeriod` INT NOT NULL DEFAULT '0';",
- //"ALTER TABLE `procedure` DROP `ProtocolTitle`;", /// Commented out to maintain compatibility with an old ResultsBrowser
- };
-
- string[] resultsDbCommands = new string[]
- {
- /// 2.12 -> 2.13
- "ALTER TABLE `watermeter` ADD `Remark` VARCHAR( 2000 ) NULL DEFAULT NULL AFTER `ResultCode`",
- "ALTER TABLE `batch` ADD `Dirty` BOOLEAN NOT NULL DEFAULT '0' AFTER `EndTime`",
- /// 2.13 -> 2.14
-#if !IPERL
- "ALTER TABLE `testrslt` ADD `FlowMean` FLOAT NOT NULL DEFAULT '0' AFTER `TempDivMax`",
-#endif
- "ALTER TABLE `testrslt` ADD `TestDone` BOOLEAN NOT NULL DEFAULT '1' AFTER `RepetitionNr`, ADD `Remark` VARCHAR( 2000 ) NULL DEFAULT NULL AFTER `TestDone`",
- "ALTER TABLE `testdata` ADD `DoControlWaterTemp` BOOLEAN NOT NULL DEFAULT '0' AFTER `Uncertainty`, ADD `TempLimLo` FLOAT NOT NULL DEFAULT '15' AFTER `DoControlWaterTemp`, ADD `TempLimHi` FLOAT NOT NULL DEFAULT '25' AFTER `TempLimLo`",
- /// 2.14 -> 2.15
- "ALTER TABLE `watermeter` ADD `ArchivePath` VARCHAR(255) NULL DEFAULT NULL AFTER `ResultCode`;",
- };
-
- ActivityStart();
-
- if ((!upgradeConfigDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
- (!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands)))
- {
- if (upgradeConfigDBCheckBox.Checked)
- {
- MySqlConnection dbConn = new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString);
- try
- {
- dbConn.Open();
-
- int maxItemNr = 0;
- MySqlCommand cmd = dbConn.CreateCommand();
- cmd.CommandText = "SELECT ItemNr FROM component";
- MySqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- int itemNr = dr.GetInt32(0);
- if (itemNr > maxItemNr) maxItemNr = itemNr;
- }
- dr.Close();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'RegisterReader for standing start/stop' WHERE ClassName = 'Fixed-Start-Register-Reader'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'TestMethods.iPerlCommunication' WHERE ClassName = 'iPerlCommunication'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET ClassName = 'WaterMeter' WHERE ClassName = 'iPerl'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- for (int i = 1; i <= 40; i++)
- {
- Text = string.Format("Upgrade selection: {0}/40", i);
-
- /// Read original iPerl water meter parameters
- int id = 0;
- string parameters = string.Empty;
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = string.Format("SELECT Id, Parameters FROM Component WHERE Name = 'iPerl{0}' AND ClassName = 'WaterMeter'", i);
- dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- id = dr.GetInt32(0);
- parameters = dr.GetString(1);
- }
- dr.Close();
- cmd.Dispose();
-
- if (id != 0)
- {
- /// Rename iPerl water meter
- cmd = dbConn.CreateCommand();
- cmd.CommandText = string.Format("UPDATE component SET Name = 'WM{0}' WHERE Name = 'iPerl{0}'", i);
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- /// Create iPerl Head
- cmd = dbConn.CreateCommand();
- cmd.CommandText = string.Format("INSERT INTO component(ItemNr, Name, ClassName, Parentname, Mode, Logging, Parameters) VALUES ({0}, 'iPerl{1}', 'RegisterReader for iPerl', '', 'Normal', 'Off', @params)",
- maxItemNr + 1, i);
- cmd.Parameters.AddWithValue("@params", parameters.Replace("WaterMeterCfg", "IperlHeadCfg"));
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- /// Clone procedure parameters
- IList idList = new List();
- IList parList = new List();
- IList procIdList = new List();
- cmd = dbConn.CreateCommand();
- cmd.CommandText = string.Format("SELECT Id, Parameters, Procedure_id FROM componentprocedure WHERE CmpntName = 'iPerl{0}'", i);
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- idList.Add(dr.GetInt32(0));
- parList.Add(dr.GetString(1));
- procIdList.Add(dr.GetInt32(2));
- }
- dr.Close();
- cmd.Dispose();
-
- if ((idList.Count == parList.Count) && (parList.Count == procIdList.Count))
- {
- for (int j = 0; j < parList.Count; j++)
- {
- cmd = dbConn.CreateCommand();
- cmd.CommandText = string.Format("INSERT INTO componentprocedure(CmpntName, Parameters, Procedure_id) VALUES ('WM{0}', @params, {1})",
- i, procIdList[j]);
- cmd.Parameters.AddWithValue("@params", parList[j].Replace("Q4", "Qmax")
- .Replace("Q3", "Qn")
- .Replace("Q2", "Qt")
- .Replace("Q1", "Qmin")
- .Replace("", "true\r\n "));
- cmd.ExecuteNonQuery();
- cmd.Dispose();
- }
- }
- }
- }
-
- /// Delete 'Parmeters' of iPerl water meters
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "UPDATE component SET Parameters = '\r\n\r\n' WHERE ClassName = 'WaterMeter'";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- Text = string.Format("Upgrade selection");
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_212_215_Button.Enabled = false;
- }
- catch (Exception exc)
- {
- log.ErrorFormat(string.Format("Exception when upgrading DB: {0}", exc.Message));
- if (exc.InnerException != null) log.ErrorFormat(string.Format("Inner exception: {0}", exc.InnerException.Message));
- ActivityEnd();
- MessageBox.Show(string.Format("Exception {0}", exc.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- finally
- {
- dbConn.Close();
- }
- }
- else
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_212_215_Button.Enabled = false;
- }
- }
- }
-
- ///---------------------------------------------------------------------
- private void upgradeDb_215_216_Button_Click(object sender, EventArgs e)
- {
- if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
- {
- MessageBox.Show("No database selected");
- return;
- }
-
- string[] commands = new string[]
- {
- "ALTER TABLE `testrslt` ADD `ErrorFlagsMd` TINYINT( 4 ) NOT NULL DEFAULT '0' AFTER `ErrorMaster`," +
- " ADD `ErrorFlags` INT NOT NULL DEFAULT '0' AFTER `ErrorFlagsMd`;",
- };
-
- ActivityStart();
-
- if (!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), commands))
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_215_216_Button.Enabled = false;
- }
- }
-
- ///---------------------------------------------------------------------
- private void upgradeDb_216_217_Button_Click(object sender, EventArgs e)
- {
- if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
- {
- MessageBox.Show("No database selected");
- return;
- }
-
- string[] commands = new string[]
- {
- "ALTER TABLE `testrslt` ADD `DiverterStart` FLOAT NOT NULL DEFAULT '0.001' AFTER `ErrorMaster`," +
- " ADD `DiverterEnd` FLOAT NOT NULL DEFAULT '0.001' AFTER `DiverterStart`;",
- "ALTER TABLE `watermeter` ADD `ErrorFlags` INT NOT NULL DEFAULT '0' AFTER `QFall`;",
- };
-
- ActivityStart();
-
- if (!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), commands))
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_216_217_Button.Enabled = false;
- }
- }
-
- ///---------------------------------------------------------------------
- private void upgradeDb_217_218_Button_Click(object sender, EventArgs e)
- {
- if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
- {
- MessageBox.Show("No database selected");
- return;
- }
-
- string[] commands = new string[]
- {
- "ALTER TABLE `measurementcorrection` ADD `RangeIx` INT NOT NULL DEFAULT '0' AFTER `Id`;",
- };
-
- ActivityStart();
-
- if (!upgradeConfigDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), commands))
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_217_218_Button.Enabled = false;
- }
- }
-
- ///---------------------------------------------------------------------
- private void upgradeDb_218_222_Button_Click(object sender, EventArgs e)
- {
- if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
- {
- MessageBox.Show("No database selected");
- return;
- }
-
- string[] resultsDbCommands = new string[]
- {
- "ALTER TABLE `metertestrslt` ADD `RegReaderType` INT NOT NULL DEFAULT '0' AFTER `CompoundMeterId`;",
- "ALTER TABLE `testrslt` ADD `MethodClass` VARCHAR(255) NULL DEFAULT NULL AFTER `RepetitionNr`," +
- " ADD `TimeBtwnMassMsrmnts` INT NOT NULL DEFAULT '0' AFTER `FlowSetTime`," +
- " ADD `TestTimeCorrection` DOUBLE NOT NULL DEFAULT '0' AFTER `TestTime`," +
- " ADD `ConstMasterRaw` DOUBLE NOT NULL DEFAULT '1' AFTER `PulsesMaster`," +
- " ADD `ConstMasterCorr` DOUBLE NOT NULL DEFAULT '1' AFTER `ConstMasterRaw`;",
- "ALTER TABLE `watermeterdata` ADD `Medium` VARCHAR(255) NULL DEFAULT NULL AFTER `ApprovalInfoAux`;",
- "ALTER TABLE `batch` ADD `Counter1` INT NOT NULL DEFAULT '0' AFTER `Custom3`," +
- " ADD `Counter2` INT NOT NULL DEFAULT '0' AFTER `Counter1`," +
- " ADD `Counter3` INT NOT NULL DEFAULT '0' AFTER `Counter2`," +
- " ADD `Counter4` INT NOT NULL DEFAULT '0' AFTER `Counter3`," +
- " ADD `Counter5` INT NOT NULL DEFAULT '0' AFTER `Counter4`," +
- " ADD `Counter6` INT NOT NULL DEFAULT '0' AFTER `Counter5`," +
- " ADD `Counter7` INT NOT NULL DEFAULT '0' AFTER `Counter6`," +
- " ADD `Counter8` INT NOT NULL DEFAULT '0' AFTER `Counter7`," +
- " ADD `Counter9` INT NOT NULL DEFAULT '0' AFTER `Counter8`," +
- " ADD `Counter10` INT NOT NULL DEFAULT '0' AFTER `Counter9`;",
- };
-
- ActivityStart();
-
- if (!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands))
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_218_222_Button.Enabled = false;
- }
- }
-
- private void upgradeDb_222_224_Button_Click(object sender, EventArgs e)
- {
- if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
- {
- MessageBox.Show("No database selected");
- return;
- }
-
- string[] configDbCommands = new string[]
- {
- /// Table profile
- "CREATE TABLE IF NOT EXISTS `profile` (" +
- "`Id` int(11) NOT NULL AUTO_INCREMENT," +
- " `ItemNr` int(11) NOT NULL DEFAULT '0'," +
- " `Name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
- " `Description` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
- " `CreationUser` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
- " `CreationTime` datetime DEFAULT NULL," +
- " `LastChgUser` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
- " `LastChgTime` datetime DEFAULT NULL," +
- " `ProfileType` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
- " `ErrorLimitType` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL," +
- " PRIMARY KEY (`Id`));",
-
- /// Table ptest
- "CREATE TABLE IF NOT EXISTS `ptest` (" +
- "`Id` int(11) NOT NULL AUTO_INCREMENT," +
- " `ItemNr` int(11) NOT NULL DEFAULT '0'," +
- " `Name` varchar(255) DEFAULT NULL," +
- " `Part` int(11) NOT NULL DEFAULT '0'," +
- " `CoefQfrom` double NOT NULL DEFAULT '0'," +
- " `CoefQto` double NOT NULL DEFAULT '0'," +
- " `ErrLimLo` double NOT NULL DEFAULT '0'," +
- " `ErrLimHi` double NOT NULL DEFAULT '0'," +
- " `TempLimLo` double NOT NULL DEFAULT '0'," +
- " `TempLimHi` double NOT NULL DEFAULT '0'," +
- " `PressLimLo` double NOT NULL DEFAULT '0'," +
- " `PressLimHi` double NOT NULL DEFAULT '0'," +
- " `Publish` tinyint(4) NOT NULL DEFAULT '1'," +
- " `Evaluate` boolean NOT NULL DEFAULT TRUE," +
- " `E1` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E2` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E3` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E4` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E5` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E6` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E7` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E8` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E9` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E10` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E11` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E12` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E13` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E14` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E15` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E16` tinyint(4) NOT NULL DEFAULT '0'," +
- " `E21` tinyint(4) NOT NULL DEFAULT '0'," +
- " `Delta_Q_pct` double NOT NULL DEFAULT '0'," +
- " `Delta_T` double NOT NULL DEFAULT '0'," +
- " `Delta_Tup_Tdn` double NOT NULL DEFAULT '0'," +
- " `TestTime_min` double NOT NULL DEFAULT '0'," +
- " `TestTime_max` double NOT NULL DEFAULT '0'," +
- " `AmbTemp_min` double NOT NULL DEFAULT '0'," +
- " `AmbTemp_max` double NOT NULL DEFAULT '0'," +
- " `Coef_E9` double NOT NULL DEFAULT '0'," +
- " `Coef_E10` double NOT NULL DEFAULT '0'," +
- " `Coef_E11` double NOT NULL DEFAULT '0'," +
- " `Coef_E12` double NOT NULL DEFAULT '0'," +
- " `Offset_E9` double NOT NULL DEFAULT '0'," +
- " `Offset_E12` double NOT NULL DEFAULT '0'," +
- " `Profile_id` int(11) DEFAULT NULL," +
- " PRIMARY KEY (`Id`));",
-
- /// Table test
- "ALTER TABLE `test` ADD `Qtg` FLOAT NULL DEFAULT NULL AFTER `Evaluate`;",
- "ALTER TABLE `test` CHANGE `RelTransAfter` `Profile` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;",
- "UPDATE `test` SET Profile = 'UserDefined';",
-
- /// Table uncertainty
- "CREATE TABLE IF NOT EXISTS `uncertainty` (" +
- " `Id` int(11) NOT NULL AUTO_INCREMENT," +
- " `Measurement` float NOT NULL DEFAULT '0'," +
- " `MainUncertainty` float NOT NULL DEFAULT '0'," +
- " `Resolution` float NOT NULL DEFAULT '0'," +
- " `DriftPerYr` float NOT NULL DEFAULT '0'," +
- " `Conditions` float NOT NULL DEFAULT '0'," +
- " `UncertaintyOfCorrection` float NOT NULL DEFAULT '0'," +
- " `Component_id` int(11) DEFAULT NULL," +
- " PRIMARY KEY (`Id`)," +
- " KEY `Component_id` (`Component_id`));",
-
- /// Table user
- "ALTER TABLE `user` ADD `Password2` VARCHAR(255) NULL DEFAULT NULL AFTER `Password`, ADD `Password3` VARCHAR(255) NULL DEFAULT NULL AFTER `Password2`, ADD `Password4` VARCHAR(255) NULL DEFAULT NULL AFTER `Password3`;",
-
- /// Tables watermeter and wmtype
- "DROP TABLE `watermeter`",
- "DROP TABLE `wmtype`",
-
- //"ALTER TABLE `procedure` DROP `ProtocolTitle`",
- };
-
- string[] resultsDbCommands = new string[]
- {
- "ALTER TABLE `testdata` ADD `Qtg` DOUBLE NULL DEFAULT NULL AFTER `Name`;",
-
- "ALTER TABLE `testrslt` ADD `Uncertnt` FLOAT NOT NULL DEFAULT '0' AFTER `FlowMax`," +
- " ADD `UncertntScale` FLOAT NOT NULL DEFAULT '0' AFTER `Uncertnt`," +
- " ADD `UncertntDensity` FLOAT NOT NULL DEFAULT '0' AFTER `UncertntScale`," +
- " ADD `UncertntTemp` FLOAT NOT NULL DEFAULT '0' AFTER `UncertntDensity`," +
- " ADD `UncertntPressure` FLOAT NOT NULL DEFAULT '0' AFTER `UncertntTemp`;",
- "ALTER TABLE `testrslt` CHANGE `ErrorFlags` `ErrorFlags` BIGINT(20) NOT NULL DEFAULT '0', CHANGE `ErrorFlagsMd` `InfoFlags` BIGINT(20) NOT NULL DEFAULT '0';",
-
- "ALTER TABLE `watermeter` CHANGE `ErrorFlags` `ErrorFlags` BIGINT(20) NOT NULL DEFAULT '0', ADD `InfoFlags` BIGINT NOT NULL DEFAULT '0' AFTER `ErrorFlags`;",
-#if IPERL
- "ALTER TABLE `watermeter` DROP `Q2CorrectionDone`, DROP `Q2Correction`;",
-#endif
- };
-
- ActivityStart();
- bool success = true;
-
- if (upgradeConfigDBCheckBox.Checked)
- {
- success = success && ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands);
-
- if (!string.IsNullOrEmpty(errorFlagsComponentsTextBox.Text))
- {
- string[] errorFlagsCmpnts = errorFlagsComponentsTextBox.Text.Split(new char[] { '~' });
- foreach (var errFCmpnt in errorFlagsCmpnts)
- {
- success = success && ChangeErrorFlags(errFCmpnt);
- }
- }
- }
-
- if (upgradeResultsDBCheckBox.Checked)
- {
- success = success && ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands);
- }
-
- if (success)
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded." + Environment.NewLine +
- "Please, create Density and Buoyancy components.",
- "Confirmation",
- MessageBoxButtons.OK,
- MessageBoxIcon.Information);
- upgradeDb_222_224_Button.Enabled = false;
- }
- }
-
- private void upgradeDb_224_225_Button_Click(object sender, EventArgs e)
- {
- MySqlConnection dbConn = null;
- MySqlCommand cmd;
-
- ActivityStart();
- bool success = false;
-
- try
- {
- dbConn = new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString);
- dbConn.Open();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "CREATE TABLE IF NOT EXISTS `usersgroups` ( `Group_id` int(11) NOT NULL, `User_id` int(11) NOT NULL );";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "ALTER TABLE `usersgroups` ADD KEY `User_id` (`User_id`), ADD KEY `Group_id` (`Group_id`)," +
- " ADD CONSTRAINT `FKEC3AF23393C4061C` FOREIGN KEY (`Group_id`) REFERENCES `group` (`Id`)," +
- " ADD CONSTRAINT `FKEC3AF23373767C99` FOREIGN KEY (`User_id`) REFERENCES `user` (`Id`);";
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- int[] groupIdsToKeep = new int[(int)Common.GID.NrOfGroups];
- IList groupTable = new List();
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = "SELECT `Id`, `Gid`, `User_id` FROM `group`;";
- MySqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- int groupId = dr.GetInt32(0);
- Common.GID gid = (Common.GID)dr.GetInt32(1);
- int userId = dr.GetInt32(2);
-
- groupTable.Add(new GroupTableRow(groupId, gid, userId));
-
- if ((gid >= 0) && (gid < Common.GID.NrOfGroups) && (groupIdsToKeep[(int)gid] == 0))
- {
- groupIdsToKeep[(int)gid] = groupId;
- }
- }
- dr.Close();
-
- foreach (var groupTableRow in groupTable)
- {
- cmd = dbConn.CreateCommand();
- cmd.CommandText = string.Format("INSERT INTO `usersgroups` (`Group_id`, `User_id`) VALUES ({0}, {1});",
- groupIdsToKeep[(int)groupTableRow.Gid],
- groupTableRow.UserId);
- cmd.ExecuteNonQuery();
- cmd.Dispose();
- }
-
- //foreach (var groupTableRow in groupTable)
- //{
- // bool deleteThisRow = true;
- // for (int i = 0; i < groupIdsToKeep.Length; i++)
- // {
- // if (groupTableRow.GroupId == groupIdsToKeep[i])
- // {
- // deleteThisRow = false;
- // break;
- // }
- // }
-
- // if (deleteThisRow)
- // {
- // cmd = dbConn.CreateCommand();
- // cmd.CommandText = string.Format("DELETE FROM `group` WHERE `Id` = {0}", groupTableRow.GroupId);
- // cmd.ExecuteNonQuery();
- // cmd.Dispose();
- // }
- //}
-
- cmd = dbConn.CreateCommand();
- cmd.CommandText = string.Format("ALTER TABLE `group` ADD `AccessFlags` BIGINT NOT NULL DEFAULT '0' AFTER `Name`;");
- cmd.ExecuteNonQuery();
- cmd.Dispose();
-
- success = true;
- }
- catch (Exception exc)
- {
- log.ErrorFormat(string.Format("Exception when upgrading DB: {0}", exc.Message));
- if (exc.InnerException != null) log.ErrorFormat(string.Format("Inner exception: {0}", exc.InnerException.Message));
- ActivityEnd();
- MessageBox.Show(string.Format("Exception {0}", exc.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- finally
- {
- if (dbConn != null) dbConn.Close();
- }
-
- if (success)
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_224_225_Button.Enabled = false;
- }
- }
-
- private void upgradeDb_225_226_Button_Click(object sender, EventArgs e)
- {
- if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
- {
- MessageBox.Show("No database selected");
- return;
- }
-
- string[] configDbCommands = new string[]
- {
- "ALTER TABLE `procedure` ADD `EventTriggers` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL AFTER `ResultsWriter`;",
-
- "CREATE TABLE IF NOT EXISTS `customevent` (" +
- "`Id` int(11) NOT NULL," +
- " `Date` datetime DEFAULT NULL," +
- " `Frequency` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL," +
- " `AllDay` tinyint(1) DEFAULT NULL," +
- " `TriggerOnExactDayOnly` tinyint(1) DEFAULT NULL," +
- " `Source` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL," +
- " `Title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL," +
- " `AutoAction` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL," +
- " `Parameters` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL," +
- " `Rank` int(11) DEFAULT NULL," +
- " `Hidden` tinyint(1) DEFAULT NULL," +
- " `ReadOnly` tinyint(1) DEFAULT NULL," +
- " `BackColor` int(11) DEFAULT NULL," +
- " `TextColor` int(11) DEFAULT NULL," +
- " `TooltipEnabled` tinyint(1) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;",
-
- "ALTER TABLE `customevent` ADD PRIMARY KEY (`Id`);",
-
- "ALTER TABLE `customevent` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;",
- };
-
- string[] resultsDbCommands = new string[]
- {
-#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
- "ALTER TABLE `testrslt` ADD `ConductMean` FLOAT NULL DEFAULT NULL AFTER `FlowMax`," +
- " ADD `ConductStart` FLOAT NULL DEFAULT NULL AFTER `ConductMean`," +
- " ADD `ConductEnd` FLOAT NULL DEFAULT NULL AFTER `ConductStart`," +
- " ADD `ConductMin` FLOAT NULL DEFAULT NULL AFTER `ConductEnd`," +
- " ADD `ConductMax` FLOAT NULL DEFAULT NULL AFTER `ConductMin`;",
-#endif
- };
-
- ActivityStart();
-
- if ((!upgradeConfigDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
- (!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands)))
- {
- ActivityEnd();
- MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
- upgradeDb_225_226_Button.Enabled = false;
- }
- }
-
- private void pressureRepresentationButton_Click(object sender, EventArgs e)
- {
- try
- {
- batchFrom = int.Parse(textBox1.Text);
- batchTo = int.Parse(textBox2.Text);
- if (batchFrom < 1 || batchFrom > batchTo) throw new Exception();
- }
- catch
- {
- MessageBox.Show("Wrong 'From batch #' or 'To batch #'", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
-
- if (MessageBox.Show("Are you sure ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
-
- ActivityStart();
-
- try
- {
- ISession session = Results.DB.CreateSession();
-
- IList bFrom = session.QueryOver().Where(x => (x.BatchNr == batchFrom)).List();
- IList bTo = session.QueryOver().Where(x => (x.BatchNr == batchTo)).List();
-
- if (bFrom.Count != 1) throw new Exception("No start batch");
- if (bTo.Count != 1) throw new Exception("No end batch");
-
- IList testResults = session.QueryOver()
- .WhereRestrictionOn(x => x.StartTime)
- .IsBetween(bFrom[0].StartTime)
- .And(bTo[0].EndTime)
- .List();
-
- foreach (var tr in testResults)
- {
- Text = string.Format("Batch # = {0}", tr.Batch.BatchNr);
-
- float factor1 = 0.01f;
-
- tr.PressUpMean *= factor1;
- tr.PressUpStart *= factor1;
- tr.PressUpEnd *= factor1;
- tr.PressUpMin *= factor1;
- tr.PressUpMax *= factor1;
-
- tr.PressDownMean *= factor1;
- tr.PressDownStart *= factor1;
- tr.PressDownEnd *= factor1;
- tr.PressDownMin *= factor1;
- tr.PressDownMax *= factor1;
-
- tr.AmbPressMean *= 0.001f;
-
- session.SaveOrUpdate(tr);
- }
-
- session.Flush();
- ActivityEnd();
- MessageBox.Show("Upgrade completed", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- catch (Exception exc)
- {
- ActivityEnd();
- MessageBox.Show(string.Format("Upgrade failed:\r\n{0}", exc.Message),
- "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
-
private void upgradePipesButton_Click(object sender, EventArgs e)
{
ActivityStart();
@@ -1124,5 +178,164 @@ namespace TBF.UI.Settings
foreach (var c in components) if (c.Name == name) return c.Id;
return 0;
}
+
+ private void upgradeDb_301_302_Button_Click(object sender, EventArgs e)
+ {
+ MessageBox.Show("Not implemented");
+ return;
+
+ string[] configDbCommands = new string[]
+ {
+ /// TODO
+ };
+
+ string[] resultsDbCommands = new string[]
+ {
+ /// TODO
+ };
+
+ if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
+ {
+ MessageBox.Show("No database selected");
+ return;
+ }
+
+ ActivityStart();
+
+ if ((!upgradeConfigDBCheckBox.Checked || configDbCommands.Length == 0 ||
+ ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
+ (!upgradeResultsDBCheckBox.Checked || resultsDbCommands.Length == 0 ||
+ ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands)))
+ {
+ ActivityEnd();
+ MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ upgradeDb_301_302_Button.Enabled = false;
+ }
+ }
+
+ private void upgradeDb_302_303_Button_Click(object sender, EventArgs e)
+ {
+ MessageBox.Show("Not implemented");
+ return;
+
+ string[] configDbCommands = new string[]
+ {
+ /// TODO
+ };
+
+ string[] resultsDbCommands = new string[]
+ {
+ /// TODO
+ };
+
+ if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
+ {
+ MessageBox.Show("No database selected");
+ return;
+ }
+
+ ActivityStart();
+
+ if ((!upgradeConfigDBCheckBox.Checked || configDbCommands.Length == 0 ||
+ ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
+ (!upgradeResultsDBCheckBox.Checked || resultsDbCommands.Length == 0 ||
+ ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands)))
+ {
+ ActivityEnd();
+ MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ upgradeDb_302_303_Button.Enabled = false;
+ }
+ }
+
+ private void upgradeDb_303_304_Button_Click(object sender, EventArgs e)
+ {
+ string[] configDbCommands = new string[]
+ {
+ "ALTER TABLE `outputpath` ADD `RegVPositions` VARCHAR(255) NULL DEFAULT NULL AFTER `Scale`;"
+ };
+
+ string[] resultsDbCommands = new string[] { };
+
+ if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
+ {
+ MessageBox.Show("No database selected");
+ return;
+ }
+
+ ActivityStart();
+
+ if ((!upgradeConfigDBCheckBox.Checked || configDbCommands.Length == 0 ||
+ ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
+ (!upgradeResultsDBCheckBox.Checked || resultsDbCommands.Length == 0 ||
+ ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands)))
+ {
+ ActivityEnd();
+ MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ upgradeDb_303_304_Button.Enabled = false;
+ }
+ }
+
+ private void upgradeDb_304_305_Button_Click(object sender, EventArgs e)
+ {
+ string[] configDbCommands = new string[]
+ {
+ "ALTER TABLE `ptest` ADD `Method` VARCHAR(255) NULL DEFAULT NULL AFTER `Evaluate`;"
+ };
+
+ string[] resultsDbCommands = new string[] { };
+
+ if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
+ {
+ MessageBox.Show("No database selected");
+ return;
+ }
+
+ ActivityStart();
+
+ if ((!upgradeConfigDBCheckBox.Checked || configDbCommands.Length == 0 ||
+ ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
+ (!upgradeResultsDBCheckBox.Checked || resultsDbCommands.Length == 0 ||
+ ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands)))
+ {
+ ActivityEnd();
+ MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ upgradeDb_304_305_Button.Enabled = false;
+ }
+ }
+
+ private void upgradeDb_305_306_Button_Click(object sender, EventArgs e)
+ {
+ string[] configDbCommands = new string[] { };
+
+ string[] resultsDbCommands = new string[]
+ {
+ "ALTER TABLE `batch` CHANGE `StartTime` `StartTime` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00';",
+ "ALTER TABLE `batch` CHANGE `EndTime` `EndTime` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00';",
+ "ALTER TABLE `batch` ADD `SaveTime` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `EndTime`;",
+#if !(MUNICH && LANG_DE)
+ "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`;"
+ };
+
+ if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
+ {
+ MessageBox.Show("No database selected");
+ return;
+ }
+
+ ActivityStart();
+
+ if ((!upgradeConfigDBCheckBox.Checked || configDbCommands.Length == 0 ||
+ ExecuteCommands(new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
+ (!upgradeResultsDBCheckBox.Checked || resultsDbCommands.Length == 0 ||
+ ExecuteCommands(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands)))
+ {
+ ActivityEnd();
+ MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ upgradeDb_305_306_Button.Enabled = false;
+ }
+ }
}
}