{"id":24372,"date":"2016-12-08T19:37:28","date_gmt":"2016-12-08T18:37:28","guid":{"rendered":"http:\/\/help.qualiware.it\/qw-help\/?p=24372"},"modified":"2023-08-18T09:44:01","modified_gmt":"2023-08-18T07:44:01","slug":"web-services-acquisizione-di-informazioni-da-google-books","status":"publish","type":"post","link":"https:\/\/help.qualiware.it\/qw-help\/web-services-acquisizione-di-informazioni-da-google-books\/","title":{"rendered":"WebService: acquisizione di dati da un servizio esterno di rilevazione dati tramite URL"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">' Il seguente frammento di codice fornisce un esempio di come sia possibile acquisire informazioni da un \r\n' un servizio esterno di rilevazione dati tramite la chiamata ad un WebService utilizzando una URL che restituisce una stringa XML.\r\n' Nella fattispecie, viene utilizzato il Web Service messo a disposizione dal sistema di monitoraggio dei \r\n' pannelli fotovoltaici SolarEdge )\r\n\r\n' L'output \u00e8 il seguente:\r\n' &lt;series&gt;\r\n'    &lt;timeUnit&gt;HOUR&lt;\/timeUnit&gt;\r\n'    &lt;unit&gt;Wh&lt;\/unit&gt;\r\n'    &lt;measuredBy&gt;INVERTER&lt;\/measuredBy&gt;\r\n'    &lt;values&gt;\r\n'      &lt;dateValue&gt;\r\n'         &lt;date&gt;2017-05-08 00:00:00&lt;\/date&gt;\r\n'         &lt;value&gt;0.0&lt;\/value&gt;\r\n'      &lt;\/dateValue&gt;\r\n' ....\r\n'    &lt;\/values&gt;\r\n' &lt;\/series&gt;\r\n\r\n' I dati vengono recuperati su base giornaliera (per il giorno corrente) e memorizzati in una griglia\r\nDim d as string=ltrim(str(Today.Year))+\"-\"+ltrim(str(Today.Month))+\"-\"+ltrim(str(Today.Day))\r\nDim url As String = \"https:\/\/monitoringapi.solaredge.com\/site\/349661\/energy.xml?timeUnit=HOUR&amp;endDate=\"+d+\"&amp;startDate=\"+d+\"&amp;api_key=KDZ46QJYX2HQPIVPJY7KX3R9HA7UENRA\" \r\n\r\nDim webClient As New System.Net.WebClient\r\nDim result As String = webClient.DownloadString(Url)\r\n\r\n' Recupero della risposta e parse dell'XML\r\nDim response = System.XML.Linq.XElement.Parse(result)\r\n\r\nfor each el as System.XML.Linq.Xelement in response.LastNode.Nodes ' Il LastNode \u00e8 \"Values\", e ne estrae tutti i nodi\r\n   ' Il quarto nodo \u00e8 quello dei Values\r\n   Dim Data As String\r\n   Dim Valore as String\r\n\r\n   Data=Ctype(el.FirstNode,System.Xml.Linq.Xelement).Value\r\n   Valore=Ctype(el.LastNode,System.Xml.Linq.Xelement).Value\r\n \r\n   if Valore&lt;&gt;\"null\"\r\n      form.findcontrol(\"Grid1\").MoveFirst()\r\n      if not form.findcontrol(\"Grid1\").LocateRow(\"CUSTOM1='\"+Data+\"'\")\r\n         form.findcontrol(\"Grid1\").AddRow()\r\n         form.findcontrol(\"Grid1\").AssignField(\"CUSTOM1\",Data)\r\n      End If\r\n      form.findcontrol(\"Grid1\").AssignField(\"NUMBER1\",val(Valore))\r\n      form.findcontrol(\"Grid1\").SaveRow()\r\n   End If \r\nnext\r\n\r\nform.findcontrol(\"Grid1\").Refresh()\r\nform.findcontrol(\"Grid1\").MoveLast()\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8216; Il seguente frammento di codice fornisce un esempio di come sia possibile acquisire informazioni da un &#8216; un servizio esterno di rilevazione dati tramite la chiamata ad un WebService utilizzando una URL che restituisce una stringa XML. &#8216; Nella fattispecie, viene utilizzato il Web Service messo a disposizione dal sistema di monitoraggio dei &#8216;&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[65],"tags":[71],"acf":[],"_links":{"self":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/24372"}],"collection":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/comments?post=24372"}],"version-history":[{"count":2,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/24372\/revisions"}],"predecessor-version":[{"id":32082,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/24372\/revisions\/32082"}],"wp:attachment":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/media?parent=24372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/categories?post=24372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/tags?post=24372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}