Exemplo n.º 1
0
        /// <summary>
        /// Email NFe-Serviço
        /// </summary>      
        public belEmail(TcInfNfse objInfNfse, string sMsgPrestador, string sHost, string sPorta, string sDe, string sSenha, string sPara, bool bAutentica)
        {
            bCorpoHTML = true;
            if (sPara == "")
            {
                _para = retEmailDestinatario(objInfNfse.IdentificacaoRps.Nfseq, belStatic.codEmpresaNFe);
            }
            else
            {
                _para = sPara;
            }

            _envia = true;
            _sSeq = objInfNfse.IdentificacaoRps.Nfseq;
            _paraTransp = "";
            _autentica = bAutentica;
            _de = sDe;
            _porta = Convert.ToInt16(sPorta);
            _host = sHost;
            _senha = sSenha;
            _corpo = geraCorpoEmail(objInfNfse, sMsgPrestador);
            _assunto = "Notificação de Emissão de Nota Fiscal Eletrônica";

        }
Exemplo n.º 2
0
        /// <summary>
        /// NFE- SERVIÇO
        /// </summary>     
        private string geraCorpoEmail(TcInfNfse objInfNfse, string sMsgPrestador)
        {
            StringBuilder corpo = new StringBuilder();
            try
            {
                corpo.Append("<H3>Sr. Contribuinte,</H3>");
                corpo.Append("Esta mensagem refere-se à Nota Fiscal Eletrônica de Serviços N°" + objInfNfse.Numero);
                corpo.Append(" emitida pelo prestador de serviços: <P>");
                corpo.Append(sMsgPrestador + Environment.NewLine);
                corpo.Append("Para visualizá-la acesse o link a seguir: " + Environment.NewLine);

                string scaminhoLink = "http://" + "itu" + ".ginfes" + (belStatic.tpAmbNFse == 2 ? "h" : "") + ".com.br/birt/frameset?__report=nfs_ver4.rptdesign&cdVerificacao=" + objInfNfse.CodigoVerificacao + "&numNota=" + objInfNfse.Numero;

                corpo.Append("<a href=" + scaminhoLink + ">Visualize a NFe-serviço aqui!</a>");
                corpo.Append("<br><br><br><I><font color = " + "\"" + "#c0c0c0" + "\"" + " size = 5>HLP - Estratégia em Sistemas</font></I><br>");
                corpo.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=" + "\"" + "http://www.hlp.com.br" + "\"" + ">www.hlp.com.br</a>");
            }
            catch (Exception x)
            {
                throw new Exception(x.Message);
            }
            return corpo.ToString();
        }
Exemplo n.º 3
0
        public string BuscaRetorno(tcIdentificacaoPrestador Prestador, KryptonLabel lblStatus, ProgressBar ProgresStatus)
        {

            bool parar = false;
            Globais glob = new Globais();
            string sMensagemErro = "";
            int iCountBuscaRet = 0;

            ProgresStatus.Step = 1;
            ProgresStatus.Minimum = 0;
            ProgresStatus.Maximum = 20;
            ProgresStatus.MarqueeAnimationSpeed = 20;
            ProgresStatus.Value = 0;

            try
            {
                for (; ; )
                {
                    ProgresStatus.PerformStep();
                    ProgresStatus.Refresh();
                    lblStatus.Text = "Sistema tentando buscar retorno!!" + Environment.NewLine + "Tentativas: " + iCountBuscaRet.ToString() + " de 21";
                    lblStatus.Refresh();
                    string sRetConsulta = BuscaRetornoWebService(Prestador);
                    XmlDocument xmlRet = new XmlDocument();
                    xmlRet.LoadXml(sRetConsulta);

                    XmlNodeList xNodeList = xmlRet.GetElementsByTagName("ns4:MensagemRetorno");

                    if (xNodeList.Count > 0)
                    {
                        sMensagemErro = "{3}Lote: " + NumeroLote + "{3}{3}Código: {0}{3}{3}Mensagem: {1}{3}{3}Correção: {2}{3}{3}Protocolo: " + Protocolo;

                        foreach (XmlNode node in xNodeList)
                        {
                            sCodigoRetorno = node["ns4:Codigo"].InnerText;

                            if (sCodigoRetorno.Equals("E4") && iCountBuscaRet <= 20)
                            {
                                iCountBuscaRet++;
                            }
                            else
                            {
                                sMensagemErro = string.Format(sMensagemErro, node["ns4:Codigo"].InnerText,
                                                      "Esse RPS ainda não se encontra em nossa base de dados.",
                                                      node["ns4:Correcao"].InnerText, Environment.NewLine);
                                parar = true;
                            }
                        }
                    }
                    else if (xmlRet.GetElementsByTagName("ns3:CompNfse").Count > 0)
                    {
                        this.sCodigoRetorno = "";
                        sMensagemErro = "";
                        Globais objGlobais = new Globais();
                        bool bAlteraDupl = Convert.ToBoolean(objGlobais.LeRegConfig("GravaNumNFseDupl"));


                        for (int i = 0; i < xmlRet.GetElementsByTagName("ns3:CompNfse").Count; i++)
                        {
                            #region Salva Arquivo por arquivo
                            string sPasta = Convert.ToDateTime(xmlRet.GetElementsByTagName("ns4:InfNfse")[i]["ns4:DataEmissao"].InnerText).ToString("MM/yy").Replace("/", "");
                            //Numero da nota no sefaz + numero da sequencia no sistema
                            string sNomeArquivo = sPasta + (xmlRet.GetElementsByTagName("ns4:InfNfse")[i]["ns4:Numero"].InnerText.PadLeft(6, '0'))
                                                 + (xmlRet.GetElementsByTagName("ns4:IdentificacaoRps")[i]["ns4:Numero"].InnerText.PadLeft(6, '0'));

                            XmlDocument xmlSaveNfes = new XmlDocument();
                            xmlSaveNfes.LoadXml(xmlRet.GetElementsByTagName("ns4:Nfse")[i].InnerXml);
                            DirectoryInfo dPastaData = new DirectoryInfo(belStaticPastas.ENVIADOS + "\\Servicos\\" + sPasta);
                            if (!dPastaData.Exists) { dPastaData.Create(); }
                            xmlSaveNfes.Save(belStaticPastas.ENVIADOS + "\\Servicos\\" + sPasta + "\\" + sNomeArquivo + "-nfes.xml");
                            #endregion

                            objNfseRetorno = new TcInfNfse();
                            objNfseRetorno.Numero = xmlRet.GetElementsByTagName("ns4:InfNfse")[i]["ns4:Numero"].InnerText;
                            objNfseRetorno.CodigoVerificacao = xmlRet.GetElementsByTagName("ns4:InfNfse")[i]["ns4:CodigoVerificacao"].InnerText;

                            tcIdentificacaoRps objIdentRps = BuscatcIdentificacaoRps(xmlRet.GetElementsByTagName("ns4:IdentificacaoRps")[i]["ns4:Numero"].InnerText.PadLeft(6, '0'));
                            belGerarXML objBelGeraXml = new belGerarXML();


                            if (belStatic.sNomeEmpresa == "LORENZON")
                            {
                                AlteraDuplicataNumNFse(objIdentRps, xmlRet.GetElementsByTagName("ns4:InfNfse")[i]["ns4:Numero"].InnerText);
                            }

                            if (xmlRet.GetElementsByTagName("ns4:SubstituicaoNfse")[i] != null)
                            {
                                objNfseRetorno.NfseSubstituida = xmlRet.GetElementsByTagName("ns4:SubstituicaoNfse")[i]["ns4:NfseSubstituidora"].InnerText;
                            }
                            objNfseRetorno.IdentificacaoRps = objIdentRps;
                            objListaNfseRetorno.Add(objNfseRetorno);

                        }
                        parar = true;
                    }

                    if (parar) break;
                }
                return sMensagemErro;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }