Example #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);
        }
Example #2
0
        public static LocalDriver GetDriver(int driverID)
        {
            LocalDriver driver = null;

            try {
                _Client = new MobileDevicesServiceClient();
                driver  = _Client.GetDriver(driverID);
                _Client.Close();
            }
            catch (FaultException fe) { throw new ApplicationException("GetEnterpriseDriver() service error.", fe); }
            catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetEnterpriseDriver() timeout error.", te); }
            catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetEnterpriseDriver() communication error.", ce); }
            return(driver);
        }
Example #3
0
        //Interface
        public dlgDriverAssignments(LocalDriver driver)
        {
            //Constructor
            try {
                InitializeComponent();
                #region Window docking
                this.grdAssignments.Controls.AddRange(new Control[] { this.txtBatteryInput, this._chkShowUnassigned });
                this.txtBatteryInput.Top     = 0;
                this.txtBatteryInput.Left    = 96;
                this._chkShowUnassigned.Top  = 3;
                this._chkShowUnassigned.Left = this.grdAssignments.Width - this._chkShowUnassigned.Width - 3;
                #endregion

                //Initialize members
                this.mDriver = driver;
                this.Text    = "Battery Assignments for " + this.mDriver.FullName + ".";
            }
            catch (Exception ex) { throw new ApplicationException("Failed to create new Driver Assignments dialog", ex); }
        }
Example #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);
        }
Example #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);
        }