Generaliserat iläsning av bankdata

This commit is contained in:
2024-02-09 12:50:16 +01:00
parent 05dfd1f35b
commit a215b54d0d
7 changed files with 71 additions and 26 deletions

View File

@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace WinFormDiApp.BLR;
public class ReadingIn : IReadingIn
public class ReadingIn : IReadingIn, IDisposable
{
private readonly IConfiguration _configuration;
private readonly ILogger<ReadingIn> _logger;
@ -46,9 +46,8 @@ public class ReadingIn : IReadingIn
if (prt)
{
//Console.WriteLine();
//// _logger.LogInformation("");
_logger.LogInformation(record.ToString());
records.Add(record);
fieldNr = 0;
}
prt = false;
for (int col = 0; col <= colCount; col++)
@ -65,6 +64,14 @@ public class ReadingIn : IReadingIn
{
prt = true;
record = new AccountRecord();
fieldNr = 0;
}
else
{
if (col == 0)
{
col = colCount;
}
}
//Console.WriteLine(" Row:" + row + " column:" + col + " Value:" + worksheet.Cells[row, col].Value.ToString().Trim());
if (prt)
@ -90,6 +97,14 @@ public class ReadingIn : IReadingIn
case 3:
{
record.Konto = _excellent.ReadCell(row, col).ToString().Trim();
if (record.Konto.ToLower().StartsWith("bg")
|| record.Konto.ToLower().StartsWith("pg")
|| record.Konto.ToLower().StartsWith("hs")){}
else
{
prt = false;
col = colCount;
}
break;
}
case 4:
@ -117,6 +132,11 @@ public class ReadingIn : IReadingIn
var restab = readXLS(fullFileName);
if (restab != null)
{
restab.ToList().ForEach(x =>
{
_logger.LogInformation(x.ToString());
});
try
{
@ -137,4 +157,8 @@ public class ReadingIn : IReadingIn
return result;
}
public void Dispose()
{
_excellent.Dispose();
}
}