private async Task <bool> GetWindData() { WindDto windDto = await wind.GetWind(); FindViewById <TextView>(Resource.Id.resultJsonText).Text = wind.ReturnedJsonString; if (windDto == null) { FindViewById <TextView>(Resource.Id.stationNameText).Text = "GetWind returned null."; return(false); } else { FindViewById <TextView>(Resource.Id.stationNameText).Text = windDto.sDn; FindViewById <TextView>(Resource.Id.windTrueSpeedText).Text = windDto.wWts.ToSpeedUnit(Settings.SpeedUnit).ToUiDashes3(); FindViewById <TextView>(Resource.Id.windTrueDirText).Text = windDto.wWtd.ToUiDashes3(); FindViewById <TextView>(Resource.Id.windTrueOrientation).Text = windDto.wWto.ToUpper(); FindViewById <TextView>(Resource.Id.windTrueMaxSpeedText).Text = windDto.wWtmxs.ToSpeedUnit(Settings.SpeedUnit).ToUiDashes3(); FindViewById <TextView>(Resource.Id.windAppSpeedText).Text = windDto.wWas.ToSpeedUnit(Settings.SpeedUnit).ToUiDashes3(); FindViewById <TextView>(Resource.Id.windAppDirText).Text = windDto.wWad.ToUiDashes3(); FindViewById <TextView>(Resource.Id.windAppOrientation).Text = windDto.wWao.ToUpper(); FindViewById <TextView>(Resource.Id.windAppMaxSpeedText).Text = windDto.wWamxs.ToSpeedUnit(Settings.SpeedUnit).ToUiDashes3(); FindViewById <TextView>(Resource.Id.latitudeText).Text = lat.ToString(windDto.wLat); FindViewById <TextView>(Resource.Id.longitudeText).Text = lng.ToString(windDto.wLng); FindViewById <TextView>(Resource.Id.sogText).Text = windDto.wSog.ToSpeedUnit(Settings.SpeedUnit).ToUiDashes3(); FindViewById <TextView>(Resource.Id.cogText).Text = windDto.wCog.ToUiDashes3() + "°"; FindViewById <TextView>(Resource.Id.hdtText).Text = windDto.wHdt.ToUiDashes3() + "°"; FindViewById <TextView>(Resource.Id.magVarText).Text = windDto.wMagVar.ToUiDashes3() + "°"; FindViewById <TextView>(Resource.Id.resultUrlText).Text = wind.GetLatestUrl(); return(true); } }
public async Task <WindDto> GetWind() { string queryString = GetLatestUrl(); var results = await DataService.GetDataFromService(queryString).ConfigureAwait(false); ReturnedJsonString = results.ToString(); // { "sGuid":"7fc30138-9d5c-e511-80cc-008cfa5abd0b", // "sDn":"HMS YUCATAN", // "sstId":8, // "sssId":100,"sA":true, // "sRon":null, // "sLat":21.0694447,"sLng":-91.0875, // "sPron":null, // "wWdt":"2016-11-19T06:14:44.003Z", // "wWas":null,"wWad":null,"wWamxs":null,"wWamns":null,"wWao":"bl", // "wWts":null,"wWtd":null,"wWtmxs":null,"wWtmns":null,"wWto":"bl", // "wLat":21.0694447,"wLng":-91.0875} if (results != null) { WindDto dto = new WindDto(); dto.sA = (bool)results["sA"]; dto.sDn = (string)results["sDn"]; dto.sstId = (int)results["sstId"]; dto.sssId = (int)results["sssId"]; dto.sLat = (float)results["sLat"]; dto.sLng = (float)results["sLng"]; dto.sPron = (DateTime?)results["sPron"]; dto.wWdt = (DateTime)results["wWdt"]; dto.wWas = ((float?)results["wWas"]).ToSpeedUnit(Settings.SpeedUnit); dto.wWad = (float?)results["wWad"]; dto.wWamxs = (float?)results["wWamxs"]; dto.wWamns = (float?)results["wWamns"]; dto.wWao = (string)results["wWao"]; dto.wWts = (float?)results["wWts"]; dto.wWtd = (float?)results["wWtd"]; dto.wWtmxs = (float?)results["wWtmxs"]; dto.wWtmns = (float?)results["wWtmns"]; dto.wWto = (string)results["wWto"]; dto.wLat = (float)results["wLat"]; dto.wLng = (float)results["wLng"]; dto.wSog = (float?)results["wSog"]; dto.wCog = (float?)results["wCog"]; dto.wHdt = (float?)results["wHdt"]; dto.wMagVar = (float?)results["wMagVar"]; return(dto); } return(null); }