UpgradeSelectionDlg : v.2.22 -> v.2.24 and v.2.24 -> v.2.25
This commit is contained in:
parent
7c070fc635
commit
670de424c2
@ -12,9 +12,7 @@ namespace Results.Mappings
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Name);
|
||||
#if TEST_PROFILES
|
||||
Map(x => x.Qtg);
|
||||
#endif
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.TargetVolume);
|
||||
|
||||
@ -2386,6 +2386,7 @@
|
||||
<Compile Include="UI\Settings\DatabaseSettingsDlg.designer.cs">
|
||||
<DependentUpon>DatabaseSettingsDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\Settings\GroupTableRow.cs" />
|
||||
<Compile Include="UI\Settings\LanguageDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
19
TBF/UI/Settings/GroupTableRow.cs
Normal file
19
TBF/UI/Settings/GroupTableRow.cs
Normal file
@ -0,0 +1,19 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus slovensko a.s.
|
||||
///
|
||||
namespace TBF.UI.Settings
|
||||
{
|
||||
public class GroupTableRow
|
||||
{
|
||||
public int GroupId;
|
||||
public Users.Entities.GID Gid;
|
||||
public int UserId;
|
||||
|
||||
public GroupTableRow(int groupId, Users.Entities.GID gid, int userId)
|
||||
{
|
||||
GroupId = groupId;
|
||||
Gid = gid;
|
||||
UserId = userId;
|
||||
}
|
||||
}
|
||||
}
|
||||
70
TBF/UI/Settings/UpgradeSelectionDlg.Designer.cs
generated
70
TBF/UI/Settings/UpgradeSelectionDlg.Designer.cs
generated
@ -44,6 +44,9 @@
|
||||
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.SuspendLayout();
|
||||
//
|
||||
// upgradeDb_215_216_Button
|
||||
@ -52,7 +55,7 @@
|
||||
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 database from ver. 2.15 to ver. 2.16";
|
||||
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);
|
||||
//
|
||||
@ -62,7 +65,7 @@
|
||||
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 database from ver. 2.16 to ver. 2.17";
|
||||
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);
|
||||
//
|
||||
@ -72,7 +75,7 @@
|
||||
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 database from ver. 2.12 to ver. 2.15";
|
||||
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);
|
||||
//
|
||||
@ -82,7 +85,7 @@
|
||||
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 database from ver. 2.17 to ver. 2.18";
|
||||
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);
|
||||
//
|
||||
@ -92,7 +95,7 @@
|
||||
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 database from ver. 2.9 to ver. 2.12";
|
||||
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);
|
||||
//
|
||||
@ -119,7 +122,8 @@
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.textBox1.Location = new System.Drawing.Point(94, 431);
|
||||
this.textBox1.Enabled = false;
|
||||
this.textBox1.Location = new System.Drawing.Point(94, 493);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(100, 20);
|
||||
this.textBox1.TabIndex = 11;
|
||||
@ -127,7 +131,8 @@
|
||||
// textBox2
|
||||
//
|
||||
this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.textBox2.Location = new System.Drawing.Point(94, 457);
|
||||
this.textBox2.Enabled = false;
|
||||
this.textBox2.Location = new System.Drawing.Point(94, 519);
|
||||
this.textBox2.Name = "textBox2";
|
||||
this.textBox2.Size = new System.Drawing.Size(100, 20);
|
||||
this.textBox2.TabIndex = 13;
|
||||
@ -136,7 +141,8 @@
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 434);
|
||||
this.label1.Enabled = false;
|
||||
this.label1.Location = new System.Drawing.Point(12, 496);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(70, 13);
|
||||
this.label1.TabIndex = 10;
|
||||
@ -146,7 +152,8 @@
|
||||
//
|
||||
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 460);
|
||||
this.label2.Enabled = false;
|
||||
this.label2.Location = new System.Drawing.Point(12, 522);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(60, 13);
|
||||
this.label2.TabIndex = 12;
|
||||
@ -155,7 +162,8 @@
|
||||
// pressureRepresentationButton
|
||||
//
|
||||
this.pressureRepresentationButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.pressureRepresentationButton.Location = new System.Drawing.Point(207, 431);
|
||||
this.pressureRepresentationButton.Enabled = false;
|
||||
this.pressureRepresentationButton.Location = new System.Drawing.Point(207, 493);
|
||||
this.pressureRepresentationButton.Name = "pressureRepresentationButton";
|
||||
this.pressureRepresentationButton.Size = new System.Drawing.Size(65, 42);
|
||||
this.pressureRepresentationButton.TabIndex = 14;
|
||||
@ -169,7 +177,7 @@
|
||||
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 database from ver. 2.4 to ver. 2.9";
|
||||
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);
|
||||
//
|
||||
@ -179,7 +187,7 @@
|
||||
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 database from ver. 2.18 to ver. 2.22";
|
||||
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);
|
||||
//
|
||||
@ -195,19 +203,48 @@
|
||||
//
|
||||
// upgradeDb_222_224_Button
|
||||
//
|
||||
this.upgradeDb_222_224_Button.Location = new System.Drawing.Point(12, 377);
|
||||
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 database from ver. 2.22 to ver. 2.24";
|
||||
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..";
|
||||
//
|
||||
// UpgradeSelectionDlg
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(284, 493);
|
||||
this.ClientSize = new System.Drawing.Size(284, 555);
|
||||
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);
|
||||
@ -249,6 +286,9 @@
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
///
|
||||
/// Copyright (c) 2016-2020 Sensus slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
@ -38,13 +41,13 @@ namespace TBF.UI.Settings
|
||||
void ActivityStart()
|
||||
{
|
||||
form = new Shared.ModelessActivityForm()
|
||||
{
|
||||
Message = "Upgrading database",
|
||||
FontFamily = "Arial",
|
||||
FontSize = 24,
|
||||
FontStyle = FontStyle.Regular,
|
||||
BackgroundColor = Color.Green,
|
||||
};
|
||||
{
|
||||
Message = "Upgrading database",
|
||||
FontFamily = "Arial",
|
||||
FontSize = 24,
|
||||
FontStyle = FontStyle.Regular,
|
||||
BackgroundColor = Color.Green,
|
||||
};
|
||||
formThread = new System.Threading.Thread(() => form.ShowDialog());
|
||||
formThread.Start();
|
||||
}
|
||||
@ -99,6 +102,63 @@ namespace TBF.UI.Settings
|
||||
return success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Common part of database upgrade code
|
||||
/// </summary>
|
||||
/// <param name="dbConn">Database connection</param>
|
||||
/// <param name="commands">Array of SQL commands to be executed</param>
|
||||
/// <returns>true = successful</returns>
|
||||
bool ChangeErrorFlags(string errorFlagsCmpntName)
|
||||
{
|
||||
bool success = false;
|
||||
ISession session = null;
|
||||
|
||||
try
|
||||
{
|
||||
session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
|
||||
|
||||
var testParams = session.QueryOver<Config.Entities.ComponentTest>()
|
||||
.Where(x => (x.CmpntName == errorFlagsCmpntName))
|
||||
.List();
|
||||
|
||||
foreach (var tp in testParams)
|
||||
{
|
||||
string temp;
|
||||
if (tp.Parameters.Contains("<Mode>Info</Mode>"))
|
||||
{
|
||||
temp = tp.Parameters.Replace("true", "1");
|
||||
}
|
||||
else if (tp.Parameters.Contains("<Mode>On</Mode>"))
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -131,7 +191,7 @@ namespace TBF.UI.Settings
|
||||
MessageBox.Show("No database selected");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string[] configDbCommands = new string[]
|
||||
{
|
||||
/// 2.4 -> 2.5
|
||||
@ -182,7 +242,7 @@ namespace TBF.UI.Settings
|
||||
MessageBox.Show("No database selected");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string[] configDbCommands = new string[]
|
||||
{
|
||||
/// 2.9 -> 2.10
|
||||
@ -310,7 +370,7 @@ namespace TBF.UI.Settings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///---------------------------------------------------------------------
|
||||
private void upgradeDb_212_215_Button_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -486,8 +546,8 @@ namespace TBF.UI.Settings
|
||||
}
|
||||
}
|
||||
|
||||
///---------------------------------------------------------------------
|
||||
private void upgradeDb_215_216_Button_Click(object sender, EventArgs e)
|
||||
///---------------------------------------------------------------------
|
||||
private void upgradeDb_215_216_Button_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
|
||||
{
|
||||
@ -510,8 +570,8 @@ namespace TBF.UI.Settings
|
||||
}
|
||||
}
|
||||
|
||||
///---------------------------------------------------------------------
|
||||
private void upgradeDb_216_217_Button_Click(object sender, EventArgs e)
|
||||
///---------------------------------------------------------------------
|
||||
private void upgradeDb_216_217_Button_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!upgradeConfigDBCheckBox.Checked && !upgradeResultsDBCheckBox.Checked)
|
||||
{
|
||||
@ -596,7 +656,75 @@ namespace TBF.UI.Settings
|
||||
|
||||
string[] configDbCommands = new string[]
|
||||
{
|
||||
"ALTER TABLE `user` ADD `Password2` VARCHAR(255) NULL DEFAULT NULL AFTER `Password`, ADD `Password3` VARCHAR(255) NULL DEFAULT NULL AFTER `Password2`;",
|
||||
/// Table profile
|
||||
"CREATE TABLE IF NOT EXISTS `profile` (" +
|
||||
"`Id` int(11) NOT NULL," +
|
||||
" `ItemNr` int(11) DEFAULT NULL," +
|
||||
" `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," +
|
||||
" `ItemNr` int(11) DEFAULT NULL," +
|
||||
" `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) NOT NULL DEFAULT '0'," +
|
||||
" 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'," +
|
||||
@ -608,19 +736,54 @@ namespace TBF.UI.Settings
|
||||
" `Component_id` int(11) DEFAULT NULL," +
|
||||
" PRIMARY KEY (`Id`)," +
|
||||
" KEY `Component_id` (`Component_id`)" +
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;",
|
||||
"UPDATE `test` SET `RelTransAfter`='UserDefined';",
|
||||
");",
|
||||
|
||||
/// 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 || ExecuteCommands(new MySqlConnection(Config.Data.CurrentBench.ProceduresDBSettings.ConnectionString), configDbCommands)) &&
|
||||
(!upgradeResultsDBCheckBox.Checked || ExecuteCommands(new MySqlConnection(DB.ConnectionString), resultsDbCommands)))
|
||||
if (upgradeConfigDBCheckBox.Checked)
|
||||
{
|
||||
success = success && ExecuteCommands(new MySqlConnection(Config.Data.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(DB.ConnectionString), resultsDbCommands);
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
ActivityEnd();
|
||||
MessageBox.Show("DB succesfully upgraded." + Environment.NewLine +
|
||||
@ -632,6 +795,110 @@ namespace TBF.UI.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private void upgradeDb_224_225_Button_Click(object sender, EventArgs e)
|
||||
{
|
||||
MySqlConnection dbConn = null;
|
||||
MySqlCommand cmd;
|
||||
|
||||
ActivityStart();
|
||||
bool success = false;
|
||||
|
||||
try
|
||||
{
|
||||
dbConn = new MySqlConnection(Config.Data.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)Users.Entities.GID.NrOfGroups];
|
||||
IList<GroupTableRow> groupTable = new List<GroupTableRow>();
|
||||
|
||||
cmd = dbConn.CreateCommand();
|
||||
cmd.CommandText = "SELECT `Id`, `Gid`, `User_id` FROM `group`;";
|
||||
MySqlDataReader dr = cmd.ExecuteReader();
|
||||
while (dr.Read())
|
||||
{
|
||||
int groupId = dr.GetInt32(0);
|
||||
Users.Entities.GID gid = (Users.Entities.GID)dr.GetInt32(1);
|
||||
int userId = dr.GetInt32(2);
|
||||
|
||||
groupTable.Add(new GroupTableRow(groupId, gid, userId));
|
||||
|
||||
if ((gid >= 0) && (gid < Users.Entities.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 pressureRepresentationButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
|
||||
@ -48,7 +48,25 @@ namespace Users.Forms
|
||||
|
||||
try
|
||||
{
|
||||
displayedGroups = session.QueryOver<Group>().List();
|
||||
IList<Group> allGroups = session.QueryOver<Group>().List();
|
||||
|
||||
///
|
||||
/// Selects groups to be displayed (so that each GID is present only once)
|
||||
///
|
||||
Group[] dspGroups = new Group[(int)Users.Entities.GID.NrOfGroups];
|
||||
foreach (var group in allGroups)
|
||||
{
|
||||
if ((group.GID >= 0) && (group.GID < Users.Entities.GID.NrOfGroups) && (dspGroups[(int)group.GID] == null))
|
||||
{
|
||||
dspGroups[(int)group.GID] = group;
|
||||
}
|
||||
}
|
||||
displayedGroups = new List<Group>();
|
||||
foreach (var group in dspGroups)
|
||||
{
|
||||
if (group != null) displayedGroups.Add(group);
|
||||
}
|
||||
|
||||
listOfUsers = session.QueryOver<User>().List();
|
||||
}
|
||||
catch (Exception)
|
||||
@ -56,6 +74,8 @@ namespace Users.Forms
|
||||
if (displayedGroups == null) displayedGroups = new List<Group>();
|
||||
if (listOfUsers == null) listOfUsers = new List<User>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void UserManagementDlg_Load(object sender, EventArgs e)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user