Add local blob-triggered CSV validation with Azurite
This commit is contained in:
1 parent
b72aa278a5
commit
2075bcb2c3
7 files changed
+153
-27
No files matched your search
@@ -17,39 +17,19 @@ if (!File.Exists(path))
|
||||
return;
|
||||
}
|
||||
|
||||
var lines = File.ReadAllLines(path);
|
||||
IReadOnlyList<InvoiceRow> rows;
|
||||
|
||||
if (lines.Length == 0 ||
|
||||
lines[0] != "InvoiceId;CustomerId;Amount;Currency")
|
||||
try
|
||||
{
|
||||
Console.Error.WriteLine(
|
||||
"Die Datei ist leer oder die Kopfzeile stimmt nicht.");
|
||||
rows = InvoiceCsvParser.Parse(File.ReadAllText(path));
|
||||
}
|
||||
catch (FormatException exception)
|
||||
{
|
||||
Console.Error.WriteLine(exception.Message);
|
||||
Environment.ExitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
var rows = new List<InvoiceRow>();
|
||||
|
||||
for (var index = 1; index < lines.Length; index++)
|
||||
{
|
||||
var line = lines[index];
|
||||
var columns = line.Split(';');
|
||||
|
||||
if (line.Contains('"') || columns.Length != 4)
|
||||
{
|
||||
Console.Error.WriteLine(
|
||||
$"Zeile {index + 1}: Erwartet werden vier Spalten ohne Anführungszeichen.");
|
||||
Environment.ExitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
rows.Add(new InvoiceRow(
|
||||
columns[0],
|
||||
columns[1],
|
||||
columns[2],
|
||||
columns[3]));
|
||||
}
|
||||
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var errors = InvoiceValidator.Validate(row);
|
||||
|
||||
Reference in new issue
Block a user