fix(BurnPdfCommand): improve JSON serialization and null safety in Signature entity and BurnPdfCommandHandler

- Added System.Text.Json.Serialization namespace and [JsonIgnore] attributes to Top and Left properties in Signature entity for .NET builds
- Applied null-forgiving operator (!) and null-coalescing defaults for frame.X and frame.Y in BurnPdfCommandHandler
- Improved runtime safety and prevented unintended JSON serialization of computed properties
This commit is contained in:
tekh 2025-11-07 09:51:02 +01:00
parent 15f6ee7be0
commit 6a5c9a3489
3 changed files with 18 additions and 6 deletions

View File

@ -43,6 +43,13 @@ public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand>
_signRepo = signRepo;
}
/// <summary>
///
/// </summary>
/// <param name="pSourceBuffer"></param>
/// <param name="pInstantJSONList"></param>
/// <param name="envelopeId"></param>
/// <returns></returns>
public byte[] BurnAnnotsToPDF(byte[] pSourceBuffer, List<string> pInstantJSONList, int envelopeId)
{
// read the elements of envelope with their annotations
@ -99,10 +106,10 @@ public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand>
var frame = element.Annotations?.FirstOrDefault(a => a.Name == "frame");
double frameY = element.Top - 0.5 - margin;
double frameYShift = frame.Y - frameY * inchFactor;
double frameXShift = frame.X - frameX * inchFactor;
double frameYShift = (frame!.Y ?? default) - frameY * inchFactor;
double frameXShift = (frame.X ?? default) - frameX * inchFactor;
foreach (var annot in element.Annotations)
foreach (var annot in element.Annotations!)
{
double yOffsetofFF;
if (!yOffsetsOfFF.TryGetValue(annot.Name, out yOffsetofFF))

View File

@ -2,6 +2,7 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
#if NETFRAMEWORK
using System;
using System.Collections.Generic;
@ -120,13 +121,17 @@ public class Signature : ISignature, IHasReceiver
#endif
Annotations { get; set; }
#if NETFRAMEWORK
#if NET
[JsonIgnore]
#endif
[NotMapped]
public double Top => Math.Round(Y, 5);
#if NET
[JsonIgnore]
#endif
[NotMapped]
public double Left => Math.Round(X, 5);
#endif
}
#if NETFRAMEWORK

View File

@ -18,5 +18,5 @@
"Receiver": [],
"EmailTemplate": [ "TBSIG_EMAIL_TEMPLATE_AFT_UPD" ]
},
"UseInMemoryDb": true
"UseInMemoryDb": false
}