public void LoadDBFFile(string FileName, string IDColumn, string NameColumn, string LengthColumn, string LRColumn) { NewMessage("Reading: " + FileName); using (DBFReader dbr = new DBFReader(FileName)) { while (!dbr.EndOfData) { var data = dbr.ReadNext(); int catchid = int.Parse(data[IDColumn].ToString()); string type = data[NameColumn].ToString(); double length = double.Parse(data[LengthColumn].ToString()); double lengthReductionFactor = double.Parse(data[LRColumn].ToString()); StreamClassification streamclass; if (StreamClasses.TryGetValue(type, out streamclass)) { Tuple <double, double> previous; if (!ReductionFactors.TryGetValue(catchid, out previous)) { previous = new Tuple <double, double>(0, 0); ReductionFactors.Add(catchid, previous); } DataRow datarow = Data.Rows.Find(new object[] { catchid }); if (datarow == null) { datarow = Data.NewRow(); datarow[0] = catchid; Data.Rows.Add(datarow); } double summer = 0; double winter = 0; if (length > 0) { summer = 0.01 * MultiplicationFactor * Math.Pow(streamclass.StreamDepthSummer / (length * lengthReductionFactor / (streamclass.StreamVelocitySummer * 365.0 * 86400.0)), Exponent); winter = 0.01 * MultiplicationFactor * Math.Pow(streamclass.StreamDepthWinter / (length * lengthReductionFactor / (streamclass.StreamVelocityWinter * 365.0 * 86400.0)), Exponent); } int i = StreamClasses.IndexOfKey(streamclass.StreamType); datarow[i + 1] = length; datarow[i + 4] = winter; datarow[i + 8] = summer; var newfact = new Tuple <double, double>(1.0 - (1.0 - previous.Item1) * (1 - summer), 1.0 - (1.0 - previous.Item2) * (1 - winter)); datarow[7] = newfact.Item2; datarow[11] = newfact.Item1; ReductionFactors[catchid] = newfact; } } } }