Safer saving corrections to runtime component, test of a null reference.
This commit is contained in:
@@ -147,13 +147,13 @@ namespace TBF.BenchControl.Output.DB.SaveDiverterCorrections
|
||||
void SaveNewCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, IList<MeasurementCorrection> corrections)
|
||||
{
|
||||
if (dbCmpnt.Corrections == null) dbCmpnt.Corrections = new List<MeasurementCorrection>();
|
||||
if (runtimeCmpnt.Corrections == null) runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
|
||||
if ((runtimeCmpnt != null) && (runtimeCmpnt.Corrections == null)) runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
|
||||
|
||||
foreach (var mc in corrections)
|
||||
{
|
||||
mc.RangeIx = 0;
|
||||
dbCmpnt.Corrections.Add(mc);
|
||||
runtimeCmpnt.Corrections.Add(mc);
|
||||
if (runtimeCmpnt != null) runtimeCmpnt.Corrections.Add(mc);
|
||||
session.SaveOrUpdate(mc);
|
||||
}
|
||||
|
||||
|
||||
@@ -146,13 +146,13 @@ namespace TBF.BenchControl.Output.DB.SaveFlowmeterCorrections
|
||||
void SaveNewCorrections(ISession session, Component dbCmpnt, IComponent runtimeCmpnt, int rangeIx, IList<MeasurementCorrection> corrections)
|
||||
{
|
||||
if (dbCmpnt.Corrections == null) dbCmpnt.Corrections = new List<MeasurementCorrection>();
|
||||
if (runtimeCmpnt.Corrections == null) runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
|
||||
if ((runtimeCmpnt != null) && (runtimeCmpnt.Corrections == null)) runtimeCmpnt.Corrections = new List<MeasurementCorrection>();
|
||||
|
||||
foreach (var mc in corrections)
|
||||
{
|
||||
mc.RangeIx = rangeIx;
|
||||
dbCmpnt.Corrections.Add(mc);
|
||||
runtimeCmpnt.Corrections.Add(mc);
|
||||
if (runtimeCmpnt != null) runtimeCmpnt.Corrections.Add(mc);
|
||||
session.SaveOrUpdate(mc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user