public LocalDriver GetDriver(int driverID) { //Get an exisitng driver LocalDriver driver = null; try { LocalDrivers drivers = GetDrivers(0, true); for (int i = 0; i < drivers.Count; i++) { if (drivers[i].DriverID == driverID) { driver = drivers[i]; ItemDS itemDS = new ItemDS(); DataSet ds = fillDataset(USP_BATTERY_ASSIGNMENTS, TBL_BATTERY_ASSIGNMENTS, new object[] { }); if (ds != null) { itemDS.Merge(ds); BatteryItemAssignments assignments = new BatteryItemAssignments(); ItemDS.BatteryItemAssignmentTableRow[] da = (ItemDS.BatteryItemAssignmentTableRow[])itemDS.BatteryItemAssignmentTable.Select("DriverID=" + driver.DriverID); for (int j = 0; j < da.Length; j++) { BatteryItemAssignment assignment = new BatteryItemAssignment(da[j]); assignments.Add(assignment); } driver.Assignments = assignments; } break; } } //DataContractSerializer dcs = new DataContractSerializer(typeof(LocalDriver)); //System.IO.MemoryStream ms = new System.IO.MemoryStream(); //dcs.WriteObject(ms,driver); //ms.Seek(0,System.IO.SeekOrigin.Begin); //System.IO.StreamReader sr = new System.IO.StreamReader(ms); //string xml = sr.ReadToEnd(); } catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading enterprise driver.", ex))); } return(driver); }
public LocalDrivers GetBatteryItemAssignments() { //Get a collection of battery item assignments LocalDrivers drivers = null; try { drivers = new LocalDrivers(); DataSet ds1 = fillDataset(USP_BATTERY_DRIVERS, TBL_BATTERY_DRIVERS, new object[] { }); if (ds1 != null) { ItemDS itemDS = new ItemDS(); DataSet ds2 = fillDataset(USP_BATTERY_ASSIGNMENTS, TBL_BATTERY_ASSIGNMENTS, new object[] { }); if (ds2 != null) { itemDS.Merge(ds2); } LocalDriverDS driverDS = new LocalDriverDS(); driverDS.Merge(ds1); for (int i = 0; i < driverDS.LocalDriverTable.Rows.Count; i++) { LocalDriver driver = new LocalDriver(driverDS.LocalDriverTable[i]); BatteryItemAssignments assignments = new BatteryItemAssignments(); ItemDS.BatteryItemAssignmentTableRow[] da = (ItemDS.BatteryItemAssignmentTableRow[])itemDS.BatteryItemAssignmentTable.Select("DriverID=" + driver.DriverID); for (int j = 0; j < da.Length; j++) { BatteryItemAssignment assignment = new BatteryItemAssignment(da[j]); assignments.Add(assignment); } driver.Assignments = assignments; drivers.Add(driver); } } } catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading battery item assignments.", ex))); } return(drivers); }