Пример #1
0
        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);
        }
Пример #2
0
 /// <summary>
 /// Deserializes workflow markup into an TConsReciNFe object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output TConsReciNFe 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 TConsReciNFe obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(TConsReciNFe);
     try
     {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
Пример #3
0
        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;
        }
Пример #4
0
 public TRetConsReciNFe Enviar(int numeroLote)
 {
     var ws = new C_WebService(Configuracao.PastaLog);
     var retEnvio = ws.EnviaLote2(this, numeroLote);
     var consRecibo = new TConsReciNFe
     {
         nRec = retEnvio.infRec.nRec,
         tpAmb = retEnvio.tpAmb,
         versao = retEnvio.versao
     };
     System.Threading.Thread.Sleep(5000);
     try
     {
         return ConsultarLote(consRecibo, retEnvio);
     }
     catch (Exception)
     {
         System.Threading.Thread.Sleep(3000);
         return ConsultarLote(consRecibo, retEnvio);
     }
 }
Пример #5
0
        public TRetConsReciNFe Enviar(int numeroLote)
        {
            var ws         = new C_WebService(Configuracao.PastaLog);
            var retEnvio   = ws.EnviaLote2(this, numeroLote);
            var consRecibo = new TConsReciNFe
            {
                nRec   = retEnvio.infRec.nRec,
                tpAmb  = retEnvio.tpAmb,
                versao = retEnvio.versao
            };

            System.Threading.Thread.Sleep(5000);
            try
            {
                return(ConsultarLote(consRecibo, retEnvio));
            }
            catch (Exception)
            {
                System.Threading.Thread.Sleep(3000);
                return(ConsultarLote(consRecibo, retEnvio));
            }
        }
Пример #6
0
        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);
            }
        }
Пример #7
0
 public static bool LoadFromFile(string fileName, out TConsReciNFe obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
Пример #8
0
 public static bool LoadFromFile(string fileName, out TConsReciNFe obj, out System.Exception exception)
 {
     return(LoadFromFile(fileName, Encoding.UTF8, out obj, out exception));
 }
Пример #9
0
 /// <summary>
 /// Deserializes xml markup from file into an TConsReciNFe object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output TConsReciNFe 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 TConsReciNFe obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(TConsReciNFe);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
Пример #10
0
 public static bool Deserialize(string xml, out TConsReciNFe obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }
 public static bool LoadFromFile(string fileName, out TConsReciNFe obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 public static bool LoadFromFile(string fileName, out TConsReciNFe obj, out System.Exception exception)
 {
     return LoadFromFile(fileName, Encoding.UTF8, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an TConsReciNFe object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output TConsReciNFe 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 TConsReciNFe obj, out System.Exception exception)
 {
     exception = null;
     obj = default(TConsReciNFe);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string xml, out TConsReciNFe obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an TConsReciNFe object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output TConsReciNFe 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 TConsReciNFe obj, out System.Exception exception)
 {
     exception = null;
     obj = default(TConsReciNFe);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }