Exemplo n.º 1
0
        private DetalheRetorno SetDetalheRetorno(DetalheRetornoCNAB240 det)
        {
            return(new DetalheRetorno
            {
                CodigoInscricao = det.SegmentoT.TipoInscricao,
                NumeroInscricao = det.SegmentoT.NumeroInscricao,

                Agencia = det.SegmentoT.Agencia,
                Conta = det.SegmentoT.Conta,
                DACConta = Int32.Parse(det.SegmentoT.DigitoConta),
                NossoNumero = det.SegmentoT.NossoNumero.Substring(0, 9),
                DACNossoNumero = det.SegmentoT.NossoNumero.Substring(9, 1),

                Carteira = det.SegmentoT.CodigoCarteira.ToString(),
                CodigoOcorrencia = Int32.Parse(det.SegmentoU.CodigoOcorrenciaSacado),

                DataOcorrencia = det.SegmentoU.DataOcorrencia,
                DataLiquidacao = det.SegmentoU.DataOcorrencia,
                NumeroDocumento = det.SegmentoT.NumeroDocumento,
                DataVencimento = det.SegmentoT.DataVencimento,

                ValorTitulo = det.SegmentoT.ValorTitulo,

                DataCredito = det.SegmentoU.DataCredito,

                ValorDespesa = det.SegmentoT.ValorTarifas,
                OutrasDespesas = det.SegmentoU.ValorOutrasDespesas,
                Abatimentos = det.SegmentoU.ValorAbatimentoConcedido,
                Descontos = det.SegmentoU.ValorDescontoConcedido,
                ValorPago = det.SegmentoU.ValorPagoPeloSacado,
                JurosMora = det.SegmentoU.JurosMultaEncargos,
                IdentificacaoTitulo = det.SegmentoT.NumeroDocumento,
                OutrosCreditos = det.SegmentoU.ValorOutrosCreditos
            });
        }
Exemplo n.º 2
0
        public override void LerArquivoRetorno(IBanco banco, Stream arquivo)
        {
            try
            {
                StreamReader stream = new StreamReader(arquivo, System.Text.Encoding.UTF8);
                string       linha  = "";

                while ((linha = stream.ReadLine()) != null)
                {
                    DetalheRetornoCNAB240 detalheRetorno = new DetalheRetornoCNAB240();

                    switch (linha.Substring(7, 1))
                    {
                    case "0":     //Header de arquivo
                        OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeArquivo);
                        break;

                    case "1":     //Header de lote
                        OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeLote);
                        break;

                    case "3":     //Detalhe
                        if (linha.Substring(13, 1) == "W")
                        {
                            OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoW);
                            detalheRetorno.SegmentoW.LerDetalheSegmentoWRetornoCNAB240(linha);
                        }
                        else
                        {
                            OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoT);
                            detalheRetorno.SegmentoT.LerDetalheSegmentoTRetornoCNAB240(linha);

                            linha = stream.ReadLine();

                            OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoU);
                            detalheRetorno.SegmentoU.LerDetalheSegmentoURetornoCNAB240(linha);
                        }
                        ListaDetalhes.Add(detalheRetorno);
                        break;

                    case "5":     //Trailler de lote
                        OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeLote);
                        break;

                    case "9":     //Trailler de arquivo
                        OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeArquivo);
                        break;
                    }
                }
                stream.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler arquivo.", ex);
            }
        }
Exemplo n.º 3
0
 public LinhaDeArquivoLidaArgs(DetalheRetornoCNAB240 detalhe, string linha, EnumTipodeLinhaLida tipoLinha)
 {
     try
     {
         _linha     = linha;
         _detalhe   = detalhe;
         _tipoLinha = tipoLinha;
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao instanciar objeto", ex);
     }
 }
Exemplo n.º 4
0
 public virtual void OnLinhaLida(DetalheRetornoCNAB240 detalheRetornoCNAB240, string linha, EnumTipodeLinhaLida tipoLinha)
 {
     try
     {
         if (this.LinhaDeArquivoLida != null)
         {
             this.LinhaDeArquivoLida(this, new LinhaDeArquivoLidaArgs(detalheRetornoCNAB240, linha, tipoLinha));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao gerar evento.", ex);
     }
 }
        public override void LerArquivoRetorno(IBanco banco, Stream arquivo)
        {
            try
            {
                StreamReader          stream         = new StreamReader(arquivo, System.Text.Encoding.UTF8);
                string                linha          = "";
                DetalheRetornoCNAB240 detalheRetorno = new DetalheRetornoCNAB240();

                // Lendo o arquivo
                linha = stream.ReadLine();
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeArquivo);
                detalheRetorno.HeaderArquivo.LerHeaderDeArquivoCNAB240(linha);

                // Próxima linha (DETALHE)
                linha = stream.ReadLine();
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeLote);
                linha = stream.ReadLine();

                while (linha.Substring(7, 1) == "3")
                {
                    if (linha.Substring(13, 1) == "W")
                    {
                        OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoW);
                        detalheRetorno.SegmentoW.LerDetalheSegmentoWRetornoCNAB240(linha);
                    }
                    else
                    {
                        OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoT);
                        detalheRetorno.SegmentoT.LerDetalheSegmentoTRetornoCNAB240(linha);

                        linha = stream.ReadLine();

                        OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoU);
                        detalheRetorno.SegmentoU.LerDetalheSegmentoURetornoCNAB240(linha);
                    }
                    ListaDetalhes.Add(detalheRetorno);
                    linha = stream.ReadLine();
                }
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeLote);
                linha = stream.ReadLine();
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeArquivo);


                stream.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler arquivo.", ex);
            }
        }
        public override void LerArquivoRetorno(IBanco banco, Stream arquivo)
        {
            try
            {
                StreamReader stream = new StreamReader(arquivo, System.Text.Encoding.UTF8);
                string linha = "";
                DetalheRetornoCNAB240 detalheRetorno = new DetalheRetornoCNAB240();

                // Lendo o arquivo
                linha = stream.ReadLine();
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeArquivo);
                detalheRetorno.HeaderArquivo.LerHeaderDeArquivoCNAB240(linha);

                // Próxima linha (DETALHE)
                linha = stream.ReadLine();
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeLote);
                linha = stream.ReadLine();

                while (linha.Substring(7, 1) == "3")
                {
                    if (linha.Substring(13, 1) == "W")
                    {
                        OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoW);
                        detalheRetorno.SegmentoW.LerDetalheSegmentoWRetornoCNAB240(linha);
                    }
                    else
                    {
                        OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoT);
                        detalheRetorno.SegmentoT.LerDetalheSegmentoTRetornoCNAB240(linha);

                        linha = stream.ReadLine();

                        OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoU);
                        detalheRetorno.SegmentoU.LerDetalheSegmentoURetornoCNAB240(linha);
                    }
                    ListaDetalhes.Add(detalheRetorno);
                    linha = stream.ReadLine();
                }
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeLote);
                linha = stream.ReadLine();
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeArquivo);


                stream.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler arquivo.", ex);
            }
        }
Exemplo n.º 7
0
        public override void LerArquivoRetorno(IBanco banco, Stream arquivo)
        {
            try
            {
                StreamReader stream = new StreamReader(arquivo);
                string       linha  = "";

                // Lendo o arquivo
                linha = stream.ReadLine();
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeArquivo);

                // Próxima linha (DETALHE)
                linha = stream.ReadLine();
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeLote);
                linha = stream.ReadLine();

                while (linha.Substring(7, 1) == "3")
                {
                    //Ler detalhe do registro - Segmento T
                    DetalheRetornoCNAB240 detalheRetorno = new DetalheRetornoCNAB240(banco.LerDetalheSegmentoTRetornoCNAB240(linha));
                    OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoT);

                    //Ler detalhe do registro - Segmento U
                    linha = stream.ReadLine();
                    detalheRetorno.SegmentoU = banco.LerDetalheSegmentoURetornoCNAB240(linha);
                    OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoU);

                    ListaDetalhes.Add(detalheRetorno);
                    linha = stream.ReadLine();
                }
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeLote);
                linha = stream.ReadLine();
                OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeArquivo);

                stream.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler arquivo.", ex);
            }
        }
Exemplo n.º 8
0
        public override void LerArquivoRetorno(IBanco banco, Stream arquivo)
        {
            try
            {
                StreamReader Linha   = new StreamReader(arquivo);
                string       strline = "";

                // Lendo o arquivo
                strline = Linha.ReadLine();
                OnLinhaLida(null, strline, EnumTipodeLinhaLida.HeaderDeArquivo);

                switch (banco.Codigo)
                {
                case 1:
                    // Próxima linha (DETALHE)
                    strline = Linha.ReadLine();
                    OnLinhaLida(null, strline, EnumTipodeLinhaLida.HeaderDeLote);
                    strline = Linha.ReadLine();

                    while (strline.Substring(7, 1) == "3")
                    {
                        DetalheRetornoCNAB240 detalheRetorno = new DetalheRetornoCNAB240();
                        detalheRetorno.SegmentoT.LerDetalheSegmentoTRetornoCNAB240(strline);
                        OnLinhaLida(detalheRetorno, strline, EnumTipodeLinhaLida.DetalheSegmentoT);

                        strline = Linha.ReadLine();
                        detalheRetorno.SegmentoU.LerDetalheSegmentoURetornoCNAB240(strline);
                        OnLinhaLida(detalheRetorno, strline, EnumTipodeLinhaLida.DetalheSegmentoU);
                        ListaDetalhes.Add(detalheRetorno);
                        strline = Linha.ReadLine();
                    }
                    OnLinhaLida(null, strline, EnumTipodeLinhaLida.TraillerDeLote);
                    strline = Linha.ReadLine();
                    OnLinhaLida(null, strline, EnumTipodeLinhaLida.TraillerDeArquivo);
                    break;

                default:
                    // Próxima linha (DETALHE)
                    strline = Linha.ReadLine();
                    OnLinhaLida(null, strline, EnumTipodeLinhaLida.HeaderDeLote);
                    strline = Linha.ReadLine();

                    while (strline.Substring(7, 1) == "3")
                    {
                        DetalheRetornoCNAB240 detalheRetorno = new DetalheRetornoCNAB240();
                        OnLinhaLida(detalheRetorno, strline, EnumTipodeLinhaLida.DetalheSegmentoT);
                        detalheRetorno.SegmentoT.LerDetalheSegmentoTRetornoCNAB240(strline);
                        strline = Linha.ReadLine();
                        OnLinhaLida(detalheRetorno, strline, EnumTipodeLinhaLida.DetalheSegmentoU);

                        detalheRetorno.SegmentoU.LerDetalheSegmentoURetornoCNAB240(strline);
                        ListaDetalhes.Add(detalheRetorno);
                        strline = Linha.ReadLine();
                    }
                    OnLinhaLida(null, strline, EnumTipodeLinhaLida.TraillerDeLote);
                    strline = Linha.ReadLine();
                    OnLinhaLida(null, strline, EnumTipodeLinhaLida.TraillerDeArquivo);
                    break;
                }

                Linha.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler arquivo.", ex);
            }
        }
Exemplo n.º 9
0
        public override void LerArquivoRetorno(IBanco banco, Stream arquivo)
        {
            try
             {
                StreamReader stream = new StreamReader(arquivo, System.Text.Encoding.UTF8);
                string linha = "";

                while ((linha = stream.ReadLine()) != null)
                {
                    if (!String.IsNullOrEmpty(linha))
                    {

                        DetalheRetornoCNAB240 detalheRetorno = new DetalheRetornoCNAB240();

                        switch (linha.Substring(7, 1))
                        {
                            case "0": //Header de arquivo
                                OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeArquivo);
                                break;
                            case "1": //Header de lote
                                OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeLote);
                                break;
                            case "3": //Detalhe
                                if (linha.Substring(13, 1) == "W")
                                {
                                    OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoW);
                                    detalheRetorno.SegmentoW.LerDetalheSegmentoWRetornoCNAB240(linha);
                                }
                                else if (linha.Substring(13, 1) == "E")
                                {
                                    OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoE);
                                    detalheRetorno.SegmentoE = new DetalheSegmentoERetornoCNAB240();
                                    detalheRetorno.SegmentoE.LerDetalheSegmentoERetornoCNAB240(linha);
                                }
                                else
                                {
                                    OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoT);
                                    //detalheRetorno.SegmentoT.LerDetalheSegmentoTRetornoCNAB240(linha);
                                    detalheRetorno.SegmentoT = banco.LerDetalheSegmentoTRetornoCNAB240(linha);

                                    linha = stream.ReadLine();

                                    OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoU);
                                    //detalheRetorno.SegmentoU.LerDetalheSegmentoURetornoCNAB240(linha);
                                    detalheRetorno.SegmentoU = banco.LerDetalheSegmentoURetornoCNAB240(linha);

                                }
                                ListaDetalhes.Add(detalheRetorno);
                                break;
                            case "5": //Trailler de lote
                                OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeLote);
                                break;
                            case "9": //Trailler de arquivo
                                OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeArquivo);
                                break;
                        }

                    }

                }
                stream.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler arquivo.", ex);
            }
        }
 public virtual void OnLinhaLida(DetalheRetornoCNAB240 detalheRetornoCNAB240, string linha, EnumTipodeLinhaLida tipoLinha)
 {
     try
     {
         if (this.LinhaDeArquivoLida != null)
             this.LinhaDeArquivoLida(this, new LinhaDeArquivoLidaArgs(detalheRetornoCNAB240, linha, tipoLinha));
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao gerar evento.", ex);
     }
 }
Exemplo n.º 11
0
        public override void LerArquivoRetorno(IBanco banco, Stream arquivo)
        {
            try
            {
                StreamReader stream      = new StreamReader(arquivo, System.Text.Encoding.UTF8);
                string       linha       = "";
                var          cnpjEmpresa = "";

                while ((linha = stream.ReadLine()) != null)
                {
                    if (!String.IsNullOrEmpty(linha))
                    {
                        DetalheRetornoCNAB240 detalheRetorno = new DetalheRetornoCNAB240();

                        switch (linha.Substring(7, 1))
                        {
                        case "0":     //Header de arquivo
                            cnpjEmpresa = linha.Substring(18, 14);
                            OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeArquivo);
                            break;

                        case "1":     //Header de lote
                            OnLinhaLida(null, linha, EnumTipodeLinhaLida.HeaderDeLote);
                            break;

                        case "3":     //Detalhe
                            if (linha.Substring(13, 1) == "W")
                            {
                                OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoW);
                                detalheRetorno.SegmentoW.LerDetalheSegmentoWRetornoCNAB240(linha);
                            }
                            else if (linha.Substring(13, 1) == "E")
                            {
                                OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoE);
                                detalheRetorno.SegmentoE = new DetalheSegmentoERetornoCNAB240();
                                detalheRetorno.SegmentoE.LerDetalheSegmentoERetornoCNAB240(linha);
                            }
                            else if (linha.Substring(13, 1) == "T")
                            {
                                //Irá ler o Segmento T e em sequencia o Segmento U
                                detalheRetorno.SegmentoT = banco.LerDetalheSegmentoTRetornoCNAB240(linha);
                                detalheRetorno.SegmentoT.NumeroInscricao = cnpjEmpresa;
                                linha = stream.ReadLine();
                                detalheRetorno.SegmentoU = banco.LerDetalheSegmentoURetornoCNAB240(linha);

                                OnLinhaLida(detalheRetorno, linha, EnumTipodeLinhaLida.DetalheSegmentoU);
                            }
                            ListaDetalhes.Add(detalheRetorno);
                            break;

                        case "5":     //Trailler de lote
                            OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeLote);
                            break;

                        case "9":     //Trailler de arquivo
                            OnLinhaLida(null, linha, EnumTipodeLinhaLida.TraillerDeArquivo);
                            break;
                        }
                    }
                }
                stream.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao ler arquivo.", ex);
            }
        }