public LocalDrivers GetDrivers(long terminalID, bool mandatoryField) { //Return a list of enterprise drivers LocalDrivers drivers = null; try { drivers = new LocalDrivers(); if (!mandatoryField) { drivers.Add(new LocalDriver()); } DataSet ds = fillDataset(USP_LOCAL_DRIVERS, TBL_LOCAL_DRIVERS, new object[] {}); if (ds != null) { LocalDriverDS driverDS = new LocalDriverDS(); driverDS.Merge(ds); for (int i = 0; i < driverDS.LocalDriverTable.Rows.Count; i++) { LocalDriver driver = new LocalDriver(driverDS.LocalDriverTable[i]); if (driver.IsActive == 1 && ((terminalID == 0) || (terminalID > 0 && driver.TerminalID == terminalID))) { drivers.Add(driver); } } } } catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading enterprise drivers.", ex))); } return(drivers); }
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); }