Beispiel #1
0
        public static TRetDownloadNFe DownloadNFe(TDownloadNFe downloadNFe, TCodUfIBGE CodUF, X509Certificate2 cert)
        {
            XmlNode         xmlNodeRetorno     = null;
            TRetDownloadNFe retornoDownloadNFe = null;

            C_WebService.ListaUrl listaURL = WsUrls.BuscaURL(CodUF, downloadNFe.tpAmb);

            //CABEÇALHO
            DownloadNF.nfeCabecMsg cab = new DownloadNF.nfeCabecMsg();
            cab.cUF         = PegarCodigoUF(CodUF);                            //UF DO CABEÇALHO
            cab.versaoDados = Funcoes.ConvertEnumToString(downloadNFe.versao); //VERSÃO DO CABEÇALHO

            //CRIA UMA INSTANCIA DA CONEXÃO COM O WEBSERVICE
            DownloadNF.NfeDownloadNF wsMsg = new DownloadNF.NfeDownloadNF(listaURL.UrlNfeDownloadNF);
            wsMsg.nfeCabecMsgValue = cab;                   //ASSOCIA CABEÇALHO NFE
            wsMsg.Timeout          = 100000;                //DEFINE TEMPO MAXIMO DE ESPERA POR RETORNO
            wsMsg.ClientCertificates.Add(cert);             //ASSOCIA CERTIFICADO A CONEXAO WEBSERVICE
            wsMsg.SoapVersion = SoapProtocolVersion.Soap12; //DEFINE PROTOCOLO USADO NA CONEXÃO

            XmlDocument dados = new XmlDocument();

            dados.LoadXml(Funcoes.RemoveNameSpaceFromXml(downloadNFe.Serialize()));

            //ENVIA REQUISIÇÂO PARA SEFAZ E OBTEM RETORNO
            xmlNodeRetorno     = wsMsg.nfeDownloadNF(dados);
            retornoDownloadNFe = TRetDownloadNFe.Deserialize(xmlNodeRetorno.OuterXml);

            return(retornoDownloadNFe);
        }
Beispiel #2
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);
            }
        }
Beispiel #3
0
        public TRetConsStatServ ConsultaStatusWs(TConsStatServ consStatServ, X509Certificate2 cert)
        {
            XmlNode          strRetorno    = null;
            TRetConsStatServ retornoStatus = new TRetConsStatServ();

            C_WebService.ListaUrl listaURL = default(C_WebService.ListaUrl);
            listaURL = WsUrls.BuscaURL(consStatServ.cUF, consStatServ.tpAmb);

            try
            {
                StatusServico2.NfeStatusServico2 wsMsg = default(StatusServico2.NfeStatusServico2);
                StatusServico2.nfeCabecMsg       cab   = new StatusServico2.nfeCabecMsg();

                //UF E VERSÃO DO CABEÇALHO
                cab.cUF         = PegarCodigoUF(consStatServ.cUF);
                cab.versaoDados = consStatServ.versao;

                //CRIA UMA INSTANCIA DA CONEXÃO COM O WEBSERVICE
                wsMsg = new StatusServico2.NfeStatusServico2(listaURL.UrlNfeStatusServico);

                //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 retornoXML     = new XmlDocument();
                string      nomeArquivoEnv = _PastaLog + System.DateTime.Now.ToString("yyyyMMddTHHmmss") + " -ped-sta.xml";
                string      nomeArquivoRet = _PastaLog + System.DateTime.Now.ToString("yyyyMMddTHHmmss") + " -ret-sta.xml";

                XmlDocument dados = new XmlDocument();
                dados.LoadXml(Funcoes.RemoveNameSpaceFromXml(consStatServ.Serialize()));
                dados.Save(nomeArquivoEnv);

                //ENVIA CONSULTA PARA SEFAZ E OBTEM RETORNO EM FORMATO STRING
                strRetorno = wsMsg.nfeStatusServicoNF2(dados);
                retornoXML.LoadXml(strRetorno.OuterXml);
                retornoXML.Save(nomeArquivoRet);
                retornoStatus = TRetConsStatServ.LoadFromFile(nomeArquivoRet);

                return(retornoStatus);
            }
            catch (Exception ex)
            {
                throw new System.InvalidOperationException("Erro ao consultar status do serviço. Erro: " + ex.Message);
            }
        }
Beispiel #4
0
        public TRetInutNFe InutilizaNumeracao(TInutNFe InutNFe, X509Certificate2 pCertificado, TAmb ambiente)
        {
            C_WebService.ListaUrl listaURL = default(C_WebService.ListaUrl);
            string arqRetInut = _PastaLog + InutNFe.infInut.ano + InutNFe.infInut.CNPJ + InutNFe.infInut.mod + InutNFe.infInut.serie + InutNFe.infInut.nNFIni + InutNFe.infInut.nNFFin + "-inu.xml";
            string arqPedInut = _PastaLog + InutNFe.infInut.cUF + InutNFe.infInut.ano + InutNFe.infInut.CNPJ + InutNFe.infInut.mod + InutNFe.infInut.serie + InutNFe.infInut.nNFIni + InutNFe.infInut.nNFFin + "-ped-inu.xml";

            listaURL = WsUrls.BuscaURL(InutNFe.infInut.cUF, ambiente);

            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(Funcoes.RemoveNameSpaceFromXml(InutNFe.Serialize()));
            xmldoc = CertificadoDigital.Assinar(xmldoc, "infInut", pCertificado);
            xmldoc.Save(arqPedInut);

            try
            {
                Inutilizacao2.nfeCabecMsg      cab   = new Inutilizacao2.nfeCabecMsg();
                Inutilizacao2.NfeInutilizacao2 wsMsg = default(Inutilizacao2.NfeInutilizacao2);

                // UF E VERSÃO DO CABEÇALHO
                cab.cUF         = PegarCodigoUF(InutNFe.infInut.cUF);
                cab.versaoDados = InutNFe.versao;

                //CABEÇALHO USADA PARA ENVIO DE LOTE
                wsMsg = new Inutilizacao2.NfeInutilizacao2(listaURL.UrlNfeInutilizacao);
                wsMsg.nfeCabecMsgValue = cab;
                wsMsg.Timeout          = 100000;
                wsMsg.ClientCertificates.Add(pCertificado);
                wsMsg.SoapVersion = SoapProtocolVersion.Soap12;

                //RETORNO DA SEFAZ
                XmlNode     strRetorno = wsMsg.nfeInutilizacaoNF2(xmldoc);
                XmlDocument xmlRetorno = new XmlDocument();
                xmlRetorno.LoadXml(strRetorno.OuterXml);
                xmlRetorno.Save(arqRetInut);

                TRetInutNFe retInutNFe = new TRetInutNFe();
                retInutNFe = TRetInutNFe.LoadFromFile(arqRetInut);

                return(retInutNFe);
            }
            catch (Exception ex)
            {
                throw new System.InvalidOperationException("Erro ao inutilizar numeração. Erro: " + ex.Message);
            }
        }
Beispiel #5
0
        public CartaCorrecao.TRetEnvEvento CartaCorrecao(TNfeProc nota, string Correcao, X509Certificate2 pCertificado, int numLote, int nSequencia, TAmb ambiente, out ACBr.Net.NFe.CartaCorrecao.TProcEvento procEvento)
        {
            string arqPedCorecao  = _PastaLog + nota.NFe.infNFe.Id.Substring(3) + "-ped-evento.xml";//-ped-cce.xml ???
            string retPedCorrecao = _PastaLog + nota.NFe.infNFe.Id.Substring(3) + "-eve.xml";

            C_WebService.ListaUrl listaURL = default(C_WebService.ListaUrl);
            listaURL = WsUrls.BuscaURL(nota.NFe.infNFe.ide.cUF, ambiente);

            #region evento
            CartaCorrecao.TEvento evento = new CartaCorrecao.TEvento();
            evento.versao = "1.00";

            #region infEvento
            CartaCorrecao.TEventoInfEvento infEvento = new CartaCorrecao.TEventoInfEvento();
            infEvento.tpAmb           = ambiente;
            infEvento.chNFe           = nota.NFe.infNFe.Id.Substring(3);
            infEvento.cOrgao          = PegarCodigoOrgaoUF(nota.NFe.infNFe.ide.cUF);
            infEvento.dhEvento        = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzzz");
            infEvento.Id              = "ID" + "110110" + nota.NFe.infNFe.Id.Substring(3) + nSequencia.ToString("D2");
            infEvento.ItemElementName = ACBr.Net.NFe.CartaCorrecao.ItemChoiceTypeCC.CNPJ;
            infEvento.Item            = nota.NFe.infNFe.emit.Item;
            infEvento.nSeqEvento      = nSequencia.ToString();
            infEvento.verEvento       = ACBr.Net.NFe.CartaCorrecao.TEventoInfEventoVerEvento.Item100;
            infEvento.tpEvento        = ACBr.Net.NFe.CartaCorrecao.TEventoInfEventoTpEvento.Item110110;

            #region detEvento
            CartaCorrecao.TEventoInfEventoDetEvento detEvento = new CartaCorrecao.TEventoInfEventoDetEvento();
            detEvento.descEvento = ACBr.Net.NFe.CartaCorrecao.TEventoInfEventoDetEventoDescEvento.CartadeCorrecao;
            detEvento.versao     = ACBr.Net.NFe.CartaCorrecao.TEventoInfEventoDetEventoVersao.Item100;
            detEvento.xCondUso   = ACBr.Net.NFe.CartaCorrecao.TEventoInfEventoDetEventoXCondUso.ACartadeCorrecaoedisciplinadapeloparagrafo1oAdoart7odoConvenioSNde15dedezembrode1970epodeserutilizadapararegularizacaodeerroocorridonaemissaodedocumentofiscaldesdequeoerronaoestejarelacionadocomIasvariaveisquedeterminamovalordoimpostotaiscomobasedecalculoaliquotadiferencadeprecoquantidadevalordaoperacaooudaprestacaoIIacorrecaodedadoscadastraisqueimpliquemudancadoremetenteoudodestinatarioIIIadatadeemissaooudesaida;
            detEvento.xCorrecao  = Correcao;
            #endregion detEvento

            infEvento.detEvento = detEvento;
            #endregion infEvento

            evento.infEvento = infEvento;

            XmlDocument xmldoc = new XmlDocument();
            xmldoc.LoadXml(Funcoes.RemoveNameSpaceFromXml(evento.Serialize()));
            xmldoc = CertificadoDigital.Assinar(xmldoc, "infEvento", pCertificado);
            xmldoc.Save(arqPedCorecao);

            #endregion evento

            dynamic envEvento = GeraLoteEvento(arqPedCorecao, numLote);

            try
            {
                RecepcaoEvento.nfeCabecMsg    cab   = new RecepcaoEvento.nfeCabecMsg();
                RecepcaoEvento.RecepcaoEvento wsMsg = default(RecepcaoEvento.RecepcaoEvento);

                // UF E VERSÃO DO CABEÇALHO
                cab.cUF         = PegarCodigoUF(nota.NFe.infNFe.ide.cUF);
                cab.versaoDados = "1.00";

                //CABEÇALHO USADA PARA ENVIO DE LOTE
                wsMsg = new RecepcaoEvento.RecepcaoEvento(listaURL.UrlRecepcaoEvento);
                wsMsg.nfeCabecMsgValue = cab;
                wsMsg.Timeout          = 100000;
                wsMsg.ClientCertificates.Add(pCertificado);
                wsMsg.SoapVersion = SoapProtocolVersion.Soap12;

                //RETORNO DA SEFAZ
                XmlElement  strRetorno = wsMsg.nfeRecepcaoEvento(envEvento);
                XmlDocument xmlRetorno = new XmlDocument();
                xmlRetorno.LoadXml(strRetorno.OuterXml);
                xmlRetorno.Save(retPedCorrecao);

                ACBr.Net.NFe.CartaCorrecao.TRetEnvEvento retCorrecaoNFe = ACBr.Net.NFe.CartaCorrecao.TRetEnvEvento.LoadFromFile(retPedCorrecao);

                //saída
                procEvento           = new CartaCorrecao.TProcEvento();
                procEvento.evento    = ACBr.Net.NFe.CartaCorrecao.TEvento.Deserialize(xmldoc.OuterXml);
                procEvento.retEvento = retCorrecaoNFe.retEvento[0];
                procEvento.versao    = "1.00";

                return(retCorrecaoNFe);
            }
            catch (Exception ex)
            {
                throw new System.InvalidOperationException("Erro ao corrigir NFe. Erro: " + ex.Message);
            }
        }
Beispiel #6
0
        public Cancelamento.TRetEnvEvento CancelaNFe(TNfeProc nota, string Justificativa, X509Certificate2 pCertificado, int numLote, int nSequencia, TAmb ambiente, out ACBr.Net.NFe.Cancelamento.TProcEvento procEvento)
        {
            XmlElement strRetorno = null;

            string arqPedCanc = _PastaLog + nota.NFe.infNFe.Id.Substring(3) + "-ped-evento.xml";
            string retPedCanc = _PastaLog + nota.NFe.infNFe.Id.Substring(3) + "-eve.xml";

            C_WebService.ListaUrl listaURL = default(C_WebService.ListaUrl);
            listaURL = WsUrls.BuscaURL(nota.NFe.infNFe.ide.cUF, ambiente);

            #region evento
            Cancelamento.TEvento evento = new Cancelamento.TEvento();
            evento.versao = "1.00";

            #region infEvento
            Cancelamento.TEventoInfEvento infEvento = new Cancelamento.TEventoInfEvento();
            infEvento.tpAmb           = ambiente;
            infEvento.chNFe           = nota.NFe.infNFe.Id.Substring(3);
            infEvento.cOrgao          = nota.NFe.infNFe.ide.cUF;
            infEvento.dhEvento        = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzzz");// +"-00:00";
            infEvento.Id              = "ID" + "110111" + nota.NFe.infNFe.Id.Substring(3) + nSequencia.ToString("D2");
            infEvento.ItemElementName = Cancelamento.TipoDocumentoCanc.CNPJ;
            infEvento.Item            = nota.NFe.infNFe.emit.Item;
            infEvento.nSeqEvento      = nSequencia.ToString();
            infEvento.verEvento       = Cancelamento.TEventoInfEventoVerEvento.Item100;
            infEvento.tpEvento        = Cancelamento.TEventoInfEventoTpEvento.Cancelamento;

            #region detEvento
            Cancelamento.TEventoInfEventoDetEvento detEvento = new Cancelamento.TEventoInfEventoDetEvento();
            detEvento.descEvento = Cancelamento.TEventoInfEventoDetEventoDescEvento.Cancelamento;
            detEvento.nProt      = nota.protNFe.infProt.nProt;
            detEvento.versao     = Cancelamento.TEventoInfEventoDetEventoVersao.Item100;
            detEvento.xJust      = Justificativa;
            #endregion detEvento

            infEvento.detEvento = detEvento;
            #endregion infEvento

            evento.infEvento = infEvento;

            XmlDocument xmldoc = new XmlDocument();
            xmldoc.LoadXml(Funcoes.RemoveNameSpaceFromXml(evento.Serialize()));
            xmldoc = CertificadoDigital.Assinar(xmldoc, "infEvento", pCertificado);
            xmldoc.Save(arqPedCanc);

            #endregion evento

            dynamic envEvento = GeraLoteEvento(arqPedCanc, numLote);

            try
            {
                RecepcaoEvento.nfeCabecMsg    cab   = new RecepcaoEvento.nfeCabecMsg();
                RecepcaoEvento.RecepcaoEvento wsMsg = default(RecepcaoEvento.RecepcaoEvento);

                // UF E VERSÃO DO CABEÇALHO
                cab.cUF         = PegarCodigoUF(nota.NFe.infNFe.ide.cUF);
                cab.versaoDados = "1.00";

                //CABEÇALHO USADA PARA ENVIO DE LOTE
                wsMsg = new RecepcaoEvento.RecepcaoEvento(listaURL.UrlRecepcaoEvento);
                wsMsg.nfeCabecMsgValue = cab;
                wsMsg.Timeout          = 100000;
                wsMsg.ClientCertificates.Add(pCertificado);
                wsMsg.SoapVersion = SoapProtocolVersion.Soap12;

                //RETORNO DA SEFAZ
                strRetorno = wsMsg.nfeRecepcaoEvento(envEvento);

                XmlDocument xmlRetorno = new XmlDocument();
                xmlRetorno.LoadXml(strRetorno.OuterXml);
                xmlRetorno.Save(retPedCanc);

                ACBr.Net.NFe.Cancelamento.TRetEnvEvento retCancNFe = ACBr.Net.NFe.Cancelamento.TRetEnvEvento.LoadFromFile(retPedCanc);

                //saída
                procEvento           = new Cancelamento.TProcEvento();
                procEvento.evento    = ACBr.Net.NFe.Cancelamento.TEvento.Deserialize(xmldoc.OuterXml);
                procEvento.retEvento = retCancNFe.retEvento[0];
                procEvento.versao    = "1.00";

                return(retCancNFe);
            }
            catch (Exception ex)
            {
                throw new System.InvalidOperationException("Erro ao cancelar NFe. Erro: " + ex.Message);
            }
        }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
        public static C_WebService.ListaUrl BuscaURL(TCodUfIBGE Estado, TAmb AmbienteNFe)
        {
            C_WebService.ListaUrl UrlWs = default(C_WebService.ListaUrl);
            switch (Estado)
            {
            //ESTADOS QUE USAM A SEFAZ VIRTUAL DO RS PARA EMITIR NFE
            // ERROR: Case labels with binary operators are unsupported : Equality
            case TCodUfIBGE.Acre:
            case TCodUfIBGE.Alagoas:
            case TCodUfIBGE.Amapa:
            case TCodUfIBGE.DistritoFederal:
            case TCodUfIBGE.Paraiba:
            case TCodUfIBGE.RioDeJaneiro:
            case TCodUfIBGE.Rondonia:
            case TCodUfIBGE.Roraima:
            case TCodUfIBGE.SantaCatarina:
            case TCodUfIBGE.Sergipe:
            case TCodUfIBGE.Tocantis:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/nferecepcao/NfeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/nferetrecepcao/NfeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/nfecancelamento/NfeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/nfeinutilizacao/NfeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/nfeconsulta/NfeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/nfestatusservico/NfeStatusServico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "";
                    UrlWs.UrlRecepcaoEvento       = "https://homologacao.nfe.sefazvirtual.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.sefazvirtual.rs.gov.br/ws/nferecepcao/NfeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.sefazvirtual.rs.gov.br/ws/nferetrecepcao/NfeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.sefazvirtual.rs.gov.br/ws/nfecancelamento/NfeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.sefazvirtual.rs.gov.br/ws/nfeinutilizacao/NfeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.sefazvirtual.rs.gov.br/ws/nfeconsulta/NfeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.sefazvirtual.rs.gov.br/ws/nfestatusservico/NfeStatusServico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "";
                    UrlWs.UrlRecepcaoEvento       = "https://nfe.sefazvirtual.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx";
                }
                break;

            //ESTADOS QUE USA O SEFAZ NACIONAL PARA EMITIR NFE
            // ERROR: Case labels with binary operators are unsupported : Equality
            case TCodUfIBGE.EspiritoSanto:
            case TCodUfIBGE.Maranhao:
            case TCodUfIBGE.Para:
            case TCodUfIBGE.Piaui:
            case TCodUfIBGE.RioGrandeDoNorte:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://hom.sefazvirtual.fazenda.gov.br/NfeRecepcao2/NfeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://hom.sefazvirtual.fazenda.gov.br/NFeRetRecepcao2/NFeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://hom.sefazvirtual.fazenda.gov.br/NFeCancelamento2/NFeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://hom.sefazvirtual.fazenda.gov.br/NFeInutilizacao2/NFeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://hom.sefazvirtual.fazenda.gov.br/nfeconsulta2/nfeconsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://hom.sefazvirtual.fazenda.gov.br/NFeStatusServico2/NFeStatusServico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "";
                    UrlWs.UrlRecepcaoEvento       = "";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://www.sefazvirtual.fazenda.gov.br/NfeRecepcao2/NfeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://www.sefazvirtual.fazenda.gov.br/NFeRetRecepcao2/NFeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://www.sefazvirtual.fazenda.gov.br/NFeCancelamento2/NFeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://www.sefazvirtual.fazenda.gov.br/NFeInutilizacao2/NFeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://www.sefazvirtual.fazenda.gov.br/nfeconsulta2/nfeconsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://www.sefazvirtual.fazenda.gov.br/NFeStatusServico2/NFeStatusServico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "";
                    UrlWs.UrlRecepcaoEvento       = "";
                }
                break;

            // ERROR: Case labels with binary operators are unsupported : Equality
            //AM USA SEFAZ PROPRIA
            case TCodUfIBGE.Amazonas:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://homnfe.sefaz.am.gov.br/services2/services/NfeRecepcao2";
                    UrlWs.UrlNfeRetRecepcao       = "https://homnfe.sefaz.am.gov.br/services2/services/NfeRetRecepcao2";
                    UrlWs.UrlNfeCancelamento      = "https://homnfe.sefaz.am.gov.br/services2/services/NfeCancelamento2";
                    UrlWs.UrlNfeInutilizacao      = "https://homnfe.sefaz.am.gov.br/services2/services/NfeInutilizacao2";
                    UrlWs.UrlNfeConsultaProtocolo = "https://homnfe.sefaz.am.gov.br/services2/services/NfeConsulta2";
                    UrlWs.UrlNfeStatusServico     = "https://homnfe.sefaz.am.gov.br/services2/services/NfeStatusServico2";
                    UrlWs.UrlNfeConsultaCadastro  = "https://homnfe.sefaz.am.gov.br/services2/services/cadconsultacadastro2";
                    UrlWs.UrlRecepcaoEvento       = "https://homnfe.sefaz.am.gov.br/services2/services/RecepcaoEvento";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.sefaz.am.gov.br/services2/services/NfeRecepcao2";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.sefaz.am.gov.br/services2/services/NfeRetRecepcao2";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.sefaz.am.gov.br/services2/services/NfeCancelamento2";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.sefaz.am.gov.br/services2/services/NfeInutilizacao2";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.sefaz.am.gov.br/services2/services/NfeConsulta2";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.sefaz.am.gov.br/services2/services/NfeStatusServico2";
                    UrlWs.UrlNfeConsultaCadastro  = "https://nfe.sefaz.am.gov.br/services2/services/cadconsultacadastro2";
                    UrlWs.UrlRecepcaoEvento       = "https://nfe.sefaz.am.gov.br/services2/services/RecepcaoEvento";
                }
                break;

            //BA USA SEFAZ PROPRIA
            // ERROR: Case labels with binary operators are unsupported : Equality
            case  TCodUfIBGE.Bahia:

                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://hnfe.sefaz.ba.gov.br/webservices/nfenw/NfeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://hnfe.sefaz.ba.gov.br/webservices/nfenw/NfeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://hnfe.sefaz.ba.gov.br/webservices/nfenw/NfeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://hnfe.sefaz.ba.gov.br/webservices/nfenw/NfeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://hnfe.sefaz.ba.gov.br/webservices/nfenw/NfeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://hnfe.sefaz.ba.gov.br/webservices/nfenw/NfeStatusServico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "https://hnfe.sefaz.ba.gov.br/webservices/nfenw/CadConsultaCadastro2.asmx";
                    UrlWs.UrlRecepcaoEvento       = "https://hnfe.sefaz.ba.gov.br/webservices/sre/nferecepcaoevento.asmx";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.sefaz.ba.gov.br/webservices/nfenw/NfeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.sefaz.ba.gov.br/webservices/nfenw/NfeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.sefaz.ba.gov.br/webservices/nfenw/NfeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.sefaz.ba.gov.br/webservices/nfenw/NfeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.sefaz.ba.gov.br/webservices/nfenw/NfeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.sefaz.ba.gov.br/webservices/nfenw/NfeStatusServico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "https://nfe.sefaz.ba.gov.br/webservices/nfenw/CadConsultaCadastro2.asmx";
                    UrlWs.UrlRecepcaoEvento       = "https://nfe.sefaz.ba.gov.br/webservices/sre/nferecepcaoevento.asmx";
                }
                break;

            // ERROR: Case labels with binary operators are unsupported : Equality
            //CE USA SEFAZ PROPRIA
            case TCodUfIBGE.Ceara:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfeh.sefaz.ce.gov.br/nfe2/services/NfeRecepcao2";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfeh.sefaz.ce.gov.br/nfe2/services/NfeRetRecepcao2";
                    UrlWs.UrlNfeCancelamento      = "https://nfeh.sefaz.ce.gov.br/nfe2/services/NfeCancelamento2";
                    UrlWs.UrlNfeInutilizacao      = "https://nfeh.sefaz.ce.gov.br/nfe2/services/NfeInutilizacao2";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfeh.sefaz.ce.gov.br/nfe2/services/NfeConsulta2";
                    UrlWs.UrlNfeStatusServico     = "https://nfeh.sefaz.ce.gov.br/nfe2/services/NfeStatusServico2";
                    UrlWs.UrlNfeConsultaCadastro  = "https://nfeh.sefaz.ce.gov.br/nfe2/services/CadConsultaCadastro2";
                    UrlWs.UrlRecepcaoEvento       = "";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.sefaz.ce.gov.br/nfe2/services/NfeRecepcao2";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.sefaz.ce.gov.br/nfe2/services/NfeRetRecepcao2";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.sefaz.ce.gov.br/nfe2/services/NfeCancelamento2";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.sefaz.ce.gov.br/nfe2/services/NfeInutilizacao2";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.sefaz.ce.gov.br/nfe2/services/NfeConsulta2";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.sefaz.ce.gov.br/nfe2/services/NfeStatusServico2";
                    UrlWs.UrlNfeConsultaCadastro  = "https://nfe.sefaz.ce.gov.br/nfe2/services/CadConsultaCadastro2";
                    UrlWs.UrlRecepcaoEvento       = "";
                }

                break;

            // ERROR: Case labels with binary operators are unsupported : Equality
            //GO USA SEFAZ PROPRIA
            case TCodUfIBGE.Goias:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeRecepcao2?wsdl ";
                    UrlWs.UrlNfeRetRecepcao       = "https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeRetRecepcao2?wsdl ";
                    UrlWs.UrlNfeCancelamento      = "https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeCancelamento2?wsdl ";
                    UrlWs.UrlNfeInutilizacao      = "https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeInutilizacao2?wsdl ";
                    UrlWs.UrlNfeConsultaProtocolo = "https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeConsulta2?wsdl ";
                    UrlWs.UrlNfeStatusServico     = "https://homolog.sefaz.go.gov.br/nfe/services/v2/NfeStatusServico2?wsdl ";
                    UrlWs.UrlNfeConsultaCadastro  = "https://homolog.sefaz.go.gov.br/nfe/services/v2/CadConsultaCadastro2?wsdl ";
                    UrlWs.UrlRecepcaoEvento       = "";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.sefaz.go.gov.br/nfe/services/v2/NfeRecepcao2?wsdl ";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.sefaz.go.gov.br/nfe/services/v2/NfeRetRecepcao2?wsdl ";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.sefaz.go.gov.br/nfe/services/v2/NfeCancelamento2?wsdl ";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.sefaz.go.gov.br/nfe/services/v2/NfeInutilizacao2?wsdl ";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.sefaz.go.gov.br/nfe/services/v2/NfeConsulta2?wsdl ";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.sefaz.go.gov.br/nfe/services/v2/NfeStatusServico2?wsdl ";
                    UrlWs.UrlNfeConsultaCadastro  = "https://nfe.sefaz.go.gov.br/nfe/services/v2/CadConsultaCadastro2?wsdl ";
                    UrlWs.UrlRecepcaoEvento       = "";
                }
                break;

            // ERROR: Case labels with binary operators are unsupported : Equality
            //MG USA SEFAZ PROPRIA
            case TCodUfIBGE.MinasGerais:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://hnfe.fazenda.mg.gov.br/nfe2/services/NfeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://hnfe.fazenda.mg.gov.br/nfe2/services/NfeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://hnfe.fazenda.mg.gov.br/nfe2/services/NfeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://hnfe.fazenda.mg.gov.br/nfe2/services/NfeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://hnfe.fazenda.mg.gov.br/nfe2/services/NfeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://hnfe.fazenda.mg.gov.br/nfe2/services/NfeStatus2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "https://hnfe.fazenda.mg.gov.br/nfe2/services/cadconsultacadastro2.asmx";
                    UrlWs.UrlRecepcaoEvento       = "";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.fazenda.mg.gov.br/nfe2/services/NfeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.fazenda.mg.gov.br/nfe2/services/NfeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.fazenda.mg.gov.br/nfe2/services/NfeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.fazenda.mg.gov.br/nfe2/services/NfeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.fazenda.mg.gov.br/nfe2/services/NfeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.fazenda.mg.gov.br/nfe2/services/NfeStatus2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "https://nfe.fazenda.mg.gov.br/nfe2/services/cadconsultacadastro2.asmx";
                    UrlWs.UrlRecepcaoEvento       = "";
                }
                break;

            // ERROR: Case labels with binary operators are unsupported : Equality
            //MS USA SEFAZ PROPRIA
            case TCodUfIBGE.MatoGrossoDoSul:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://homologacao.nfe.ms.gov.br/homologacao/services2/NfeRecepcao2";
                    UrlWs.UrlNfeRetRecepcao       = "https://homologacao.nfe.ms.gov.br/homologacao/services2/NfeRetRecepcao2";
                    UrlWs.UrlNfeCancelamento      = "https://homologacao.nfe.ms.gov.br/homologacao/services2/NfeCancelamento2";
                    UrlWs.UrlNfeInutilizacao      = "https://homologacao.nfe.ms.gov.br/homologacao/services2/NfeInutilizacao2";
                    UrlWs.UrlNfeConsultaProtocolo = "https://homologacao.nfe.ms.gov.br/homologacao/services2/NfeConsulta2";
                    UrlWs.UrlNfeStatusServico     = "https://homologacao.nfe.ms.gov.br/homologacao/services2/NfeStatusServico2";
                    UrlWs.UrlNfeConsultaCadastro  = "https://homologacao.nfe.ms.gov.br/homologacao/services2/CadConsultaCadastro2";
                    UrlWs.UrlRecepcaoEvento       = "https://homologacao.nfe.fazenda.ms.gov.br/homologacao/services2/NfeRecepcaoEvento";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.fazenda.ms.gov.br/producao/services2/NfeRecepcao2";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.fazenda.ms.gov.br/producao/services2/NfeRetRecepcao2";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.fazenda.ms.gov.br/producao/services2/NfeCancelamento2";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.fazenda.ms.gov.br/producao/services2/NfeInutilizacao2";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.fazenda.ms.gov.br/producao/services2/NfeConsulta2";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.fazenda.ms.gov.br/producao/services2/NfeStatusServico2";
                    UrlWs.UrlNfeConsultaCadastro  = "https://nfe.fazenda.ms.gov.br/producao/services2/CadConsultaCadastro2";
                    UrlWs.UrlRecepcaoEvento       = "https://nfe.fazenda.ms.gov.br/producao/services2/NfeRecepcaoEvento";
                }
                break;

            // ERROR: Case labels with binary operators are unsupported : Equality
            //MT USA SEFAZ PROPRIA
            case TCodUfIBGE.MatoGrosso:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://homologacao.sefaz.mt.gov.br/nfews/NfeRecepcao2?wsdl ";
                    UrlWs.UrlNfeRetRecepcao       = "https://homologacao.sefaz.mt.gov.br/nfews/NfeRetRecepcao2?wsdl ";
                    UrlWs.UrlNfeCancelamento      = "https://homologacao.sefaz.mt.gov.br/nfews/NfeCancelamento2?wsdl ";
                    UrlWs.UrlNfeInutilizacao      = "https://homologacao.sefaz.mt.gov.br/nfews/NfeInutilizacao2?wsdl ";
                    UrlWs.UrlNfeConsultaProtocolo = "https://homologacao.sefaz.mt.gov.br/nfews/NfeConsulta2?wsdl ";
                    UrlWs.UrlNfeStatusServico     = "https://homologacao.sefaz.mt.gov.br/nfews/NfeStatusServico2?wsdl ";
                    UrlWs.UrlNfeConsultaCadastro  = "";
                    UrlWs.UrlRecepcaoEvento       = "https://homologacao.sefaz.mt.gov.br/nfews/v2/services/RecepcaoEvento?wsdl ";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.sefaz.mt.gov.br/nfews/v2/services/NfeRecepcao2?wsdl ";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.sefaz.mt.gov.br/nfews/v2/services/NfeRetRecepcao2?wsdl ";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.sefaz.mt.gov.br/nfews/v2/services/NfeCancelamento2?wsdl ";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.sefaz.mt.gov.br/nfews/v2/services/NfeInutilizacao2?wsdl ";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.sefaz.mt.gov.br/nfews/v2/services/NfeConsulta2?wsdl ";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.sefaz.mt.gov.br/nfews/v2/services/NfeStatusServico2?wsdl ";
                    UrlWs.UrlNfeConsultaCadastro  = "https://nfe.sefaz.mt.gov.br/nfews/CadConsultaCadastro?wsdl ";
                    UrlWs.UrlRecepcaoEvento       = "https://nfe.sefaz.mt.gov.br/nfews/v2/services/RecepcaoEvento?wsdl ";
                }
                break;

            // ERROR: Case labels with binary operators are unsupported : Equality
            //PB USA SEFAZ VIRTUAL DO RIO GRANDE DO SUL
            case TCodUfIBGE.Pernambuco:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfehomolog.sefaz.pe.gov.br/nfe-service/services/NfeRecepcao2";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfehomolog.sefaz.pe.gov.br/nfe-service/services/NfeRetRecepcao2";
                    UrlWs.UrlNfeCancelamento      = "https://nfehomolog.sefaz.pe.gov.br/nfe-service/services/NfeCancelamento2";
                    UrlWs.UrlNfeInutilizacao      = "https://nfehomolog.sefaz.pe.gov.br/nfe-service/services/NfeInutilizacao2";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfehomolog.sefaz.pe.gov.br/nfe-service/services/NfeConsulta2";
                    UrlWs.UrlNfeStatusServico     = "https://nfehomolog.sefaz.pe.gov.br/nfe-service/services/NfeStatusServico2";
                    UrlWs.UrlNfeConsultaCadastro  = "";
                    UrlWs.UrlRecepcaoEvento       = "https://nfehomolog.sefaz.pe.gov.br/nfe-service/services/RecepcaoEvento";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.sefaz.pe.gov.br/nfe-service/services/NfeRecepcao2";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.sefaz.pe.gov.br/nfe-service/services/NfeRetRecepcao2";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.sefaz.pe.gov.br/nfe-service/services/NfeCancelamento2";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.sefaz.pe.gov.br/nfe-service/services/NfeInutilizacao2";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.sefaz.pe.gov.br/nfe-service/services/NfeInutilizacao2";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.sefaz.pe.gov.br/nfe-service/services/NfeStatusServico2";
                    UrlWs.UrlNfeConsultaCadastro  = "https://nfe.sefaz.pe.gov.br/nfe-service/services/CadConsultaCadastro2";
                    UrlWs.UrlRecepcaoEvento       = "https://nfe.sefaz.pe.gov.br/nfe-service/services/RecepcaoEvento";
                }
                break;

            // ERROR: Case labels with binary operators are unsupported : Equality
            //PB USA SEFAZ VIRTUAL DO RIO GRANDE DO SUL
            case TCodUfIBGE.Parana:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://homologacao.nfe2.fazenda.pr.gov.br/nfe/NFeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://homologacao.nfe2.fazenda.pr.gov.br/nfe/NFeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://homologacao.nfe2.fazenda.pr.gov.br/nfe/NFeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://homologacao.nfe2.fazenda.pr.gov.br/nfe/NFeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://homologacao.nfe2.fazenda.pr.gov.br/nfe/NFeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://homologacao.nfe2.fazenda.pr.gov.br/nfe/NFeStatusServico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "";
                    UrlWs.UrlRecepcaoEvento       = "";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe2.fazenda.pr.gov.br/nfe/NFeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe2.fazenda.pr.gov.br/nfe/NFeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://nfe2.fazenda.pr.gov.br/nfe/NFeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe2.fazenda.pr.gov.br/nfe/NFeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe2.fazenda.pr.gov.br/nfe/NFeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://nfe2.fazenda.pr.gov.br/nfe/NFeConsulta2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "";
                    UrlWs.UrlRecepcaoEvento       = "";
                }

                break;

            case TCodUfIBGE.RioGrandeDoSul:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://homologacao.nfe.sefaz.rs.gov.br/ws/Nferecepcao/NFeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://homologacao.nfe.sefaz.rs.gov.br/ws/nferetrecepcao/NfeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://homologacao.nfe.sefaz.rs.gov.br/ws/nfecancelamento/NfeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://homologacao.nfe.sefaz.rs.gov.br/ws/nfeinutilizacao/NfeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://homologacao.nfe.sefaz.rs.gov.br/ws/nfeconsulta/NfeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://homologacao.nfe.sefaz.rs.gov.br/ws/nfestatusservico/NfeStatusServico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "";
                    UrlWs.UrlRecepcaoEvento       = "https://homologacao.nfe.sefaz.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.sefaz.rs.gov.br/ws/Nferecepcao/NFeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.sefaz.rs.gov.br/ws/NfeRetRecepcao/NfeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.sefaz.rs.gov.br/ws/NfeCancelamento/NfeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.sefaz.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.sefaz.rs.gov.br/ws/NfeConsulta/NfeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.sefaz.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "https://sef.sefaz.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro2.asmx";
                    UrlWs.UrlRecepcaoEvento       = "https://nfe.sefaz.rs.gov.br/ws/recepcaoevento/recepcaoevento.asmx";
                }
                break;

            //SP USA SEFAZ PROPRIO
            case TCodUfIBGE.SaoPaulo:
                if (AmbienteNFe != TAmb.Producao)
                {
                    UrlWs.UrlNfeRecepcao          = "https://homologacao.nfe.fazenda.sp.gov.br/nfeweb/services/NfeRecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://homologacao.nfe.fazenda.sp.gov.br/nfeweb/services/NfeRetRecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://homologacao.nfe.fazenda.sp.gov.br/nfeweb/services/NfeCancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://homologacao.nfe.fazenda.sp.gov.br/nfeweb/services/NfeInutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://homologacao.nfe.fazenda.sp.gov.br/nfeweb/services/NfeConsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://homologacao.nfe.fazenda.sp.gov.br/nfeweb/services/NfeStatusServico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "https://homologacao.nfe.fazenda.sp.gov.br/nfeweb/services/CadConsultaCadastro2.asmx";
                    UrlWs.UrlRecepcaoEvento       = "https://homologacao.nfe.fazenda.sp.gov.br/eventosWEB/services/RecepcaoEvento.asmx";
                }
                else
                {
                    UrlWs.UrlNfeRecepcao          = "https://nfe.fazenda.sp.gov.br/nfeweb/services/nferecepcao2.asmx";
                    UrlWs.UrlNfeRetRecepcao       = "https://nfe.fazenda.sp.gov.br/nfeweb/services/nferetrecepcao2.asmx";
                    UrlWs.UrlNfeCancelamento      = "https://nfe.fazenda.sp.gov.br/nfeweb/services/nfecancelamento2.asmx";
                    UrlWs.UrlNfeInutilizacao      = "https://nfe.fazenda.sp.gov.br/nfeweb/services/nfeinutilizacao2.asmx";
                    UrlWs.UrlNfeConsultaProtocolo = "https://nfe.fazenda.sp.gov.br/nfeweb/services/nfeconsulta2.asmx";
                    UrlWs.UrlNfeStatusServico     = "https://nfe.fazenda.sp.gov.br/nfeweb/services/nfestatusservico2.asmx";
                    UrlWs.UrlNfeConsultaCadastro  = "https://nfe.fazenda.sp.gov.br/nfeweb/services/cadconsultacadastro2.asmx";
                    UrlWs.UrlRecepcaoEvento       = "https://nfe.fazenda.sp.gov.br/eventosWEB/services/RecepcaoEvento.asmx";
                }
                break;
            }
            if (AmbienteNFe != TAmb.Producao)
            {
                UrlWs.UrlNfeDownloadNF = "https://hom.nfe.fazenda.gov.br/NfeDownloadNF/NfeDownloadNF.asmx";
            }
            else
            {
                UrlWs.UrlNfeDownloadNF = "https://www.nfe.fazenda.gov.br/NfeDownloadNF/NfeDownloadNF.asmx";
            }
            return(UrlWs);
        }