Bug fix in MetrologyDlgFlowMeterTab, etc. when ranges are enabled, ver. 2.26.1588

This commit is contained in:
Milan Hanajik
2021-02-08 10:12:12 +01:00
parent 55d9d58978
commit 2e75d91adc
14 changed files with 86 additions and 14 deletions
+6 -2
View File
@@ -67,9 +67,13 @@ namespace TBF.BenchControl.Elde.FlowMeter
/// ///
public void Initialize() public void Initialize()
{ {
if (flowMeterCfg.CalibValidDate != DateTime.MinValue && flowMeterCfg.CalibValidDate.Date < DateTime.Now.Date) for (int r = 0; r <= 5; r++)
{ {
throw new Exception(string.Format("{0}: {1}", Name, Strings.Calibration_certificate_validity_expired)); if (RangeEnabled(r) && flowMeterCfg.GetCalibValidDate(r) != DateTime.MinValue
&& flowMeterCfg.GetCalibValidDate(r).Date < DateTime.Now.Date)
{
throw new Exception(string.Format("{0}/r{1}: {2}", Name, r, Strings.Calibration_certificate_validity_expired));
}
} }
log.FatalFormat("Successfully initialized device {0}", Name); log.FatalFormat("Successfully initialized device {0}", Name);
+2 -2
View File
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("2.26.1586.0")] [assembly: AssemblyVersion("2.26.1588.0")]
[assembly: AssemblyFileVersion("2.26.1586.0")] [assembly: AssemblyFileVersion("2.26.1588.0")]
@@ -2,6 +2,7 @@
/// Copyright (c) 2013-2015 Sensus Slovensko a.s. /// Copyright (c) 2013-2015 Sensus Slovensko a.s.
/// ///
using System.Collections.Generic; using System.Collections.Generic;
using NHibernate;
using Config.Entities; using Config.Entities;
namespace TBF.UI.Bench.Metrology namespace TBF.UI.Bench.Metrology
@@ -14,6 +15,8 @@ namespace TBF.UI.Bench.Metrology
/// </summary> /// </summary>
Component MeterEntity { get; set; } Component MeterEntity { get; set; }
void SaveEntityToDB(ISession session);
/// <summary> /// <summary>
/// A list of 'measurement-correction' pairs to be deleted from the database on OK. /// A list of 'measurement-correction' pairs to be deleted from the database on OK.
/// </summary> /// </summary>
+14 -3
View File
@@ -110,15 +110,26 @@ namespace TBF.UI.Bench.Metrology
{ {
BenchControl.Elde.FlowMeter.FlowMeterCfg flowMeterCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.Elde.FlowMeter.FlowMeterCfg; BenchControl.Elde.FlowMeter.FlowMeterCfg flowMeterCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.Elde.FlowMeter.FlowMeterCfg;
for (int r = 0; r <= 5; r++) for (int r = 0; r <= 5; r++)
{ {
if (flowMeterCfg.RangeEnabled(r)) if (flowMeterCfg.RangeEnabled(r))
{ {
bool isLastFlowMeterRange = true;
for (int nxt = r + 1; nxt <= 5; nxt++)
{
if (flowMeterCfg.RangeEnabled(nxt))
{
isLastFlowMeterRange = false;
break;
}
}
flowMetersCount++; flowMetersCount++;
TabPage tabPage = new TabPage(string.Format(((r == 0) ? " {0} " : " {0} r{1} "), cmpnt.Name, r)); TabPage tabPage = new TabPage(string.Format(((r == 0) ? " {0} " : " {0} r{1} "), cmpnt.Name, r));
MetrologyDlgFlowMeterTab uiControl = new MetrologyDlgFlowMeterTab(r); MetrologyDlgFlowMeterTab uiControl = new MetrologyDlgFlowMeterTab(r, isLastFlowMeterRange);
uiControl.MeterEntity = cmpnt; uiControl.MeterEntity = cmpnt;
uiControl.CalibInfoCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.ICalibRangesCfg; uiControl.CalibInfoCfg = flowMeterCfg;
uiControl.Dock = DockStyle.Fill; uiControl.Dock = DockStyle.Fill;
tabPage.Tag = uiControl; tabPage.Tag = uiControl;
tabPage.Controls.Add(uiControl); tabPage.Controls.Add(uiControl);
@@ -236,7 +247,7 @@ namespace TBF.UI.Bench.Metrology
if (tab != null) if (tab != null)
{ {
tab.OkBtnClicked(); tab.OkBtnClicked();
session.SaveOrUpdate(tab.MeterEntity); tab.SaveEntityToDB(session);
foreach (var entity in tab.ToBeRemoved) session.Delete(entity); foreach (var entity in tab.ToBeRemoved) session.Delete(entity);
} }
} }
@@ -395,5 +395,10 @@ namespace TBF.UI.Bench.Metrology
public void UpdateRelatedItems(Dictionary<string, string> renameInfo) public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{ {
} }
public void SaveEntityToDB(NHibernate.ISession session)
{
session.SaveOrUpdate(MeterEntity);
}
} }
} }
@@ -127,5 +127,10 @@ namespace TBF.UI.Bench.Metrology
public void UpdateRelatedItems(Dictionary<string, string> renameInfo) public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{ {
} }
public void SaveEntityToDB(NHibernate.ISession session)
{
session.SaveOrUpdate(MeterEntity);
}
} }
} }
@@ -182,5 +182,10 @@ namespace TBF.UI.Bench.Metrology
densityCorrTextBox.Text = Config.Formulas.DensityCorrection(density, temp).ToString(); densityCorrTextBox.Text = Config.Formulas.DensityCorrection(density, temp).ToString();
} }
} }
public void SaveEntityToDB(NHibernate.ISession session)
{
session.SaveOrUpdate(MeterEntity);
}
} }
} }
@@ -345,5 +345,10 @@ namespace TBF.UI.Bench.Metrology
public void UpdateRelatedItems(Dictionary<string, string> renameInfo) public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{ {
} }
public void SaveEntityToDB(NHibernate.ISession session)
{
session.SaveOrUpdate(MeterEntity);
}
} }
} }
@@ -345,5 +345,10 @@ namespace TBF.UI.Bench.Metrology
public void UpdateRelatedItems(Dictionary<string, string> renameInfo) public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{ {
} }
public void SaveEntityToDB(NHibernate.ISession session)
{
session.SaveOrUpdate(MeterEntity);
}
} }
} }
@@ -48,12 +48,13 @@ namespace TBF.UI.Bench.Metrology
Control measurementTextBox; Control measurementTextBox;
Control correctionTextBox; Control correctionTextBox;
Control errorTextBox; Control errorTextBox;
int rangeIx; /// 0 (no range) or 1..5 (range #) readonly int rangeIx; /// 0 (no range) or 1..5 (range #)
readonly bool isLastFlowMeterRange; /// true when this is the last range of this flow meter.
/// This is to prevent double saving of the meter entity to a DB
public MetrologyDlgFlowMeterTab() : this(0, true) {}
public MetrologyDlgFlowMeterTab() : this(0) {} public MetrologyDlgFlowMeterTab(int rangeIx1, bool isLastFlowMeterRange)
public MetrologyDlgFlowMeterTab(int rangeIx1)
{ {
InitializeComponent(); InitializeComponent();
calibDateTimePicker.CustomFormat = Constants.DateFormat; calibDateTimePicker.CustomFormat = Constants.DateFormat;
@@ -61,6 +62,7 @@ namespace TBF.UI.Bench.Metrology
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat; calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
calibExpirationDateTimePicker.MinDate = Constants.MinDate; calibExpirationDateTimePicker.MinDate = Constants.MinDate;
this.rangeIx = rangeIx1; this.rangeIx = rangeIx1;
this.isLastFlowMeterRange = isLastFlowMeterRange;
toBeRemoved = new List<MeasurementCorrection>(); toBeRemoved = new List<MeasurementCorrection>();
unlocked = false; unlocked = false;
} }
@@ -279,9 +281,6 @@ namespace TBF.UI.Bench.Metrology
CalibInfoCfg.SetCalibCertificate(rangeIx, calibCertificateNrTextBox.Text); CalibInfoCfg.SetCalibCertificate(rangeIx, calibCertificateNrTextBox.Text);
CalibInfoCfg.SetCalibDate(rangeIx, calibDateTimePicker.Value.Date); CalibInfoCfg.SetCalibDate(rangeIx, calibDateTimePicker.Value.Date);
CalibInfoCfg.SetCalibValidDate(rangeIx, calibExpirationDateTimePicker.Value.Date); CalibInfoCfg.SetCalibValidDate(rangeIx, calibExpirationDateTimePicker.Value.Date);
Component modified = CalibInfoCfg.CreateDbEntity();
MeterEntity.Parameters = modified.Parameters;
} }
catch catch
{ {
@@ -393,5 +392,15 @@ namespace TBF.UI.Bench.Metrology
public void UpdateRelatedItems(Dictionary<string, string> renameInfo) public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{ {
} }
public void SaveEntityToDB(NHibernate.ISession session)
{
if (isLastFlowMeterRange)
{
Component modified = CalibInfoCfg.CreateDbEntity();
MeterEntity.Parameters = modified.Parameters;
session.SaveOrUpdate(MeterEntity);
}
}
} }
} }
@@ -345,5 +345,10 @@ namespace TBF.UI.Bench.Metrology
public void UpdateRelatedItems(Dictionary<string, string> renameInfo) public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{ {
} }
public void SaveEntityToDB(NHibernate.ISession session)
{
session.SaveOrUpdate(MeterEntity);
}
} }
} }
@@ -231,5 +231,10 @@ namespace TBF.UI.Bench.Metrology
public void UpdateRelatedItems(Dictionary<string, string> renameInfo) public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{ {
} }
public void SaveEntityToDB(NHibernate.ISession session)
{
session.SaveOrUpdate(MeterEntity);
}
} }
} }
@@ -372,5 +372,10 @@ namespace TBF.UI.Bench.Metrology
public void UpdateRelatedItems(Dictionary<string, string> renameInfo) public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{ {
} }
public void SaveEntityToDB(NHibernate.ISession session)
{
session.SaveOrUpdate(MeterEntity);
}
} }
} }
@@ -372,5 +372,10 @@ namespace TBF.UI.Bench.Metrology
public void UpdateRelatedItems(Dictionary<string, string> renameInfo) public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{ {
} }
public void SaveEntityToDB(NHibernate.ISession session)
{
session.SaveOrUpdate(MeterEntity);
}
} }
} }