UpgradeSelectionDlg support for 2.12-->2.17, ver. 2.17.722
This commit is contained in:
+91
-78
@@ -31,84 +31,96 @@ namespace TBF.Forms
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NoBenchOrDatabaseDlg));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NoBenchOrDatabaseDlg));
|
||||||
this.exitButton = new System.Windows.Forms.Button();
|
this.exitButton = new System.Windows.Forms.Button();
|
||||||
this.retryButton = new System.Windows.Forms.Button();
|
this.retryButton = new System.Windows.Forms.Button();
|
||||||
this.configureButton = new System.Windows.Forms.Button();
|
this.configureButton = new System.Windows.Forms.Button();
|
||||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||||
this.errorMessageLabel = new System.Windows.Forms.Label();
|
this.errorMessageLabel = new System.Windows.Forms.Label();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
this.upgradeButton = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
//
|
this.SuspendLayout();
|
||||||
// exitButton
|
//
|
||||||
//
|
// exitButton
|
||||||
this.exitButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
//
|
||||||
this.exitButton.Location = new System.Drawing.Point(42, 68);
|
this.exitButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
this.exitButton.Name = "exitButton";
|
this.exitButton.Location = new System.Drawing.Point(42, 68);
|
||||||
this.exitButton.Size = new System.Drawing.Size(246, 33);
|
this.exitButton.Name = "exitButton";
|
||||||
this.exitButton.TabIndex = 0;
|
this.exitButton.Size = new System.Drawing.Size(388, 33);
|
||||||
this.exitButton.Text = "Exit";
|
this.exitButton.TabIndex = 0;
|
||||||
this.exitButton.UseVisualStyleBackColor = true;
|
this.exitButton.Text = "Exit";
|
||||||
this.exitButton.Click += new System.EventHandler(this.exitButton_Click);
|
this.exitButton.UseVisualStyleBackColor = true;
|
||||||
//
|
this.exitButton.Click += new System.EventHandler(this.exitButton_Click);
|
||||||
// retryButton
|
//
|
||||||
//
|
// retryButton
|
||||||
this.retryButton.Location = new System.Drawing.Point(42, 146);
|
//
|
||||||
this.retryButton.Name = "retryButton";
|
this.retryButton.Location = new System.Drawing.Point(42, 146);
|
||||||
this.retryButton.Size = new System.Drawing.Size(246, 33);
|
this.retryButton.Name = "retryButton";
|
||||||
this.retryButton.TabIndex = 1;
|
this.retryButton.Size = new System.Drawing.Size(388, 33);
|
||||||
this.retryButton.Text = "Retry database connection";
|
this.retryButton.TabIndex = 1;
|
||||||
this.retryButton.UseVisualStyleBackColor = true;
|
this.retryButton.Text = "Retry database connection";
|
||||||
this.retryButton.Click += new System.EventHandler(this.retryButton_Click);
|
this.retryButton.UseVisualStyleBackColor = true;
|
||||||
//
|
this.retryButton.Click += new System.EventHandler(this.retryButton_Click);
|
||||||
// configureButton
|
//
|
||||||
//
|
// configureButton
|
||||||
this.configureButton.Location = new System.Drawing.Point(42, 107);
|
//
|
||||||
this.configureButton.Name = "configureButton";
|
this.configureButton.Location = new System.Drawing.Point(42, 107);
|
||||||
this.configureButton.Size = new System.Drawing.Size(246, 33);
|
this.configureButton.Name = "configureButton";
|
||||||
this.configureButton.TabIndex = 2;
|
this.configureButton.Size = new System.Drawing.Size(388, 33);
|
||||||
this.configureButton.Text = "Configure test benches (password required)";
|
this.configureButton.TabIndex = 2;
|
||||||
this.configureButton.UseVisualStyleBackColor = true;
|
this.configureButton.Text = "Configure test benches (password required)";
|
||||||
this.configureButton.Click += new System.EventHandler(this.configureButton_Click);
|
this.configureButton.UseVisualStyleBackColor = true;
|
||||||
//
|
this.configureButton.Click += new System.EventHandler(this.configureButton_Click);
|
||||||
// pictureBox1
|
//
|
||||||
//
|
// pictureBox1
|
||||||
this.pictureBox1.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.ErrorImage")));
|
//
|
||||||
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
|
this.pictureBox1.ErrorImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.ErrorImage")));
|
||||||
this.pictureBox1.InitialImage = null;
|
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
|
||||||
this.pictureBox1.Location = new System.Drawing.Point(42, 21);
|
this.pictureBox1.InitialImage = null;
|
||||||
this.pictureBox1.Name = "pictureBox1";
|
this.pictureBox1.Location = new System.Drawing.Point(42, 21);
|
||||||
this.pictureBox1.Size = new System.Drawing.Size(32, 32);
|
this.pictureBox1.Name = "pictureBox1";
|
||||||
this.pictureBox1.TabIndex = 3;
|
this.pictureBox1.Size = new System.Drawing.Size(32, 32);
|
||||||
this.pictureBox1.TabStop = false;
|
this.pictureBox1.TabIndex = 3;
|
||||||
//
|
this.pictureBox1.TabStop = false;
|
||||||
// errorMessageLabel
|
//
|
||||||
//
|
// errorMessageLabel
|
||||||
this.errorMessageLabel.AutoSize = true;
|
//
|
||||||
this.errorMessageLabel.Location = new System.Drawing.Point(80, 31);
|
this.errorMessageLabel.AutoSize = true;
|
||||||
this.errorMessageLabel.Name = "errorMessageLabel";
|
this.errorMessageLabel.Location = new System.Drawing.Point(80, 31);
|
||||||
this.errorMessageLabel.Size = new System.Drawing.Size(160, 13);
|
this.errorMessageLabel.Name = "errorMessageLabel";
|
||||||
this.errorMessageLabel.TabIndex = 4;
|
this.errorMessageLabel.Size = new System.Drawing.Size(160, 13);
|
||||||
this.errorMessageLabel.Text = "Cannot connect to the database";
|
this.errorMessageLabel.TabIndex = 4;
|
||||||
//
|
this.errorMessageLabel.Text = "Cannot connect to the database";
|
||||||
// NoBenchOrDatabaseDlg
|
//
|
||||||
//
|
// upgradeButton
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
//
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.upgradeButton.Location = new System.Drawing.Point(42, 185);
|
||||||
this.CancelButton = this.exitButton;
|
this.upgradeButton.Name = "upgradeButton";
|
||||||
this.ClientSize = new System.Drawing.Size(328, 194);
|
this.upgradeButton.Size = new System.Drawing.Size(388, 33);
|
||||||
this.Controls.Add(this.errorMessageLabel);
|
this.upgradeButton.TabIndex = 5;
|
||||||
this.Controls.Add(this.pictureBox1);
|
this.upgradeButton.Text = "Upgrade the database";
|
||||||
this.Controls.Add(this.configureButton);
|
this.upgradeButton.UseVisualStyleBackColor = true;
|
||||||
this.Controls.Add(this.retryButton);
|
this.upgradeButton.Click += new System.EventHandler(this.upgradeButton_Click);
|
||||||
this.Controls.Add(this.exitButton);
|
//
|
||||||
this.Name = "NoBenchOrDatabaseDlg";
|
// NoBenchOrDatabaseDlg
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
//
|
||||||
this.Text = "Error";
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.Load += new System.EventHandler(this.NoDatabaseMsgDlg_Load);
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
this.CancelButton = this.exitButton;
|
||||||
this.ResumeLayout(false);
|
this.ClientSize = new System.Drawing.Size(466, 240);
|
||||||
this.PerformLayout();
|
this.Controls.Add(this.upgradeButton);
|
||||||
|
this.Controls.Add(this.errorMessageLabel);
|
||||||
|
this.Controls.Add(this.pictureBox1);
|
||||||
|
this.Controls.Add(this.configureButton);
|
||||||
|
this.Controls.Add(this.retryButton);
|
||||||
|
this.Controls.Add(this.exitButton);
|
||||||
|
this.Name = "NoBenchOrDatabaseDlg";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Error";
|
||||||
|
this.Load += new System.EventHandler(this.NoDatabaseMsgDlg_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,5 +131,6 @@ namespace TBF.Forms
|
|||||||
private System.Windows.Forms.Button configureButton;
|
private System.Windows.Forms.Button configureButton;
|
||||||
private System.Windows.Forms.PictureBox pictureBox1;
|
private System.Windows.Forms.PictureBox pictureBox1;
|
||||||
private System.Windows.Forms.Label errorMessageLabel;
|
private System.Windows.Forms.Label errorMessageLabel;
|
||||||
|
private System.Windows.Forms.Button upgradeButton;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,19 +33,9 @@ namespace TBF.Forms
|
|||||||
if (!ShowRetry) retryButton.Enabled = false;
|
if (!ShowRetry) retryButton.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exitButton_Click(object sender, EventArgs e)
|
private void exitButton_Click(object sender, EventArgs e) { DialogResult = DialogResult.Abort; } /// Exit
|
||||||
{
|
private void configureButton_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; } /// Configure test benches
|
||||||
DialogResult = DialogResult.Abort;
|
private void retryButton_Click(object sender, EventArgs e) { DialogResult = DialogResult.Retry; } /// Retry connection to the database
|
||||||
}
|
private void upgradeButton_Click(object sender, EventArgs e) { DialogResult = DialogResult.Yes; } /// Upgrade the database
|
||||||
|
|
||||||
private void retryButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void configureButton_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,8 +229,8 @@
|
|||||||
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAOvwAA
|
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAOvgAA
|
||||||
Dr8BOAVTJAAACG1JREFUSEu1lmlQW9cVx/mG0GIZZCczGcZjvCQEiLHNYpABAQKEwBjTeqmXCfkQ3Mx4
|
Dr4B6kKxwAAACG1JREFUSEu1lmlQW9cVx/mG0GIZZCczGcZjvCQEiLHNYpABAQKEwBjTeqmXCfkQ3Mx4
|
||||||
xp58SlMnY/dLmxl3TJIZu3UhBAQBsYNsisBoByS0C21oMUhCYIQkbFzqxo4n9C89TElqt/3SM1dv3tM7
|
xp58SlMnY/dLmxl3TJIZu3UhBAQBsYNsisBoByS0C21oMUhCYIQkbFzqxo4n9C89TElqt/3SM1dv3tM7
|
||||||
93fOPfecc1/M+n+UQCCgnJzs5PPrb9787OrVK5cvY+AGj/gTr6Cwofoaea0Bh8PR1dl5/do1Ho8nlUqd
|
93fOPfecc1/M+n+UQCCgnJzs5PPrb9787OrVK5cvY+AGj/gTr6Cwofoaea0Bh8PR1dl5/do1Ho8nlUqd
|
||||||
TudKOPxDVHCDR/yJV1CAGpQ3pv2bvMJAMBgcGBior6+XSCQhPDhm/CKRu4Nvv3Xb8vsv9J9fm77xRwev
|
TudKOPxDVHCDR/yJV1CAGpQ3pv2bvMJAMBgcGBior6+XSCQhPDhm/CKRu4Nvv3Xb8vsv9J9fm77xRwev
|
||||||
|
|||||||
+26
-13
@@ -28,37 +28,49 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.upgradeDbButton = new System.Windows.Forms.Button();
|
this.upgradeDb_215_217_Button = new System.Windows.Forms.Button();
|
||||||
this.upgradeDb_216_217_Button = new System.Windows.Forms.Button();
|
this.upgradeDb_216_217_Button = new System.Windows.Forms.Button();
|
||||||
|
this.upgradeDb_212_217_Button = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// upgradeDbButton
|
// upgradeDb_215_217_Button
|
||||||
//
|
//
|
||||||
this.upgradeDbButton.Location = new System.Drawing.Point(12, 12);
|
this.upgradeDb_215_217_Button.Location = new System.Drawing.Point(12, 52);
|
||||||
this.upgradeDbButton.Name = "upgradeDbButton";
|
this.upgradeDb_215_217_Button.Name = "upgradeDb_215_217_Button";
|
||||||
this.upgradeDbButton.Size = new System.Drawing.Size(260, 34);
|
this.upgradeDb_215_217_Button.Size = new System.Drawing.Size(260, 34);
|
||||||
this.upgradeDbButton.TabIndex = 0;
|
this.upgradeDb_215_217_Button.TabIndex = 1;
|
||||||
this.upgradeDbButton.Text = "Upgrade database from ver. 2.15 to ver. 2.17";
|
this.upgradeDb_215_217_Button.Text = "Upgrade database from ver. 2.15 to ver. 2.17";
|
||||||
this.upgradeDbButton.UseVisualStyleBackColor = true;
|
this.upgradeDb_215_217_Button.UseVisualStyleBackColor = true;
|
||||||
this.upgradeDbButton.Click += new System.EventHandler(this.upgradeDbButton_Click);
|
this.upgradeDb_215_217_Button.Click += new System.EventHandler(this.upgradeDb_215_217_Button_Click);
|
||||||
//
|
//
|
||||||
// upgradeDb_216_217_Button
|
// upgradeDb_216_217_Button
|
||||||
//
|
//
|
||||||
this.upgradeDb_216_217_Button.Location = new System.Drawing.Point(12, 52);
|
this.upgradeDb_216_217_Button.Location = new System.Drawing.Point(12, 92);
|
||||||
this.upgradeDb_216_217_Button.Name = "upgradeDb_216_217_Button";
|
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.Size = new System.Drawing.Size(260, 34);
|
||||||
this.upgradeDb_216_217_Button.TabIndex = 1;
|
this.upgradeDb_216_217_Button.TabIndex = 2;
|
||||||
this.upgradeDb_216_217_Button.Text = "Upgrade database from ver. 2.16 to ver. 2.17";
|
this.upgradeDb_216_217_Button.Text = "Upgrade database from ver. 2.16 to ver. 2.17";
|
||||||
this.upgradeDb_216_217_Button.UseVisualStyleBackColor = true;
|
this.upgradeDb_216_217_Button.UseVisualStyleBackColor = true;
|
||||||
this.upgradeDb_216_217_Button.Click += new System.EventHandler(this.upgradeDb_216_217_Button_Click);
|
this.upgradeDb_216_217_Button.Click += new System.EventHandler(this.upgradeDb_216_217_Button_Click);
|
||||||
//
|
//
|
||||||
|
// upgradeDb_212_217_Button
|
||||||
|
//
|
||||||
|
this.upgradeDb_212_217_Button.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.upgradeDb_212_217_Button.Name = "upgradeDb_212_217_Button";
|
||||||
|
this.upgradeDb_212_217_Button.Size = new System.Drawing.Size(260, 34);
|
||||||
|
this.upgradeDb_212_217_Button.TabIndex = 0;
|
||||||
|
this.upgradeDb_212_217_Button.Text = "Upgrade database from ver. 2.12 to ver. 2.17";
|
||||||
|
this.upgradeDb_212_217_Button.UseVisualStyleBackColor = true;
|
||||||
|
this.upgradeDb_212_217_Button.Click += new System.EventHandler(this.upgradeDb_212_217_Button_Click);
|
||||||
|
//
|
||||||
// UpgradeSelectionDlg
|
// UpgradeSelectionDlg
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(284, 262);
|
this.ClientSize = new System.Drawing.Size(284, 262);
|
||||||
|
this.Controls.Add(this.upgradeDb_212_217_Button);
|
||||||
this.Controls.Add(this.upgradeDb_216_217_Button);
|
this.Controls.Add(this.upgradeDb_216_217_Button);
|
||||||
this.Controls.Add(this.upgradeDbButton);
|
this.Controls.Add(this.upgradeDb_215_217_Button);
|
||||||
this.Name = "UpgradeSelectionDlg";
|
this.Name = "UpgradeSelectionDlg";
|
||||||
this.Text = "Upgrade selection";
|
this.Text = "Upgrade selection";
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
@@ -67,8 +79,9 @@
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.Button upgradeDbButton;
|
private System.Windows.Forms.Button upgradeDb_215_217_Button;
|
||||||
private System.Windows.Forms.Button upgradeDb_216_217_Button;
|
private System.Windows.Forms.Button upgradeDb_216_217_Button;
|
||||||
|
private System.Windows.Forms.Button upgradeDb_212_217_Button;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,51 +1,27 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using log4net;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using Results;
|
|
||||||
|
|
||||||
namespace TBF.Forms
|
namespace TBF.Forms
|
||||||
{
|
{
|
||||||
public partial class UpgradeSelectionDlg : Form
|
public partial class UpgradeSelectionDlg : Form
|
||||||
{
|
{
|
||||||
int batchFrom;
|
private static readonly ILog log = LogManager.GetLogger(typeof(UpgradeSelectionDlg));
|
||||||
int batchTo;
|
|
||||||
|
|
||||||
public UpgradeSelectionDlg()
|
public UpgradeSelectionDlg()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
batchFrom = 1;
|
|
||||||
batchTo = Program.LocalSettings.BatchNr - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upgradeDbButton_Click(object sender, EventArgs e)
|
/// <summary>
|
||||||
{
|
/// Common part of database upgrade code
|
||||||
string[] commands = new string[]
|
/// </summary>
|
||||||
{
|
/// <param name="dbConn">Database connection</param>
|
||||||
"ALTER TABLE `testrslt` ADD `ErrorFlagsMd` TINYINT( 4 ) NOT NULL DEFAULT '0' AFTER `ErrorMaster`, ADD `ErrorFlags` INT NOT NULL DEFAULT '0' AFTER `ErrorFlagsMd`, ADD `DiverterStart` FLOAT NOT NULL DEFAULT '0.001' AFTER `ErrorMaster`, ADD `DiverterEnd` FLOAT NOT NULL DEFAULT '0.001' AFTER `DiverterStart`;",
|
/// <param name="commands">Array of SQL commands to be executed</param>
|
||||||
"ALTER TABLE `watermeter` ADD `ErrorFlags` INT NOT NULL DEFAULT '0' AFTER `QFall`;",
|
/// <returns>true = successful</returns>
|
||||||
};
|
bool UpgradeCommon(MySqlConnection dbConn, string[] commands)
|
||||||
|
|
||||||
if (Common(new MySqlConnection(Results.DB.ConnectionString), commands))
|
|
||||||
{
|
|
||||||
upgradeDbButton.Enabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void upgradeDb_216_217_Button_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
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`;",
|
|
||||||
};
|
|
||||||
|
|
||||||
if (Common(new MySqlConnection(Results.DB.ConnectionString), commands))
|
|
||||||
{
|
|
||||||
upgradeDb_216_217_Button.Enabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Common(MySqlConnection dbConn, string[] commands)
|
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
@@ -58,13 +34,15 @@ namespace TBF.Forms
|
|||||||
MySqlCommand cmd = dbConn.CreateCommand();
|
MySqlCommand cmd = dbConn.CreateCommand();
|
||||||
cmd.CommandText = cmdText;
|
cmd.CommandText = cmdText;
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
catch (Exception exc)
|
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));
|
||||||
MessageBox.Show(string.Format("Exception {0}", exc.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
MessageBox.Show(string.Format("Exception {0}", exc.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -74,5 +52,200 @@ namespace TBF.Forms
|
|||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///---------------------------------------------------------------------
|
||||||
|
private void upgradeDb_212_217_Button_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
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`;",
|
||||||
|
/// 2.15 -> 2.17
|
||||||
|
"ALTER TABLE `testrslt` ADD `ErrorFlagsMd` TINYINT( 4 ) NOT NULL DEFAULT '0' AFTER `ErrorMaster`, ADD `ErrorFlags` INT NOT NULL DEFAULT '0' AFTER `ErrorFlagsMd`, 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`;",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (UpgradeCommon(new MySqlConnection(Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands) &&
|
||||||
|
UpgradeCommon(new MySqlConnection(Results.DB.ConnectionString), resultsDbCommands))
|
||||||
|
{
|
||||||
|
MySqlConnection dbConn = new MySqlConnection(Config.Data.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<int> idList = new List<int>();
|
||||||
|
IList<string> parList = new List<string>();
|
||||||
|
IList<int> procIdList = new List<int>();
|
||||||
|
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("<Qmax>", "<NewQnames>true</NewQnames>\r\n <Qmax>"));
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Delete 'Parmeters' of iPerl water meters
|
||||||
|
cmd = dbConn.CreateCommand();
|
||||||
|
cmd.CommandText = "UPDATE component SET Parameters = '<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<WaterMeterCfg xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n</WaterMeterCfg>' WHERE ClassName = 'WaterMeter'";
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Dispose();
|
||||||
|
|
||||||
|
Text = string.Format("Upgrade selection");
|
||||||
|
MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
upgradeDb_212_217_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));
|
||||||
|
MessageBox.Show(string.Format("Exception {0}", exc.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
dbConn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///---------------------------------------------------------------------
|
||||||
|
private void upgradeDb_215_217_Button_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
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`, 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`;",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (UpgradeCommon(new MySqlConnection(Results.DB.ConnectionString), commands))
|
||||||
|
{
|
||||||
|
MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
upgradeDb_215_217_Button.Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///---------------------------------------------------------------------
|
||||||
|
private void upgradeDb_216_217_Button_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
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`;",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (UpgradeCommon(new MySqlConnection(Results.DB.ConnectionString), commands))
|
||||||
|
{
|
||||||
|
MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
upgradeDb_216_217_Button.Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -305,14 +305,14 @@ namespace TBF
|
|||||||
Results.DB.DbType = Config.Data.CurrentBench.WaterMetersDBSettings.DbType;
|
Results.DB.DbType = Config.Data.CurrentBench.WaterMetersDBSettings.DbType;
|
||||||
Results.DB.ConnectionString = Config.Data.CurrentBench.WaterMetersDBSettings.ConnectionString;
|
Results.DB.ConnectionString = Config.Data.CurrentBench.WaterMetersDBSettings.ConnectionString;
|
||||||
Results.DB.LoadSharedData();
|
Results.DB.LoadSharedData();
|
||||||
int maxBatchNr = Results.DB.GetMaxSavedBatchNr();
|
int maxBatchNr = Results.DB.GetMaxSavedBatchNr();
|
||||||
if (!Config.Data.CurrentBench.IsRealBench || Program.LocalSettings.BatchNr <= maxBatchNr)
|
if (!Config.Data.CurrentBench.IsRealBench || Program.LocalSettings.BatchNr <= maxBatchNr)
|
||||||
{
|
{
|
||||||
log.FatalFormat("Max. BatchNr in DB = {0}, LocalSettings.BatchNr = {1}", maxBatchNr, Program.LocalSettings.BatchNr);
|
log.FatalFormat("Max. BatchNr in DB = {0}, LocalSettings.BatchNr = {1}", maxBatchNr, Program.LocalSettings.BatchNr);
|
||||||
Program.LocalSettings.BatchNr = maxBatchNr + 1;
|
Program.LocalSettings.BatchNr = maxBatchNr + 1;
|
||||||
Program.LocalSettings.Save();
|
Program.LocalSettings.Save();
|
||||||
log.FatalFormat("LocalSettings.BatchNr updated to {0}", Program.LocalSettings.BatchNr);
|
log.FatalFormat("LocalSettings.BatchNr updated to {0}", Program.LocalSettings.BatchNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is to trigger an exception in case of a power user and no Config database
|
/// This is to trigger an exception in case of a power user and no Config database
|
||||||
IList<Procedure> listOfProcedures = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config)
|
IList<Procedure> listOfProcedures = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config)
|
||||||
@@ -343,18 +343,28 @@ namespace TBF
|
|||||||
/// Ask what to do
|
/// Ask what to do
|
||||||
switch ((new Forms.NoBenchOrDatabaseDlg { Message = Strings.NoDatabaseMsg, ShowRetry = true }).ShowDialog())
|
switch ((new Forms.NoBenchOrDatabaseDlg { Message = Strings.NoDatabaseMsg, ShowRetry = true }).ShowDialog())
|
||||||
{
|
{
|
||||||
case DialogResult.Abort: return; /// Exit program
|
case DialogResult.Abort:
|
||||||
case DialogResult.Retry: break; /// Retry the loop
|
return; /// Exit program
|
||||||
|
|
||||||
|
case DialogResult.Retry:
|
||||||
|
break; /// Retry connection to the database, stay inside the loop
|
||||||
|
|
||||||
|
case DialogResult.Yes:
|
||||||
|
new UpgradeSelectionDlg().ShowDialog();
|
||||||
|
break; /// Stay inside the loop
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/// Open 'DatabaseSetingsDlg' and retry DB connect on OK
|
/// Open 'DatabaseSetingsDlg' and retry DB connect on OK
|
||||||
if (new Users.Forms.LoginDlg(true).ShowDialog() == DialogResult.Cancel ||
|
if (new Users.Forms.LoginDlg(true).ShowDialog() == DialogResult.Cancel ||
|
||||||
new BenchesDlg().ShowDialog() == DialogResult.Cancel)
|
new BenchesDlg().ShowDialog() == DialogResult.Cancel)
|
||||||
{
|
{
|
||||||
return; /// Exit program
|
return; /// Exit program
|
||||||
}
|
}
|
||||||
Program.LocalSettings = LocalSettings.Load(Program.LocalSettingsFileName);
|
Program.LocalSettings = LocalSettings.Load(Program.LocalSettingsFileName);
|
||||||
if (Program.LocalSettings == null) return; /// Fatal error
|
if (Program.LocalSettings == null)
|
||||||
break; /// Retry the loop
|
return; /// Fatal error -> Exit program
|
||||||
|
else
|
||||||
|
break; /// Stay inside the loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // if benchname is OK
|
} // if benchname is OK
|
||||||
|
|||||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2.17.721.1")]
|
[assembly: AssemblyVersion("2.17.722.1")]
|
||||||
[assembly: AssemblyFileVersion("2.17.721.1")]
|
[assembly: AssemblyFileVersion("2.17.722.1")]
|
||||||
|
|||||||
Reference in New Issue
Block a user