Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsParser.cs =================================================================== diff -u -r5f1c70d7eea83fca2ef6305a87a8098820ded1d9 -r02bec66c8cb3d6e26100d11cb842428144f91965 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsParser.cs (.../IllustrationPointsParser.cs) (revision 5f1c70d7eea83fca2ef6305a87a8098820ded1d9) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsParser.cs (.../IllustrationPointsParser.cs) (revision 02bec66c8cb3d6e26100d11cb842428144f91965) @@ -112,6 +112,11 @@ } } + /// + /// Proceeds to the next result in the data set. + /// + /// The database reader. + /// Thrown there was no other result in the data set. private static void ProceedOrThrow(HydraRingDatabaseReader reader) { if (!reader.NextResult()) @@ -147,8 +152,10 @@ int windDirectionId = Convert.ToInt32(readFaultTreeAlphaValue[IllustrationPointsDatabaseConstants.WindDirectionId]); int closingSituationid = Convert.ToInt32(readFaultTreeAlphaValue[IllustrationPointsDatabaseConstants.ClosingSituationId]); string name = Convert.ToString(readFaultTreeAlphaValue[IllustrationPointsDatabaseConstants.StochastName]); - double duration = Convert.ToDouble(readFaultTreeAlphaValue[IllustrationPointsDatabaseConstants.Duration]); - double alpha = Convert.ToDouble(readFaultTreeAlphaValue[IllustrationPointsDatabaseConstants.AlphaValue]); + double duration = ConvertToDouble(readFaultTreeAlphaValue[IllustrationPointsDatabaseConstants.Duration], + IllustrationPointsDatabaseConstants.Duration); + double alpha = ConvertToDouble(readFaultTreeAlphaValue[IllustrationPointsDatabaseConstants.AlphaValue], + IllustrationPointsDatabaseConstants.AlphaValue); var key = new ThreeKeyIndex(windDirectionId, closingSituationid, faultTreeId); if (!faultTreeStochasts.ContainsKey(key)) @@ -172,8 +179,8 @@ int faultTreeId = Convert.ToInt32(readFaultTreeBetaValue[IllustrationPointsDatabaseConstants.FaultTreeId]); int windDirectionId = Convert.ToInt32(readFaultTreeBetaValue[IllustrationPointsDatabaseConstants.WindDirectionId]); int closingSituationid = Convert.ToInt32(readFaultTreeBetaValue[IllustrationPointsDatabaseConstants.ClosingSituationId]); - double beta = Convert.ToDouble(readFaultTreeBetaValue[IllustrationPointsDatabaseConstants.BetaValue]); - + double beta = ConvertToDouble(readFaultTreeBetaValue[IllustrationPointsDatabaseConstants.BetaValue], + IllustrationPointsDatabaseConstants.BetaValue); var threeKeyIndex = new ThreeKeyIndex(windDirectionId, closingSituationid, faultTreeId); if (faultTreeBetaValues.ContainsKey(threeKeyIndex)) { @@ -191,9 +198,12 @@ int windDirectionId = Convert.ToInt32(readSubMechanismAlphaValue[IllustrationPointsDatabaseConstants.WindDirectionId]); int closingSituationid = Convert.ToInt32(readSubMechanismAlphaValue[IllustrationPointsDatabaseConstants.ClosingSituationId]); string name = Convert.ToString(readSubMechanismAlphaValue[IllustrationPointsDatabaseConstants.StochastName]); - double duration = Convert.ToDouble(readSubMechanismAlphaValue[IllustrationPointsDatabaseConstants.Duration]); - double alpha = Convert.ToDouble(readSubMechanismAlphaValue[IllustrationPointsDatabaseConstants.AlphaValue]); - double realization = Convert.ToDouble(readSubMechanismAlphaValue[IllustrationPointsDatabaseConstants.Realization]); + double duration = ConvertToDouble(readSubMechanismAlphaValue[IllustrationPointsDatabaseConstants.Duration], + IllustrationPointsDatabaseConstants.Duration); + double alpha = ConvertToDouble(readSubMechanismAlphaValue[IllustrationPointsDatabaseConstants.AlphaValue], + IllustrationPointsDatabaseConstants.AlphaValue); + double realization = ConvertToDouble(readSubMechanismAlphaValue[IllustrationPointsDatabaseConstants.Realization], + IllustrationPointsDatabaseConstants.Realization); var key = new ThreeKeyIndex(windDirectionId, closingSituationid, subMechanismId); if (!subMechanismStochasts.ContainsKey(key)) @@ -237,7 +247,8 @@ int windDirectionId = Convert.ToInt32(readSubMechanismResult[IllustrationPointsDatabaseConstants.WindDirectionId]); int closingSituationid = Convert.ToInt32(readSubMechanismResult[IllustrationPointsDatabaseConstants.ClosingSituationId]); string description = Convert.ToString(readSubMechanismResult[IllustrationPointsDatabaseConstants.IllustrationPointResultDescription]); - double value = Convert.ToDouble(readSubMechanismResult[IllustrationPointsDatabaseConstants.IllustrationPointResultValue]); + double value = ConvertToDouble(readSubMechanismResult[IllustrationPointsDatabaseConstants.IllustrationPointResultValue], + IllustrationPointsDatabaseConstants.IllustrationPointResultValue); var key = new ThreeKeyIndex(windDirectionId, closingSituationid, subMechanismId); if (!subMechanismResults.ContainsKey(key)) @@ -367,16 +378,35 @@ { throw new HydraRingFileParserException(Resources.IllustrationPointsParser_Parse_Multiple_values_for_beta_of_illustration_point_found); } - Output.Beta = Convert.ToDouble(betaValues[0][IllustrationPointsDatabaseConstants.BetaValue]); + Output.Beta = ConvertToDouble(betaValues[0][IllustrationPointsDatabaseConstants.BetaValue], + IllustrationPointsDatabaseConstants.BetaValue); } + /// + /// Converts to . + /// + /// + /// The identifier. + /// The converted double. + /// Throw when + /// is . + /// + private static double ConvertToDouble(object doubleValue, string identifier) + { + if (doubleValue.Equals(DBNull.Value)) + { + throw new HydraRingFileParserException(string.Format(Resources.IllustrationPointsParser_Parse_Column_0_is_Null, identifier)); + } + return Convert.ToDouble(doubleValue); + } + private void ParseGeneralAlphaValues(HydraRingDatabaseReader reader) { Output.Stochasts = GetIterator(reader).Select(a => new Stochast { Name = Convert.ToString(a[IllustrationPointsDatabaseConstants.StochastName]), - Duration = Convert.ToDouble(a[IllustrationPointsDatabaseConstants.Duration]), - Alpha = Convert.ToDouble(a[IllustrationPointsDatabaseConstants.AlphaValue]) + Duration = ConvertToDouble(a[IllustrationPointsDatabaseConstants.Duration], IllustrationPointsDatabaseConstants.Duration), + Alpha = ConvertToDouble(a[IllustrationPointsDatabaseConstants.AlphaValue], IllustrationPointsDatabaseConstants.AlphaValue) }).ToArray(); } @@ -395,7 +425,8 @@ { int key = Convert.ToInt32(readWindDirection[IllustrationPointsDatabaseConstants.WindDirectionId]); string name = Convert.ToString(readWindDirection[IllustrationPointsDatabaseConstants.WindDirectionName]); - double angle = Convert.ToDouble(readWindDirection[IllustrationPointsDatabaseConstants.WindDirectionAngle]); + double angle = ConvertToDouble(readWindDirection[IllustrationPointsDatabaseConstants.WindDirectionAngle], + IllustrationPointsDatabaseConstants.WindDirectionAngle); bool isGoverning = Convert.ToBoolean(readWindDirection[IllustrationPointsDatabaseConstants.IsGoverning]); var windDirection = new WindDirection(name, angle);