public TRetConsReciNFe ConsultarLote(TConsReciNFe consRecibo, TRetEnviNFe retEnvio) { var ws = new C_WebService(Configuracao.PastaLog); var reciboNFe = ws.ConsultaRecLote2(consRecibo, retEnvio, Certificado); if (reciboNFe.protNFe == null) { return(reciboNFe); } foreach (var item in reciboNFe.protNFe) { var nota = NotasFiscais.FirstOrDefault(n => n.NFe.infNFe.Id == "NFe" + item.infProt.chNFe); if (nota == null) { continue; } nota.protNFe = item; if (item.infProt.cStat == "100") { SalvarNFe(ref nota); } } return(reciboNFe); }
/// <summary> /// Deserializes workflow markup into an TRetEnviNFe object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output TRetEnviNFe object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out TRetEnviNFe obj, out System.Exception exception) { exception = null; obj = default(TRetEnviNFe); try { obj = Deserialize(xml); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
public TRetConsReciNFe ConsultarLote(TConsReciNFe consRecibo, TRetEnviNFe retEnvio) { var ws = new C_WebService(Configuracao.PastaLog); var reciboNFe = ws.ConsultaRecLote2(consRecibo, retEnvio, Certificado); if (reciboNFe.protNFe == null) return reciboNFe; foreach (var item in reciboNFe.protNFe) { var nota = NotasFiscais.FirstOrDefault(n => n.NFe.infNFe.Id == "NFe" + item.infProt.chNFe); if (nota == null) continue; nota.protNFe = item; if (item.infProt.cStat == "100") { SalvarNFe(ref nota); } } return reciboNFe; }
public TRetEnviNFe EnviaLote2(HiperNFe Notas, int NumLote) { XmlNode strRetorno = null; dynamic xmldoc = new XmlDocument(); ListaUrl listaURL = default(ListaUrl); listaURL = WsUrls.BuscaURL(Notas.Configuracao.CodUF, Notas.Configuracao.Ambiente); string nomeArquivoLote = _PastaLog + NumLote.ToString() + "-env-lot.xml"; string nomeArquivoRetLote = _PastaLog + NumLote.ToString() + "-rec.xml"; try { TEnviNFe LoteNFe = new TEnviNFe(); LoteNFe.idLote = NumLote.ToString(); LoteNFe.versao = Notas.Configuracao.Versao; // ERROR: Not supported in C#: ReDimStatement int indice = 0; LoteNFe.NFe = new TNFe[Notas.NotasFiscais.Count]; foreach (TNfeProc nota in Notas.NotasFiscais) { LoteNFe.NFe[indice] = nota.NFe; indice += 1; } LoteNFe.GeraLoteNFe(nomeArquivoLote); xmldoc.Load(nomeArquivoLote); //Carrega o arquivo XML Recepcao2.NfeRecepcao2 wsMsg = default(Recepcao2.NfeRecepcao2); Recepcao2.nfeCabecMsg cab = new Recepcao2.nfeCabecMsg(); //UF E VERSÃO DO CABEÇALHO cab.cUF = PegarCodigoUF(Notas.Configuracao.CodUF); cab.versaoDados = LoteNFe.versao; //CABEÇALHO USADA PARA ENVIO DE LOTE wsMsg = new Recepcao2.NfeRecepcao2(listaURL.UrlNfeRecepcao); wsMsg.nfeCabecMsgValue = cab; wsMsg.Timeout = 100000; wsMsg.ClientCertificates.Add(Notas.Certificado); wsMsg.SoapVersion = SoapProtocolVersion.Soap12; xmldoc.Save(nomeArquivoLote); //RETORNO DA SEFAZ strRetorno = wsMsg.nfeRecepcaoLote2(xmldoc); TRetEnviNFe retornoEnvio = new TRetEnviNFe(); XmlDocument retornoXML = new XmlDocument(); retornoXML.LoadXml(strRetorno.OuterXml); retornoXML.Save(nomeArquivoRetLote); retornoEnvio = TRetEnviNFe.LoadFromFile(nomeArquivoRetLote); return retornoEnvio; } catch (Exception) { throw new ACBr.Net.NFe.Exceptions.EnviaLote2Exception("Falha ao enviar o lote de NFe."); } }
public TRetConsReciNFe ConsultaRecLote2(TConsReciNFe consReciNFe, TRetEnviNFe retEnvNFe, X509Certificate2 cert) { XmlNode strRetorno = null; C_WebService.ListaUrl listaURL = default(C_WebService.ListaUrl); listaURL = WsUrls.BuscaURL(retEnvNFe.cUF, retEnvNFe.tpAmb); string nomeArquivoPedido = _PastaLog + retEnvNFe.infRec.nRec + "-ped-rec.xml"; string nomeArquivoRetProc = _PastaLog + retEnvNFe.infRec.nRec + "-pro-rec.xml"; try { RetRecepcao2.NfeRetRecepcao2 wsMsg = default(RetRecepcao2.NfeRetRecepcao2); RetRecepcao2.nfeCabecMsg cab = new RetRecepcao2.nfeCabecMsg(); //UF E VERSÃO DO CABEÇALHO cab.cUF = PegarCodigoUF(retEnvNFe.cUF); cab.versaoDados = retEnvNFe.versao; //CRIA UMA INSTANCIA DA CONEXÃO COM O WEBSERVICE wsMsg = new RetRecepcao2.NfeRetRecepcao2(listaURL.UrlNfeRetRecepcao); //ASSOCIA CABEÇALHO NFE wsMsg.nfeCabecMsgValue = cab; //DEFINE TEMPO MAXIMO DE ESPERA POR RETORNO wsMsg.Timeout = 100000; //ASSOCIA CERTIFICADO A CONEXAO WEBSERVICE wsMsg.ClientCertificates.Add(cert); //DEFINE PROTOCOLO USADO NA CONEXÃO //wsMsg.SoapVersion = SoapProtocolVersion.Soap12 //CRIA UM NOVO DOCUMENTO XML XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(Funcoes.RemoveNameSpaceFromXml(consReciNFe.Serialize())); xmldoc.Save(nomeArquivoPedido); //ENVIA CONSULTA PARA SEFAZ E OBTEM RETORNO EM FORMATO STRING strRetorno = wsMsg.nfeRetRecepcao2(xmldoc); TRetConsReciNFe retornoReciNFe = new TRetConsReciNFe(); XmlDocument retornoXML = new XmlDocument(); retornoXML.LoadXml(strRetorno.OuterXml); retornoXML.Save(nomeArquivoRetProc); retornoReciNFe = TRetConsReciNFe.LoadFromFile(nomeArquivoRetProc); retornoReciNFe.XmlRetorno = retornoXML; return retornoReciNFe; } catch (Exception) { throw new ACBr.Net.NFe.Exceptions.ConsultaRecLote2Exception("Falha ao consultar o recebimento de lote de NFe.", consReciNFe, retEnvNFe, cert); } }
public static bool LoadFromFile(string fileName, out TRetEnviNFe obj) { System.Exception exception = null; return LoadFromFile(fileName, out obj, out exception); }
public static bool LoadFromFile(string fileName, out TRetEnviNFe obj, out System.Exception exception) { return LoadFromFile(fileName, Encoding.UTF8, out obj, out exception); }
/// <summary> /// Deserializes xml markup from file into an TRetEnviNFe object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output TRetEnviNFe object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out TRetEnviNFe obj, out System.Exception exception) { exception = null; obj = default(TRetEnviNFe); try { obj = LoadFromFile(fileName, encoding); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static bool Deserialize(string xml, out TRetEnviNFe obj) { System.Exception exception = null; return Deserialize(xml, out obj, out exception); }
/// <summary> /// Deserializes workflow markup into an TRetEnviNFe object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output TRetEnviNFe object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out TRetEnviNFe obj, out System.Exception exception) { exception = null; obj = default(TRetEnviNFe); try { obj = Deserialize(xml); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static bool LoadFromFile(string fileName, out TRetEnviNFe obj) { System.Exception exception = null; return(LoadFromFile(fileName, out obj, out exception)); }
public static bool LoadFromFile(string fileName, out TRetEnviNFe obj, out System.Exception exception) { return(LoadFromFile(fileName, Encoding.UTF8, out obj, out exception)); }
/// <summary> /// Deserializes xml markup from file into an TRetEnviNFe object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output TRetEnviNFe object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out TRetEnviNFe obj, out System.Exception exception) { exception = null; obj = default(TRetEnviNFe); try { obj = LoadFromFile(fileName, encoding); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
public static bool Deserialize(string xml, out TRetEnviNFe obj) { System.Exception exception = null; return(Deserialize(xml, out obj, out exception)); }