SegmentLining _GetSL(DGObjects objs, DataRow row) { if (IsDbNull(row, "LineNo") || IsDbNull(row, "RingNo")) return null; int lineNo = ReadInt(row, "LineNo").Value; int ringNo = ReadInt(row, "RingNo").Value; string key = lineNo.ToString() + ":" + ringNo.ToString(); if (!objs.containsKey(key)) { string error = string.Format( "Segment Lining does not exist when reading [{0}]!!! " + "LineNo={1}, RingNo={2}.", row.Table.TableName, lineNo, ringNo); ErrorReport.Report(error); return null; } SegmentLining SL = (SegmentLining)objs[key]; return SL; }
void _ReadMonReadings(DGObjects objs) { if (objs.rawDataSet.Tables.Count <= 1) return; DataTable dt = objs.rawDataSet.Tables[1]; foreach (DataRow row in dt.Rows) { if (IsDbNull(row, "monPointName") || IsDbNull(row, "time")) continue; // if both the reading and the value are null, skip it if (IsDbNull(row, "reading") && IsDbNull(row, "value")) continue; MonReading reading = new MonReading(); reading.monPointName = ReadString(row, "monPointName"); reading.time = ReadDateTime(row, "time").Value; reading.component = ReadString(row, "component"); reading.reading = ReadString(row, "reading"); reading.unit = ReadString(row, "unit"); double? value = ReadDouble(row, "value"); if (value == null) { try { reading.value = Double.Parse(reading.reading); } catch(Exception) { // do nothing } } else reading.value = value.Value; MonPoint monPnt; if (objs.containsKey(reading.monPointName)) monPnt = objs[reading.monPointName] as MonPoint; else continue; _AddReading(monPnt, reading); } }