Enhance logging in FdsSqlOptions and related classes

- Updated FdsSqlOptions to accept an optional ILogger parameter for improved error logging.
- Modified FdsMfr and FdsMfrClient classes to pass the logger instance to FdsSqlOptions.
- Added detailed error logging in various methods to capture SQL execution issues and file handling errors.
- Improved documentation for FdsSqlOptions to clarify logging behavior.
- Updated Archive class to log compression errors, enhancing traceability of failures.
- Adjusted project configuration to suppress specific warnings related to transitive dependencies.
- Added NuGet.config to define package sources for dependency management.
- Updated submodule references for OCORE and related projects.
This commit is contained in:
Stefan
2026-07-03 20:22:05 +02:00
parent 1a3bf30442
commit 882e97509a
57 changed files with 2121 additions and 106 deletions
+25 -10
View File
@@ -51,34 +51,49 @@ public sealed class CamtParser
/// <summary>
/// Parses all CAMT XML files found inside a ZIP archive and returns
/// the combined list of statements. Non-XML entries and malformed XML
/// entries are silently skipped. Used for camt.052 deliveries where the
/// the combined list of statements. Non-XML entries and malformed XML
/// entries are skipped. Used for camt.052 deliveries where the
/// bank wraps one or more intraday reports in a single ZIP file.
/// </summary>
public List<CamtStatement> ParseZip(byte[] bytes)
{
using var ms = new MemoryStream(bytes);
return ParseZip(ms);
}
public List<CamtStatement> ParseZip(byte[] bytes) => ParseZip(bytes, out _);
/// <inheritdoc cref="ParseZip(byte[])"/>
public List<CamtStatement> ParseZip(Stream stream)
public List<CamtStatement> ParseZip(Stream stream) => ParseZip(stream, out _);
/// <summary>
/// Same as <see cref="ParseZip(byte[])"/>, but also reports which entries were
/// skipped and why (non-.xml name, non-XML content, malformed XML), so callers
/// can log a reason instead of silently losing part of a delivery.
/// </summary>
public List<CamtStatement> ParseZip(byte[] bytes, out List<string> skippedEntries)
{
using var ms = new MemoryStream(bytes);
return ParseZip(ms, out skippedEntries);
}
/// <inheritdoc cref="ParseZip(byte[], out List{string})"/>
public List<CamtStatement> ParseZip(Stream stream, out List<string> skippedEntries)
{
var result = new List<CamtStatement>();
var skipped = new List<string>();
using var archive = new ZipArchive(stream, ZipArchiveMode.Read, leaveOpen: true);
foreach (var entry in archive.Entries)
{
if (!entry.Name.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
continue;
continue; // non-XML entries (e.g. checksums, manifests) are expected, not worth reporting
using var entryStream = entry.Open();
using var buffer = new MemoryStream();
entryStream.CopyTo(buffer);
var entryBytes = buffer.ToArray();
if (!LooksLikeXml(entryBytes))
{
skipped.Add($"{entry.Name}: not XML content");
continue;
}
try { result.AddRange(Parse(entryBytes)); }
catch (FormatException) { /* skip malformed XML entries */ }
catch (FormatException ex) { skipped.Add($"{entry.Name}: {ex.Message}"); }
}
skippedEntries = skipped;
return result;
}