public async Task <Domoticz_Times> GetSunRiseSunSet(string uri) { Domoticz_Times _domoResponse = null; try { string jsonstring = string.Empty; jsonstring = await GetAsync(uri); if (jsonstring == null) { #region Example Result //jsonstring = "{\n \"ServerTime\" : \"2017-05-21 11:13:05\",\n \"Sunrise\" : \"04:34\",\n \"Sunset\" : \"19:39\",\n \"status\" : \"OK\",\n \"title\" : \"getSunRiseSet\"\n}\n"; #endregion } if (jsonstring != null) { _domoResponse = JsonConvert.DeserializeObject <Domoticz_Times> (jsonstring); } } catch (System.Exception ex) { Debug.WriteLine(string.Format("Error Message: {0}", ex.Message)); Debug.WriteLine(string.Format("Error Inner: {0}", ex.InnerException)); } return(_domoResponse); }
private async Task <Response_Status> CheckNetworkForDomoticz(string uri) { Domoticz_Times result = null; Response_Status success = Response_Status.ERR; try { // You must set the Uri to the base HtpClient or the request fails _baseUrl = uri; result = await GetSunRiseSunSet(uri); if (result?.status == Response_Status.OK.ToString( )) { success = Response_Status.OK; } } catch (Exception ex) { Debug.WriteLine(string.Format("Error Message: {0}", ex.Message)); Debug.WriteLine(string.Format("Error Inner: {0}", ex.InnerException)); } return(success); }