public int NFeRetAutorizacao(string nRecibo, string cnpj, int cUF, int ambiente) { #region "Seleção de Certificado Digital" if (xCert == null) { xCert = selectCert(cnpj); } if (xCert == null) { errorBroken = "Nenhum Certificado Digital selecionado"; return(999); } #endregion urlNF = new UrlNF(cUF, ambiente); string urlService = "http://www.portalfiscal.inf.br/nfe/wsdl/NFeRetAutorizacao4"; string xmlDoc = createXML_RetAutorizacao(nRecibo, Convert.ToString(ambiente)); string xmlSoap = getSoapXml(xmlDoc.ToString(), urlService, Convert.ToString(cUF), urlNF.ver_RetAutorizacao); retXML = String.Empty; if (xmlSoap != String.Empty) { string action = "http://www.portalfiscal.inf.br/nfe/wsdl/NfeRetAutorizacao/nfeRetAutorizacaoLote"; Thread.Sleep(10000); retXML = RequestWebService(urlNF._RetAutorizacao, xmlSoap, action, ambiente); if (retXML != String.Empty) { if (getRetStat() == "104") { int indexIni = retXML.IndexOf("<protNFe"); int comp = retXML.IndexOf("</protNFe>") + 10 - indexIni; protNFe = retXML.Substring(indexIni, comp); } return(0); } else { return(999); } } else { return(999); } }
public int NFAutorizacaoLote(string xmlDoc, string cnpj, int cUF, int ambiente) { #region "Seleção de Certificado Digital" if (xCert == null) { xCert = selectCert(cnpj); } if (xCert == null) { errorBroken = "Nenhum Certificado Digital selecionado."; return(999); } #endregion urlNF = new UrlNF(cUF, ambiente); string urlService = "http://www.portalfiscal.inf.br/nfe/wsdl/NFeAutorizacao4"; xmlDoc = createXML_LoteNFe(xmlDoc, cnpj, cUF); string xmlSoap = getSoapXml(xmlDoc.ToString(), urlService, Convert.ToString(cUF), urlNF.ver_Autorizacaos); #region "Gera o arquivo XML para ver os dados" string path = pathApp + "\\EnvioNFe-autorizacao.xml"; TextWriter tw = new StreamWriter(path); tw.WriteLine(xmlSoap.ToString()); tw.Close(); #endregion retXML = String.Empty; if (xmlSoap != String.Empty) { string action = "http://www.portalfiscal.inf.br/nfe/wsdl/NfeAutorizacao/nfeAutorizacaoLote"; retXML = RequestWebService(urlNF._Autorizacaos, xmlSoap, action, ambiente); if (retXML != String.Empty) { return(0); } else { return(999); } } else { return(999); } }
public int NFeConsultarProtocolo(string chaveNF, string cnpj, int cUF, int ambiente) { #region "Seleção de Certificado Digital" if (xCert == null) { xCert = selectCert(cnpj); } if (xCert == null) { errorBroken = "Nenhum Certificado Digital selecionado"; return(999); } #endregion urlNF = new UrlNF(cUF, ambiente); string urlService = "http://www.portalfiscal.inf.br/nfe/wsdl/NFeConsultaProtocolo4"; string xmlDoc = createXML_ConsultaProtocolo(chaveNF, Convert.ToString(ambiente)); string xmlSoap = getSoapXml(xmlDoc.ToString(), urlService, Convert.ToString(cUF), urlNF.ver_ConsultaNFe); retXML = String.Empty; if (xmlSoap != String.Empty) { string action = "http://www.portalfiscal.inf.br/nfe/wsdl/NfeConsulta2/nfeConsultaNF2"; retXML = RequestWebService(urlNF._ConsultaNFe, xmlSoap, action, ambiente); if (retXML != String.Empty) { if (getRetStat() == "100" || getRetStat() == "101") { int indexIni = retXML.IndexOf("<protNFe"); int comp = retXML.IndexOf("</protNFe>") + 10 - indexIni; protNFe = retXML.Substring(indexIni, comp); } return(0); } else { return(999); } } else { return(999); } }
public int NFeCartaCorrecao(string correcao, string cnpj, string chave, string nSeq, string idLote, string date, int cUF, int ambiente) { correcao = alteraCaracter(correcao); urlNF = new UrlNF(cUF, ambiente); string urlService = "http://www.portalfiscal.inf.br/nfe/wsdl/NFeRecepcaoEvento4"; string xmlDoc = createXML_CartaDeCorrecao(correcao, cnpj, chave, nSeq, idLote, date, ambiente); if (AssinarNFE(xmlDoc.ToString(), cnpj, "evento") == 0) { xmlDoc = getXmlAssinado(); } else { return(999); } string xmlSoap = getSoapXml(xmlDoc.ToString(), urlService, Convert.ToString(cUF), urlNF.ver_RecepcaoEvento); retXML = String.Empty; procEvento = String.Empty; if (xmlSoap != String.Empty) { string action = "http://www.portalfiscal.inf.br/nfe/wsdl/RecepcaoEvento/nfeRecepcaoEvento"; retXML = RequestWebService(urlNF._RecepcaoEvento, xmlSoap, action, ambiente); if (retXML != String.Empty) { createProcEvento(xmlDoc, retXML, urlNF.ver_RecepcaoEvento); return(0); } else { return(999); } } else { return(999); } }
public int NFeStatusServico(String cnpj, int cUF, int ambiente) { #region "Seleção de Certificado Digital" if (xCert == null) { xCert = selectCert(cnpj); } if (xCert == null) { errorBroken = "Nenhum Certificado Digital selecionado"; return(999); } #endregion urlNF = new UrlNF(cUF, ambiente); string urlService = "http://www.portalfiscal.inf.br/nfe/wsdl/NFeStatusServico4"; string xmlDoc = createXML_StatusServicos(cUF, ambiente); string xmlSoap = getSoapXml(xmlDoc, urlService, Convert.ToString(cUF), urlNF.ver_StatusServicos); retXML = String.Empty; if (xmlSoap != String.Empty) { string action = "http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2/nfeStatusServicoNF2"; retXML = RequestWebService(urlNF._StatusServicos, xmlSoap, action, ambiente); if (retXML != String.Empty) { return(0); } else { return(999); } } else { return(999); } }
public int NFeInutilizar(string just, int nInicial, int nFinal, string cnpj, int cUF, int ambiente) { just = alteraCaracter(just); urlNF = new UrlNF(cUF, ambiente); string urlService = "http://www.portalfiscal.inf.br/nfe/wsdl/NFeInutilizacao4"; string xmlDoc = createXML_Inutilizacao(just, Convert.ToString(nInicial), Convert.ToString(nFinal), cnpj, Convert.ToString(cUF), Convert.ToString(ambiente)); if (AssinarNFE(xmlDoc.ToString(), cnpj, "inutNFe") == 0) { xmlDoc = getXmlAssinado(); } else { return(999); } string xmlSoap = getSoapXml(xmlDoc.ToString(), urlService, Convert.ToString(cUF), urlNF.ver_Inutilizacao); retXML = String.Empty; if (xmlSoap != String.Empty) { string action = "http://www.portalfiscal.inf.br/nfe/wsdl/NfeInutilizacao2/nfeInutilizacaoNF2"; retXML = RequestWebService(urlNF._Inutilizacao, xmlSoap, action, ambiente); if (retXML != String.Empty) { return(0); } else { return(999); } } else { return(999); } }