private RetornoSimples EnviarEvento(StringBuilder eventoXml, String id, String arquivoEvento, String schema) { var documentXml = Assinar(eventoXml, id, schema); var xmlDoc = new XmlDocument(); xmlDoc.Load(arquivoEvento); var conteudoXml = xmlDoc.OuterXml; var nota = new Nota(NFeContexto) { CaminhoFisico = arquivoEvento }; var bllXml = new Xml(); var xmlString = new StringBuilder(); xmlString.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); xmlString.Append("<envEvento versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\">"); xmlString.Append(" <idLote>0131318</idLote>"); xmlString.Append(conteudoXml); xmlString.Append("</envEvento>"); var SW_2 = File.CreateText(arquivoEvento); SW_2.Write(xmlString.ToString()); SW_2.Close(); //Verifica se a nota está de acordo com o schema, se não estiver vai disparar um erro try { bllXml.ValidaSchema(arquivoEvento, Util.ContentFolderSchemaValidacao + "\\" + NFeContexto.Versao.PastaXml + "\\" + schema); } catch (Exception e) { throw new Exception("Erro ao validar Nota: " + e.Message); } var recepcao = new RecepcaoEvento2.RecepcaoEvento(); var cabecalho = new nfeCabecMsg(); cabecalho.cUF = "35"; cabecalho.versaoDados = "1.00"; recepcao.nfeCabecMsgValue = cabecalho; recepcao.ClientCertificates.Add(NFeContexto.Certificado); var resposta = recepcao.nfeRecepcaoEvento(Xml.StringToXml(xmlString.ToString())); var status = resposta["retEvento"]["infEvento"]["xMotivo"].InnerText; var motivo = resposta["retEvento"]["infEvento"]["cStat"].InnerText; return(new RetornoSimples(status, motivo)); }
private RetornoSimples EnviarEvento(StringBuilder eventoXml, String id, String arquivoEvento, String schema) { var documentXml = Assinar(eventoXml, id, schema); var xmlDoc = new XmlDocument(); xmlDoc.Load(arquivoEvento); var conteudoXml = xmlDoc.OuterXml; var nota = new Nota(NFeContexto) {CaminhoFisico = arquivoEvento}; var bllXml = new Xml(); var xmlString = new StringBuilder(); xmlString.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); xmlString.Append("<envEvento versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\">"); xmlString.Append(" <idLote>0131318</idLote>"); xmlString.Append(conteudoXml); xmlString.Append("</envEvento>"); var SW_2 = File.CreateText(arquivoEvento); SW_2.Write(xmlString.ToString()); SW_2.Close(); //Verifica se a nota está de acordo com o schema, se não estiver vai disparar um erro try { bllXml.ValidaSchema(arquivoEvento, Util.ContentFolderSchemaValidacao + "\\" + NFeContexto.Versao.PastaXml + "\\" + schema); } catch (Exception e) { throw new Exception("Erro ao validar Nota: " + e.Message); } var recepcao = new RecepcaoEvento2.RecepcaoEvento(); var cabecalho = new nfeCabecMsg(); cabecalho.cUF = "35"; cabecalho.versaoDados = "1.00"; recepcao.nfeCabecMsgValue = cabecalho; recepcao.ClientCertificates.Add(NFeContexto.Certificado); var resposta = recepcao.nfeRecepcaoEvento(Xml.StringToXml(xmlString.ToString())); var status = resposta["retEvento"]["infEvento"]["xMotivo"].InnerText; var motivo = resposta["retEvento"]["infEvento"]["cStat"].InnerText; return new RetornoSimples(status, motivo); }