public static List <GeometryRule> LoadGeometryRules(SqlConnection connection) { SqlCommand command = new SqlCommand("proc_spectrum_geometry_rules_select", connection); command.CommandType = CommandType.StoredProcedure; SqlDataReader reader = null; Rules.Clear(); try { reader = command.ExecuteReader(); while (reader.Read()) { GeometryRule rule = new GeometryRule(); rule.GeometryName = Convert.ToString(reader["Geometry"]).Trim(); rule.Unit = Convert.ToString(reader["Unit"]).Trim(); rule.Minimum = Convert.ToDouble(reader["Minimum"]); rule.Maximum = Convert.ToDouble(reader["Maximum"]); Rules.Add(rule); } } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } return(Rules); }
private void ApproveReportGeometry(SpectrumReport report, List <GeometryRule> geomRules) { GeometryRule rule = geomRules.Find( r => r.GeometryName.ToLower() == report.SampleGeometry.ToLower() && r.Unit.ToLower() == report.SampleUnit.ToLower()); if (rule != null) { if (report.SampleSize > rule.Maximum || report.SampleSize < rule.Minimum) { report.Approved = false; report.ApprovedStatus = "Prøve volum er utenfor geometri volum"; } } }