0
I am processing files .txt
, however I process more than 1 file at a time, but in the database only saves 1 file, debugging I see that it reads and processes the 2 files, or up to 3 depending on how many files I am processing.
Follow my controller
and Negocio
.
You’d have to be putting the files together .txt
for me to generate a single report after.
Before processing it clears the data base with method removerSabemi()
, but it processes 1 file and then goes back to the method removerSabemi()
, and then process the other file.
I need you to go through the method removerSabemi()
only at first execution.
I need to treat in some way that I’m not finding.
Controller
if ((arquivosSabemi != null) && (arquivosSabemi.Any(f => f != null)))
{
foreach (var arquivo in arquivosSabemi.Where(s => s.ContentLength > 0))
{
InstanceResolverFor<IServicoFIDC>.Instance.SalvarSabemi(arquivo.InputStream);
}
}
Service
public void SalvarSabemi(Stream dados)
{
using (var arquivoSabemi = new StreamReader(dados))
{
var dal = InstanceResolverFor<IDadosFIDC>.Instance;
var primeiraLinha = true;
string linha;
dal.RemoverSabemi();
while (!arquivoSabemi.EndOfStream && !string.IsNullOrEmpty(linha = arquivoSabemi.ReadLine()))
{
if (primeiraLinha) { primeiraLinha = false; continue; }
var colunas = linha.Split("\t".ToCharArray());
dal.Inserir(new DadosSabemi
{
CEDNTE_CEDN = ParseValueOrNull<long>(colunas[0]),
In your "controller", do something like:
InstanceResolverFor<IDadosFIDC>.Instance.RemoverSabemi();
(before theforeach
). And in "service" remove thedal.RemoverSabemi();
. That should work.– stderr
Thanks for the help, I managed to settle with the method below.
– Renan Carvalho