Example #1
0
        public HLP.GeraXml.bel.CTe.Evento.TRetEvento TransmiteLoteCCeCTe()
        {
            string sRetorno = "";

            XmlDocument _xmlxelem = new XmlDocument();

            _xmlxelem.PreserveWhitespace = true;
            _xmlxelem.LoadXml(this.sXMLfinal);

            XmlNode xNelem = null;

            xNelem = _xmlxelem.DocumentElement;
            try
            {
                //Homologação
                if (Acesso.TP_AMB == 2)
                {
                    HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.cteCabecMsg objCabecCancelamento = new HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.cteCabecMsg();
                    objCabecCancelamento.cUF         = Acesso.cUF.ToString();
                    objCabecCancelamento.versaoDados = Acesso.versaoCTe;

                    HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.CteCancelamento objCancelamento = new HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.CteCancelamento();
                    objCancelamento.cteCabecMsgValue = objCabecCancelamento;
                    objCancelamento.ClientCertificates.Add(Acesso.cert_CTe);
                    sRetorno = objCancelamento.cteCancelamentoCT(xNelem).OuterXml;
                }
                //Produção
                else if (Acesso.TP_AMB == 1)
                {
                    HLP.GeraXml.WebService.CTe_Producao_evento.cteCabecMsg       cabec           = new WebService.CTe_Producao_evento.cteCabecMsg();
                    HLP.GeraXml.WebService.CTe_Producao_evento.CteRecepcaoEvento objCancelamento = new WebService.CTe_Producao_evento.CteRecepcaoEvento();
                    cabec.cUF         = Acesso.cUF.ToString();
                    cabec.versaoDados = Acesso.versaoCTe;
                    objCancelamento.cteCabecMsgValue = cabec;
                    objCancelamento.ClientCertificates.Add(Acesso.cert_CTe);
                    sRetorno = objCancelamento.cteRecepcaoEvento(xNelem).OuterXml;
                }

                XDocument xRet  = XDocument.Parse(sRetorno);
                string    sPath = Pastas.PROTOCOLOS + "\\" + this.objlItensPesquisa.FirstOrDefault().CHNFE + "_ret-cce.xml";
                xRet.Save(sPath);
                HLP.GeraXml.bel.CTe.Evento.TRetEvento retorno = SerializeClassToXml.DeserializeClasse <HLP.GeraXml.bel.CTe.Evento.TRetEvento>(sPath);
                return(retorno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public string CancelarCte(XmlDocument doc)
        {
            string sRetorno = "";

            try
            {


                //Homologação
                if (Acesso.TP_AMB == 2)
                {
                    HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.cteCabecMsg objCabecCancelamento = new HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.cteCabecMsg();
                    objCabecCancelamento.cUF = Acesso.cUF.ToString();
                    objCabecCancelamento.versaoDados = Acesso.versaoCTe;

                    HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.CteCancelamento objCancelamento = new HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.CteCancelamento();
                    objCancelamento.cteCabecMsgValue = objCabecCancelamento;
                    objCancelamento.ClientCertificates.Add(Acesso.cert_CTe);
                    sRetorno = objCancelamento.cteCancelamentoCT(doc).OuterXml;
                }
                //Produção
                else if (Acesso.TP_AMB == 1)
                {

                    HLP.GeraXml.WebService.CTe_Producao_evento.cteCabecMsg cabec = new WebService.CTe_Producao_evento.cteCabecMsg();
                    HLP.GeraXml.WebService.CTe_Producao_evento.CteRecepcaoEvento objCancelamento = new WebService.CTe_Producao_evento.CteRecepcaoEvento();
                    cabec.cUF = Acesso.cUF.ToString();
                    cabec.versaoDados = Acesso.versaoCTe;
                    objCancelamento.cteCabecMsgValue = cabec;
                    objCancelamento.ClientCertificates.Add(Acesso.cert_CTe);
                    sRetorno = objCancelamento.cteRecepcaoEvento(doc).OuterXml;
                }
                return sRetorno;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
        public HLP.GeraXml.bel.CTe.Evento.TRetEvento TransmiteLoteCCeCTe()
        {
            string sRetorno = "";

            XmlDocument _xmlxelem = new XmlDocument();
            _xmlxelem.PreserveWhitespace = true;
            _xmlxelem.LoadXml(this.sXMLfinal);

            XmlNode xNelem = null;
            xNelem = _xmlxelem.DocumentElement;
            try
            {
                //Homologação
                if (Acesso.TP_AMB == 2)
                {
                    HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.cteCabecMsg objCabecCancelamento = new HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.cteCabecMsg();
                    objCabecCancelamento.cUF = Acesso.cUF.ToString();
                    objCabecCancelamento.versaoDados = Acesso.versaoCTe;

                    HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.CteCancelamento objCancelamento = new HLP.GeraXml.WebService.CTe_Homologacao_cteCancelamento.CteCancelamento();
                    objCancelamento.cteCabecMsgValue = objCabecCancelamento;
                    objCancelamento.ClientCertificates.Add(Acesso.cert_CTe);
                    sRetorno = objCancelamento.cteCancelamentoCT(xNelem).OuterXml;
                }
                //Produção
                else if (Acesso.TP_AMB == 1)
                {
                    HLP.GeraXml.WebService.CTe_Producao_evento.cteCabecMsg cabec = new WebService.CTe_Producao_evento.cteCabecMsg();
                    HLP.GeraXml.WebService.CTe_Producao_evento.CteRecepcaoEvento objCancelamento = new WebService.CTe_Producao_evento.CteRecepcaoEvento();
                    cabec.cUF = Acesso.cUF.ToString();
                    cabec.versaoDados = Acesso.versaoCTe;
                    objCancelamento.cteCabecMsgValue = cabec;
                    objCancelamento.ClientCertificates.Add(Acesso.cert_CTe);
                    sRetorno = objCancelamento.cteRecepcaoEvento(xNelem).OuterXml;
                }

                XDocument xRet = XDocument.Parse(sRetorno);
                string sPath = Pastas.PROTOCOLOS + "\\" + this.objlItensPesquisa.FirstOrDefault().CHNFE + "_ret-cce.xml";
                xRet.Save(sPath);
                HLP.GeraXml.bel.CTe.Evento.TRetEvento retorno = SerializeClassToXml.DeserializeClasse<HLP.GeraXml.bel.CTe.Evento.TRetEvento>(sPath);
                return retorno;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }