コード例 #1
0
        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);
        }
コード例 #2
0
        public static LocalDrivers GetBatteryItemAssignments()
        {
            LocalDrivers assignments = null;

            try {
                _Client     = new MobileDevicesServiceClient();
                assignments = _Client.GetBatteryItemAssignments();
                _Client.Close();
            }
            catch (FaultException fe) { throw new ApplicationException("GetBatteryAssignments() service error.", fe); }
            catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetBatteryAssignments() timeout error.", te); }
            catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetBatteryAssignments() communication error.", ce); }
            return(assignments);
        }
コード例 #3
0
        public static LocalDrivers GetDrivers(long terminalID, bool mandatoryField)
        {
            LocalDrivers drivers = null;

            try {
                _Client = new MobileDevicesServiceClient();
                drivers = _Client.GetDrivers(terminalID, mandatoryField);
                _Client.Close();
            }
            catch (FaultException fe) { throw new ApplicationException("GetEnterpriseDrivers() service error.", fe); }
            catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetEnterpriseDrivers() timeout error.", te); }
            catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetEnterpriseDrivers() communication error.", ce); }
            return(drivers);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }