예제 #1
0
        public string TransmitirLote()
        {
            XmlNode xNelem = xml.DocumentElement;
            string  sRet   = string.Empty;

            if (Acesso.TP_AMB == 1)
            {
                HLP.GeraXml.WebService.MDFe_Producao_Recepcao.mdfeCabecMsg cabec   = new WebService.MDFe_Producao_Recepcao.mdfeCabecMsg();
                HLP.GeraXml.WebService.MDFe_Producao_Recepcao.MDFeRecepcao servico = new WebService.MDFe_Producao_Recepcao.MDFeRecepcao();
                cabec.cUF                 = Acesso.cUF.ToString();
                cabec.versaoDados         = Acesso.versaoMDFe;
                servico.mdfeCabecMsgValue = cabec;
                servico.ClientCertificates.Add(Acesso.cert_CTe);
                sRet = servico.mdfeRecepcaoLote(xNelem).OuterXml;
            }
            else
            {
                HLP.GeraXml.WebServiceHomologacao.MDFe_Homologacao_Recepcao.mdfeCabecMsg cabec   = new WebServiceHomologacao.MDFe_Homologacao_Recepcao.mdfeCabecMsg();
                HLP.GeraXml.WebServiceHomologacao.MDFe_Homologacao_Recepcao.MDFeRecepcao servico = new WebServiceHomologacao.MDFe_Homologacao_Recepcao.MDFeRecepcao();
                cabec.cUF                 = Acesso.cUF.ToString();
                cabec.versaoDados         = Acesso.versaoMDFe;
                servico.mdfeCabecMsgValue = cabec;
                servico.ClientCertificates.Add(Acesso.cert_CTe);
                sRet = servico.mdfeRecepcaoLote(xNelem).OuterXml;
            }

            if (sRet != string.Empty)
            {
                sRet = sRet.Replace(" xmlns=\"http://www.portalfiscal.inf.br/mdfe\" versao=\"1.00\"", "");

                string sPathRecibo = Pastas.PROTOCOLOS + enviMDFe.idLote + "-rec.xml";
                if (System.IO.File.Exists(sPathRecibo))
                {
                    System.IO.File.Delete(sPathRecibo);
                }

                XmlDocument x = new XmlDocument();
                x.LoadXml(sRet);
                x.Save(sPathRecibo);
                recibo = SerializeClassToXml.DeserializeClasse <retEnviMDFe>(sPathRecibo);
                daoManifesto.gravaRecibo(recibo.infRec.nRec, Convert.ToInt32(enviMDFe.MDFe.infMDFe.ide.cMDF).ToString().PadLeft(7, '0'));
                daoManifesto.gravaChave(enviMDFe.MDFe.infMDFe.Id.Replace("MDFe", ""), Convert.ToInt32(enviMDFe.MDFe.infMDFe.ide.cMDF).ToString().PadLeft(7, '0'));
                return(recibo.infRec.nRec);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public string TransmitirLote()
        {

            XmlNode xNelem = xml.DocumentElement;
            string sRet = string.Empty;

            if (Acesso.TP_AMB == 1)
            {
                HLP.GeraXml.WebService.MDFe_Producao_Recepcao.mdfeCabecMsg cabec = new WebService.MDFe_Producao_Recepcao.mdfeCabecMsg();
                HLP.GeraXml.WebService.MDFe_Producao_Recepcao.MDFeRecepcao servico = new WebService.MDFe_Producao_Recepcao.MDFeRecepcao();
                cabec.cUF = Acesso.cUF.ToString();
                cabec.versaoDados = Acesso.versaoMDFe;
                servico.mdfeCabecMsgValue = cabec;
                servico.ClientCertificates.Add(Acesso.cert_CTe);
                sRet = servico.mdfeRecepcaoLote(xNelem).OuterXml;
            }
            else
            {
                HLP.GeraXml.WebServiceHomologacao.MDFe_Homologacao_Recepcao.mdfeCabecMsg cabec = new WebServiceHomologacao.MDFe_Homologacao_Recepcao.mdfeCabecMsg();
                HLP.GeraXml.WebServiceHomologacao.MDFe_Homologacao_Recepcao.MDFeRecepcao servico = new WebServiceHomologacao.MDFe_Homologacao_Recepcao.MDFeRecepcao();
                cabec.cUF = Acesso.cUF.ToString();
                cabec.versaoDados = Acesso.versaoMDFe;
                servico.mdfeCabecMsgValue = cabec;
                servico.ClientCertificates.Add(Acesso.cert_CTe);
                sRet = servico.mdfeRecepcaoLote(xNelem).OuterXml;
            }

            if (sRet != string.Empty)
            {
                sRet = sRet.Replace(" xmlns=\"http://www.portalfiscal.inf.br/mdfe\" versao=\"1.00\"", "");

                string sPathRecibo = Pastas.PROTOCOLOS + enviMDFe.idLote + "-rec.xml";
                if (System.IO.File.Exists(sPathRecibo))
                {
                    System.IO.File.Delete(sPathRecibo);
                }

                XmlDocument x = new XmlDocument();
                x.LoadXml(sRet);
                x.Save(sPathRecibo);
                recibo = SerializeClassToXml.DeserializeClasse<retEnviMDFe>(sPathRecibo);
                daoManifesto.gravaRecibo(recibo.infRec.nRec, Convert.ToInt32(enviMDFe.MDFe.infMDFe.ide.cMDF).ToString().PadLeft(7, '0'));
                daoManifesto.gravaChave(enviMDFe.MDFe.infMDFe.Id.Replace("MDFe", ""), Convert.ToInt32(enviMDFe.MDFe.infMDFe.ide.cMDF).ToString().PadLeft(7, '0'));
                return recibo.infRec.nRec;
            }
            else
                return null;
        }