|
New Procedure WS CEP Rota |
Débuté par adrianoboller, 18 nov. 2014 13:36 - 3 réponses |
| |
| | | |
|
| |
Membre enregistré 3 651 messages Popularité : +175 (223 votes) |
|
Posté le 18 novembre 2014 - 13:36 |
Procedure WS_CEP_Rota(LOCAL Origem, LOCAL Destino, LOCAL DebugSN)
IF GloDebugSN = "S" THEN DebugSN = "S" END
IF Origem <> "" AND Destino = "" THEN Destino = Origem END
nVirgula is int = 0
nID_Numero is int = 1 nID_Endereco is int = 1 nID_Bairro01 is int = 1 nID_Bairro02 is int = 1 nID_Cidade01 is int = 1 nID_Cidade02 is int = 1 nID_Estado is int = 1 nID_Pais is int = 1 nID_CEP is int = 1 nQTD_ADDRESS_COMPONENT is int = 0
GloVoceEnderecoLongo = "ERRO" GloDestinoEnderecoLongo = "ERRO" GloVoceLatitude = 0 GloVoceLongitude = 0 GloDestinoLatitude = 0 GloDestinoLongitude = 0
GloLatitudeNorte = "" GloLongitudeNorte = ""
GloLatitudeSul = "" GloLongitudeSul = ""
GloTempoDestino = "" GloTempoDestinoText = "" GloTempoTaxi = ""
GloDistanciaDestino = "" GloDistanciaDestinoText = "" GloDistanciaTaxi = ""
ok is boolean = False
IF Origem <> "" AND Destino <> ""
ChangeCharset(charsetOccidental)
Origem = Replace(Origem," ","+")
Origem = Capitalize(WS_RemoveAcentos(Origem))
Destino = Replace(Destino," ","+")
Destino = Capitalize( WS_RemoveAcentos(Destino))
UrlRota is string = "http://maps.googleapis.com/maps/api/directions/xml?origin="+Origem+"&destination="+Destino+"&sensor=false&mode=driving"
IF DebugSN ="S" THEN Info("URL Busca Origem Google",UrlRota) END ok = HTTPRequest(UrlRota)
IF ok = True THEN
XmlResultado is string = WS_Android_IOS_HTTPGetResult()
IF PositionOccurrence(XmlResultado,"<status>OK</status>",firstRank,FromBeginning) > 0 OR PositionOccurrence(XmlResultado,"<status>ok</status>",firstRank,FromBeginning) > 0
IF Length(XmlResultado) > 0 THEN
GloRotaEncode = XmlResultado nInicioPoint is int = PositionOccurrence(XmlResultado,"<copyrights>",firstRank,FromBeginning) GloRotaEncode = Middle(XmlResultado,nInicioPoint,Length(XmlResultado)) nInicioPoint = PositionOccurrence(GloRotaEncode,"<points>",firstRank,FromBeginning)+Length("<points>") nFinalPoint is int = PositionOccurrence(GloRotaEncode,"</points>",firstRank,FromBeginning) GloRotaEncode = Middle(GloRotaEncode,nInicioPoint,nFinalPoint-nInicioPoint)
IF DebugSN = "S" Info("POINT",GloRotaEncode,"",XmlResultado) END
XmlResultado = WS_RemoveAcentos(XmlResultado)
sXmlResultadoRecorte is string = XmlResultado
XmlResultado = WS_RemoveCaracteresRota(XmlResultado)
IF DebugSN ="S" THEN Info("Retorno XML Busca Origem",XmlResultado) END
nInicio is int = PositionOccurrence(XmlResultado,"</step>",lastRank,FromBeginning) + 7 XmlResultado = Middle(XmlResultado,nInicio,Length(XmlResultado)) XmlResultado = "<leg>"+XmlResultado
nFim is int = PositionOccurrence(XmlResultado,"</leg>",firstRank,FromBeginning) + 5 XmlResultado = Middle(XmlResultado,1,nFim)
IF IniOSMode() = True THEN
NoXml is string = XMLExtractString(XmlResultado,"leg")
GloVoceEnderecoLongo = XMLExtractString(NoXml,"start_address") GloVoceEnderecoLongo = Capitalize(GloVoceEnderecoLongo)
GloDestinoEnderecoLongo = XMLExtractString(NoXml,"end_address") GloDestinoEnderecoLongo = Capitalize(GloDestinoEnderecoLongo)
NoXml1 is string = XMLExtractString(NoXml,"duration") GloTempoDestino = XMLExtractString(NoXml1,"value") GloTempoDestinoText = XMLExtractString(NoXml1,"text") GloTempoTaxi = GloTempoDestino
NoXml1 = XMLExtractString(NoXml,"distance") GloDistanciaDestino =XMLExtractString(NoXml1,"value") GloDistanciaDestinoText = XMLExtractString(NoXml1,"text") GloDistanciaTaxi = GloDistanciaDestino
NoXml1 = XMLExtractString(NoXml,"start_location") IF Val(XMLExtractString(NoXml1,"lat")) < 0 GloVoceLatitude = XMLExtractString(NoXml1,"lat") GloVoceLongitude = XMLExtractString(NoXml1,"lng") END
NoXml1 = XMLExtractString(NoXml,"end_location") IF Val(XMLExtractString(NoXml1,"lat")) < 0 THEN GloDestinoLatitude = XMLExtractString(NoXml1,"lat") GloDestinoLongitude = XMLExtractString(NoXml1,"lng") END
ELSE IF InAndroidMode() = True
XmlDoc02 is XMLDocument XmlDoc02 = XMLOpen(XmlResultado,fromString)
GloVoceEnderecoLongo = XmlDoc02.leg.start_address GloVoceEnderecoLongo = Capitalize(GloVoceEnderecoLongo)
GloDestinoEnderecoLongo = XmlDoc02.leg.end_address GloDestinoEnderecoLongo = Capitalize(GloDestinoEnderecoLongo)
GloTempoDestino = XmlDoc02.leg.duration.value GloTempoDestinoText = XmlDoc02.leg.duration.text GloTempoTaxi = GloTempoDestino
GloDistanciaDestino = XmlDoc02.leg.distance.value GloDistanciaDestinoText = XmlDoc02.leg.distance.text GloDistanciaTaxi = GloDistanciaDestino
IF XmlDoc02.leg.start_location.lat < 0 GloVoceLatitude = XmlDoc02.leg.start_location.lat GloVoceLongitude = XmlDoc02.leg.start_location.lng END
IF XmlDoc02.leg.end_location.lat < 0 THEN GloDestinoLatitude = XmlDoc02.leg.end_location.lat GloDestinoLongitude = XmlDoc02.leg.end_location.lng END
END
END
ELSE GloDestinoEndereco = "" GloDestinoEnderecoLongo = ""
GloTempoDestino = "" GloDistanciaDestino = "" END
END
END
IF DebugSN = "S" THEN Info(GloRotaEncode) Info("Origem:",GloVoceEnderecoLongo,GloVoceEndereco,"","Destino:",GloDestinoEnderecoLongo,GloDestinoEndereco,"","Tempo: "+GloTempoDestino,"Distancia: "+GloDistanciaDestino,"","Latitude Origem: "+GloVoceLatitude,"Longitute Origem: "+GloVoceLongitude,"","Latitude Destino: "+GloDestinoLatitude,"Longitude Destino: "+GloDestinoLongitude) END
IF QtdeOccurrence(GloVoceEnderecoLongo," - ") = 1 GloVoceEndereco = "" GloVoceNumero = "" GloVoceEnderecoLongo = "ERRO" GloVoceLatitude = 0 GloVoceLongitude = 0 END
IF QtdeOccurrence(GloDestinoEnderecoLongo," - ") = 1 GloDestinoEndereco = "" GloDestinoNumero = "" GloDestinoEnderecoLongo = "ERRO" END IF DebugSN = "S" IF GloVoceEnderecoLongo = "ERRO" OR GloDestinoEnderecoLongo = "ERRO" Info("Endereço inválido") END END
RESULT(GloVoceEnderecoLongo) |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 3 651 messages Popularité : +175 (223 votes) |
|
Posté le 25 avril 2017 - 20:43 |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 3 651 messages Popularité : +175 (223 votes) |
|
Posté le 30 août 2017 - 05:09 |
arr_Resultados is array of string
gsValorMemorizado is string = 1
DeclareWebserviceContext(gsValorMemorizado)
DeclareWebserviceContext(arr_Resultados)
Procedure Ws_BuscaEndereco(Token, Endereco)
arrResultado is array of string ok is boolean = False X is int = 0 nTokenOk is int = 0 sTabela is string = "Enderecos" Resultado is string = "" sErro is string = "" GloToken is string = ""
OkConn is boolean = False
OkConn = HConnectionOpen(MyHfsql)
ok = HExecuteQuery(QRY_Select_Cliente,hQueryWithoutHFCorrection,Token)
IF ok = True THEN FOR EACH QRY_Select_Cliente IF HFound(QRY_Select_Cliente) = True AND Token = QRY_Select_Cliente.Token THEN GloToken = QRY_Select_Cliente.Token ELSE GloToken = "" END END END
IF Token <> "" AND Token = GloToken IF OkConn = True THEN ok = HExecuteQuery(QRY_Select_Cliente,MyHfsql,hQueryWithoutHFCorrection,Token) IF ok = True THEN FOR EACH QRY_Select_Cliente IF HFound(QRY_Select_Cliente) = True THEN ok = HExecuteQuery(QRY_Select_CEP,MyHfsql,hQueryWithoutCorrection,Endereco) IF ok =True THEN Resultado = "<Xml><Retorno>" FOR EACH QRY_Select_CEP IF HFound(QRY_Select_CEP) = True AND X = 0 X += 1 Resultado += ws_xml_registro_comeco(X) Resultado += ws_xml_registro_corpo(QRY_Select_CEP.Sequencial,"Sequencial") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.LogradouroUpper,"LogradouroUpper") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.LogradouroAbrev,"LogradouroAbrev") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.Logradouro,"Logradouro") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.LogradouroCompl,"LogradouroCompl") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.Fonetica,"Fonetica") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.LogradouroTipo,"LogradouroTipo") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.CEP,"CEP") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.Bairro,"Bairro") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.BairroAbrev,"BairroAbrev") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.IDCidade,"IDCidade") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.Cidade,"Cidade") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.SubCidadeAbrev,"SubCidadeAbrev") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.SubCidade,"SubCidade") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.CodIBGECid,"CodIBGECid") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.CodIBGEUF,"CodIBGEUF") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.UF,"UF") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.Pais,"Pais") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.LogradouroIniciais,"LogradouroIniciais") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.NumeroInicial,"NumeroInicial") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.NumeroFinal,"NumeroFinal") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.DMSLatitude,"DMSLatitude") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.DMSLongitude,"DMSLongitude") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.GDLatitude,"GDLatitude") Resultado += ws_xml_registro_corpo(QRY_Select_CEP.GDLongitude,"GDLongitude") Resultado += ws_xml_registro_final() END END IF X = 0 THEN Resultado = ws_zero_registros(sTabela) END Resultado += "<TOTAL>"+X+"</TOTAL>" Resultado += "</Retorno></Xml>" ELSE Resultado += "<Error>Erro 002 tabela<Error>" END ELSE Resultado += "<Error>Erro 003 tabela<Error>" END END ELSE Resultado += "<Error>Erro 004 tabela<Error>" END ELSE Resultado += "<Error>Erro 005 Conexao<Error>" END ip is string = WebserviceClientIPAddress(False) ok = HExecuteQuery(QRY_Insert_Log,hQueryWithoutHFCorrection,DateSys()+TimeSys(),ip,Token,Endereco) HReset(QRY_Select_CEP)
HReset(QRY_Select_Cliente) HConnectionClose(ConnNativa) ELSE Resultado += "<Error>Token invalido<Error>" END
nTamanho is int = Length(Resultado)
Add(arrResultado,Resultado)
RESULT (arrResultado)
SELECT enderecoscorreios.Sequencial AS Sequencial, enderecoscorreios.LogradouroUpper AS LogradouroUpper, enderecoscorreios.LogradouroAbrev AS LogradouroAbrev, enderecoscorreios.Logradouro AS Logradouro, enderecoscorreios.LogradouroCompl AS LogradouroCompl, enderecoscorreios.Fonetica AS Fonetica, enderecoscorreios.LogradouroTipo AS LogradouroTipo, enderecoscorreios.CEP AS CEP, enderecoscorreios.Bairro AS Bairro, enderecoscorreios.BairroAbrev AS BairroAbrev, enderecoscorreios.IDCidade AS IDCidade, enderecoscorreios.Cidade AS Cidade, enderecoscorreios.SubCidadeAbrev AS SubCidadeAbrev, enderecoscorreios.SubCidade AS SubCidade, enderecoscorreios.CodIBGECid AS CodIBGECid, enderecoscorreios.CodIBGEUF AS CodIBGEUF, enderecoscorreios.UF AS UF, enderecoscorreios.Pais AS Pais, enderecoscorreios.LogradouroIniciais AS LogradouroIniciais, enderecoscorreios.NumeroInicial AS NumeroInicial, enderecoscorreios.NumeroFinal AS NumeroFinal, enderecoscorreios.DMSLatitude AS DMSLatitude, enderecoscorreios.DMSLongitude AS DMSLongitude, enderecoscorreios.GDLatitude AS GDLatitude, enderecoscorreios.GDLongitude AS GDLongitude, MATCH(enderecoscorreios.LogradouroUpper, enderecoscorreios.LogradouroAbrev, enderecoscorreios.Logradouro, enderecoscorreios.LogradouroCompl, enderecoscorreios.Fonetica, enderecoscorreios.LogradouroTipo, enderecoscorreios.CEP, enderecoscorreios.Bairro, enderecoscorreios.BairroAbrev, enderecoscorreios.Cidade, enderecoscorreios.SubCidadeAbrev, enderecoscorreios.SubCidade, enderecoscorreios.UF, enderecoscorreios.Pais, enderecoscorreios.LogradouroIniciais) AGAINST({ParamKFulltext}) AS FullTextPertinence FROM enderecoscorreios WHERE FullTextPertinence > {ParamFullTextPertinence} ORDER BY FullTextPertinence DESC
SELECT clientes.id AS id, clientes.Nome AS Nome, clientes.Email AS Email, clientes.Celular AS Celular, clientes.Token AS Token FROM clientes WHERE clientes.Token = {ParamToken}
INSERT INTO wslog ( datahora, ip, Token, acao ) VALUES ( {Paramdatahora}, {Paramip}, {ParamToken}, {Paramacao} )
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 99949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.com.br/ |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 3 651 messages Popularité : +175 (223 votes) |
|
Posté le 09 juin 2018 - 02:18 |
| |
| |
| | | |
|
| | | | |
| | |
|