{"id":26061,"date":"2020-03-26T15:24:25","date_gmt":"2020-03-26T14:24:25","guid":{"rendered":"http:\/\/help.qualiware.it\/qw-help\/?p=26061"},"modified":"2023-03-16T11:20:43","modified_gmt":"2023-03-16T10:20:43","slug":"aggiornamento-delle-coordinate-gps-di-clienti-e-fornitori","status":"publish","type":"post","link":"https:\/\/help.qualiware.it\/qw-help\/aggiornamento-delle-coordinate-gps-di-clienti-e-fornitori\/","title":{"rendered":"Aggiornamento delle coordinate GPS di clienti e fornitori"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">' Il seguente snippet pu\u00f2 essere inserito in un task per aggiornare le coordinate GPS di clienti e fornitori\r\n'\r\n\r\ndim key as string = \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"  ' Inserire qui l'api key che si ottiene registrandosi gratuitamente al sito https:\/\/developer.mapquest.com\/ (free fino a 15000 richieste\/mese)\r\n\r\n\r\n\r\ndim via,citta,prov,cap,nazione,CODICE as string\r\ndim x as integer\r\nDim Q as new QWTable\r\nQ.Database=DB\r\nQ.sql=\"select * from CLIFOR where VIA is not null and CITTA is not null and (GPS_LAT=0 or GPS_LONG=0)\"\r\nQ.requestlive=false\r\nQ.allowallrecords=true\r\nQ.active=true\r\n\r\n\r\nif not q.rowset.endofset\r\n   for x=0 to q.rowset.count-1\r\n      via = q.rowset.fields(\"via\").value\r\n      citta = q.rowset.fields(\"citta\").value\r\n      prov = q.rowset.fields(\"prov\").value\r\n      cap = q.rowset.fields(\"cap\").value\r\n      nazione = q.rowset.fields(\"nazione\").value\r\n      if empty(nazione)\r\n         nazione=\"Italy\"\r\n      End If\r\n      CODICE = q.rowset.fields(\"CODICE\").value\r\n\r\n      Dim url As string \r\n   url=\"https:\/\/www.mapquestapi.com\/geocoding\/v1\/address?key=\" &amp; key &amp; \"&amp;street=\"+escape(via)+\"&amp;city=\"+escape(citta)+iif(not empty(cap),\"&amp;postalCode=\"+cap,\"\")+\"&amp;country=\"+escape(nazione)\r\n\r\n      Dim webClient As New System.Net.WebClient\r\n      Dim json As String = webClient.DownloadString(Url)\r\n      Dim obj As Newtonsoft.Json.linq.JObject = Newtonsoft.Json.linq.JObject.Parse(json)\r\n      if obj.selecttoken(\"results\").count&gt;0 then\r\n         dim lat as double=obj.SelectToken(\"results[0].locations[0].latLng.lat\")\r\n         dim lng as double=obj.SelectToken(\"results[0].locations[0].latLng.lng\")\r\n\r\n         Dim par5 As AssocArray = New AssocArray\r\n         par5(\"CODICE\")=CODICE\r\n         dim msg5 as string\r\n         dim SQL5 as string\r\n         dim q5 as qwtable\r\n         SQL5=\"select * from clifor where CODICE=:CODICE\"\r\n         q5=OpenTable(db,SQL5,par5,false,true,msg5)\r\n         if empty(msg5) then\r\n            If not q5.rowset.endofset\r\n               q5.replace(\"GPS_LAT\", lat)\r\n               q5.replace(\"GPS_LONG\", lng)\r\n               q5.saverecord()\r\n            end if  \r\n            CloseTable(q5)\r\n         else\r\n            'Errore\r\n            writelog(\"Errore: \"+msg5)\r\n         end if\r\n      end if\r\n\r\n      q.rowset.next()\t\t   \r\n   next\r\nend if\r\nq.active = false\r\nq.dispose()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8216; Il seguente snippet pu\u00f2 essere inserito in un task per aggiornare le coordinate GPS di clienti e fornitori &#8216; dim key as string = &#8220;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&#8221; &#8216; Inserire qui l&#8217;api key che si ottiene registrandosi gratuitamente al sito https:\/\/developer.mapquest.com\/ (free fino a 15000 richieste\/mese) dim via,citta,prov,cap,nazione,CODICE as string dim x as integer Dim Q as&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":[82],"acf":[],"_links":{"self":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/26061"}],"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=26061"}],"version-history":[{"count":1,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/26061\/revisions"}],"predecessor-version":[{"id":30006,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/26061\/revisions\/30006"}],"wp:attachment":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/media?parent=26061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/categories?post=26061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/tags?post=26061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}