giovanyvecchi Posted April 15, 2016 Report Share Posted April 15, 2016 Estou disponibilizando os meus fontes para usar em conjunto com o acbrbfemonitor.exe estes procedimentos Baixem o arquivo no link abaixo. Nào tive tempo para gerar um exemplo, mais vai o prg meu com a rotina de buscar, manifestar, e efetuar o download do xml. Tem que usar minha classe acbrnfemonitor para funcionar ta tudo la. qualquer duvida postem aqui. https://www.sendspace.com/file/sc28nl Quote Link to comment Share on other sites More sharing options...
kapiaba Posted April 15, 2016 Report Share Posted April 15, 2016 Meu super obrigado giovanyvecchiVamos ver se entendemos. Very tanques. Quote Link to comment Share on other sites More sharing options...
Frazato Posted April 16, 2016 Report Share Posted April 16, 2016 Eu tenho essa usando ACBR, de uma olhada pra ver se ajuda! //--------------------------------------------- Static Function Manifestacao() Local cNumero := Space(44) Local cTitulo := '...### MANIFESTACAO DO DESTINATARIO ###...' //Alerta("em desenvolvimento!") //cNumero := "31130623643315009451550030005460011692218633" CAIXATEXTO(06,10,20,90,cTitulo,"G/GR+","BG+/NB+","NN/NN","N") @ 07,11 SAY 'Nr. Chave NFe:' Get cNumero Read If LastKey()==27 .or. Empty(cNumero) FechaJanela() Return nil Endif If MSGCONF("Gera Evento de manifestacao ?","1") == .F. FechaJanela() Return nil Endif //---- Consultando nota Centra(24,'Consulta Chave Nr. '+cNumero) cCmd := 'NFE.ConsultarNfe("'+cNumero+'")' Grava_Acbr(cCmd) cRetornoStatus := Ler_Ecf(0.3) cStatusConsulta := '' If Substr(cRetornoStatus,1,2)#'OK' ALERTA('Erro na Consulta :'+Chr(10)+; cRetornoStatus) FechaJanela() Return nil Else cStatusConsulta := cRetornoStatus Endif if '[EVENTO001]' $ cStatusConsulta Alerta("ja houve um evento com esta nota") @ 08,11 say "Situacao NFe (Envento):"+cStatusConsulta Else @ 08,11 say "Situacao NFe :"+Substr(cRetornoStatus,1,2) Endif nop := 1 tipoper := '' ajustific := '' vetnum := {'210200' , '210210' , '210220' , '210240' } cDescEnvento := '' @ 12,11 prompt "1-"+hb_ansitooem('Confirmação da Operação') @ 13,11 prompt "2-"+hb_ansitooem('Ciência da Operação') @ 14,11 Prompt "3-"+hb_ansitooem('Desconhecimento da Operação') @ 15,11 prompt "4-"+hb_ansitooem('Operação não Realizada') Menu to nOp Do Case Case nOp==1 cDescEnvento :='Confirmação da Operação' tipoper:='210200' Case nOp==2 cDescEnvento :='Ciência da Operação' tipoper:='210210' Case nOp==3 cDescEnvento :='Desconhecimento da Operação' tipoper:='210220' Case nOp==4 cDescEnvento :='Operação não Realizada' tipoper:='210240' EndCase If nop==3 .or. nop==4 ajustific:=space(800) @ 18,11 say "Justificativa:" @ 19,11 Get ajustific Pict '@!S35' Read Endif oidlote := 1 oseqevent := 1 Centra(24,'Gerando nova sequencia de envento.....') cCnpj := Lerparam("CGC_EMPRESA") cCnpj := StrTran(cCnpj,'.','') cCnpj := StrTran(cCnpj,'-','') cCnpj := StrTran(cCnpj,'/','') while 'EVENTO NUMERO '+strzero(oseqevent,3) $ cStatusConsulta oseqevent++ end fll := '' fll += 'NFE.ENVIAREVENTO("[EVENTO]'+crlf fll += 'idLote='+ltri(str(oidlote))+crlf fll += '[EVENTO001]'+crlf fll += 'chNFe='+cNumero+crlf fll += 'cOrgao=91'+crlf fll += 'CNPJ='+cCnpj+crlf set century off fll += 'dhEvento='+dtoc(Date())+' '+time()+crlf set century on fll += 'tpEvento='+tipoper+crlf // 210200 fll += 'cOrgao=91'+crlf fll += 'nSeqEvento='+strzero(oseqevent,2)+crlf fll += 'versaoEvento=1.00'+crlf fll += 'descEvento= '+hb_oemtoansi(cDescEnvento) + if(!strzero(nop,2) $ '03 04','")','')+crlf fll += if(strzero(nop,2) $ '03 04','xJust='+hb_oemtoansi(trim(ajustific))+'")','')+crlf //Alerta(fll) cCmd := fll Grava_Acbr(cCmd) cRetornoStatus := Ler_Ecf(0.3) cStatusConsulta := '' lErronoEvendo := .f. If Substr(cRetornoStatus,1,2)#'OK' Alerta('Erro na envio do EVENTO'+chr(10)+; cRetornoStatus) lErronoEvendo := .t. Endif //---- Pegando xml e colocando na pasta de importacao If lErronoEvendo==.f. Centra(24,'Baixando Xml da chave...'+cNumero) cCmd := 'NFE.DownLoadNfe('+cCnpj+','+cNumero+')' Grava_Acbr(cCmd) cRetornoStatus := Ler_Ecf(0.3) if '[NFE001]' $ cRetornoStatus Grava_xml_Pasta_Lerdanfe(cNumero,cRetornoStatus) Else Alerta('Problema no DownLoad do Xml') Endif Endif FechaJanela() Return Nil //------------------------------------------------------------------------ //Static Function Grava_Acbr(WTXT) Function Grava_Acbr(WTXT) Local RET := .T. Local cCmdLimpa:= WTXT Local nBytes := Len(cCmdLimpa) Local WARQ := cPastaACBR+'Ent'+cTerminalNfe+'.txt' If lComSocket // Via Socket TCP-Ip InetSetTimeout( sSOCKET, 3000 ) // Timeout de Recepção 3 seg // If inetsendall( sSocket,cCmdLimpa+CR+LF+'.'+CR+LF) <= 0 Alerta('ERRO: Nao foi possivel transmitir dados para o ACBrMonitor'+chr(10)+; '('+AllTrim(Str(InetErrorCode( sSOCKET )))+') '+Chr(10)+; InetErrorDesc( sSOCKET ) + ETX ) Endif Else // Via Txt Padrao Centra(24,'Apagando Arquivo de Comunicacao...'+WARQ) Do While .t. If File (cPastaACBR+'Sai'+cTerminalNfe+'.txt') Delete File (cPastaACBR+'Sai'+cTerminalNfe+'.txt') Endif If ! File (cPastaACBR+'Sai'+cTerminalNfe+'.txt') Exit Endif Enddo Centra(24,'Enviando Comando... ACBrNFe'+WTXT) HANDLE := fcreate(WARQ, FC_NORMAL ) if HANDLE > 0 fwrite(HANDLE, WTXT + chr(13) + chr(10) ) RET := (ferror() = 0) fclose(HANDLE) endif Endif RETURN (Ret) //------------------------------------------ //Static Function Ler_Ecf(nTime) Function Ler_Ecf(nTime) Local RET_IMP := '' Local ESPERA := 5 Local TENTA := .t. Local mArqLocal := cPastaACBR+"Sai"+cTerminalNfe+".txt" Local Arquivo := mArqLocal Local nTempo := 0 Local nTimeOut := 1000 //30 Local Erro := .f. Local mString := "ATIVO" If lComSocket lSair := .f. InetSetTimeout( sSOCKET, 500 ) TINI := Seconds() do while (right(RET_IMP,1) <> ETX) .or. lSair BLOCO := space(64) Centra(24,'Aguarde...'+Trim(str(TINI + ESPERA - seconds(),2)) ) BYTES := inetrecv(sSOCKET, @BLOCO, 64) RET_IMP += left(BLOCO,BYTES) if Seconds() > (TINI + 5) lSair:= .t. endif if Seconds() > (TINI + ESPERA) if ! TENTA RET_IMP := 'ERRO: Sem resposta do ACBrNFeMonitor em '+alltrim(str(ESPERA))+; ' segundos (TimeOut)' + ETX endif endif enddo Return (RET_IMP) Else // Via Txt Normal Cores() Inkey(nTime) nJanGet:= CAIXATEXTO(15,20,18,50,"Comunicando AcbrNFeMonitor","BG+/NB+","NN/NN","N") If ! file(mArqLocal) Do While .t. Centra(24,"Aguarde...."+Alltrim(Str(nTempo,5))+" Tentativa(s)") @ 16,21 say "Aguarde...."+Alltrim(Str(nTempo,5))+" Tentativa(s)" If nTempo >= nTimeOut Erro:=.t. Exit Endif //Inkey(0.2) Millisec(1000) nTempo++ If File(Arquivo) //Inkey(0.5) Millisec(100) Exit Endif Enddo Endif If Erro==.t. mString := "NAO ATIVO" Else mString := MemoRead(mArqLocal) Endif @ 17,21 say mString FechaJanela(nJanGet) Return (mString) Endif Return Nil Quote Link to comment Share on other sites More sharing options...
kapiaba Posted April 18, 2016 Report Share Posted April 18, 2016 Bom dia Frazato esse fonte em modo console, é para MDF-e? Serve para fazer isso aqui, do link? http://www.mdfe.ms.gov.br/ Obg. abs. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted May 3, 2016 Report Share Posted May 3, 2016 Ainda esperando algo concreto. abs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.