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); } }
public T getObjectById <T>(int id) where T : DGObject { string klassName = typeof(T).Name; string name = domain.objsDefinitions.Values.FirstOrDefault((d) => d.Type == klassName).Name; domain.loadObjects(name); DGObjects objs = domain[name]; if (!objs.containsKey(id)) { return(default(T)); } DGObject obj = objs[id]; return((T)obj); }