protected override void PrepararEnviar(RetornoEnviar retornoWebservice, NotaServicoCollection notas)
        {
            if (retornoWebservice.Lote == 0)
            {
                retornoWebservice.Erros.Add(new Evento {
                    Codigo = "0", Descricao = "Lote não informado."
                });
            }
            if (notas.Count == 0)
            {
                retornoWebservice.Erros.Add(new Evento {
                    Codigo = "0", Descricao = "RPS não informado."
                });
            }
            if (retornoWebservice.Erros.Count > 0)
            {
                return;
            }

            var xmlLoteRps = new StringBuilder();

            foreach (var nota in notas)
            {
                var xmlRps = WriteXmlRps(nota, false, false);
                xmlLoteRps.Append(xmlRps);
                GravarRpsEmDisco(xmlRps, $"Rps-{nota.IdentificacaoRps.DataEmissao:yyyyMMdd}-{nota.IdentificacaoRps.Numero}.xml", nota.IdentificacaoRps.DataEmissao);
            }

            var xmlLote = new StringBuilder();

            xmlLote.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            xmlLote.Append("<p:EnviarLoteRpsEnvio xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:p=\"http://ws.speedgov.com.br/enviar_lote_rps_envio_v1.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://ws.speedgov.com.br/enviar_lote_rps_envio_v1.xsd enviar_lote_rps_envio_v1.xsd\">");
            xmlLote.Append("<p:LoteRps Id=\"\">");
            xmlLote.Append($"<NumeroLote>{retornoWebservice.Lote}</NumeroLote>");
            xmlLote.Append($"<Cnpj>{Configuracoes.PrestadorPadrao.CpfCnpj.ZeroFill(14)}</Cnpj>");
            xmlLote.Append($"<InscricaoMunicipal>{Configuracoes.PrestadorPadrao.InscricaoMunicipal}</InscricaoMunicipal>");
            xmlLote.Append($"<QuantidadeRps>{notas.Count}</QuantidadeRps>");
            xmlLote.Append("<ListaRps>");
            xmlLote.Append(xmlLoteRps);
            xmlLote.Append("</ListaRps>");
            xmlLote.Append("</p:LoteRps>");
            xmlLote.Append("</p:EnviarLoteRpsEnvio>");

            var document = XDocument.Parse(xmlLote.ToString());

            document.ElementAnyNs("EnviarLoteRpsEnvio").AddAttribute(new XAttribute(XNamespace.Xmlns + "p1", p1));
            NFSeUtil.ApplyNamespace(document.Root, p1, "LoteRps", "EnviarLoteRpsEnvio");

            retornoWebservice.XmlEnvio = document.AsString();
        }
Beispiel #2
0
        protected override void PrepararEnviar(RetornoEnviar retornoWebservice, NotaServicoCollection notas)
        {
            if (retornoWebservice.Lote == 0)
            {
                retornoWebservice.Erros.Add(new Evento {
                    Codigo = "0", Descricao = "Lote não informado."
                });
            }
            if (notas.Count == 0)
            {
                retornoWebservice.Erros.Add(new Evento {
                    Codigo = "0", Descricao = "RPS não informado."
                });
            }
            if (retornoWebservice.Erros.Count > 0)
            {
                return;
            }

            var xmlLoteRps = new StringBuilder();

            foreach (var nota in notas)
            {
                var xmlRps = WriteXmlRps(nota, false, false);
                xmlLoteRps.Append(xmlRps);
                GravarRpsEmDisco(xmlRps, $"Rps-{nota.IdentificacaoRps.DataEmissao:yyyyMMdd}-{nota.IdentificacaoRps.Numero}.xml", nota.IdentificacaoRps.DataEmissao);
            }

            var xmlLote = new StringBuilder();

            xmlLote.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            xmlLote.Append("<EnviarLoteRpsEnvio xmlns=\"http://www.issnetonline.com.br/webserviceabrasf/vsd/servico_enviar_lote_rps_envio.xsd\">");
            xmlLote.Append("<LoteRps>");
            xmlLote.Append($"<NumeroLote>{retornoWebservice.Lote}</NumeroLote>");
            xmlLote.Append($"<CpfCnpj><Cnpj>{Configuracoes.PrestadorPadrao.CpfCnpj.ZeroFill(14)}</Cnpj></CpfCnpj>");
            xmlLote.Append($"<InscricaoMunicipal>{Configuracoes.PrestadorPadrao.InscricaoMunicipal}</InscricaoMunicipal>");
            xmlLote.Append($"<QuantidadeRps>{notas.Count}</QuantidadeRps>");
            xmlLote.Append("<ListaRps>");
            xmlLote.Append(xmlLoteRps);
            xmlLote.Append("</ListaRps>");
            xmlLote.Append("</LoteRps>");
            xmlLote.Append("</EnviarLoteRpsEnvio>");

            var document = XDocument.Parse(xmlLote.ToString());

            document.ElementAnyNs("EnviarLoteRpsEnvio").AddAttribute(new XAttribute(XNamespace.Xmlns + "tc", tc));
            NFSeUtil.ApplyNamespace(document.Root, tc, "LoteRps", "EnviarLoteRpsEnvio");

            retornoWebservice.XmlEnvio = document.AsString();
        }
Beispiel #3
0
        public string AjustarMensagem(string msg, params string[] tags)
        {
            var document = XDocument.Parse(msg);
            var element  = document.Root;

            foreach (var tag in tags)
            {
                element = element.ElementAnyNs(tag);
            }

            element.AddAttribute(new XAttribute(XNamespace.Xmlns + "nfse", tc));
            NFSeUtil.ApplyNamespace(element, tc);

            var result  = document.AsString(false, false);
            var tagName = document.Root.Name.LocalName;

            return(result.Contains($"nfse:{tagName}") ? result.Replace($"nfse:{tagName}", $"sis:{tagName}") :
                   result.Replace(tagName, $"sis:{tagName}"));
        }