DB upgrade via menu Settings/Upgrade from 2.15 to 2.17 implemented, ver. 2.17.684
This commit is contained in:
+12
-56
@@ -28,78 +28,34 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.pressureRepresentationButton = new System.Windows.Forms.Button();
|
this.upgradeDbButton = new System.Windows.Forms.Button();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
|
||||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBox2 = new System.Windows.Forms.TextBox();
|
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// pressureRepresentationButton
|
// upgradeDbButton
|
||||||
//
|
//
|
||||||
this.pressureRepresentationButton.Location = new System.Drawing.Point(12, 61);
|
this.upgradeDbButton.Location = new System.Drawing.Point(12, 12);
|
||||||
this.pressureRepresentationButton.Name = "pressureRepresentationButton";
|
this.upgradeDbButton.Name = "upgradeDbButton";
|
||||||
this.pressureRepresentationButton.Size = new System.Drawing.Size(260, 35);
|
this.upgradeDbButton.Size = new System.Drawing.Size(260, 34);
|
||||||
this.pressureRepresentationButton.TabIndex = 0;
|
this.upgradeDbButton.TabIndex = 0;
|
||||||
this.pressureRepresentationButton.Text = "Upgrade pressure representation";
|
this.upgradeDbButton.Text = "Upgrade database from ver. 2.15 to ver. 2.17";
|
||||||
this.pressureRepresentationButton.UseVisualStyleBackColor = true;
|
this.upgradeDbButton.UseVisualStyleBackColor = true;
|
||||||
this.pressureRepresentationButton.Click += new System.EventHandler(this.pressureRepresentationButton_Click);
|
this.upgradeDbButton.Click += new System.EventHandler(this.upgradeDbButton_Click);
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(12, 13);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(70, 13);
|
|
||||||
this.label1.TabIndex = 1;
|
|
||||||
this.label1.Text = "From batch #";
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
this.label2.AutoSize = true;
|
|
||||||
this.label2.Location = new System.Drawing.Point(12, 38);
|
|
||||||
this.label2.Name = "label2";
|
|
||||||
this.label2.Size = new System.Drawing.Size(60, 13);
|
|
||||||
this.label2.TabIndex = 2;
|
|
||||||
this.label2.Text = "To batch #";
|
|
||||||
//
|
|
||||||
// textBox1
|
|
||||||
//
|
|
||||||
this.textBox1.Location = new System.Drawing.Point(103, 10);
|
|
||||||
this.textBox1.Name = "textBox1";
|
|
||||||
this.textBox1.Size = new System.Drawing.Size(58, 20);
|
|
||||||
this.textBox1.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// textBox2
|
|
||||||
//
|
|
||||||
this.textBox2.Location = new System.Drawing.Point(103, 35);
|
|
||||||
this.textBox2.Name = "textBox2";
|
|
||||||
this.textBox2.Size = new System.Drawing.Size(58, 20);
|
|
||||||
this.textBox2.TabIndex = 4;
|
|
||||||
//
|
//
|
||||||
// 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.textBox2);
|
this.Controls.Add(this.upgradeDbButton);
|
||||||
this.Controls.Add(this.textBox1);
|
|
||||||
this.Controls.Add(this.label2);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Controls.Add(this.pressureRepresentationButton);
|
|
||||||
this.Name = "UpgradeSelectionDlg";
|
this.Name = "UpgradeSelectionDlg";
|
||||||
this.Text = "Upgrade selection";
|
this.Text = "Upgrade selection";
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.Button pressureRepresentationButton;
|
private System.Windows.Forms.Button upgradeDbButton;
|
||||||
private System.Windows.Forms.Label label1;
|
|
||||||
private System.Windows.Forms.Label label2;
|
|
||||||
private System.Windows.Forms.TextBox textBox1;
|
|
||||||
private System.Windows.Forms.TextBox textBox2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Results.Entities;
|
using MySql.Data.MySqlClient;
|
||||||
using NHibernate;
|
using Results;
|
||||||
|
|
||||||
namespace TBF.Forms
|
namespace TBF.Forms
|
||||||
{
|
{
|
||||||
@@ -21,74 +15,38 @@ namespace TBF.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
batchFrom = 1;
|
batchFrom = 1;
|
||||||
batchTo = Program.LocalSettings.BatchNr - 1;
|
batchTo = Program.LocalSettings.BatchNr - 1;
|
||||||
|
|
||||||
textBox1.Text = batchFrom.ToString();
|
|
||||||
textBox2.Text = batchTo.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pressureRepresentationButton_Click(object sender, EventArgs e)
|
private void upgradeDbButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
MySqlConnection dbConn = new MySqlConnection(Results.DB.ConnectionString);
|
||||||
|
string[] commands = new string[]
|
||||||
{
|
{
|
||||||
batchFrom = int.Parse(textBox1.Text);
|
"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`;",
|
||||||
batchTo = int.Parse(textBox2.Text);
|
"ALTER TABLE `watermeter` ADD `ErrorFlags` INT NOT NULL DEFAULT '0' AFTER `QFall`;",
|
||||||
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;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ISession session = Results.DB.CreateSession();
|
dbConn.Open();
|
||||||
|
|
||||||
IList<Batch> bFrom = session.QueryOver<Batch>().Where(x => (x.BatchNr == batchFrom)).List<Batch>();
|
foreach (var cmdText in commands)
|
||||||
IList<Batch> bTo = session.QueryOver<Batch>().Where(x => (x.BatchNr == batchTo)).List<Batch>();
|
|
||||||
|
|
||||||
if (bFrom.Count != 1) throw new Exception("No start batch");
|
|
||||||
if (bTo.Count != 1) throw new Exception("No end batch");
|
|
||||||
|
|
||||||
IList<TestRslt> testResults = session.QueryOver<TestRslt>()
|
|
||||||
.WhereRestrictionOn(x => x.StartTime)
|
|
||||||
.IsBetween(bFrom[0].StartTime)
|
|
||||||
.And(bTo[0].EndTime)
|
|
||||||
.List<TestRslt>();
|
|
||||||
|
|
||||||
foreach (var tr in testResults)
|
|
||||||
{
|
{
|
||||||
Text = string.Format("Batch # = {0}", tr.Batch.BatchNr);
|
MySqlCommand cmd = dbConn.CreateCommand();
|
||||||
|
cmd.CommandText = cmdText;
|
||||||
float factor1 = 0.01f;
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
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();
|
MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
upgradeDbButton.Enabled = false;
|
||||||
MessageBox.Show("Upgrade completed", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
}
|
||||||
catch (Exception exc)
|
catch (Exception exc)
|
||||||
{
|
{
|
||||||
MessageBox.Show(string.Format("Upgrade failed:\r\n{0}", exc.Message),
|
MessageBox.Show(string.Format("Exception {0}", exc.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
"Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
dbConn.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace TBF
|
|||||||
usersTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Users.Grp.GID.Administrators) ||
|
usersTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Users.Grp.GID.Administrators) ||
|
||||||
Users.GlobalData.CurrentUser.IsMemberOf(Users.Grp.GID.HeadOfLab);
|
Users.GlobalData.CurrentUser.IsMemberOf(Users.Grp.GID.HeadOfLab);
|
||||||
|
|
||||||
upgradeTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Users.Grp.GID.Administrators) && Users.GlobalData.CurrentUser.UserName == "milan";
|
upgradeTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Users.Grp.GID.Administrators) && Users.GlobalData.CurrentUser.IsPowerUser();
|
||||||
|
|
||||||
benchInitializationFailed = false;
|
benchInitializationFailed = false;
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2.17.681.1")]
|
[assembly: AssemblyVersion("2.17.684.1")]
|
||||||
[assembly: AssemblyFileVersion("2.17.681.1")]
|
[assembly: AssemblyFileVersion("2.17.684.1")]
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace Users.Entities
|
|||||||
public virtual IList<Group> Groups { get; set; } //User can be a member of a list of groups
|
public virtual IList<Group> Groups { get; set; } //User can be a member of a list of groups
|
||||||
|
|
||||||
private bool powerUser; /// true for built-in users, power users have full access even with empty Groups list
|
private bool powerUser; /// true for built-in users, power users have full access even with empty Groups list
|
||||||
|
public virtual bool IsPowerUser() { return powerUser; }
|
||||||
|
|
||||||
private string legalizator; /// Not mapped to a database !!!, 2nd user entered in a logging dialog
|
private string legalizator; /// Not mapped to a database !!!, 2nd user entered in a logging dialog
|
||||||
public virtual void SetLegalizator(string value) { legalizator = value; }
|
public virtual void SetLegalizator(string value) { legalizator = value; }
|
||||||
|
|||||||
Reference in New Issue
Block a user