public async Task<SummaryTemperatureData> GetStdAsync()
 {
     // var uri = new Uri("http://jeffa.org:81/ha/SummaryData.php");
     //var uri = new Uri(App.SummaryDataUrl);
     //var client = new HttpClient();
     //var opContent = (await client.GetAsync(uri)).Content;
     //string foo = await opContent.ReadAsStringAsync();
     //var fooo = JsonConvert.DeserializeObjectAsync<SummaryTemperatureData>(foo);
     //return await fooo;
     var applicationDataSettingsService = new ApplicationDataSettingsService();
     try
     {
     // ToDo need to wrap this a bit. error checking. disposal....
     WebHeaderCollection headers = new WebHeaderCollection();
     WebRequest request = WebRequest.Create(new Uri(applicationDataSettingsService.SummaryDataUrl));
     request.ContentType = "application/xml";
     WebResponse response = await request.GetResponseAsync();
     // response.Close(); // ?? hmmm
     Debug.WriteLine("\nThe HttpHeaders are \n{0}", request.Headers);
     Stream inputStream = response.GetResponseStream();
     XmlReader xmlReader = XmlReader.Create(inputStream);
     XmlSerializer xml = new XmlSerializer(typeof(SummaryTemperatureData));
     var stdXml = (SummaryTemperatureData)xml.Deserialize(xmlReader);
     return stdXml;
     }
     catch (Exception e)
     {
         Utility.Log(this, e.ToString());
         return null;
     }
 }
        public async Task <SummaryTemperatureData> GetStdAsync()
        {
            // var uri = new Uri("http://jeffa.org:81/ha/SummaryData.php");
            //var uri = new Uri(App.SummaryDataUrl);
            //var client = new HttpClient();
            //var opContent = (await client.GetAsync(uri)).Content;
            //string foo = await opContent.ReadAsStringAsync();
            //var fooo = JsonConvert.DeserializeObjectAsync<SummaryTemperatureData>(foo);
            //return await fooo;
            var applicationDataSettingsService = new ApplicationDataSettingsService();

            try
            {
                // ToDo need to wrap this a bit. error checking. disposal....
                WebHeaderCollection headers = new WebHeaderCollection();
                WebRequest          request = WebRequest.Create(new Uri(applicationDataSettingsService.SummaryDataUrl));
                request.ContentType = "application/xml";
                WebResponse response = await request.GetResponseAsync();

                // response.Close(); // ?? hmmm
                Debug.WriteLine("\nThe HttpHeaders are \n{0}", request.Headers);
                Stream        inputStream = response.GetResponseStream();
                XmlReader     xmlReader   = XmlReader.Create(inputStream);
                XmlSerializer xml         = new XmlSerializer(typeof(SummaryTemperatureData));
                var           stdXml      = (SummaryTemperatureData)xml.Deserialize(xmlReader);
                return(stdXml);
            }
            catch (Exception e)
            {
                Utility.Log(this, e.ToString());
                return(null);
            }
        }
 public async Task<ObservableCollection<HistoricalTemperatureData>> GetWeekHtdes()
 {
     var applicationDataSettingsService = new ApplicationDataSettingsService();
     try
     {
         JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();
         jsonSerializerSettings.DateParseHandling = DateParseHandling.None;
         // var strJson = await GetJsonHistoricalTemperatureData.GetHistoricalTemperatureData(applicationDataSettingsService.HistoricalDataUrl);
         var strJson = await GetHistoricalTemperatureData(applicationDataSettingsService.HistoricalDataUrl);
         return await JsonConvert.DeserializeObjectAsync<ObservableCollection<HistoricalTemperatureData>>(strJson, jsonSerializerSettings);
     }
     catch (Exception e)
     {
         Utility.Log(this, e.ToString());
         return null;
     }
 }
        public async Task <ObservableCollection <HistoricalTemperatureData> > GetWeekHtdes()
        {
            var applicationDataSettingsService = new ApplicationDataSettingsService();

            try
            {
                JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();
                jsonSerializerSettings.DateParseHandling = DateParseHandling.None;
                // var strJson = await GetJsonHistoricalTemperatureData.GetHistoricalTemperatureData(applicationDataSettingsService.HistoricalDataUrl);
                var strJson = await GetHistoricalTemperatureData(applicationDataSettingsService.HistoricalDataUrl);

                return(await JsonConvert.DeserializeObjectAsync <ObservableCollection <HistoricalTemperatureData> >(strJson, jsonSerializerSettings));
            }
            catch (Exception e)
            {
                Utility.Log(this, e.ToString());
                return(null);
            }
        }
Ejemplo n.º 5
0
 public GeneralSettings()
 {
     applicationDataSettingsService = new ApplicationDataSettingsService();
     this.InitializeComponent();
     LoadSettings();
 }