public void LoadAllReadCycles() { fb_con.Open(); string sql = "SELECT * FROM READCYCLE ORDER BY ID"; FbCommand cmd = new FbCommand(sql, fb_con); readcycle onecycle; int intTemp; DateTime datetemp = new DateTime(); using (FbDataReader r = cmd.ExecuteReader()) { int i; while (r.Read()) { if (cycles.Count == 121) { i = 0; } i = 0; onecycle = new readcycle(); onecycle.ID = r.GetInt32(i++); if (int.TryParse(r.GetString(i++), out intTemp)) { onecycle.DEVICEID = intTemp; } if (int.TryParse(r.GetString(i++), out intTemp)) { onecycle.CARID = intTemp; } if (int.TryParse(r.GetString(i++), out intTemp)) { onecycle.WORKER1ID = intTemp; } if (int.TryParse(r.GetString(i++), out intTemp)) { onecycle.WORKER2ID = intTemp; } onecycle.CREATEWHO = r.GetString(i++); onecycle.CREATEWHEN = r.GetString(i++); onecycle.CHANGEWHO = r.GetString(i++); onecycle.CHANGEWHEN = r.GetString(i++); if (DateTime.TryParse(r.GetString(i++), out datetemp)) { onecycle.TIMEFROM = datetemp; } if (DateTime.TryParse(r.GetString(i++), out datetemp)) { onecycle.TIMETO = datetemp; } if (int.TryParse(r.GetString(i++), out intTemp)) { onecycle.CMAXCONSUMPTPH = intTemp; } if (int.TryParse(r.GetString(i++), out intTemp)) { onecycle.CSTABILITYTIME = intTemp; } //sensors onecycle.installedSensors = new PLFUnit.PLFRecord(); onecycle.installedSensors.SetNForAllParams(); if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.SYSTEM_TIME = new PLFUnit.PLFSystemTime(); onecycle.installedSensors.SYSTEM_TIME.systemTime = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.FUEL_VOLUME1 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.FUEL_VOLUME2 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.FUEL_COUNTER = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.FUEL_CONSUMPTION = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.DISTANCE_COUNTER = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.VOLTAGE = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.ENGINE_RPM = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.LATITUDE = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.LONGITUDE = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.ALTITUDE = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.TEMPERATURE1 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.TEMPERATURE2 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.WEIGHT1 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.WEIGHT2 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.WEIGHT3 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.WEIGHT4 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.WEIGHT5 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.ADDITIONAL_SENSORS = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.RESERVED_3 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.RESERVED_4 = "Y"; } } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.RESERVED_5 = "Y"; } } i++;//ADD_SENS5 if (int.TryParse(r.GetString(i++), out intTemp)) { onecycle.TIMESTEP = intTemp; } if (int.TryParse(r.GetString(i++), out intTemp)) { if (intTemp == 1) { onecycle.installedSensors.SPEED = "Y"; } } // cycles.Add(onecycle); } } fb_con.Close(); }
public void LoadAllReadCycles() { fb_con.Open(); string sql = "SELECT * FROM READCYCLE ORDER BY ID"; FbCommand cmd = new FbCommand(sql, fb_con); readcycle onecycle; int intTemp; DateTime datetemp = new DateTime(); using (FbDataReader r = cmd.ExecuteReader()) { int i; while (r.Read()) { if (cycles.Count == 121) i = 0; i = 0; onecycle = new readcycle(); onecycle.ID = r.GetInt32(i++); if (int.TryParse(r.GetString(i++), out intTemp)) onecycle.DEVICEID = intTemp; if (int.TryParse(r.GetString(i++), out intTemp)) onecycle.CARID = intTemp; if (int.TryParse(r.GetString(i++), out intTemp)) onecycle.WORKER1ID = intTemp; if (int.TryParse(r.GetString(i++), out intTemp)) onecycle.WORKER2ID = intTemp; onecycle.CREATEWHO = r.GetString(i++); onecycle.CREATEWHEN = r.GetString(i++); onecycle.CHANGEWHO = r.GetString(i++); onecycle.CHANGEWHEN = r.GetString(i++); if (DateTime.TryParse(r.GetString(i++), out datetemp)) onecycle.TIMEFROM = datetemp; if (DateTime.TryParse(r.GetString(i++), out datetemp)) onecycle.TIMETO = datetemp; if (int.TryParse(r.GetString(i++), out intTemp)) onecycle.CMAXCONSUMPTPH = intTemp; if (int.TryParse(r.GetString(i++), out intTemp)) onecycle.CSTABILITYTIME = intTemp; //sensors onecycle.installedSensors = new PLFUnit.PLFRecord(); onecycle.installedSensors.SetNForAllParams(); if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) { onecycle.installedSensors.SYSTEM_TIME = new PLFUnit.PLFSystemTime(); onecycle.installedSensors.SYSTEM_TIME.systemTime = "Y"; } if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.FUEL_VOLUME1 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.FUEL_VOLUME2 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.FUEL_COUNTER = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.FUEL_CONSUMPTION = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.DISTANCE_COUNTER = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.VOLTAGE = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.ENGINE_RPM = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.LATITUDE = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.LONGITUDE = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.ALTITUDE = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.TEMPERATURE1 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.TEMPERATURE2 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.WEIGHT1 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.WEIGHT2 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.WEIGHT3 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.WEIGHT4 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.WEIGHT5 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.ADDITIONAL_SENSORS = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.RESERVED_3 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.RESERVED_4 = "Y"; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.RESERVED_5 = "Y"; i++;//ADD_SENS5 if (int.TryParse(r.GetString(i++), out intTemp)) onecycle.TIMESTEP = intTemp; if (int.TryParse(r.GetString(i++), out intTemp)) if (intTemp == 1) onecycle.installedSensors.SPEED = "Y"; // cycles.Add(onecycle); } } fb_con.Close(); }