Page 1 of 1
VB a Fivewin/xharbour
Posted:
Mon Mar 04, 2013 2:09 pm
by Wanderson
Como passar o código de VB a Fivewin/xharbour?
'
' declaração das variáveis que serão utilizadas na passagem de parâmetros da DLL
'
' ********IMPORTANTE O tipoXML da versão 1.04 é 35 ***************
'
Dim XML As String ' informar uma string com o XML que será validada.
Dim msgResultado As String ' retorna a literal do resultado da chamada do WS
Dim erroXML As String ' retorna um texto com o erros de validações encontados
Dim tipoXML As Long ' informar o código do ***tipoXML*** do schema XML que será utilizado na validação
Dim qtdeErros As Long ' retorna a literal com resultado da chamada da DLL
Dim resultado As Long ' código do resultado da chamada da DLL
'
' carregar arquivo XML na string
'
Dim nomeArquivo As String ' nome do arquivo que será validado
'
nomeArquivo = "exemplo.xml"
'
' Carrega o conteúdo do nome do arquivo em XML
'
Open nomeArquivo For Input As #1
XML= Input$(LOF(1), #1)
Close #1
' ********IMPORTANTE O tipoXML da versão 1.04 é 35 ***************
tipoXML = 35 ' validar CT-e (opção fixa para validar CT-e layout 1.04 neste exemplo)
qtdeErros = 0 ' quantidade de erros, se o XML não estiver assinado vai ocorrer um erro
erroXML = "" ' retorna um texto com o erros de validações encontados
msgResultado = "" ' retorna a literal com resultado da chamada da DLL
resultado = 0 ' código do resultado da chamada da DLL
'
' referenciando a DLL em late binding
' não é necessário fazer o reference da DLL
' o intelisense não funciona
'
Dim objCTeUtil As Object
Set objCTeUtil = CreateObject("CTe_Util.Util")
'
Screen.MousePointer = vbHourglass ' ponteiro ampulheta
'
'
resultado = objCTeUtil.ValidaXML(XML, tipoXML, msgResultado, qtdeErros, erroXML)
'
'
Screen.MousePointer = vbDefault ' ponteiro normal
'
' tratar retorno
'
If (resultado = 0) Then
MsgBox msgResultado, vbInformation, "Informação"
Else
MsgBox "Processo de validação do XML falhou..." & vbCrLf & msgResultado, vbExclamation, "Atenção"
End If
'
' liberar DLL
'
Set objCTeUtil = Nothing
End Sub
Gracias.
Re: VB a Fivewin/xharbour
Posted:
Mon Mar 04, 2013 5:11 pm
by Antonio Linares
Wanderson,
Prueba este código y dime que te muestra:
- Code: Select all Expand view
function Main()
MsgInfo( ValType( CreateObject( "CTe_Util.Util" ) ) )
return nil
Re: VB a Fivewin/xharbour
Posted:
Mon Mar 04, 2013 5:15 pm
by Wanderson
Olá Antonio me muestra: O
Gracias.
Re: VB a Fivewin/xharbour
Posted:
Mon Mar 04, 2013 5:22 pm
by Antonio Linares
Bien, ahora prueba esto:
- Code: Select all Expand view
function Main()
local o := CreateObject( "CTe_Util.Util" )
local nTipoXML := 1
local cResultado := Space( 100 )
local nErrors := 0
local nErrorXML := 0
MsgInfo( o:ValidaXML( MemoRead( "test.xml" ), nTipoXML, @cResultado, @nErrors, @nErrorXML) )
MsgInfo( cResultado )
return nil
Re: VB a Fivewin/xharbour
Posted:
Mon Mar 04, 2013 5:34 pm
by Wanderson
Fivewin Error:
Application
===========
Path and name: D:\Sistemas\Galanew\v1.0b\CTE.exe (32 bits)
Size: 1,910,784 bytes
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 03/04/13, 14:32:50
Error description: Error CTe_Util.Util/3 DISP_E_MEMBERNOTFOUND: VALIDAXML
Args:
[ 1] = C <?xml version="1.0" encoding="UTF-8"?><CTe xmlns="http://www.portalfiscal.inf.br/cte"><infCte versao="1.04" Id="CTe52120408766660000190570010000000441498289605"><ide><cUF>52</cUF><cCT>49828960</cCT><CFOP>6353</CFOP><natOp>PRESTACAO DE SERVICO DE TRANSP INTERESTADUAL A ESTAB COMERCI</natOp><forPag>1</forPag><mod>57</mod><serie>1</serie><nCT>44</nCT><dhEmi>2012-04-16T11:51:34</dhEmi><tpImp>1</tpImp><tpEmis>1</tpEmis><cDV>5</cDV><tpAmb>2</tpAmb><tpCTe>0</tpCTe><procEmi>0</procEmi><verProc>1.1.2</verProc><cMunEnv>5208707</cMunEnv><xMunEnv>GOIANIA</xMunEnv><UFEnv>GO</UFEnv><modal>01</modal><tpServ>0</tpServ><cMunIni>5208707</cMunIni><xMunIni>GOIANIA</xMunIni><UFIni>GO</UFIni><cMunFim>2105302</cMunFim><xMunFim>IMPERATRIZ</xMunFim><UFFim>MA</UFFim><retira>1</retira><toma03><toma>3</toma></toma03></ide><compl><fluxo /></compl><emit><CNPJ>08766660000190</CNPJ><IE>104110643</IE><xNome>LINK TRANSPORTES E LOGISTICA LTDA</xNome><xFant>LINK TRANSPORTES</xFant><enderEmit><xLgr>RUA DOS MISSIONARIOS</xLgr><nro>643</nro><xCpl>SL 01</xCpl><xBairro>RODOVIARIO</xBairro><cMun>5208707</cMun><xMun>GOIANIA</xMun><CEP>74430360</CEP><UF>GO</UF><fone>6230936896</fone></enderEmit></emit><rem><CNPJ>61092037000505</CNPJ><IE>100005934</IE><xNome>ETERNIT S/A</xNome><xFant>ETERNIT S/A</xFant><fone>6235455052</fone><enderReme><xLgr>RODOVIA BR 060</xLgr><nro>S/N</nro><xCpl>74393351</xCpl><xBairro>ZONA RURAL</xBairro><cMun>5208707</cMun><xMun>GOIANIA</xMun><CEP>74393351</CEP><UF>GO</UF><cPais>1058</cPais><xPais>BRASIL</xPais></enderReme><infNF><mod>01</mod><serie>1</serie><nDoc>1</nDoc><dEmi>2012-04-14</dEmi><vBC>0.00</vBC><vICMS>0.00</vICMS><vBCST>0.00</vBCST><vST>0.00</vST><vProd>12.00</vProd><vNF>12.00</vNF><nCFOP>5102</nCFOP><nPeso>14.000</nPeso></infNF></rem><dest><CNPJ>05657512000149</CNPJ><IE>122383591</IE><xNome>A ALENCAR MATERIAIS P CONSTRUCAO LTDA</xNome><fone>9935263416</fone><enderDest><xLgr>RUA CEARA</xLgr><nro>226A</nro><xCpl>65900530</xCpl><xBairro>JUCARA</xBairro><cMun>2105302</cMun><xMun>IMPERATRIZ</xMun><CEP>65900530</CEP><UF>MA</UF><cPais>1058</cPais><xPais>BRASIL</xPais></enderDest></dest><vPrest><vTPrest>1.75</vTPrest><vRec>1.75</vRec><Comp><xNome>FRETE PESO</xNome><vComp>1.75</vComp></Comp></vPrest><imp><ICMS><ICMS00><CST>00</CST><vBC>1.75</vBC><pICMS>0.00</pICMS><vICMS>0.00</vICMS></ICMS00></ICMS></imp><infCTeNorm><infCarga><vCarga>12.00</vCarga><proPred>DIVERSOS</proPred><infQ><cUnid>01</cUnid><tpMed>KILO</tpMed><qCarga>14.0000</qCarga></infQ><infQ><cUnid>03</cUnid><tpMed>UNIDADES</tpMed><qCarga>13.0000</qCarga></infQ></infCarga><infModal versaoModal="1.04"><rodo><RNTRC>00000000</RNTRC><dPrev>2012-04-20</dPrev><lota>0</lota><veic><cInt>0</cInt><RENAVAM>523417632</RENAVAM><placa>AAB2462</placa><tara>200</tara><capKG>2000</capKG><capM3>300</capM3><tpProp>T</tpProp><tpVeic>0</tpVeic><tpRod>01</tpRod><tpCar>00</tpCar><UF>PR</UF><prop><CNPJ>84571488000105</CNPJ><RNTRC>11111111</RNTRC><xNome>11 DE JULHO MAT P/ CONST LTDA</xNome><IE>3010264714</IE><UF>RO</UF><tpProp>2</tpProp></prop></veic><veic><cInt>0</cInt><RENAVAM>111111111</RENAVAM><placa>AAA5536</placa><tara>2000</tara><capKG>2000</capKG><capM3>300</capM3><tpProp>T</tpProp><tpVeic>1</tpVeic><tpRod>00</tpRod><tpCar>04</tpCar><UF>PR</UF><prop><CNPJ>84571488000105</CNPJ><RNTRC>11111111</RNTRC><xNome>11 DE JULHO MAT P/ CONST LTDA</xNome><IE>3010264714</IE><UF>RO</UF><tpProp>2</tpProp></prop></veic><veic><cInt>0</cInt><RENAVAM>111111111</RENAVAM><placa>AAA5537</placa><tara>200</tara><capKG>2000</capKG><capM3>300</capM3><tpProp>T</tpProp><tpVeic>1</tpVeic><tpRod>00</tpRod><tpCar>03</tpCar><UF>PR</UF><prop><CNPJ>84571488000105</CNPJ><RNTRC>11111111</RNTRC><xNome>11 DE JULHO MAT P/ CONST LTDA</xNome><IE>3010264714</IE><UF>RO</UF><tpProp>2</tpProp></prop></veic><lacRodo><nLacre>252525</nLacre></lacRodo><moto><xNome>ABADIO DE PAULA JESUS</xNome><CPF>41305264134</CPF></moto></rodo></infModal></infCTeNorm></infCte><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI="#CTe52120408766660000190570010000000441498289605"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>6u8sgSiQmRLk7MFcRMSaL/JNmN0=</DigestValue></Reference></SignedInfo><SignatureValue>gUehfBkHLhJMPs1szZ3WTK+g48PZ3Q7hcpbfueuECtzwdz0OZb+MO2oXEO4PlYQt9UAUQqtPjHXPxxSqg4rbxDqxNPA/KfvBbGOmQs35U2q5gYicFh1DM+rjG2OUUwdEPh6HsVKEMugXRYmyEzT4Ayf9FQOqyScCeSb1rW+pvKI=</SignatureValue><KeyInfo><X509Data><X509Certificate>MIIG3DCCBcSgAwIBAgIQffpEMynaS4knXoThJ0w4oTANBgkqhkiG9w0BAQUFADB0MQswCQYDVQQGEwJCUjETMBEGA1UEChMKSUNQLUJyYXNpbDEtMCsGA1UECxMkQ2VydGlzaWduIENlcnRpZmljYWRvcmEgRGlnaXRhbCBTLkEuMSEwHwYDVQQDExhBQyBDZXJ0aXNpZ24gTXVsdGlwbGEgRzMwHhcNMTExMjEzMDAwMDAwWhcNMTIxMjExMjM1OTU5WjCCARUxCzAJBgNVBAYTAkJSMRMwEQYDVQQKFApJQ1AtQnJhc2lsMRUwEwYDVQQLFAxJRCAtIDI0MDUyNDQxODA2BgNVBAsUL0F1dGVudGljYWRvIHBvciBDZXJ0aXNpZ24gQ2VydGlmaWNhZG9yYSBEaWdpdGFsMRswGQYDVQQLFBJBc3NpbmF0dXJhIFRp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XRyYWxjci5jb20uYnIvcmVwb3NpdG9yaW8vbGNyL0FDQ2VydGlzaWduTXVsdGlwbGFHMy9MYXRlc3RDUkwuY3JsMFugWaBXhlVodHRwOi8vcmVwb3NpdG9yaW8uaWNwYnJhc2lsLmdvdi5ici9sY3IvQ2VydGlzaWduL0FDQ2VydGlzaWduTXVsdGlwbGFHMy9MYXRlc3RDUkwuY3JsMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDBDCBoAYIKwYBBQUHAQEEgZMwgZAwKAYIKwYBBQUHMAGGHGh0dHA6Ly9vY3NwLmNlcnRpc2lnbi5jb20uYnIwZAYIKwYBBQUHMAKGWGh0dHA6Ly9pY3AtYnJhc2lsLmNlcnRpc2lnbi5jb20uYnIvcmVwb3NpdG9yaW8vY2VydGlmaWNhZG9zL0FDX0NlcnRpc2lnbl9NdWx0aXBsYV9HMy5wN2MwDQYJKoZIhvcNAQEFBQADggEBAGNAJg2wWFGWooYcYvIOr0plQvp7IZMmgcXhiqfTUL1YGX9cIXszNJJ2s8opx2lT7ERm+19rukd7/ktIHa8a5cVepH0q+rjV7qzBUdPRv9Irs5Wcg6pH0VdfF5xbjcGQuUA3DUtH/H39tvjaS9LQY+V6Pu2uEHojZWsQvp9U0ppAmfC+lHEOe3KSMa1e0wZL0cU7Tfe2yUZHzquJEhzKipgBW7JKeOP7D5UZmHCBkUusPHRmBn+LG3L7EA5tQ1JGHWamTH4JjumyohTwPuckCU6cMzVhgq/kDvCpEx7++wlnTXqssv0sX2/CX2umrf/+waIORwkR6i5MvclYpC1V53Y=</X509Certificate></X509Data></KeyInfo></Signature></CTe>
[ 2] = N 1
[ 3] = C E r r o : X M L n ã o a t e n d e S c h e m a X M L .
[ 4] = N 7
[ 5] = N 0
Re: VB a Fivewin/xharbour
Posted:
Mon Mar 04, 2013 5:52 pm
by Antonio Linares
Re: VB a Fivewin/xharbour
Posted:
Mon Mar 04, 2013 6:00 pm
by Wanderson
Antonio con harbour no funciona solo xharbour
Compiling...
Harbour 3.2.0dev (Rev. 18881)
Copyright (c) 1999-2013,
http://harbour-project.org/Compiling 'CTE.prg' and generating preprocessed output to 'CTE.ppo'...
Lines 3633, Functions/Procedures 1
Generating C source output to 'CTE.c'... Done.
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
cte.c:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_hb_retclen_buffer' referenced from D:\LANG\FWH0910\HARBOUR\LIB\
HBSIX.LIB|sxcrypt
Error: Unresolved external '_HB_FUN_FW_GT' referenced from D:\SISTEMAS\GALANEW\V1.0B\CTE.OBJ
* Linking errors *
Re: VB a Fivewin/xharbour
Posted:
Mon Mar 04, 2013 6:09 pm
by Wanderson
Antonio,
O manual de la dll cte_util.dll tem essa chamada:
int ValidaXML(string XML, long tipoXML, out string msgResultado, out long qtdeErros, out string erroXML)
Como passar isso a DLL FUNCTION .... ? Talvez funcione assi.
Gracias.
Re: VB a Fivewin/xharbour
Posted:
Mon Mar 04, 2013 9:25 pm
by Antonio Linares
DLL FUNCTION ValidaXML( cXML AS LPSTR, nTipoXML AS LONG, cMsgResultado AS LPSTR, nErrors AS LONG, cErroXML AS LPSTR ) AS LONG FROM "CTe_Util.dll"
We can solve this, so you can try with Harbour:
Error: Unresolved external '_hb_retclen_buffer' referenced from D:\LANG\FWH0910\HARBOUR\LIB\HBSIX.LIB|sxcrypt
Error: Unresolved external '_HB_FUN_FW_GT' referenced from D:\SISTEMAS\GALANEW\V1.0B\CTE.OBJ
Re: VB a Fivewin/xharbour
Posted:
Tue Mar 05, 2013 1:46 am
by Wanderson
Gracias Antonio,
Mais una dúvida:
in flexdocs dll manual:
Int PegaDadosCertificado(ref string Nome, out string MsgResultado, out string Titular, out string CNPJ, out string NroSerie, out string Emissor, out string InicioValidade, out string FimValidade)
I try do this:
o:PegaDadosCertificado(@Nome,@MsgResultado,@Titular,@CNPJ,@NroSerie,@Emissor,@InicioValidade,@FimValidade)
funciona bien mostra una dlg com todos los certificados cadastrados en windows, mas se eu carrego la variavel:
Nome := "LINKTRANS TRANSPORTE LOGISTICA" no me acha lo certificado
Creio que estoy passando erroneamente la variável Nome, como seria (ref String Nome)?
Gracias.
Re: VB a Fivewin/xharbour
Posted:
Tue Mar 05, 2013 7:44 am
by Antonio Linares
Este parámetro @Nome no lo pases por referencia. Solo Nome
Re: VB a Fivewin/xharbour
Posted:
Tue Mar 05, 2013 7:55 pm
by Wanderson
Gracias Antonio, funciono com xharbour.