예제 #1
0
        /// <summary>
        /// This function retuens all the vehicles in the system with detailed information about every vehicle.
        /// </summary>
        /// <returns>List of all available vehicles with information</returns>
        public List<Vehicle> GetAllVehicles()
        {
            try
            {
                // Look for the vehicle model the corresponds to the vehicle model id
                XmlNodeList vehicles_nodes = GetTableData("Vehicle");

                if (vehicles_nodes != null)
                {
                    List<Vehicle> vehicles = new List<Vehicle>();
                    foreach (XmlNode xn in vehicles_nodes.Item(0).ChildNodes)
                    {

                        if (xn.HasChildNodes)
                        {
                            Vehicle vehicle = new Vehicle();

                            // User has a bitacora, so get the vehicle model
                            vehicle.VehicleModelName = GetVehicleModelName(xn.ChildNodes[0].InnerText);
                            vehicle.Id = xn.Attributes[0].Value;
                            /*vehicle.Organization = GetOrganization(xn.ChildNodes[1].InnerText);
                            vehicle.Plate = xn.ChildNodes[2].InnerText;
                            vehicle.Bitacora = GetVehicleBitacora(xn.Attributes[0].Value);*/

                            vehicles.Add(vehicle);
                        }
                    }
                    return vehicles;
                }
                return null;

            }
            catch (Exception)
            {
                return null;
                throw;
            }
        }
예제 #2
0
        /// <summary>
        /// This function retuens all the vehicles in the system with detailed information about every vehicle.
        /// </summary>
        /// <returns>List of all available vehicles with information</returns>
        public Vehicle GetVehicleById(string VehicleId)
        {
            try
            {
                // Look for the vehicle model the corresponds to the vehicle model id
                XmlNodeList vehicle_node = GetTableData("Vehicle", VehicleId);

                if (vehicle_node != null)
                {
                    XmlNode xn = vehicle_node.Item(0);
                    Vehicle vehicle = new Vehicle();

                    // User has a bitacora, so get the vehicle model
                    vehicle.VehicleModelName = GetVehicleModelName(xn.ChildNodes[0].ChildNodes[0].InnerText);
                    vehicle.VDetails.Organization = GetOrganization(xn.ChildNodes[0].ChildNodes[1].InnerText);
                    vehicle.VDetails.Plate = xn.ChildNodes[0].ChildNodes[2].InnerText;
                    vehicle.VDetails.Bitacora = GetVehicleBitacora(xn.ChildNodes[0].Attributes[0].Value);
                    vehicle.VDetails.VSData = GetVehicleSensorsData(VehicleId);
                    return vehicle;
                }
                return null;

            }
            catch (Exception)
            {
                return null;
                throw;
            }
        }