Bump version to 1.2.0 and enhance QR code documentation
Updated `DocumentService.Client.csproj` to version 1.2.0, reflecting new features and improvements. Enhanced `README.md` with detailed examples for the new `InspectSwissQrCodeAsync` method, showcasing two approaches (TryExtract and direct null-check) for accessing QR code data. Added PowerShell-specific notes and improved code formatting for better readability. Clarified that `TryExtract` is an optional helper method.
This commit is contained in:
@@ -11,9 +11,9 @@
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<RepositoryUrl>http://git.dd:3000/AppStd/Rec.git</RepositoryUrl>
|
||||
<PackageTags>digital data document service api client</PackageTags>
|
||||
<Version>1.1.0</Version>
|
||||
<AssemblyVersion>1.1.0.0</AssemblyVersion>
|
||||
<FileVersion>1.1.0.0</FileVersion>
|
||||
<Version>1.2.0</Version>
|
||||
<AssemblyVersion>1.2.0.0</AssemblyVersion>
|
||||
<FileVersion>1.2.0.0</FileVersion>
|
||||
<Description></Description>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
@@ -189,6 +189,8 @@ Alle Beispiele nutzen ausschließlich den statischen `Client`-Einstiegspunkt. Vo
|
||||
|
||||
#### Swiss QR Code – Validierung und Extraktion in einem Schritt
|
||||
|
||||
`InspectSwissQrCodeAsync` gibt immer ein `SwissQrCodeResult` zurück, das sowohl das Validierungsergebnis als auch den extrahierten QR-Code enthält. Für den Zugriff auf den QR-Code stehen zwei gleichwertige Varianten zur Verfügung:
|
||||
|
||||
```csharp
|
||||
using DocumentService.Client;
|
||||
using DocumentService.Client.Models.Results;
|
||||
@@ -197,20 +199,27 @@ byte[] pdfBytes = await File.ReadAllBytesAsync("rechnung.pdf");
|
||||
SwissQrCodeResult result = await Client.Workflows.InspectSwissQrCodeAsync(pdfBytes);
|
||||
|
||||
// Validierungsergebnis ist immer verfügbar
|
||||
Console.WriteLine($"Gültig: {result.Validation.IsValid}");
|
||||
Console.WriteLine($"Seiten: {result.Validation.PageCount}");
|
||||
Console.WriteLine($"Gültig: {result.Validation.IsValid}");
|
||||
Console.WriteLine($"Seiten: {result.Validation.PageCount}");
|
||||
Console.WriteLine($"Verschlüsselt: {result.Validation.IsEncrypted}");
|
||||
|
||||
// QR-Code nur auswerten wenn Dokument gültig war
|
||||
if (result.QrCode is not null)
|
||||
// Variante A: TryExtract – lesbarerer Code, kein expliziter Null-Check notwendig
|
||||
// (optionale Hilfsmethode; Variante B ist gleichwertig)
|
||||
if (result.TryExtract(out var qrCode))
|
||||
{
|
||||
Console.WriteLine($"Betrag: {result.QrCode.Bill?.Amount} {result.QrCode.Bill?.Currency}");
|
||||
Console.WriteLine($"Empfänger: {result.QrCode.Bill?.Creditor?.Name}");
|
||||
Console.WriteLine($"Betrag: {qrCode.Bill?.Amount} {qrCode.Bill?.Currency}");
|
||||
Console.WriteLine($"Empfänger: {qrCode.Bill?.Creditor?.Name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Kein Swiss QR Code gefunden oder Dokument ungültig.");
|
||||
}
|
||||
|
||||
// Variante B: direkter Null-Check auf QrCode
|
||||
if (result.QrCode is not null)
|
||||
{
|
||||
Console.WriteLine($"Betrag: {result.QrCode.Bill?.Amount} {result.QrCode.Bill?.Currency}");
|
||||
}
|
||||
```
|
||||
|
||||
```vbnet
|
||||
@@ -224,12 +233,19 @@ Console.WriteLine($"Gültig: {result.Validation.IsValid}")
|
||||
Console.WriteLine($"Seiten: {result.Validation.PageCount}")
|
||||
Console.WriteLine($"Verschlüsselt: {result.Validation.IsEncrypted}")
|
||||
|
||||
If result.QrCode IsNot Nothing Then
|
||||
Console.WriteLine($"Betrag: {result.QrCode.Bill?.Amount} {result.QrCode.Bill?.Currency}")
|
||||
Console.WriteLine($"Empfänger: {result.QrCode.Bill?.Creditor?.Name}")
|
||||
' Variante A: TryExtract
|
||||
Dim qrCode As DocumentService.Application.Common.DTOs.SwissQrCodeExtractionResult = Nothing
|
||||
If result.TryExtract(qrCode) Then
|
||||
Console.WriteLine($"Betrag: {qrCode.Bill?.Amount} {qrCode.Bill?.Currency}")
|
||||
Console.WriteLine($"Empfänger: {qrCode.Bill?.Creditor?.Name}")
|
||||
Else
|
||||
Console.WriteLine("Kein Swiss QR Code gefunden oder Dokument ungültig.")
|
||||
End If
|
||||
|
||||
' Variante B: direkter Null-Check
|
||||
If result.QrCode IsNot Nothing Then
|
||||
Console.WriteLine($"Betrag: {result.QrCode.Bill?.Amount} {result.QrCode.Bill?.Currency}")
|
||||
End If
|
||||
```
|
||||
|
||||
```powershell
|
||||
@@ -242,6 +258,8 @@ Write-Host "Gueltig: $($result.Validation.IsValid)"
|
||||
Write-Host "Seiten: $($result.Validation.PageCount)"
|
||||
Write-Host "Verschluesselt:$($result.Validation.IsEncrypted)"
|
||||
|
||||
# TryExtract ist in PowerShell nicht direkt nutzbar (out-Parameter).
|
||||
# Direkter Null-Check ist hier die einzige Option:
|
||||
if ($null -ne $result.QrCode) {
|
||||
Write-Host "Betrag: $($result.QrCode.Bill.Amount) $($result.QrCode.Bill.Currency)"
|
||||
Write-Host "Empfaenger:$($result.QrCode.Bill.Creditor.Name)"
|
||||
@@ -250,6 +268,8 @@ if ($null -ne $result.QrCode) {
|
||||
}
|
||||
```
|
||||
|
||||
> **`TryExtract` – Hinweis:** Die Methode ist eine optionale Lesbarkeits-Hilfe und nicht zwingend erforderlich. Der direkte Null-Check auf `result.QrCode` ist gleichwertig. Gibt `TryExtract` `false` zurück, ist der `out`-Parameter `qrCode` `null` – er darf in diesem Fall nicht verwendet werden.
|
||||
|
||||
---
|
||||
|
||||
### 1. PDF-Validierung
|
||||
|
||||
Reference in New Issue
Block a user