Compare commits

...

11 Commits

Author SHA1 Message Date
ecc7552951 refactor: move CreateAnnotationCommand extension to separate static class 2025-10-13 17:15:00 +02:00
d10f19d92a refactor(annotation): add lazy JSON deserialization for PSPDFKitInstantJSON
- Introduced Lazy<dynamic> field for deferred deserialization of PSPDFKitInstantJSON
- Added ExpandoObject property (PSPDFKitInstant) for dynamic access
- Updated handler to use ParsePSPDFKitInstant instead of ParsePSPDFKitInstantJSON
- Improved JsonSerializerOptions for case-insensitive property handling
2025-10-13 16:56:00 +02:00
5e53f2b691 refactor(CreateAnnotationCommand): update to return IEnumerable<Signature> as result 2025-10-13 15:51:53 +02:00
f56928f44f feat(CreateAnnotationCommand): implement CreateAnnotationCommand and handler logic
Added full implementation for CreateAnnotationCommand and its handler:
- Introduced `PSPDFKitInstantJSON` property to the command
- Injected repositories for `Signature` and `Annotation`
- Implemented query filtering for Envelope and Receiver
- Added annotation creation from parsed PSPDFKit JSON
- Created helper method `ParsePSPDFKitInstantJSON` for JSON parsing
2025-10-13 15:28:38 +02:00
faa37e0dcd add CreateAnnotationCommandHandler without implementation 2025-10-13 11:17:50 +02:00
e51470a449 create AnnotationDto 2025-10-13 11:16:37 +02:00
adce61fead feat: add CreateAnnotationCommand record for annotation creation 2025-10-13 10:59:58 +02:00
e052bf56f4 feat(EGDbContext): add annotations mapping and clean up constructor initialization
- Added model configuration for Signature → Annotation relationship
- Removed redundant DbSet initializations from EGDbContextBase constructor
- Updated Config DbSet type from Domain.Entities.Config to Config
- Simplified using directives and removed unnecessary configuration imports
- Maintained existing trigger registration and entity configurations
2025-10-13 10:02:26 +02:00
22a7619627 feat(Signature): add Annotations navigation property to Signature entity
- Added `IEnumerable<Annotation>? Annotations` to Signature class
- Added `using System.Collections.Generic;` for .NET Framework builds
2025-10-13 09:48:24 +02:00
281cf47834 refactor(Annotation): rename Guid as Id
- convert type to long
2025-10-13 09:43:08 +02:00
a258dcdad0 feat(Annotation): add Annotation entity for document receiver element annotations
- Added Annotation entity mapped to table TBSIG_DOCUMENT_RECEIVER_ELEMENT_ANNOTATION
- Included data annotations for key, required fields, and relationships
- Added conditional compilation for .NET and .NET Framework compatibility
2025-10-13 09:40:41 +02:00
15 changed files with 300 additions and 38 deletions

View File

@@ -0,0 +1,146 @@
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Common.Query;
using EnvelopeGenerator.Domain.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;
using System.Dynamic;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace EnvelopeGenerator.Application.Annotations.Commands;
/// <summary>
///
/// </summary>
public record CreateAnnotationCommand : EnvelopeReceiverQueryBase, IRequest<IEnumerable<Signature>>
{
/// <summary>
///
/// </summary>
public CreateAnnotationCommand()
{
_lazyPSPDFKitInstant = new(() =>
{
var options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = null
};
return JsonSerializer.Deserialize<dynamic>(PSPDFKitInstantJSON, options) ?? new ExpandoObject();
});
}
/// <summary>
///
/// </summary>
[JsonIgnore]
public string PSPDFKitInstantJSON { get; set; } = null!;
private readonly Lazy<dynamic> _lazyPSPDFKitInstant;
/// <summary>
///
/// </summary>
[JsonIgnore]
public ExpandoObject PSPDFKitInstant => _lazyPSPDFKitInstant.Value;
}
/// <summary>
///
/// </summary>
public static class CreateAnnotationCommandExtensions
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="envelopeKey"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public static Task<IEnumerable<Signature>> CreateAnnotation(this ISender sender, string envelopeKey, CancellationToken cancel = default)
=> sender.Send(new CreateAnnotationCommand() { Key = envelopeKey }, cancel);
}
/// <summary>
///
/// </summary>
public class CreateAnnotationCommandHandler : IRequestHandler<CreateAnnotationCommand, IEnumerable<Signature>>
{
/// <summary>
///
/// </summary>
private readonly IRepository<Signature> _signRepo;
/// <summary>
///
/// </summary>
private readonly IRepository<Annotation> _annotRepo;
/// <summary>
///
/// </summary>
/// <param name="signRepo"></param>
/// <param name="annotRepo"></param>
public CreateAnnotationCommandHandler(IRepository<Signature> signRepo, IRepository<Annotation> annotRepo)
{
_signRepo = signRepo;
_annotRepo = annotRepo;
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <returns></returns>
public async Task<IEnumerable<Signature>> Handle(CreateAnnotationCommand request, CancellationToken cancel)
{
var query = _signRepo.Query;
#region Envelope Query
if (request.Envelope.Id is int envelopeId)
query = query.Where(annot => annot.Document.EnvelopeId == envelopeId);
if (request.Envelope.Uuid is string envelopeUuid)
query = query.Where(annot => annot.Document.Envelope!.Uuid == envelopeUuid);
#endregion
// Receiver Query
query = query.Where(request.Receiver);
var elements = await query.ToListAsync(cancel);
foreach (var element in elements)
{
var annots = ParsePSPDFKitInstant(request.PSPDFKitInstant, element.Id)
.Select(annot => new Annotation()
{
ElementId = element.Id,
Name = annot.Key,
Value = annot.Value,
AddedWhen = DateTime.UtcNow
});
element.Annotations = await _annotRepo.CreateAsync(annots, cancel);
}
return elements;
}
/// <summary>
///
/// </summary>
/// <param name="instant"></param>
/// <param name="elementId"></param>
/// <returns></returns>
public static Dictionary<string, string> ParsePSPDFKitInstant(ExpandoObject instant, int elementId)
{
Dictionary<string, string> annots = new();
// parse json here
return annots;
}
}

View File

@@ -0,0 +1,42 @@
namespace EnvelopeGenerator.Application.Common.Dto;
/// <summary>
///
/// </summary>
public record AnnotationDto
{
/// <summary>
///
/// </summary>
public long Id { get; init; }
/// <summary>
///
/// </summary>
public int ElementId { get; init; }
/// <summary>
///
/// </summary>
public string Name { get; init; } = null!;
/// <summary>
///
/// </summary>
public string Value { get; init; } = null!;
/// <summary>
///
/// </summary>
public DateTime AddedWhen { get; init; }
/// <summary>
///
/// </summary>
public DateTime? ChangedWhen { get; init; }
/// <summary>
///
/// </summary>
public string? ChangedWho { get; init; }
}

View File

@@ -35,6 +35,7 @@ public class MappingProfile : Profile
CreateMap<EnvelopeType, EnvelopeTypeDto>();
CreateMap<Domain.Entities.Receiver, ReceiverDto>();
CreateMap<Domain.Entities.EnvelopeReceiverReadOnly, EnvelopeReceiverReadOnlyDto>();
CreateMap<Annotation, AnnotationDto>();
// DTO to Entity mappings
CreateMap<ConfigDto, Config>();

View File

@@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.66" />
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.3.5" />
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.3.6" />
<PackageReference Include="DigitalData.Core.Application" Version="3.4.0" />
<PackageReference Include="DigitalData.Core.Client" Version="2.1.0" />
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />

View File

@@ -70,8 +70,8 @@
<Reference Include="DigitalData.Controls.DocumentViewer, Version=1.9.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Controls.DocumentViewer.1.9.8\lib\net462\DigitalData.Controls.DocumentViewer.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Core.Abstraction.Application, Version=1.3.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstraction.Application.1.3.5\lib\net462\DigitalData.Core.Abstraction.Application.dll</HintPath>
<Reference Include="DigitalData.Core.Abstraction.Application, Version=1.3.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstraction.Application.1.3.6\lib\net462\DigitalData.Core.Abstraction.Application.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Core.Abstractions, Version=4.1.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstractions.4.1.1\lib\net462\DigitalData.Core.Abstractions.dll</HintPath>

View File

@@ -3,7 +3,7 @@
<package id="AutoMapper" version="10.1.1" targetFramework="net462" />
<package id="BouncyCastle.Cryptography" version="2.5.0" targetFramework="net462" />
<package id="DigitalData.Controls.DocumentViewer" version="1.9.8" targetFramework="net462" />
<package id="DigitalData.Core.Abstraction.Application" version="1.3.5" targetFramework="net462" />
<package id="DigitalData.Core.Abstraction.Application" version="1.3.6" targetFramework="net462" />
<package id="DigitalData.Core.Abstractions" version="4.1.1" targetFramework="net462" />
<package id="DigitalData.Modules.Base" version="1.3.8" targetFramework="net462" />
<package id="DigitalData.Modules.Config" version="1.3.0" targetFramework="net462" />

View File

@@ -72,8 +72,8 @@
<Reference Include="DevExpress.XtraEditors.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.XtraGauges.v21.2.Core, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.XtraReports.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DigitalData.Core.Abstraction.Application, Version=1.3.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstraction.Application.1.3.5\lib\net462\DigitalData.Core.Abstraction.Application.dll</HintPath>
<Reference Include="DigitalData.Core.Abstraction.Application, Version=1.3.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstraction.Application.1.3.6\lib\net462\DigitalData.Core.Abstraction.Application.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Core.Abstractions, Version=4.1.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Core.Abstractions.4.1.1\lib\net462\DigitalData.Core.Abstractions.dll</HintPath>

View File

@@ -2,7 +2,7 @@
<packages>
<package id="AutoMapper" version="10.1.1" targetFramework="net462" />
<package id="BouncyCastle.Cryptography" version="2.5.0" targetFramework="net462" />
<package id="DigitalData.Core.Abstraction.Application" version="1.3.5" targetFramework="net462" />
<package id="DigitalData.Core.Abstraction.Application" version="1.3.6" targetFramework="net462" />
<package id="DigitalData.Core.Abstractions" version="4.1.1" targetFramework="net462" />
<package id="DigitalData.Modules.Base" version="1.3.8" targetFramework="net462" />
<package id="DigitalData.Modules.Config" version="1.3.0" targetFramework="net462" />

View File

@@ -0,0 +1,60 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;
#endif
namespace EnvelopeGenerator.Domain.Entities
#if NET
;
#elif NETFRAMEWORK
{
#endif
[Table("TBSIG_DOCUMENT_RECEIVER_ELEMENT_ANNOTATION")]
public class Annotation
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID", TypeName = "int")]
public long Id { get; set; }
[Required]
[Column("ELEMENT_ID", TypeName = "int")]
public int ElementId { get; set; }
[Required]
[Column("NAME", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string Name { get; set; }
[Required]
[Column("VALUE", TypeName = "nvarchar(max)")]
public string Value { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
[Column("CHANGED_WHO", TypeName = "nchar(100)")]
[StringLength(100)]
public string
#if NET
?
#endif
ChangedWho { get; set; }
[ForeignKey("ElementId")]
public virtual Signature
#if NET
?
#endif
Element { get; set; }
}
#if NETFRAMEWORK
}
#endif

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using EnvelopeGenerator.Domain.Interfaces;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System.Drawing;
@@ -14,7 +15,7 @@ namespace EnvelopeGenerator.Domain.Entities
#endif
[Table("TBSIG_ENVELOPE_DOCUMENT", Schema = "dbo")]
public class Document
public class Document : IHasEnvelope
{
public Document()
{
@@ -41,6 +42,13 @@ public class Document
[NotMapped]
public string Filepath { get; set; }
[ForeignKey("EnvelopeId")]
public virtual Envelope
#if NET
?
#endif
Envelope { get; set; }
#if NETFRAMEWORK
[NotMapped]
public string FileNameOriginal { get; set; }

View File

@@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;
using System.Collections.Generic;
#endif
namespace EnvelopeGenerator.Domain.Entities
@@ -14,7 +15,7 @@ namespace EnvelopeGenerator.Domain.Entities
#endif
[Table("TBSIG_DOCUMENT_RECEIVER_ELEMENT", Schema = "dbo")]
public class Signature : ISignature
public class Signature : ISignature, IHasReceiver
{
public Signature()
{
@@ -107,7 +108,18 @@ public class Signature : ISignature
public virtual Document Document { get; set; }
[ForeignKey("ReceiverId")]
public virtual Receiver Receiver { get; set; }
public virtual Receiver
#if NET
?
#endif
Receiver
{ get; set; }
public virtual IEnumerable<Annotation>
#if NET
?
#endif
Annotations { get; set; }
#if NETFRAMEWORK
[NotMapped]

View File

@@ -11,7 +11,6 @@ using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
using DigitalData.UserManager.Infrastructure;
using DigitalData.UserManager.Infrastructure.Contracts;
using DigitalData.Core.Client;
using EnvelopeGenerator.Application.Common.Configurations;
#elif NETFRAMEWORK
using System.Linq;
#endif
@@ -40,7 +39,7 @@ public abstract class EGDbContextBase : DbContext
, IUserManagerDbContext, IMailDbContext
#endif
{
public DbSet<Domain.Entities.Config> Configs { get; set; }
public DbSet<Config> Configs { get; set; }
public DbSet<EnvelopeReceiver> EnvelopeReceivers { get; set; }
@@ -98,27 +97,6 @@ public abstract class EGDbContextBase : DbContext
{
_triggers = triggerParamOptions.Value;
_logger = logger;
Configs = Set<Config>();
EnvelopeReceivers = Set<EnvelopeReceiver>();
Envelopes = Set<Envelope>();
DocumentReceiverElements = Set<Signature>();
DocumentStatus = Set<DocumentStatus>();
EnvelopeDocument = Set<Document>();
EnvelopeHistories = Set<History>();
EnvelopeTypes = Set<EnvelopeType>();
Receivers = Set<Receiver>();
GroupOfUsers = Set<GroupOfUser>();
Groups = Set<Group>();
ModuleOfUsers = Set<ModuleOfUser>();
Modules = Set<Module>();
Users = Set<User>();
UserReps = Set<UserRep>();
#if NET
EMailOuts = Set<EmailOut>();
#endif
EnvelopeReceiverReadOnlys = Set<EnvelopeReceiverReadOnly>();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
@@ -215,6 +193,13 @@ public abstract class EGDbContextBase : DbContext
.HasForeignKey(ds => ds.ReceiverId);
#endregion DocumentStatus
#region Annotation
modelBuilder.Entity<Signature>()
.HasMany(signature => signature.Annotations)
.WithOne(annot => annot.Element)
.HasForeignKey(annot => annot.ElementId);
#endregion
#region Trigger
// Configure entities to handle database triggers
void AddTrigger<T>() where T : class => _triggers

View File

@@ -22,8 +22,8 @@
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.66" />
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.3.5" />
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.4.3" />
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.3.6" />
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.4.4" />
<PackageReference Include="QuestPDF" Version="2025.7.1" />
</ItemGroup>

View File

@@ -20,7 +20,7 @@
<ItemGroup>
<PackageReference Include="Bogus" Version="35.6.3" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.3.5" />
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.3.6" />
<PackageReference Include="DigitalData.Core.Abstractions" Version="4.1.1" />
<PackageReference Include="DigitalData.Core.API" Version="2.2.1" />
<PackageReference Include="DigitalData.Core.Application" Version="3.4.0" />

View File

@@ -1,4 +1,5 @@
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Annotations.Commands;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Common.Notifications.RemoveSignature;
using MediatR;
using Microsoft.AspNetCore.Mvc;
@@ -27,4 +28,11 @@ public class TestAnnotationController : ControllerBase
await _mediator.Publish(new RemoveSignatureNotification(uuid));
return Ok();
}
[HttpPost("{envelopeKey}")]
public async Task<IActionResult> Create([FromRoute] string envelopeKey, CancellationToken cancel)
{
var annot = await _mediator.CreateAnnotation(envelopeKey, cancel);
return Ok(annot);
}
}