// Copyright (C) Stichting Deltares 2016. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using System.Data.SQLite; using Core.Common.IO.Readers; using Core.Common.Utils.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; namespace Ringtoets.Piping.IO.SoilProfile { /// /// Class responsible for reading layer properties from a database reader. /// internal class LayerProperties { internal readonly double? IsAquifer; internal readonly string MaterialName; internal readonly double? Color; internal readonly long? BelowPhreaticLevelDistribution; internal readonly double? BelowPhreaticLevelShift; internal readonly double? BelowPhreaticLevelMean; internal readonly double? BelowPhreaticLevelDeviation; internal readonly long? DiameterD70Distribution; internal readonly double? DiameterD70Shift; internal readonly double? DiameterD70Mean; internal readonly double? DiameterD70Deviation; internal readonly long? PermeabilityDistribution; internal readonly double? PermeabilityShift; internal readonly double? PermeabilityMean; internal readonly double? PermeabilityDeviation; /// /// Creates a new instance of , which contains properties /// that are required to create a complete soil layer. If these properties /// cannot be read, then the reader can proceed to the next profile. /// /// The to read the required layer property values from. /// The profile name used in generating exceptions messages if casting failed. /// Thrown when the values in the database could not be /// casted to the expected column types. internal LayerProperties(IRowBasedDatabaseReader reader, string profileName) { string readColumn = SoilProfileDatabaseColumns.IsAquifer; try { IsAquifer = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.MaterialName; MaterialName = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.Color; Color = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelDistribution; BelowPhreaticLevelDistribution = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelShift; BelowPhreaticLevelShift = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelMean; BelowPhreaticLevelMean = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevelDeviation; BelowPhreaticLevelDeviation = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.DiameterD70Distribution; DiameterD70Distribution = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.DiameterD70Shift; DiameterD70Shift = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.DiameterD70Mean; DiameterD70Mean = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.DiameterD70Deviation; DiameterD70Deviation = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.PermeabilityDistribution; PermeabilityDistribution = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.PermeabilityShift; PermeabilityShift = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.PermeabilityMean; PermeabilityMean = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.PermeabilityDeviation; PermeabilityDeviation = reader.ReadOrDefault(readColumn); } catch (InvalidCastException e) { var message = new FileReaderErrorMessageBuilder(reader.Path) .WithSubject(string.Format(Resources.PipingSoilProfileReader_SoilProfileName_0_, profileName)) .Build(string.Format(Resources.PipingSoilProfileReader_Profile_has_invalid_value_on_Column_0_, readColumn)); throw new PipingSoilProfileReadException(profileName, message, e); } } } }