/// <summary> /// Deserializes workflow markup into an TConsSitNFe object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output TConsSitNFe 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 TConsSitNFe obj, out System.Exception exception) { exception = null; obj = default(TConsSitNFe); try { obj = Deserialize(xml); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
public List<TRetConsSitNFe> ConsultaSitNFe(HiperNFe hiperNFe, X509Certificate2 cert) { XmlNode strRetorno = null; C_WebService.ListaUrl listaURL = default(C_WebService.ListaUrl); listaURL = WsUrls.BuscaURL(hiperNFe.Configuracao.CodUF, hiperNFe.Configuracao.Ambiente); try { Consulta2.NfeConsulta2 wsMsg = default(Consulta2.NfeConsulta2); Consulta2.nfeCabecMsg cab = new Consulta2.nfeCabecMsg(); //UF E VERSÃO DO CABEÇALHO cab.cUF = PegarCodigoUF(hiperNFe.Configuracao.CodUF); cab.versaoDados = hiperNFe.Configuracao.Versao; //CRIA UMA INSTANCIA DA CONEXÃO COM O WEBSERVICE wsMsg = new Consulta2.NfeConsulta2(listaURL.UrlNfeConsultaProtocolo); //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 List<TRetConsSitNFe> listaRetorno = new List<TRetConsSitNFe>(); foreach (TNfeProc nota in hiperNFe.NotasFiscais) { TConsSitNFe consSitNfe = new TConsSitNFe(); string chaveNfe = nota.NFe.infNFe.Id.Substring(3); string arquivoConsulta = _PastaLog + chaveNfe + "-ped-sit.xml"; string arquivoRetorno = _PastaLog + chaveNfe + "-sit.xml"; consSitNfe.chNFe = chaveNfe; consSitNfe.tpAmb = hiperNFe.Configuracao.Ambiente; //consSitNfe.versao = nota.NFe.infNFe.versao; consSitNfe.versao = TVerConsSitNFe.Versao201; consSitNfe.xServ = TConsSitNFeXServ.CONSULTAR; XmlDocument dados = new XmlDocument(); dados.LoadXml(Funcoes.RemoveNameSpaceFromXml(consSitNfe.Serialize())); dados.Save(arquivoConsulta); strRetorno = wsMsg.nfeConsultaNF2(dados); XmlDocument retornoXML = new XmlDocument(); retornoXML.LoadXml(strRetorno.OuterXml); retornoXML.Save(arquivoRetorno); TRetConsSitNFe retornoSitNFe = new TRetConsSitNFe(); retornoSitNFe = TRetConsSitNFe.LoadFromFile(arquivoRetorno); nota.procEventoNFe = retornoSitNFe.procEventoNFe; if (nota.procEventoNFe != null) { foreach (var item in nota.procEventoNFe) { string arquivoProcEvento = _PastaLog + item.evento.infEvento.tpEvento + chaveNfe + item.evento.infEvento.nSeqEvento + "-procEventoNfe.xml"; XmlDocument xmlEvento = new XmlDocument(); item.SaveToFile(arquivoProcEvento); xmlEvento.LoadXml(item.Serialize()); item.ArquivoXML = xmlEvento; item.NomeArquivo = arquivoProcEvento; } } listaRetorno.Add(retornoSitNFe); } return listaRetorno; } catch (Exception ex) { throw new System.InvalidOperationException("Erro ao consultar a situação da NFe. Erro: " + ex.Message); } }
public static bool LoadFromFile(string fileName, out TConsSitNFe obj) { System.Exception exception = null; return LoadFromFile(fileName, out obj, out exception); }
public static bool LoadFromFile(string fileName, out TConsSitNFe obj, out System.Exception exception) { return LoadFromFile(fileName, Encoding.UTF8, out obj, out exception); }
/// <summary> /// Deserializes xml markup from file into an TConsSitNFe object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output TConsSitNFe 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 TConsSitNFe obj, out System.Exception exception) { exception = null; obj = default(TConsSitNFe); try { obj = LoadFromFile(fileName, encoding); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static bool Deserialize(string xml, out TConsSitNFe obj) { System.Exception exception = null; return Deserialize(xml, out obj, out exception); }
/// <summary> /// Deserializes workflow markup into an TConsSitNFe object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output TConsSitNFe 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 TConsSitNFe obj, out System.Exception exception) { exception = null; obj = default(TConsSitNFe); try { obj = Deserialize(xml); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static bool LoadFromFile(string fileName, out TConsSitNFe obj) { System.Exception exception = null; return(LoadFromFile(fileName, out obj, out exception)); }
public static bool LoadFromFile(string fileName, out TConsSitNFe obj, out System.Exception exception) { return(LoadFromFile(fileName, Encoding.UTF8, out obj, out exception)); }
/// <summary> /// Deserializes xml markup from file into an TConsSitNFe object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output TConsSitNFe 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 TConsSitNFe obj, out System.Exception exception) { exception = null; obj = default(TConsSitNFe); try { obj = LoadFromFile(fileName, encoding); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
public static bool Deserialize(string xml, out TConsSitNFe obj) { System.Exception exception = null; return(Deserialize(xml, out obj, out exception)); }