public RetornoGenerico LerArquivoRetorno(List <string> linhasArquivo) { if (linhasArquivo == null || linhasArquivo.Any() == false) { throw new ApplicationException("Arquivo informado é inválido."); } /* Identifica o layout: 240 ou 400 */ if (linhasArquivo.First().Length == 240) { var leitor = new LeitorRetornoCnab240Bradesco(linhasArquivo); var retornoProcessado = leitor.ProcessarRetorno(); var objRetornar = new RetornoGenerico(retornoProcessado); return(objRetornar); } if (linhasArquivo.First().Length == 400) { var leitor = new LeitorRetornoCnab400Bradesco(linhasArquivo); var retornoProcessado = leitor.ProcessarRetorno(); var objRetornar = new RetornoGenerico(retornoProcessado); return(objRetornar); } throw new Exception("Arquivo de RETORNO com " + linhasArquivo.First().Length + " posições, não é suportado."); }
public void TestTrailerArquivoRetornoCnab400BancoBradesco() { LeitorRetornoCnab400Bradesco leitor = new LeitorRetornoCnab400Bradesco(null); string valorTesteRegistro = "9201237 000008850000003044113700000131 00000000000000000000000122998000030000001229980000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000 000006"; var resultado = leitor.ObterTrailer(valorTesteRegistro); Assert.AreEqual(resultado.NumeroSequencial, 6); }
public void TestHeaderArquivoRetornoCnab400BancoBradesco() { LeitorRetornoCnab400Bradesco leitor = new LeitorRetornoCnab400Bradesco(null); string valorTesteRegistro = "02RETORNO01COBRANCA 00000000000004603020RMEX CONSTRUTORA E INCORPORADO237BRADESCO 0907140160000000131 100714 000001"; var resultado = leitor.ObterHeader(valorTesteRegistro); Assert.AreEqual(resultado.CodigoDoBanco, "237"); }
public void TestRegistroArquivoRetornoCnab400BancoBradesco() { LeitorRetornoCnab400Bradesco leitor = new LeitorRetornoCnab400Bradesco(null); string valorTesteRegistro = "10210623013000170000000901923000105100001217010 000000002300000684440000000000000000000000000906090714000121701000000000230000068444100714000000002902410400162 000000000000000000000000000000000000000000000000000000000000000000000000000000000000002902400000000000000000000000000 100714 00000000000000 000002"; var resultado = leitor.ObterRegistrosDetalhe(valorTesteRegistro); Assert.AreEqual(resultado.NumeroSequencial, 2); }
public RetornoGenerico LerArquivoRetorno(List<string> linhasArquivo) { if (linhasArquivo == null || linhasArquivo.Any() == false) throw new ApplicationException("Arquivo informado é inválido."); /* Identifica o layout: 240 ou 400 */ if (linhasArquivo.First().Length == 240) { var leitor = new LeitorRetornoCnab240Bradesco(linhasArquivo); var retornoProcessado = leitor.ProcessarRetorno(); var objRetornar = new RetornoGenerico(retornoProcessado); return objRetornar; } if (linhasArquivo.First().Length == 400) { var leitor = new LeitorRetornoCnab400Bradesco(linhasArquivo); var retornoProcessado = leitor.ProcessarRetorno(); var objRetornar = new RetornoGenerico(retornoProcessado); return objRetornar; } throw new Exception("Arquivo de RETORNO com " + linhasArquivo.First().Length + " posições, não é suportado."); }