Example #1
0
        // GET: Results
        //public ActionResult Index()
        //{
        //    return View();
        //}

        public ActionResult Index(TrailerModel trailer)
        {
            XMLSerializerManager xmlManager = new XMLSerializerManager();

            string        usn = AppSettings.GetStringValue("username");
            string        pwd = AppSettings.GetStringValue("password");
            int           requestedRowNumber = 1;
            ArrayOfString columns            = new ArrayOfString {
                "Latitude", "Longitude", "RecordTimeStamp", "VehicleTypeID", "VehicleName"
            };
            //DateTime startTimeStamp = new DateTime(2019, 11, 05);
            DateTime startTimeStamp = DateTime.Now.AddHours(-24);
            //DateTime startTimeStamp = DateTime.Now.AddDays(-6);
            string options   = "";
            int    vehicleID = trailer.VehicleId;

            // Instantiate API client
            var api = new FleetManagerAPISoapClient();
            // Get response
            var response = api.GetGpsReadingsForVehicle_v1Async(usn, pwd, requestedRowNumber, columns, startTimeStamp, options, vehicleID);
            // Get response body
            var responseBody = response.Result.Body;
            // Get GetGpsReadingsForVehicle_v1Result body
            string result = responseBody.GetGpsReadingsForVehicle_v1Result;
            // Split string body into an array
            // string[] rows = result.Split(new[] { " /><" }, StringSplitOptions.None);

            var listOfCoords = xmlManager.TestDeserializer <XmlTrailerModel>(result);

            var trailerCheck = TrailerCheckManager.TrailerCheck(listOfCoords); // TODO: still need to add an else  for error

            if (trailerCheck.ErrorMessage == "This is not a trailer")
            {
                return(View("Error"));
            }
            ;

            var lastTrailer = trailerCheck.TrailerResponse.row.LastOrDefault();

            var trailerCoordinates = new ResultsModel()
            {
                Latitude  = lastTrailer.Latitude,
                Longitude = lastTrailer.Longitude
            };

            ViewBag.Latitude  = trailerCoordinates.Latitude;
            ViewBag.Longitude = trailerCoordinates.Longitude;

            return(View());
        }
Example #2
0
 public VehicleAPIAdapter()
 {
     xmlManager = new XMLSerializerManager();
 }
Example #3
0
 public TrailerAPIAdapter()
 {
     xmlManager        = new XMLSerializerManager();
     vehicleAPIAdapter = new VehicleAPIAdapter();
 }