From ca3772e2a8903870286a489e3c80c7872c928e14 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 3 Nov 2026 20:42:21 +0100 Subject: [PATCH] Add CloseAsync method and WorkflowClosing entity Introduced a new method `CloseAsync` in the `IWorkflowRepository` interface to handle workflow item closure and return a procedure result. Added a new class `WorkflowClosing` in `WorkflowClosing.cs` as a sealed class inheriting from `ProcedureResultBase`. Updated `TaskFlowDbContext` to include a `DbSet` for keyless workflow close procedure results. Configured the `WorkflowClosing` entity in `OnModelCreating` with specific column mappings and a maximum length for the `Result` property. --- .../Common/Interfaces/IWorkflowRepository.cs | 20 +++++++++++++++++++ .../ProcedureResults/WorkflowClosing.cs | 5 +++++ .../Persistence/TaskFlowDbContext.cs | 13 ++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 src/core/DigitalData.TaskFlow.Domain/ProcedureResults/WorkflowClosing.cs diff --git a/src/core/DigitalData.TaskFlow.Application/Common/Interfaces/IWorkflowRepository.cs b/src/core/DigitalData.TaskFlow.Application/Common/Interfaces/IWorkflowRepository.cs index 5f122a3..4ae9111 100644 --- a/src/core/DigitalData.TaskFlow.Application/Common/Interfaces/IWorkflowRepository.cs +++ b/src/core/DigitalData.TaskFlow.Application/Common/Interfaces/IWorkflowRepository.cs @@ -14,4 +14,24 @@ public interface IWorkflowRepository : IRepository /// Cancellation token. /// Workflow data grouped by source. Task GetByWisagIdAsync(int wisagId, CancellationToken cancellationToken); + + /// + /// Closes a workflow item and returns procedure result code/message. + /// + /// Internal user identifier expected by the procedure. + /// Source system identifier. + /// Process identifier. + /// Closing method identifier. + /// Optional comment. + /// Optional rejection reason identifier. + /// Cancellation token. + /// Close operation result. + Task CloseAsync( + int userId, + string source, + long processId, + int closingMethodId, + string? comment, + byte? rejectionReasonId, + CancellationToken cancellationToken); } diff --git a/src/core/DigitalData.TaskFlow.Domain/ProcedureResults/WorkflowClosing.cs b/src/core/DigitalData.TaskFlow.Domain/ProcedureResults/WorkflowClosing.cs new file mode 100644 index 0000000..b01d7fc --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/ProcedureResults/WorkflowClosing.cs @@ -0,0 +1,5 @@ +namespace DigitalData.TaskFlow.Domain.ProcedureResults; + +public sealed class WorkflowClosing : ProcedureResultBase +{ +} diff --git a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Persistence/TaskFlowDbContext.cs b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Persistence/TaskFlowDbContext.cs index 20b3bc1..3f406fc 100644 --- a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Persistence/TaskFlowDbContext.cs +++ b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Persistence/TaskFlowDbContext.cs @@ -18,6 +18,11 @@ public sealed class TaskFlowDbContext(DbContextOptions option /// public DbSet Documents => Set(); + /// + /// Gets the keyless result model used for workflow close procedure results. + /// + public DbSet WorkflowClosings => Set(); + protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -37,5 +42,13 @@ public sealed class TaskFlowDbContext(DbContextOptions option entity.Property(x => x.Code).HasColumnName("CODE").HasColumnType("int"); entity.Property(x => x.Result).HasColumnName("RESULT").HasColumnType("nvarchar(max)"); }); + + modelBuilder.Entity(entity => + { + entity.HasNoKey(); + entity.ToView(null); + entity.Property(x => x.Code).HasColumnName("CODE").HasColumnType("int"); + entity.Property(x => x.Result).HasColumnName("RESULT").HasColumnType("nvarchar(400)"); + }); } }