diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 30a08e8b6..401a780e5 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.33.2127.0")] -[assembly: AssemblyFileVersion("2.33.2127.0")] +[assembly: AssemblyVersion("2.33.2134.0")] +[assembly: AssemblyFileVersion("2.33.2134.0")] diff --git a/TBF/Rig/DataContainers/Buoyancy/ComponentFactory.cs b/TBF/Rig/DataContainers/Buoyancy/ComponentFactory.cs index 14f88daa6..ff46947ca 100644 --- a/TBF/Rig/DataContainers/Buoyancy/ComponentFactory.cs +++ b/TBF/Rig/DataContainers/Buoyancy/ComponentFactory.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2019-2023 Sensus Slovensko a.s. /// using System.Collections.Generic; using TBF.Rig.Generic; @@ -14,7 +14,7 @@ namespace TBF.Rig.DataContainers.Buoyancy public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } - public IComponentCfg DefaultConfig() { return new ComponentCfg(this.GetType().Namespace.Substring(32), this); } + public IComponentCfg DefaultConfig() { return new ComponentCfg(GetType().Namespace.Substring(23), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TBF/Rig/DataContainers/Density/ComponentFactory.cs b/TBF/Rig/DataContainers/Density/ComponentFactory.cs index 80b411d5c..86606d058 100644 --- a/TBF/Rig/DataContainers/Density/ComponentFactory.cs +++ b/TBF/Rig/DataContainers/Density/ComponentFactory.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2019-2023 Sensus Slovensko a.s. /// using System.Collections.Generic; using TBF.Rig.Generic; @@ -14,7 +14,7 @@ namespace TBF.Rig.DataContainers.Density public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } - public IComponentCfg DefaultConfig() { return new ComponentCfg(this.GetType().Namespace.Substring(32), this); } + public IComponentCfg DefaultConfig() { return new ComponentCfg(GetType().Namespace.Substring(23), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TBF/Rig/DataContainers/Evaporation/Factory.cs b/TBF/Rig/DataContainers/Evaporation/Factory.cs index 91ee839c9..48e331edc 100644 --- a/TBF/Rig/DataContainers/Evaporation/Factory.cs +++ b/TBF/Rig/DataContainers/Evaporation/Factory.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2020 Sensus Slovensko a.s. +/// Copyright (c) 2020-2023 Sensus Slovensko a.s. /// using System.Collections.Generic; using TBF.Rig.Generic; @@ -16,7 +16,7 @@ namespace TBF.Rig.DataContainers.Evaporation public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } - public IComponentCfg DefaultConfig() { return new EvaporationCfg(this.GetType().Namespace.Substring(32), this); } + public IComponentCfg DefaultConfig() { return new EvaporationCfg(GetType().Namespace.Substring(23), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TBF/UI/Settings/UpgradeSelectionDlg.cs b/TBF/UI/Settings/UpgradeSelectionDlg.cs index 509501173..a99b825c5 100644 --- a/TBF/UI/Settings/UpgradeSelectionDlg.cs +++ b/TBF/UI/Settings/UpgradeSelectionDlg.cs @@ -559,7 +559,7 @@ namespace TBF.UI.Settings string[] commands = new string[] { - "ALTER TABLE `testrslt` ADD `ErrorFlagsMd` TINYINT( 4 ) NOT NULL DEFAULT '0' AFTER `ErrorMaster`," + + "ALTER TABLE `testrslt` ADD `ErrorFlagsMd` TINYINT( 4 ) NOT NULL DEFAULT '0' AFTER `ErrorMaster`," + " ADD `ErrorFlags` INT NOT NULL DEFAULT '0' AFTER `ErrorFlagsMd`;", }; @@ -584,7 +584,7 @@ namespace TBF.UI.Settings string[] commands = new string[] { - "ALTER TABLE `testrslt` ADD `DiverterStart` FLOAT NOT NULL DEFAULT '0.001' AFTER `ErrorMaster`," + + "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`;", }; @@ -635,21 +635,21 @@ namespace TBF.UI.Settings 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`," + + "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`," + + "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`;", }; @@ -771,7 +771,7 @@ namespace TBF.UI.Settings "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 `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';", @@ -827,7 +827,12 @@ namespace TBF.UI.Settings { dbConn = new MySqlConnection(TBF.DB.CurrentBench.ProceduresDBSettings.ConnectionString); dbConn.Open(); - +#if !IPERL + cmd = dbConn.CreateCommand(); + cmd.CommandText = "ALTER TABLE `user` ADD `Tag` VARCHAR(255) NULL DEFAULT NULL AFTER `Number`;"; + cmd.ExecuteNonQuery(); + cmd.Dispose(); +#endif 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(); @@ -850,9 +855,10 @@ namespace TBF.UI.Settings { 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)); + int userId = 0; + try { userId = dr.GetInt32(2); } catch { } /// Cope with User_id == null + if (userId != 0) groupTable.Add(new GroupTableRow(groupId, gid, userId)); if ((gid >= 0) && (gid < Common.GID.NrOfGroups) && (groupIdsToKeep[(int)gid] == 0)) { @@ -947,14 +953,21 @@ namespace TBF.UI.Settings " `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[] { + "ALTER TABLE `batch` DROP `Counter1`, DROP `Counter2`, DROP `Counter3`, DROP `Counter4`, DROP `Counter5`;", + "ALTER TABLE `testrslt`" + + " ADD `Counter1` INT NOT NULL DEFAULT '0' AFTER `Custom8`," + + " 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`;", #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`," + @@ -1266,18 +1279,18 @@ namespace TBF.UI.Settings private void upgradeDb_232_233_Button_Click(object sender, EventArgs e) { string[] configDbCommands = new string[] - { - "ALTER TABLE `test` CHANGE `Qtg` `Qtg` DOUBLE NOT NULL DEFAULT '0';", - "ALTER TABLE `test` CHANGE `Qfrom` `Qfrom` DOUBLE NOT NULL DEFAULT '0';", - "ALTER TABLE `test` CHANGE `Qto` `Qto` DOUBLE NOT NULL DEFAULT '0';", - "ALTER TABLE `test` CHANGE `Volume` `Volume` DOUBLE NOT NULL DEFAULT '0';", - "ALTER TABLE `test` CHANGE `TstTime` `TstTime` DOUBLE NOT NULL DEFAULT '0';" - }; + { + "ALTER TABLE `test` CHANGE `Qtg` `Qtg` DOUBLE NOT NULL DEFAULT '0';", + "ALTER TABLE `test` CHANGE `Qfrom` `Qfrom` DOUBLE NOT NULL DEFAULT '0';", + "ALTER TABLE `test` CHANGE `Qto` `Qto` DOUBLE NOT NULL DEFAULT '0';", + "ALTER TABLE `test` CHANGE `Volume` `Volume` DOUBLE NOT NULL DEFAULT '0';", + "ALTER TABLE `test` CHANGE `TstTime` `TstTime` DOUBLE NOT NULL DEFAULT '0';" + }; string[] resultsDbCommands = new string[] { "ALTER TABLE `watermeterdata` ADD `Qnames` TINYINT(4) NOT NULL DEFAULT '1' AFTER `Mounting`;", - "ALTER TABLE `watermeterdata` ADD `ErrLimHiQ` DOUBLE NOT NULL DEFAULT '2' AFTER `Q1_Qmin`," + + "ALTER TABLE `watermeterdata` ADD `ErrLimHiQ` DOUBLE NOT NULL DEFAULT '2' AFTER `Q1_Qmin`," + " ADD `ErrLimLoQ` DOUBLE NOT NULL DEFAULT '5' AFTER `ErrLimHiQ`;" }; @@ -1296,50 +1309,67 @@ namespace TBF.UI.Settings { if (upgradeConfigDBCheckBox.Checked) { - ISession session = null; - try - { - session = TBF.DB.ConfigDBSessionFactory.OpenSession(); - var tests = session.QueryOver().List(); - - foreach (var t in tests) - { - string singlePrecStr = Convert.ToSingle(t.Qtg).ToString(); - if (t.Qtg.ToString().Length > 2 * singlePrecStr.Length) t.Qtg = double.Parse(singlePrecStr); - - singlePrecStr = Convert.ToSingle(t.Qfrom).ToString(); - if (t.Qfrom.ToString().Length > 2 * singlePrecStr.Length) t.Qfrom = double.Parse(singlePrecStr); - - singlePrecStr = Convert.ToSingle(t.Qto).ToString(); - if (t.Qto.ToString().Length > 2 * singlePrecStr.Length) t.Qto = double.Parse(singlePrecStr); - - singlePrecStr = Convert.ToSingle(t.Volume).ToString(); - if (t.Volume.ToString().Length > 2 * singlePrecStr.Length) t.Volume = double.Parse(singlePrecStr); - - singlePrecStr = Convert.ToSingle(t.TestTime).ToString(); - if (t.TestTime.ToString().Length > 2 * singlePrecStr.Length) t.TestTime = double.Parse(singlePrecStr); - - session.SaveOrUpdate(t); - } - - session.Flush(); - } - catch (Exception exc) - { - ActivityEnd(); - MessageBox.Show(string.Format("Test flow rounding after a conversion to double failed:\r\n{0}", exc.Message), - "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - finally - { - if (session != null && session.IsOpen) session.Close(); - } + RoundFlowsAfterConversionToDbl(); } - + ActivityEnd(); MessageBox.Show("DB succesfully upgraded", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); upgradeDb_232_233_Button.Enabled = false; } } + + private void RoundFlowsAfterConversionToDbl() + { + ISession session = null; + try + { + session = TBF.DB.ConfigDBSessionFactory.OpenSession(); + var tests = session.QueryOver().List(); + + foreach (var t in tests) + { + string singlePrecStr = Convert.ToSingle(t.Qtg).ToString(); + if (t.Qtg.ToString().Length > 2 * singlePrecStr.Length) t.Qtg = double.Parse(singlePrecStr); + + singlePrecStr = Convert.ToSingle(t.Qfrom).ToString(); + if (t.Qfrom.ToString().Length > 2 * singlePrecStr.Length) t.Qfrom = double.Parse(singlePrecStr); + + singlePrecStr = Convert.ToSingle(t.Qto).ToString(); + if (t.Qto.ToString().Length > 2 * singlePrecStr.Length) t.Qto = double.Parse(singlePrecStr); + + singlePrecStr = Convert.ToSingle(t.Volume).ToString(); + if (t.Volume.ToString().Length > 2 * singlePrecStr.Length) t.Volume = double.Parse(singlePrecStr); + + singlePrecStr = Convert.ToSingle(t.TestTime).ToString(); + if (t.TestTime.ToString().Length > 2 * singlePrecStr.Length) t.TestTime = double.Parse(singlePrecStr); + + session.SaveOrUpdate(t); + } + + var mcorrections = session.QueryOver().List(); + foreach (var mc in mcorrections) + { + string singlePrecStr = Convert.ToSingle(mc.Measurement).ToString(); + if (mc.Measurement.ToString().Length > 2 * singlePrecStr.Length) mc.Measurement = double.Parse(singlePrecStr); + + singlePrecStr = Convert.ToSingle(mc.Correction).ToString(); + if (mc.Correction.ToString().Length > 2 * singlePrecStr.Length) mc.Correction = double.Parse(singlePrecStr); + + session.SaveOrUpdate(mc); + } + + session.Flush(); + } + catch (Exception exc) + { + ActivityEnd(); + MessageBox.Show(string.Format("Test flow rounding after a conversion to double failed:\r\n{0}", exc.Message), + "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + finally + { + if (session != null && session.IsOpen) session.Close(); + } + } } }