//novo public DetalheSegmentoERetornoCnab240 ObterRegistrosDetalheE(string registro) { DetalheSegmentoERetornoCnab240 objRetornar = new DetalheSegmentoERetornoCnab240(); objRetornar.LerDetalheSegmentoERetornoItauCnab240(registro); return(objRetornar); }
//novo public DetalheSegmentoERetornoCnab240 ObterRegistrosDetalheE(string linha) { DetalheSegmentoERetornoCnab240 objRetornar = new DetalheSegmentoERetornoCnab240(); objRetornar.LerDetalheSegmentoERetornoCnab240(linha); return(objRetornar); }
public RetornoCnab240 ProcessarRetorno() { /* Validações */ #region Validações ValidaArquivoRetorno(); #endregion var objRetornar = new RetornoCnab240(); LoteRetornoCnab240 ultimoLoteIdentificado = null; DetalheRetornoCnab240 ultimoRegistroIdentificado = null; foreach (var linhaAtual in _linhasArquivo) { /* Header de arquivo */ if (linhaAtual.ExtrairValorDaLinha(8, 8) == "0") { objRetornar.Header = ObterHeader(linhaAtual); } /* Header de Lote */ if (linhaAtual.ExtrairValorDaLinha(8, 8) == "1") { ultimoLoteIdentificado = new LoteRetornoCnab240(); ultimoRegistroIdentificado = new DetalheRetornoCnab240(); objRetornar.Lotes.Add(ultimoLoteIdentificado); ultimoLoteIdentificado.HeaderLote = ObterHeaderLote(linhaAtual); } if (linhaAtual.ExtrairValorDaLinha(8, 8) == "3") { if (linhaAtual.ExtrairValorDaLinha(14, 14) == "T") { if (ultimoLoteIdentificado == null) { throw new Exception("Não foi encontrado header de lote para o segmento atual."); } //ultimoLoteIdentificado.RegistrosDetalheSegmentoT.Add(objDetalhe); ultimoRegistroIdentificado.SegmentoT = ObterRegistrosDetalheT(linhaAtual); } if (linhaAtual.ExtrairValorDaLinha(14, 14) == "U") { if (ultimoLoteIdentificado == null) { throw new Exception("Não foi encontrado header de lote para o segmento atual."); } //ultimoLoteIdentificado.RegistrosDetalheSegmentoU.Add(objDetalhe); ultimoRegistroIdentificado.SegmentoU = ObterRegistrosDetalheU(linhaAtual); } if (linhaAtual.ExtrairValorDaLinha(14, 14) == "E") { if (ultimoLoteIdentificado == null) { throw new Exception("Não foi encontrado header de lote para o segmento atual."); } //ultimoLoteIdentificado.RegistrosDetalheSegmentoU.Add(objDetalhe); ultimoRegistroIdentificado.SegmentoE = ObterRegistrosDetalheE(linhaAtual); DetalheSegmentoERetornoCnab240 detalheSegmentoE = new DetalheSegmentoERetornoCnab240(); detalheSegmentoE = ultimoRegistroIdentificado.SegmentoE; DetalheRetornoCnab240 registro = new DetalheRetornoCnab240(); registro.SegmentoE = detalheSegmentoE; ultimoLoteIdentificado.RegistrosDetalheSegmentos.Add(registro); } } /* Trailer de Lote */ if (linhaAtual.ExtrairValorDaLinha(8, 8) == "5") { if (ultimoLoteIdentificado != null) { ultimoLoteIdentificado.TrailerLote = ObterTrailerLote(linhaAtual); } } /* Trailer de arquivo */ if (linhaAtual.ExtrairValorDaLinha(8, 8) == "9") { objRetornar.Trailer = ObterTrailer(linhaAtual); } } return(objRetornar); }