Compare commits

...

24 Commits

Author SHA1 Message Date
307c81001a Update project version to 1.4.0-beta
Updated the `DigitalData.TaskFlow.API` project version from `1.3.0-beta` to `1.4.0-beta`. This includes updates to the `FileVersion` and `AssemblyVersion` from `1.3.0.0` to `1.4.0.0`, reflecting a new release with potential new features, improvements, or fixes.
2026-11-09 16:15:17 +01:00
9c5346213e Add GetAuthorizedUsersQuery and UsersController
Introduced the `GetAuthorizedUsersQuery` feature to retrieve
authorized users, including the query, result, metadata, and
handler implementation. The handler interacts with the
`IUserRepository` to fetch user data.

Added a new `UsersController` with an `[HttpGet("authorized")]`
endpoint to expose the query via a RESTful API. The endpoint
returns appropriate HTTP status codes (`200 OK`, `401
Unauthorized`, `500 Internal Server Error`) based on the
result metadata.

Included necessary `using` directives for MediatR, ASP.NET
Core, and application features.
2026-11-09 15:59:09 +01:00
6542d804f8 Add IUserRepository and implement UserRepository
Added the `IUserRepository` interface to define a method for retrieving authorized users asynchronously. Registered `IUserRepository` with its implementation `UserRepository` in the dependency injection container. Implemented `UserRepository` to execute a stored procedure and fetch authorized users using `TaskFlowDbContext`.
2026-11-09 15:15:16 +01:00
f470367d89 Add AuthorizedUser entity and DbSet to TaskFlowDbContext
A new `DbSet` property `AuthorizedUsers` was added to the
`TaskFlowDbContext` class to represent keyless results for
authorized users procedure results.

The `OnModelCreating` method was updated to configure the
`AuthorizedUser` entity as keyless, map it to a database view,
and define the `WisagId` property mapping.

Additionally, a new `AuthorizedUser` class was introduced in
the `DigitalData.TaskFlow.Domain.ProcedureResults` namespace
with an immutable `WisagId` property.
2026-11-09 15:07:13 +01:00
6ec2187361 Update project version to 1.3.0-beta
Updated the `DigitalData.TaskFlow.API` project version from `1.2.0-beta` to `1.3.0-beta`. This includes updates to the `FileVersion` and `AssemblyVersion` from `1.2.0.0` to `1.3.0.0`, reflecting a new release with potential new features, improvements, or changes.
2026-11-09 15:01:56 +01:00
8c6102d161 Refactor workflow closure logic and enhance API
Updated `CloseWorkflowCommand` to use nullable `Code` and `Message` properties for better result representation. Refactored `CloseWorkflowCommandHandler` to use a capitalized `Repo` and improved exception handling with `InvalidWorkflowPayloadException`. Enhanced `WorkflowsController` by implementing the `CloseAsync` method, which now processes `CloseWorkflowReqBody` and returns appropriate HTTP status codes. Updated XML documentation for clarity.
2026-11-04 10:07:33 +01:00
3c3744c0ce Add CloseWorkflowReqBody and CloseWorkflowReqResponse
Introduce two new classes in the DigitalData.TaskFlow.API.Models namespace to handle workflow closure requests and responses.

- CloseWorkflowReqBody.cs:
  - Added CloseWorkflowReqBody class with properties:
    - ClosingMethodId: int, mapped to "closing_method_id".
    - Comment: nullable string.
    - RejectionReasonId: nullable byte, mapped to "rejection_reason_id".

- CloseWorkflowReqResponse.cs:
  - Added CloseWorkflowReqResponse class with Meta property:
    - Meta: List of CloseWorkflowResult, initialized to an empty list.
2026-11-04 10:07:03 +01:00
46da385b92 Add CloseWorkflowCommandHandler for workflow closure
Introduce CloseWorkflowCommandHandler class to handle the
closure of workflows using the MediatR library. This class
implements IRequestHandler and processes CloseWorkflowCommand
requests, returning CloseWorkflowResult objects. It interacts
with IWorkflowRepository to execute the CloseAsync method,
validating the procedure result and throwing an exception if
the result is invalid. Necessary using directives for
DigitalData.TaskFlow.Application.Common.Interfaces and MediatR
are also added.
2026-11-03 20:57:45 +01:00
210c1f414c Add CloseAsync method to WorkflowRepository
Introduced a new asynchronous method `CloseAsync` in the
`WorkflowRepository` class to handle workflow process closing.
This method executes the `PRCUST_F19_CLOSING` stored procedure
with parameters for user ID, source, process ID, closing method
ID, comment, and rejection reason ID. It uses `FromSqlInterpolated`
for safe SQL parameterization and retrieves results with
`AsNoTracking()` and `ToListAsync(cancellationToken)`. The method
returns the first result as a `WorkflowClosing` object or `null`.
2026-11-03 20:44:08 +01:00
ca3772e2a8 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<WorkflowClosing>`
for keyless workflow close procedure results. Configured the
`WorkflowClosing` entity in `OnModelCreating` with specific
column mappings and a maximum length for the `Result` property.
2026-11-03 20:42:21 +01:00
a01e61aafe Add CloseWorkflowCommand with MediatR support
Introduce CloseWorkflowCommand and CloseWorkflowResult records
in CloseWorkflowCommand.cs within the DigitalData.TaskFlow
namespace. The command encapsulates data for closing a workflow,
including WisagId, Source, ProcessId, ClosingMethodId, Comment,
and RejectionReasonId. The result record provides ResultCode and
ResultMessage to convey the operation's outcome. These changes
utilize MediatR, aligning with the CQRS pattern for state
modification.
2026-11-03 20:34:34 +01:00
f3784d24bd Set API key in appsettings for all environments
Updated the `appsettings.Development.json` and `appsettings.json` files to replace the `ApiKey` value from `null` to `"jGXP7m536fnyTVCh4NROu1wgjaSOrJ5"`. This ensures that a specific API key is used in both development and production environments.
2026-10-31 22:56:32 +01:00
7d032c4a2c Update project version to 1.2.0-beta
The versioning information for the `DigitalData.TaskFlow.API` project has been updated. The `<Version>`, `<FileVersion>`, and `<AssemblyVersion>` elements have been incremented from `1.1.0-beta` to `1.2.0-beta`, and from `1.1.0.0` to `1.2.0.0` respectively. This minor version update likely includes new features or improvements that maintain backward compatibility.
2026-10-31 21:26:20 +01:00
1a6baef807 Add new endpoint and improve exception handling
Removed the `asByte` parameter from XML documentation in `DocumentController.cs`, indicating the method no longer supports byte array returns. Added a new HTTP POST endpoint `CloseAsync` in `WorkflowsController.cs`, which is currently not implemented and throws a `NotImplementedException`. Enhanced `ExceptionHandlingMiddleware.cs` to handle `NotImplementedException` by logging a warning and returning a `501 Not Implemented` response in a problem details format.
2026-10-31 21:25:49 +01:00
b35017fddc chore: update solution and remove obsolete documentation 2026-10-31 17:09:46 +01:00
893b063ae9 refactor(api): update document endpoints and middleware contracts 2026-10-31 17:09:33 +01:00
9b60f5116b refactor(infrastructure): align persistence with procedure result models 2026-10-31 17:09:21 +01:00
11ebb0567a refactor(application): update workflow queries and exception handling 2026-10-31 17:09:16 +01:00
12cb46d054 refactor(domain): replace workflow aggregates with procedure results 2026-10-31 17:09:10 +01:00
e00be89d1a Add CustDocBase64 entity and integrate into DbContext
Introduce a new entity class `CustDocBase64` mapped to the
`TBCUST_DOC_BASE64` table in the `dbo` schema. This class includes
properties for various document attributes. Update `TaskFlowDbContext`
to include a `DbSet<CustDocBase64>` for querying and interacting with
the table. Configure the entity in `OnModelCreating` to have no key
and map it to the appropriate table and schema.
2026-10-27 15:45:31 +01:00
569bf360e6 Update project version to 1.1.0
The versioning information for the DigitalData.TaskFlow.API project has been updated. The <Version>, <FileVersion>, and <AssemblyVersion> elements have been incremented from 1.0.0-beta, 1.0.0.0, and 1.0.0.0 respectively to 1.1.0-beta, 1.1.0.0, and 1.1.0.0. This indicates a minor version update, suggesting that new features or improvements have been added to the project while maintaining backward compatibility.
2026-10-26 11:46:37 +01:00
405215a8bf Enhance validation and data reading logic
Add validation in CloseWorkflowCommandHandler to reject "Contracts" as a source for closing operations. Modify ReadArray in WorkflowRepository to accept multiple property names, improving flexibility in data retrieval. Refactor database reader logic to extract JSON payloads more robustly, iterating over all fields and results.
2026-10-26 10:12:02 +01:00
232491d4ac Update development ports in launchSettings.json
Updated the `applicationUrl` property in the `https` profile of
`launchSettings.json` to use new ports:
- Changed `https://localhost:7049` to `https://localhost:7050`
- Changed `http://localhost:5298` to `http://localhost:5299`

This ensures the application runs on the updated ports during
development.
2026-10-20 11:21:46 +02:00
d07bc2418b Add API key authentication middleware support
Introduced `ApiKeyAuthOptions` for API key configuration,
including a `Key` property and `SectionName` for binding.
Updated `ApiKeyAuthMiddleware` to validate the `X-Api-Key`
header against the configured API key.

Added conditional middleware application in `Program.cs`
based on the presence of a configured API key. Bound the
`ApiKey` section in `appsettings.json` and
`appsettings.Development.json` to store the API key, with
a default value of `null`. This improves security and
centralizes API key management.
2026-10-20 11:21:18 +02:00
75 changed files with 663 additions and 1865 deletions

View File

@@ -1,30 +0,0 @@
# AGENTS
## Repo Snapshot (verified)
- This is a .NET 8 solution with 4 projects: API (`src/presentation/DigitalData.TaskFlow.API`), Application, Domain, Infrastructure.
- `Program.cs` only wires DI + Swagger + `MapControllers`; there are currently no controller classes, so no HTTP endpoints are exposed yet.
- There is no test project in the repository right now.
## High-value Commands
- Restore/build whole solution from repo root:
- `dotnet restore DigitalData.TaskFlow.sln`
- `dotnet build DigitalData.TaskFlow.sln`
- Run API project:
- `dotnet run --project src/presentation/DigitalData.TaskFlow.API/DigitalData.TaskFlow.API.csproj`
- Focused build for one layer:
- `dotnet build src/core/DigitalData.TaskFlow.Application/DigitalData.TaskFlow.Application.csproj`
## Architecture That Matters During Edits
- Dependency direction is strict: `API -> Application -> Domain`; `Infrastructure` depends on `Application` + `Domain` and is injected by API.
- Application layer uses MediatR + FluentValidation pipeline behavior (`ValidationBehavior<,>`) + AutoMapper profile (`ApplicationMappingProfile`).
- Response contract is centralized in Domain `ApiEnvelope<T>` + `MetaEntry`; use `ApiEnvelopeFactory` for consistent `meta.code/message` mapping.
- Infrastructure registers `TaskFlowDbContext` and repository interfaces in `DependencyInjection.cs`; missing `ConnectionStrings:TaskFlowDb` throws at startup.
- DB row-shape models (for procedures/views) live in Infrastructure (`Persistence/Models`), not in Domain.
## Current Implementation Gaps (easy to miss)
- `DocumentRepository` and `WorkflowRepository.CloseAsync` are still baseline/stub implementations returning placeholder data.
- `WorkflowListingReadModel` column mapping is based on read-only DB metadata and observed SP result sets; final shape must be re-verified from DB metadata (`sp_describe_first_result_set` or equivalent) before production hardening.
- `Swagger:EnabledInProduction` exists in config model but is not used in `Program.cs` yet.
## Config/Security Gotcha
- `src/presentation/DigitalData.TaskFlow.API/appsettings.json` currently contains a concrete SQL connection string and a MediatR license key; treat this file as sensitive and avoid propagating those values in docs, logs, or commits.

View File

@@ -1,23 +1,28 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59 VisualStudioVersion = 17.14.36717.8
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalData.TaskFlow.API", "src\presentation\DigitalData.TaskFlow.API\DigitalData.TaskFlow.API.csproj", "{C0F3BD78-47FF-4320-A139-99D42648BA6B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "presentation", "presentation", "{BC4CBCBB-D810-4AA5-855C-C9E8FDADA008}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "presentation", "presentation", "{4F1A8452-FAEC-4EE4-87A3-DB0AF05B780F}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{06231918-0EB3-49B0-B6CA-2A441D58B02F}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
EndProjectSection
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "infrastructure", "infrastructure", "{FD60D353-ABC5-4C93-92E5-069EE28B452E}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{C3F5466A-4F6B-4DF3-B594-2B4FE943AC1E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalData.TaskFlow.API", "src\presentation\DigitalData.TaskFlow.API\DigitalData.TaskFlow.API.csproj", "{DAECF4CE-7AE3-4DBE-8D32-F5F2B4EC8AEC}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalData.TaskFlow.Domain", "src\core\DigitalData.TaskFlow.Domain\DigitalData.TaskFlow.Domain.csproj", "{42B3A931-DDB1-4648-9EFA-9812354C6982}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalData.TaskFlow.Domain", "src\core\DigitalData.TaskFlow.Domain\DigitalData.TaskFlow.Domain.csproj", "{EA5328FE-D015-4DAF-838D-57B4218ADA15}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "infrastructure", "infrastructure", "{9C44DE52-84B0-4441-9419-E810762D195D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalData.TaskFlow.Application", "src\core\DigitalData.TaskFlow.Application\DigitalData.TaskFlow.Application.csproj", "{104944BD-55C2-458C-B0C6-1B41C84B2C08}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalData.TaskFlow.Infrastructure", "src\infrastructure\DigitalData.TaskFlow.Infrastructure\DigitalData.TaskFlow.Infrastructure.csproj", "{D414DF56-EBE6-4972-B76C-4004F1CEA812}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalData.TaskFlow.Infrastructure", "src\infrastructure\DigitalData.TaskFlow.Infrastructure\DigitalData.TaskFlow.Infrastructure.csproj", "{D4459BE4-B483-46E8-9052-523646D24B90}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalData.TaskFlow.Application", "src\core\DigitalData.TaskFlow.Application\DigitalData.TaskFlow.Application.csproj", "{FAC8E4F4-C0B2-4582-A5CE-A8BC76A135B8}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -25,36 +30,36 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DAECF4CE-7AE3-4DBE-8D32-F5F2B4EC8AEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C0F3BD78-47FF-4320-A139-99D42648BA6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DAECF4CE-7AE3-4DBE-8D32-F5F2B4EC8AEC}.Debug|Any CPU.Build.0 = Debug|Any CPU {C0F3BD78-47FF-4320-A139-99D42648BA6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAECF4CE-7AE3-4DBE-8D32-F5F2B4EC8AEC}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0F3BD78-47FF-4320-A139-99D42648BA6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAECF4CE-7AE3-4DBE-8D32-F5F2B4EC8AEC}.Release|Any CPU.Build.0 = Release|Any CPU {C0F3BD78-47FF-4320-A139-99D42648BA6B}.Release|Any CPU.Build.0 = Release|Any CPU
{EA5328FE-D015-4DAF-838D-57B4218ADA15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {42B3A931-DDB1-4648-9EFA-9812354C6982}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA5328FE-D015-4DAF-838D-57B4218ADA15}.Debug|Any CPU.Build.0 = Debug|Any CPU {42B3A931-DDB1-4648-9EFA-9812354C6982}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA5328FE-D015-4DAF-838D-57B4218ADA15}.Release|Any CPU.ActiveCfg = Release|Any CPU {42B3A931-DDB1-4648-9EFA-9812354C6982}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA5328FE-D015-4DAF-838D-57B4218ADA15}.Release|Any CPU.Build.0 = Release|Any CPU {42B3A931-DDB1-4648-9EFA-9812354C6982}.Release|Any CPU.Build.0 = Release|Any CPU
{104944BD-55C2-458C-B0C6-1B41C84B2C08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D414DF56-EBE6-4972-B76C-4004F1CEA812}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{104944BD-55C2-458C-B0C6-1B41C84B2C08}.Debug|Any CPU.Build.0 = Debug|Any CPU {D414DF56-EBE6-4972-B76C-4004F1CEA812}.Debug|Any CPU.Build.0 = Debug|Any CPU
{104944BD-55C2-458C-B0C6-1B41C84B2C08}.Release|Any CPU.ActiveCfg = Release|Any CPU {D414DF56-EBE6-4972-B76C-4004F1CEA812}.Release|Any CPU.ActiveCfg = Release|Any CPU
{104944BD-55C2-458C-B0C6-1B41C84B2C08}.Release|Any CPU.Build.0 = Release|Any CPU {D414DF56-EBE6-4972-B76C-4004F1CEA812}.Release|Any CPU.Build.0 = Release|Any CPU
{D4459BE4-B483-46E8-9052-523646D24B90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FAC8E4F4-C0B2-4582-A5CE-A8BC76A135B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4459BE4-B483-46E8-9052-523646D24B90}.Debug|Any CPU.Build.0 = Debug|Any CPU {FAC8E4F4-C0B2-4582-A5CE-A8BC76A135B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4459BE4-B483-46E8-9052-523646D24B90}.Release|Any CPU.ActiveCfg = Release|Any CPU {FAC8E4F4-C0B2-4582-A5CE-A8BC76A135B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4459BE4-B483-46E8-9052-523646D24B90}.Release|Any CPU.Build.0 = Release|Any CPU {FAC8E4F4-C0B2-4582-A5CE-A8BC76A135B8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{BC4CBCBB-D810-4AA5-855C-C9E8FDADA008} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {C0F3BD78-47FF-4320-A139-99D42648BA6B} = {4F1A8452-FAEC-4EE4-87A3-DB0AF05B780F}
{06231918-0EB3-49B0-B6CA-2A441D58B02F} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {4F1A8452-FAEC-4EE4-87A3-DB0AF05B780F} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{FD60D353-ABC5-4C93-92E5-069EE28B452E} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {C3F5466A-4F6B-4DF3-B594-2B4FE943AC1E} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{DAECF4CE-7AE3-4DBE-8D32-F5F2B4EC8AEC} = {BC4CBCBB-D810-4AA5-855C-C9E8FDADA008} {42B3A931-DDB1-4648-9EFA-9812354C6982} = {C3F5466A-4F6B-4DF3-B594-2B4FE943AC1E}
{EA5328FE-D015-4DAF-838D-57B4218ADA15} = {06231918-0EB3-49B0-B6CA-2A441D58B02F} {9C44DE52-84B0-4441-9419-E810762D195D} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{104944BD-55C2-458C-B0C6-1B41C84B2C08} = {06231918-0EB3-49B0-B6CA-2A441D58B02F} {D414DF56-EBE6-4972-B76C-4004F1CEA812} = {9C44DE52-84B0-4441-9419-E810762D195D}
{D4459BE4-B483-46E8-9052-523646D24B90} = {FD60D353-ABC5-4C93-92E5-069EE28B452E} {FAC8E4F4-C0B2-4582-A5CE-A8BC76A135B8} = {C3F5466A-4F6B-4DF3-B594-2B4FE943AC1E}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {95DC4052-26B6-44D1-8B13-9D934628204D} SolutionGuid = {9CDB06DD-EB59-4309-8B48-B34F488F9D2F}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@@ -1,2 +0,0 @@
# DigitalData.TaskFlow

View File

@@ -1,32 +0,0 @@
using DigitalData.TaskFlow.Domain.Enums;
namespace DigitalData.TaskFlow.Application.Common.Exceptions;
/// <summary>
/// Represents an API-facing exception that carries HTTP and domain meta information.
/// </summary>
public class ApiException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
/// <param name="statusCode">HTTP status code to return.</param>
/// <param name="metaCode">Domain meta code to return.</param>
/// <param name="message">Response message.</param>
public ApiException(int statusCode, MetaCode metaCode, string message)
: base(message)
{
StatusCode = statusCode;
MetaCode = metaCode;
}
/// <summary>
/// Gets the HTTP status code.
/// </summary>
public int StatusCode { get; }
/// <summary>
/// Gets the domain meta code.
/// </summary>
public MetaCode MetaCode { get; }
}

View File

@@ -1,19 +0,0 @@
using DigitalData.TaskFlow.Domain.Enums;
namespace DigitalData.TaskFlow.Application.Common.Exceptions;
/// <summary>
/// Represents a 409 API exception.
/// </summary>
public sealed class ConflictApiException : ApiException
{
/// <summary>
/// Initializes a new instance of the <see cref="ConflictApiException"/> class.
/// </summary>
/// <param name="metaCode">Domain meta code to return.</param>
/// <param name="message">Response message.</param>
public ConflictApiException(MetaCode metaCode, string message)
: base(409, metaCode, message)
{
}
}

View File

@@ -1,18 +0,0 @@
using DigitalData.TaskFlow.Domain.Enums;
namespace DigitalData.TaskFlow.Application.Common.Exceptions;
/// <summary>
/// Represents a 403 API exception.
/// </summary>
public sealed class ForbiddenApiException : ApiException
{
/// <summary>
/// Initializes a new instance of the <see cref="ForbiddenApiException"/> class.
/// </summary>
/// <param name="message">Response message.</param>
public ForbiddenApiException(string message)
: base(403, MetaCode.NoAccess, message)
{
}
}

View File

@@ -1,18 +0,0 @@
using DigitalData.TaskFlow.Domain.Enums;
namespace DigitalData.TaskFlow.Application.Common.Exceptions;
/// <summary>
/// Represents a 400 API exception.
/// </summary>
public sealed class InvalidRequestApiException : ApiException
{
/// <summary>
/// Initializes a new instance of the <see cref="InvalidRequestApiException"/> class.
/// </summary>
/// <param name="message">Response message.</param>
public InvalidRequestApiException(string message)
: base(400, MetaCode.InvalidRequest, message)
{
}
}

View File

@@ -0,0 +1,5 @@
namespace DigitalData.TaskFlow.Application.Common.Exceptions;
public sealed class InvalidWorkflowPayloadException(string message) : Exception(message)
{
}

View File

@@ -1,18 +0,0 @@
using DigitalData.TaskFlow.Domain.Enums;
namespace DigitalData.TaskFlow.Application.Common.Exceptions;
/// <summary>
/// Represents a 404 API exception.
/// </summary>
public sealed class NotFoundApiException : ApiException
{
/// <summary>
/// Initializes a new instance of the <see cref="NotFoundApiException"/> class.
/// </summary>
/// <param name="message">Response message.</param>
public NotFoundApiException(string message)
: base(404, MetaCode.NotFound, message)
{
}
}

View File

@@ -1,49 +0,0 @@
using DigitalData.TaskFlow.Domain.Common;
using DigitalData.TaskFlow.Domain.Enums;
namespace DigitalData.TaskFlow.Application.Common.Factories;
/// <summary>
/// Creates standard API envelope instances with centralized meta code/message handling.
/// </summary>
public static class ApiEnvelopeFactory
{
/// <summary>
/// Creates a successful or business-result response envelope.
/// </summary>
/// <typeparam name="T">Payload type.</typeparam>
/// <param name="data">Payload data.</param>
/// <param name="code">Business result code.</param>
/// <param name="message">Optional custom message. If not supplied, a default message is resolved from <paramref name="code"/>.</param>
/// <returns>Response envelope containing meta and payload.</returns>
public static ApiEnvelope<T> Create<T>(T data, MetaCode code = MetaCode.Ok, string? message = null)
{
return new ApiEnvelope<T>
{
Meta =
[
new MetaEntry
{
Code = (int)code,
Message = message ?? ResolveDefaultMessage(code)
}
],
Data = data
};
}
private static string ResolveDefaultMessage(MetaCode code)
{
return code switch
{
MetaCode.Ok => "OK",
MetaCode.NoOpenWorkflows => "Keine offenen Workflows",
MetaCode.NoAccess => "Kein Zugriff",
MetaCode.InvalidRequest => "Ungultiger Request",
MetaCode.InternalError => "Interner Fehler",
MetaCode.NotFound => "Vorgang nicht gefunden",
MetaCode.AlreadyClosed => "Vorgang bereits abgeschlossen",
_ => "Interner Fehler"
};
}
}

View File

@@ -1,17 +1,13 @@
using DigitalData.TaskFlow.Domain.Documents; using DigitalData.TaskFlow.Domain.ProcedureResults;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DigitalData.TaskFlow.Application.Common.Interfaces; namespace DigitalData.TaskFlow.Application.Common.Interfaces;
/// <summary> public interface IDocumentRepository
/// Defines document-specific data access operations.
/// </summary>
public interface IDocumentRepository : IRepository
{ {
/// <summary> Task<Document?> GetAsync(int userId, long processId, long docId, CancellationToken cancellationToken);
/// Gets document binary content for the given document identifier.
/// </summary>
/// <param name="id">Document identifier.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Binary document payload when found; otherwise <see langword="null"/>.</returns>
Task<DocumentBinaryResult?> GetAsync(string id, CancellationToken cancellationToken);
} }

View File

@@ -0,0 +1,8 @@
using DigitalData.TaskFlow.Domain.ProcedureResults;
namespace DigitalData.TaskFlow.Application.Common.Interfaces;
public interface IUserRepository : IRepository
{
Task<IEnumerable<AuthorizedUser>> GetAuthorizedAsync(CancellationToken cancellationToken);
}

View File

@@ -1,5 +1,4 @@
using DigitalData.TaskFlow.Domain.Closing; using DigitalData.TaskFlow.Domain.ProcedureResults;
using DigitalData.TaskFlow.Domain.Workflows;
namespace DigitalData.TaskFlow.Application.Common.Interfaces; namespace DigitalData.TaskFlow.Application.Common.Interfaces;
@@ -14,21 +13,25 @@ public interface IWorkflowRepository : IRepository
/// <param name="wisagId">WISAG user identifier.</param> /// <param name="wisagId">WISAG user identifier.</param>
/// <param name="cancellationToken">Cancellation token.</param> /// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Workflow data grouped by source.</returns> /// <returns>Workflow data grouped by source.</returns>
Task<WorkflowSourcesResponse> GetAsync(int wisagId, CancellationToken cancellationToken); Task<Workflow?> GetByWisagIdAsync(int wisagId, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Applies a closing decision to a workflow process. /// Closes a workflow item and returns procedure result code/message.
/// </summary> /// </summary>
/// <param name="wisagId">WISAG user identifier.</param> /// <param name="userId">Internal user identifier expected by the procedure.</param>
/// <param name="source">Source system name.</param> /// <param name="source">Source system identifier.</param>
/// <param name="processId">Process identifier.</param> /// <param name="processId">Process identifier.</param>
/// <param name="decision">Closing decision payload.</param> /// <param name="closingMethodId">Closing method identifier.</param>
/// <param name="comment">Optional comment.</param>
/// <param name="rejectionReasonId">Optional rejection reason identifier.</param>
/// <param name="cancellationToken">Cancellation token.</param> /// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Closing operation result.</returns> /// <returns>Close operation result.</returns>
Task<CloseWorkflowResult> CloseAsync( Task<WorkflowClosing?> CloseAsync(
int wisagId, int userId,
string source, string source,
int processId, long processId,
CloseWorkflowDecision decision, int closingMethodId,
string? comment,
byte? rejectionReasonId,
CancellationToken cancellationToken); CancellationToken cancellationToken);
} }

View File

@@ -1,19 +0,0 @@
using AutoMapper;
using DigitalData.TaskFlow.Application.Features.Workflows.Commands.CloseWorkflow;
using DigitalData.TaskFlow.Domain.Closing;
namespace DigitalData.TaskFlow.Application.Common.Mappings;
/// <summary>
/// Defines AutoMapper configuration for application-level mappings.
/// </summary>
public sealed class ApplicationMappingProfile : Profile
{
/// <summary>
/// Initializes mapping configuration.
/// </summary>
public ApplicationMappingProfile()
{
CreateMap<CloseWorkflowCommand, CloseWorkflowDecision>();
}
}

View File

@@ -1,5 +1,4 @@
using DigitalData.TaskFlow.Application.Options; using FluentValidation;
using FluentValidation;
using MediatR; using MediatR;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@@ -10,29 +9,30 @@ namespace DigitalData.TaskFlow.Application;
public static class DependencyInjection public static class DependencyInjection
{ {
public const string LuckyPennySoftLicenseKeySection = "LuckyPennySoftLicenseKey";
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration configuration) public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration configuration)
{ {
var mediatROptions = configuration var lpSoftLicenseKey = configuration[LuckyPennySoftLicenseKeySection];
.GetSection(MediatROptions.SectionName) var hasLpSoftLicenseKey = !string.IsNullOrWhiteSpace(lpSoftLicenseKey);
.Get<MediatROptions>();
services var assembly = Assembly.GetExecutingAssembly();
.AddOptions<MediatROptions>()
.Bind(configuration.GetSection(MediatROptions.SectionName));
services.AddMediatR(config => services.AddMediatR(config =>
{ {
config.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly); config.RegisterServicesFromAssembly(assembly);
if (!string.IsNullOrWhiteSpace(mediatROptions?.LuckyPennySoftLicenseKey)) if (hasLpSoftLicenseKey)
{ config.LicenseKey = lpSoftLicenseKey;
config.LicenseKey = mediatROptions.LuckyPennySoftLicenseKey;
}
}); });
services.AddValidatorsFromAssembly(typeof(DependencyInjection).Assembly); services.AddValidatorsFromAssembly(assembly);
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
services.AddAutoMapper(_ => { }, Assembly.GetExecutingAssembly()); services.AddAutoMapper(config =>
{
if (hasLpSoftLicenseKey)
config.LicenseKey = lpSoftLicenseKey;
}, assembly);
return services; return services;
} }

View File

@@ -1,56 +0,0 @@
using DigitalData.TaskFlow.Application.Common.Factories;
using DigitalData.TaskFlow.Application.Common.Exceptions;
using DigitalData.TaskFlow.Application.Common.Interfaces;
using DigitalData.TaskFlow.Domain.Common;
using DigitalData.TaskFlow.Domain.Documents;
using DigitalData.TaskFlow.Domain.Enums;
using FluentValidation;
using MediatR;
namespace DigitalData.TaskFlow.Application.Features.Documents.Queries.GetDocument;
/// <summary>
/// Represents a request to retrieve binary document content by document identifier.
/// </summary>
/// <param name="Id">Document identifier.</param>
public sealed record GetDocumentQuery(string Id) : IRequest<ApiEnvelope<DocumentBinaryResult>>;
/// <summary>
/// Validates <see cref="GetDocumentQuery"/> requests.
/// </summary>
public sealed class GetDocumentQueryValidator : AbstractValidator<GetDocumentQuery>
{
/// <summary>
/// Initializes validation rules for <see cref="GetDocumentQuery"/>.
/// </summary>
public GetDocumentQueryValidator()
{
RuleFor(x => x.Id)
.NotEmpty();
}
}
/// <summary>
/// Handles <see cref="GetDocumentQuery"/> requests.
/// </summary>
public sealed class GetDocumentQueryHandler(IDocumentRepository documentRepository)
: IRequestHandler<GetDocumentQuery, ApiEnvelope<DocumentBinaryResult>>
{
/// <summary>
/// Executes the query and returns binary document data in the standard API envelope.
/// </summary>
/// <param name="request">Query request.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Document response envelope.</returns>
public async Task<ApiEnvelope<DocumentBinaryResult>> Handle(GetDocumentQuery request, CancellationToken cancellationToken)
{
var document = await documentRepository.GetAsync(request.Id, cancellationToken);
if (document is null)
{
throw new NotFoundApiException("Dokument nicht gefunden");
}
return ApiEnvelopeFactory.Create(document);
}
}

View File

@@ -0,0 +1,37 @@
using DigitalData.TaskFlow.Application.Common.Exceptions;
using DigitalData.TaskFlow.Application.Common.Interfaces;
using MediatR;
using System.Text.Json;
namespace DigitalData.TaskFlow.Application.Features.Documents.Queries;
/// <summary>
///
/// </summary>
/// <param name="UserId"></param>
/// <param name="ProcessId"></param>
/// <param name="Id"></param>
public sealed record GetDocumentQuery(int UserId, long ProcessId, long Id) : IRequest<JsonElement>;
public sealed class GetDocumentQueryHandler(IDocumentRepository Repo) : IRequestHandler<GetDocumentQuery, JsonElement>
{
public async Task<JsonElement> Handle(GetDocumentQuery request, CancellationToken cancellationToken)
{
var document = await Repo.GetAsync(userId: request.UserId, processId: request.ProcessId, docId: request.Id, cancellationToken);
if (!string.IsNullOrWhiteSpace(document?.Result))
{
using var doc = JsonDocument.Parse(document.Result);
var root = doc.RootElement;
if (root.ValueKind == JsonValueKind.Object &&
root.TryGetProperty("response", out var response))
{
return response.Clone();
}
}
throw new InvalidWorkflowPayloadException(
"Stored procedure returned an invalid payload. Expected a JSON object with a 'response' property.");
}
}

View File

@@ -0,0 +1,22 @@
using DigitalData.TaskFlow.Application.Common.Interfaces;
using MediatR;
namespace DigitalData.TaskFlow.Application.Features.Users.Queries;
public sealed record GetAuthorizedUsersQuery : IRequest<GetAuthorizedUsersResult>;
public sealed record GetAuthorizedUsersResult(IEnumerable<GetAuthorizedUsersMeta> Meta, IEnumerable<int> Wisagids);
public sealed record GetAuthorizedUsersMeta(int? Code, string Message);
public sealed class GetAuthorizedUsersQueryHandler(IUserRepository repo) : IRequestHandler<GetAuthorizedUsersQuery, GetAuthorizedUsersResult>
{
public async Task<GetAuthorizedUsersResult> Handle(GetAuthorizedUsersQuery request, CancellationToken cancellationToken)
{
var users = await repo.GetAuthorizedAsync(cancellationToken);
return new GetAuthorizedUsersResult(
Meta: [new GetAuthorizedUsersMeta(Code: 0, Message: "OK")],
Wisagids: users.Select(x => x.WisagId));
}
}

View File

@@ -1,121 +0,0 @@
using DigitalData.TaskFlow.Application.Common.Exceptions;
using DigitalData.TaskFlow.Application.Common.Interfaces;
using DigitalData.TaskFlow.Application.Common.Factories;
using AutoMapper;
using DigitalData.TaskFlow.Domain.Closing;
using DigitalData.TaskFlow.Domain.Common;
using DigitalData.TaskFlow.Domain.Enums;
using FluentValidation;
using MediatR;
namespace DigitalData.TaskFlow.Application.Features.Workflows.Commands.CloseWorkflow;
/// <summary>
/// Represents a request to close a workflow process using a selected closing method.
/// </summary>
/// <param name="WisagId">WISAG user identifier.</param>
/// <param name="Source">Source system name.</param>
/// <param name="ProcessId">Process identifier.</param>
/// <param name="ClosingMethodId">Selected closing method identifier.</param>
/// <param name="Comment">Optional user comment.</param>
/// <param name="RejectionReasonId">Optional rejection reason identifier.</param>
public sealed record CloseWorkflowCommand(
int WisagId,
string Source,
int ProcessId,
int ClosingMethodId,
string? Comment,
int? RejectionReasonId)
: IRequest<ApiEnvelope<CloseWorkflowResult>>;
/// <summary>
/// Validates <see cref="CloseWorkflowCommand"/> requests.
/// </summary>
public sealed class CloseWorkflowCommandValidator : AbstractValidator<CloseWorkflowCommand>
{
private static readonly string[] AllowedSources = ["Ferdinand", "Contracts"];
private const int ApproveMethodId = 2;
private const int RejectMethodId = 3;
private const int BackToPerMethodId = 4;
/// <summary>
/// Initializes validation rules for <see cref="CloseWorkflowCommand"/>.
/// </summary>
public CloseWorkflowCommandValidator()
{
RuleFor(x => x.WisagId)
.GreaterThan(0);
RuleFor(x => x.ProcessId)
.GreaterThan(0);
RuleFor(x => x.ClosingMethodId)
.GreaterThan(0);
RuleFor(x => x.Source)
.NotEmpty()
.Must(source => AllowedSources.Contains(source))
.WithMessage("Source must be one of the supported source systems.");
RuleFor(x => x.ClosingMethodId)
.Must(methodId => methodId is ApproveMethodId or RejectMethodId or BackToPerMethodId)
.WithMessage("Unbekannte closing_method_id");
RuleFor(x => x.Comment)
.NotEmpty()
.When(x => x.ClosingMethodId is RejectMethodId or BackToPerMethodId)
.WithMessage("Kommentar ist fur diese closing_method Pflicht");
RuleFor(x => x.RejectionReasonId)
.NotNull()
.When(x => x.ClosingMethodId == RejectMethodId)
.WithMessage("rejection_reason_id ist fur diese closing_method Pflicht");
}
}
/// <summary>
/// Handles <see cref="CloseWorkflowCommand"/> requests.
/// </summary>
public sealed class CloseWorkflowCommandHandler(IWorkflowRepository workflowRepository, IMapper mapper)
: IRequestHandler<CloseWorkflowCommand, ApiEnvelope<CloseWorkflowResult>>
{
/// <summary>
/// Executes the closing request and returns the operation result in the standard API envelope.
/// </summary>
/// <param name="request">Command request.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Closing result envelope.</returns>
public async Task<ApiEnvelope<CloseWorkflowResult>> Handle(CloseWorkflowCommand request, CancellationToken cancellationToken)
{
var decision = mapper.Map<CloseWorkflowDecision>(request);
var result = await workflowRepository.CloseAsync(
request.WisagId,
request.Source,
request.ProcessId,
decision,
cancellationToken);
if (result.Outcome == CloseWorkflowOutcome.NoAccess)
{
throw new ForbiddenApiException("Kein Zugriff");
}
if (result.Outcome == CloseWorkflowOutcome.NotImplemented)
{
throw new InvalidOperationException("Closing integration is not finalized yet.");
}
if (result.ProcessId <= 0)
{
throw new NotFoundApiException("Vorgang nicht gefunden");
}
if (!result.IsClosed)
{
throw new ConflictApiException(MetaCode.AlreadyClosed, "Vorgang bereits abgeschlossen");
}
return ApiEnvelopeFactory.Create(result);
}
}

View File

@@ -0,0 +1,15 @@
using MediatR;
namespace DigitalData.TaskFlow.Application.Features.Workflows.Commands;
public sealed record CloseWorkflowCommand(
int WisagId,
string Source,
long ProcessId,
int ClosingMethodId,
string? Comment,
byte? RejectionReasonId) : IRequest<CloseWorkflowResult>;
public sealed record CloseWorkflowResult(
int? Code,
string Message);

View File

@@ -0,0 +1,26 @@
using DigitalData.TaskFlow.Application.Common.Exceptions;
using DigitalData.TaskFlow.Application.Common.Interfaces;
using MediatR;
namespace DigitalData.TaskFlow.Application.Features.Workflows.Commands;
public sealed class CloseWorkflowCommandHandler(IWorkflowRepository Repo) : IRequestHandler<CloseWorkflowCommand, CloseWorkflowResult>
{
public async Task<CloseWorkflowResult> Handle(CloseWorkflowCommand request, CancellationToken cancellationToken)
{
var procedureResult = await Repo.CloseAsync(
userId: request.WisagId,
source: request.Source,
processId: request.ProcessId,
closingMethodId: request.ClosingMethodId,
comment: request.Comment,
rejectionReasonId: request.RejectionReasonId,
cancellationToken: cancellationToken);
return procedureResult is null
? throw new InvalidWorkflowPayloadException("Close workflow closing procedure returned no result.")
: new CloseWorkflowResult(
Code: procedureResult.Code,
Message: procedureResult.Result ?? string.Empty);
}
}

View File

@@ -1,67 +0,0 @@
using DigitalData.TaskFlow.Application.Common.Factories;
using DigitalData.TaskFlow.Application.Common.Interfaces;
using DigitalData.TaskFlow.Domain.Common;
using DigitalData.TaskFlow.Domain.Enums;
using DigitalData.TaskFlow.Domain.Workflows;
using FluentValidation;
using MediatR;
namespace DigitalData.TaskFlow.Application.Features.Workflows.Queries.GetWorkflows;
/// <summary>
/// Represents a request to fetch grouped workflow data for a WISAG user.
/// </summary>
/// <param name="WisagId">WISAG user identifier.</param>
public sealed record GetWorkflowsQuery(int WisagId) : IRequest<ApiEnvelope<WorkflowSourcesResponse>>;
/// <summary>
/// Validates <see cref="GetWorkflowsQuery"/> requests.
/// </summary>
public sealed class GetWorkflowsQueryValidator : AbstractValidator<GetWorkflowsQuery>
{
/// <summary>
/// Initializes validation rules for <see cref="GetWorkflowsQuery"/>.
/// </summary>
public GetWorkflowsQueryValidator()
{
RuleFor(x => x.WisagId)
.GreaterThan(0);
}
}
/// <summary>
/// Handles <see cref="GetWorkflowsQuery"/> requests.
/// </summary>
public sealed class GetWorkflowsQueryHandler(IWorkflowRepository workflowRepository)
: IRequestHandler<GetWorkflowsQuery, ApiEnvelope<WorkflowSourcesResponse>>
{
/// <summary>
/// Executes the query and returns a workflow payload wrapped in the standard API envelope.
/// </summary>
/// <param name="request">Query request.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Workflow response envelope.</returns>
public async Task<ApiEnvelope<WorkflowSourcesResponse>> Handle(GetWorkflowsQuery request, CancellationToken cancellationToken)
{
var data = await workflowRepository.GetAsync(request.WisagId, cancellationToken);
if (data.Sources.Count == 0)
{
return ApiEnvelopeFactory.Create(data, MetaCode.NoAccess);
}
var hasListingData = data.Sources.Any(source => source switch
{
FerdinandSourceBlock ferdinand => ferdinand.Listing.Count > 0,
ContractsSourceBlock contracts => contracts.Listing.Count > 0,
_ => false
});
if (!hasListingData)
{
return ApiEnvelopeFactory.Create(data, MetaCode.NoOpenWorkflows);
}
return ApiEnvelopeFactory.Create(data);
}
}

View File

@@ -0,0 +1,35 @@
using DigitalData.TaskFlow.Application.Common.Exceptions;
using DigitalData.TaskFlow.Application.Common.Interfaces;
using MediatR;
using System.Text.Json;
namespace DigitalData.TaskFlow.Application.Features.Workflows.Queries;
/// <summary>
/// Represents a request to fetch grouped workflow data for a WISAG user.
/// </summary>
/// <param name="WisagId">WISAG user identifier.</param>
public sealed record GetWorkflowsQuery(int WisagId) : IRequest<JsonElement>;
public sealed class GetWorkflowsQueryHandler(IWorkflowRepository Repo) : IRequestHandler<GetWorkflowsQuery, JsonElement>
{
public async Task<JsonElement> Handle(GetWorkflowsQuery request, CancellationToken cancellationToken)
{
var workflow = await Repo.GetByWisagIdAsync(request.WisagId, cancellationToken);
if (!string.IsNullOrWhiteSpace(workflow?.Result))
{
using var document = JsonDocument.Parse(workflow.Result);
var root = document.RootElement;
if (root.ValueKind == JsonValueKind.Object &&
root.TryGetProperty("response", out var response))
{
return response.Clone();
}
}
throw new InvalidWorkflowPayloadException(
"Stored procedure returned an invalid payload. Expected a JSON object with a 'response' property.");
}
}

View File

@@ -1,8 +0,0 @@
namespace DigitalData.TaskFlow.Application.Options;
public sealed class MediatROptions
{
public const string SectionName = "MediatR";
public string? LuckyPennySoftLicenseKey { get; init; }
}

View File

@@ -1,41 +0,0 @@
# DigitalData.TaskFlow.Application
Dieses Projekt enthaelt die Use-Case-Schicht der Anwendung.
## Zweck
Die Application-Schicht orchestriert fachliche Anwendungsfaelle. Sie nimmt Requests entgegen, validiert diese, ruft Domain-nahe Abstraktionen auf und liefert strukturierte Ergebnisse zurueck.
## Aktueller Inhalt
- `DependencyInjection.cs`
- Registriert zentrale Application-Dienste:
- MediatR
- FluentValidation
- AutoMapper
- Bindet `MediatR`-Optionen inklusive Lizenzschluessel.
- `Options/`
- `MediatROptions`: Konfiguration fuer MediatR (z. B. `LuckyPennySoftLicenseKey`).
## Geplante Inhalte (naechste Phasen)
- `Features/`
- Queries/Commands fuer Workflows, Closing und Documents.
- `Validators/`
- FluentValidation-Regeln pro Request.
- `Common/Behaviors/`
- Pipeline-Behavior (z. B. zentrale Request-Validierung).
- `Common/Interfaces/`
- Repository-Abstraktionen fuer Datenzugriff.
- `Mappings/`
- AutoMapper-Profile zwischen Infrastrukturmodellen und Domainmodellen.
## Architektur-Regeln
- Keine direkten SQL- oder EF-Core-Aufrufe.
- Keine HTTP-spezifischen Controller-Abhaengigkeiten.
- Kommunikation nach aussen nur ueber Interfaces.
## Rolle im Gesamtsystem
Diese Schicht ist der zentrale Ausfuehrungspunkt fuer Use-Cases und verbindet die API-Schicht mit Domain und Infrastructure, ohne Technologie-Details nach oben durchzureichen.

View File

@@ -1,22 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Closing;
/// <summary>
/// Represents the user decision payload for closing a workflow process.
/// </summary>
public sealed record CloseWorkflowDecision
{
/// <summary>
/// Gets the selected closing method identifier.
/// </summary>
public required int ClosingMethodId { get; init; }
/// <summary>
/// Gets the optional comment attached to the decision.
/// </summary>
public string? Comment { get; init; }
/// <summary>
/// Gets the optional rejection reason identifier.
/// </summary>
public int? RejectionReasonId { get; init; }
}

View File

@@ -1,32 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Closing;
/// <summary>
/// Defines business outcomes of a close workflow attempt.
/// </summary>
public enum CloseWorkflowOutcome
{
/// <summary>
/// Workflow can be closed successfully.
/// </summary>
Closed = 0,
/// <summary>
/// Caller has no access to the requested workflow.
/// </summary>
NoAccess = 1,
/// <summary>
/// Workflow process was not found.
/// </summary>
NotFound = 2,
/// <summary>
/// Workflow is already closed and cannot be closed again.
/// </summary>
AlreadyClosed = 3,
/// <summary>
/// Closing cannot be completed yet because write integration is not finalized.
/// </summary>
NotImplemented = 4
}

View File

@@ -1,22 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Closing;
/// <summary>
/// Represents the result of a workflow closing operation.
/// </summary>
public sealed record CloseWorkflowResult
{
/// <summary>
/// Gets the process identifier.
/// </summary>
public required int ProcessId { get; init; }
/// <summary>
/// Gets a value indicating whether the process was closed successfully.
/// </summary>
public required bool IsClosed { get; init; }
/// <summary>
/// Gets the business outcome of the close request.
/// </summary>
public CloseWorkflowOutcome Outcome { get; init; } = CloseWorkflowOutcome.Closed;
}

View File

@@ -1,18 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Common;
/// <summary>
/// Represents the standard API envelope that contains meta information and payload data.
/// </summary>
/// <typeparam name="T">Type of the payload in the response.</typeparam>
public sealed record ApiEnvelope<T>
{
/// <summary>
/// Gets the list of metadata entries describing the business result.
/// </summary>
public required IReadOnlyList<MetaEntry> Meta { get; init; }
/// <summary>
/// Gets the payload data returned by the endpoint.
/// </summary>
public T? Data { get; init; }
}

View File

@@ -1,17 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Common;
/// <summary>
/// Represents a single metadata item describing the business result state of an API response.
/// </summary>
public sealed record MetaEntry
{
/// <summary>
/// Gets the domain-specific result code.
/// </summary>
public required int Code { get; init; }
/// <summary>
/// Gets the human-readable message that belongs to <see cref="Code"/>.
/// </summary>
public required string Message { get; init; }
}

View File

@@ -1,27 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Documents;
/// <summary>
/// Represents binary document content returned by the document endpoint.
/// </summary>
public sealed record DocumentBinaryResult
{
/// <summary>
/// Gets the raw binary content.
/// </summary>
public required byte[] Content { get; init; }
/// <summary>
/// Gets the MIME content type.
/// </summary>
public required string ContentType { get; init; }
/// <summary>
/// Gets the file name used for download.
/// </summary>
public required string FileName { get; init; }
/// <summary>
/// Gets the content length in bytes.
/// </summary>
public required long Length { get; init; }
}

View File

@@ -1,42 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Enums;
/// <summary>
/// Defines domain-level result codes used in API meta responses.
/// </summary>
public enum MetaCode
{
/// <summary>
/// Operation completed successfully.
/// </summary>
Ok = 0,
/// <summary>
/// Request is valid but no open workflows are available.
/// </summary>
NoOpenWorkflows = 1,
/// <summary>
/// Caller has no access to the requested resource.
/// </summary>
NoAccess = 2,
/// <summary>
/// Request is invalid or authentication failed according to endpoint rules.
/// </summary>
InvalidRequest = 4,
/// <summary>
/// Internal server error occurred.
/// </summary>
InternalError = 5,
/// <summary>
/// Requested resource was not found.
/// </summary>
NotFound = 6,
/// <summary>
/// Target workflow was already closed.
/// </summary>
AlreadyClosed = 7
}

View File

@@ -0,0 +1,6 @@
namespace DigitalData.TaskFlow.Domain.ProcedureResults;
public class AuthorizedUser
{
public int WisagId { get; init; }
}

View File

@@ -0,0 +1,5 @@
namespace DigitalData.TaskFlow.Domain.ProcedureResults;
public class Document : ProcedureResultBase
{
}

View File

@@ -0,0 +1,8 @@
namespace DigitalData.TaskFlow.Domain.ProcedureResults;
public abstract class ProcedureResultBase
{
public virtual int? Code { get; init; }
public virtual string? Result { get; init; }
}

View File

@@ -0,0 +1,5 @@
namespace DigitalData.TaskFlow.Domain.ProcedureResults;
public class Workflow : ProcedureResultBase
{
}

View File

@@ -0,0 +1,5 @@
namespace DigitalData.TaskFlow.Domain.ProcedureResults;
public sealed class WorkflowClosing : ProcedureResultBase
{
}

View File

@@ -1,33 +0,0 @@
# DigitalData.TaskFlow.Domain
Dieses Projekt bildet den fachlichen Kern von `DigitalData.TaskFlow`.
## Zweck
Die Domain-Schicht enthaelt ausschließlich fachliche Modelle und Begriffe. Hier wird beschrieben, **was** das System fachlich darstellt, nicht **wie** Daten gelesen/geschrieben werden.
## Aktueller Inhalt
- `Common/`
- `ApiEnvelope<T>`: Standard-Response-Huelle mit `Meta` und `Data`.
- `MetaEntry`: Einzelner Meta-Eintrag (`Code`, `Message`).
- `Enums/`
- `MetaCode`: Fachliche Status-Codes (z. B. `Ok`, `NoAccess`, `AlreadyClosed`).
- `Workflows/`
- Modelle fuer den Endpoint `GET /workflows/{wisagid}`.
- Enthalten Quellblock-Struktur (`SourceBlock`, `FerdinandSourceBlock`, `ContractsSourceBlock`) und Untermodelle (`ProfileItem`, `WorkflowListingItem`, `ApprovalItem`, `DocumentReferenceItem`, `ClosingMethodItem`, `RejectionReasonItem`).
- `Closing/`
- Modelle fuer den Endpoint `POST /workflows/{wisagid}/{source}/{processid}/closing`.
- `CloseWorkflowDecision` (Eingabe), `CloseWorkflowResult` (Ergebnis).
- `Documents/`
- `DocumentBinaryResult` fuer den Endpoint `GET /documents/{id}`.
## Architektur-Regeln
- Keine EF-Core-, HTTP-, SQL- oder Infrastruktur-Abhaengigkeiten.
- Keine Controller- oder Middleware-Logik.
- Modelle bleiben in PascalCase; technische DB-Namensabweichungen werden spaeter in Infrastructure gemappt.
## Warum diese Schicht wichtig ist
Die Domain stellt eine stabile, technologieunabhaengige Sprache bereit. Dadurch koennen API, Application und Infrastructure getrennt entwickelt werden, ohne den fachlichen Vertrag zu verlieren.

View File

@@ -1,32 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
/// <summary>
/// Represents a completed approval action for a workflow process.
/// </summary>
public sealed record ApprovalItem
{
/// <summary>
/// Gets the process identifier.
/// </summary>
public required int ProcessId { get; init; }
/// <summary>
/// Gets the approval sequence index.
/// </summary>
public required int Sequence { get; init; }
/// <summary>
/// Gets the user name or identifier of the approver.
/// </summary>
public required string ApprovedBy { get; init; }
/// <summary>
/// Gets the UTC timestamp when approval was recorded.
/// </summary>
public required DateTime ApprovedAtUtc { get; init; }
/// <summary>
/// Gets the optional approval comment.
/// </summary>
public string? Comment { get; init; }
}

View File

@@ -1,27 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
/// <summary>
/// Represents a workflow closing option available for user decision.
/// </summary>
public sealed record ClosingMethodItem
{
/// <summary>
/// Gets the closing method identifier.
/// </summary>
public required int ClosingMethodId { get; init; }
/// <summary>
/// Gets the display name of the method.
/// </summary>
public required string Name { get; init; }
/// <summary>
/// Gets a value indicating whether a comment is mandatory for this method.
/// </summary>
public required bool CommentRequired { get; init; }
/// <summary>
/// Gets a value indicating whether this method represents a rejection.
/// </summary>
public required bool IsRejection { get; init; }
}

View File

@@ -1,40 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
using System.Text.Json;
using System.Text.Json.Serialization;
/// <summary>
/// Represents workflow data for the Contracts source system.
/// </summary>
public sealed record ContractsSourceBlock : SourceBlock
{
/// <summary>
/// Gets available approval profiles.
/// </summary>
[JsonPropertyName("profile")]
public required IReadOnlyList<JsonElement> Profile { get; init; }
/// <summary>
/// Gets workflow listing items.
/// </summary>
[JsonPropertyName("Listing")]
public required IReadOnlyList<JsonElement> Listing { get; init; }
/// <summary>
/// Gets already executed approvals.
/// </summary>
[JsonPropertyName("approvals")]
public required IReadOnlyList<JsonElement> Approvals { get; init; }
/// <summary>
/// Gets document references for workflows.
/// </summary>
[JsonPropertyName("document")]
public required IReadOnlyList<JsonElement> Document { get; init; }
/// <summary>
/// Gets available closing methods for workflows.
/// </summary>
[JsonPropertyName("closing_method")]
public required IReadOnlyList<JsonElement> ClosingMethod { get; init; }
}

View File

@@ -1,27 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
/// <summary>
/// Represents a lightweight document reference linked to a workflow process.
/// </summary>
public sealed record DocumentReferenceItem
{
/// <summary>
/// Gets the document identifier used for binary retrieval.
/// </summary>
public required string Id { get; init; }
/// <summary>
/// Gets the process identifier.
/// </summary>
public required int ProcessId { get; init; }
/// <summary>
/// Gets the document title.
/// </summary>
public required string Title { get; init; }
/// <summary>
/// Gets the document subtitle.
/// </summary>
public required string Subtitle { get; init; }
}

View File

@@ -1,46 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
using System.Text.Json;
using System.Text.Json.Serialization;
/// <summary>
/// Represents workflow data for the Ferdinand source system.
/// </summary>
public sealed record FerdinandSourceBlock : SourceBlock
{
/// <summary>
/// Gets available approval profiles.
/// </summary>
[JsonPropertyName("profile")]
public required IReadOnlyList<JsonElement> Profile { get; init; }
/// <summary>
/// Gets workflow listing items.
/// </summary>
[JsonPropertyName("Listing")]
public required IReadOnlyList<JsonElement> Listing { get; init; }
/// <summary>
/// Gets already executed approvals.
/// </summary>
[JsonPropertyName("approvals")]
public required IReadOnlyList<JsonElement> Approvals { get; init; }
/// <summary>
/// Gets document references for workflows.
/// </summary>
[JsonPropertyName("document")]
public required IReadOnlyList<JsonElement> Document { get; init; }
/// <summary>
/// Gets available closing methods for workflows.
/// </summary>
[JsonPropertyName("closing_method")]
public required IReadOnlyList<JsonElement> ClosingMethod { get; init; }
/// <summary>
/// Gets available rejection reasons for rejection-type methods.
/// </summary>
[JsonPropertyName("rejection_reason")]
public required IReadOnlyList<JsonElement> RejectionReason { get; init; }
}

View File

@@ -1,22 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
/// <summary>
/// Represents an approval profile for workflow processing.
/// </summary>
public sealed record ProfileItem
{
/// <summary>
/// Gets the profile identifier.
/// </summary>
public required int ProfileId { get; init; }
/// <summary>
/// Gets the display title of the profile.
/// </summary>
public required string Title { get; init; }
/// <summary>
/// Gets the optional priority value.
/// </summary>
public int? Priority { get; init; }
}

View File

@@ -1,17 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
/// <summary>
/// Represents a rejection reason that can be selected for rejection methods.
/// </summary>
public sealed record RejectionReasonItem
{
/// <summary>
/// Gets the rejection reason identifier.
/// </summary>
public required int RejectionReasonId { get; init; }
/// <summary>
/// Gets the display name of the rejection reason.
/// </summary>
public required string Name { get; init; }
}

View File

@@ -1,12 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
/// <summary>
/// Base type for source-specific workflow blocks.
/// </summary>
public abstract record SourceBlock
{
/// <summary>
/// Gets the source system name.
/// </summary>
public required string Source { get; init; }
}

View File

@@ -1,87 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
/// <summary>
/// Represents a single workflow listing row.
/// </summary>
public sealed record WorkflowListingItem
{
/// <summary>
/// Gets the process identifier.
/// </summary>
public required int ProcessId { get; init; }
/// <summary>
/// Gets the profile identifier associated with the process.
/// </summary>
public required int ProfileId { get; init; }
/// <summary>
/// Gets the voucher type.
/// </summary>
public required string VoucherType { get; init; }
/// <summary>
/// Gets the voucher number.
/// </summary>
public required string VoucherNumber { get; init; }
/// <summary>
/// Gets the voucher date.
/// </summary>
public required DateOnly VoucherDate { get; init; }
/// <summary>
/// Gets the cost center number.
/// </summary>
public required string CostCenter { get; init; }
/// <summary>
/// Gets the cost center description.
/// </summary>
public required string CostCenterDescription { get; init; }
/// <summary>
/// Gets the client number.
/// </summary>
public required int ClientNumber { get; init; }
/// <summary>
/// Gets the client name.
/// </summary>
public required string ClientName { get; init; }
/// <summary>
/// Gets the supplier number.
/// </summary>
public required string SupplierNumber { get; init; }
/// <summary>
/// Gets the supplier name.
/// </summary>
public required string SupplierName { get; init; }
/// <summary>
/// Gets the net amount.
/// </summary>
public required decimal NetAmount { get; init; }
/// <summary>
/// Gets the gross amount.
/// </summary>
public required decimal GrossAmount { get; init; }
/// <summary>
/// Gets the discount amount.
/// </summary>
public required decimal DiscountAmount { get; init; }
/// <summary>
/// Gets the currency.
/// </summary>
public required string Currency { get; init; }
/// <summary>
/// Gets the priority value.
/// </summary>
public required int Priority { get; init; }
}

View File

@@ -1,12 +0,0 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
/// <summary>
/// Represents the workflow payload grouped by source systems.
/// </summary>
public sealed record WorkflowSourcesResponse
{
/// <summary>
/// Gets the source blocks included in the response.
/// </summary>
public required IReadOnlyList<SourceBlock> Sources { get; init; }
}

View File

@@ -1,5 +1,4 @@
using DigitalData.TaskFlow.Application.Common.Interfaces; using DigitalData.TaskFlow.Application.Common.Interfaces;
using DigitalData.TaskFlow.Infrastructure.Options;
using DigitalData.TaskFlow.Infrastructure.Persistence; using DigitalData.TaskFlow.Infrastructure.Persistence;
using DigitalData.TaskFlow.Infrastructure.Repositories; using DigitalData.TaskFlow.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -13,25 +12,17 @@ public static class DependencyInjection
public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, IConfiguration configuration) public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, IConfiguration configuration)
{ {
var connectionString = configuration.GetConnectionString("TaskFlowDb"); var connectionString = configuration.GetConnectionString("TaskFlowDb");
var databaseOptions = configuration.GetSection(DatabaseOptions.SectionName).Get<DatabaseOptions>() ?? new DatabaseOptions();
if (string.IsNullOrWhiteSpace(connectionString)) if (string.IsNullOrWhiteSpace(connectionString))
{
throw new InvalidOperationException("Connection string 'TaskFlowDb' is not configured."); throw new InvalidOperationException("Connection string 'TaskFlowDb' is not configured.");
}
services.AddDbContext<TaskFlowDbContext>(options => services.AddDbContext<TaskFlowDbContext>(options =>
{ {
options.UseSqlServer(connectionString, sqlOptions => options.UseSqlServer(connectionString);
{
sqlOptions.CommandTimeout(databaseOptions.CommandTimeoutSeconds);
}); });
});
services.Configure<DatabaseOptions>(configuration.GetSection(DatabaseOptions.SectionName));
services.AddScoped<IWorkflowRepository, WorkflowRepository>(); services.AddScoped<IWorkflowRepository, WorkflowRepository>();
services.AddScoped<IDocumentRepository, DocumentRepository>(); services.AddScoped<IDocumentRepository, DocumentRepository>();
services.AddScoped<IUserRepository, UserRepository>();
return services; return services;
} }

View File

@@ -18,9 +18,4 @@
<ProjectReference Include="..\..\core\DigitalData.TaskFlow.Application\DigitalData.TaskFlow.Application.csproj" /> <ProjectReference Include="..\..\core\DigitalData.TaskFlow.Application\DigitalData.TaskFlow.Application.csproj" />
<ProjectReference Include="..\..\core\DigitalData.TaskFlow.Domain\DigitalData.TaskFlow.Domain.csproj" /> <ProjectReference Include="..\..\core\DigitalData.TaskFlow.Domain\DigitalData.TaskFlow.Domain.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Options\" />
</ItemGroup>
</Project> </Project>

View File

@@ -1,22 +0,0 @@
namespace DigitalData.TaskFlow.Infrastructure.Options;
/// <summary>
/// Holds infrastructure database options.
/// </summary>
public sealed class DatabaseOptions
{
/// <summary>
/// Configuration section name.
/// </summary>
public const string SectionName = "Database";
/// <summary>
/// Gets or sets command timeout in seconds for SQL operations.
/// </summary>
public int CommandTimeoutSeconds { get; set; } = 30;
/// <summary>
/// Gets or sets object type passed to workflow listing procedure.
/// </summary>
public string WorkflowListingObjectType { get; set; } = "Ferdinand";
}

View File

@@ -1,111 +0,0 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace DigitalData.TaskFlow.Infrastructure.Persistence.Models;
/// <summary>
/// Represents a stored procedure row shape for workflow listing data.
/// </summary>
public sealed class WorkflowListingReadModel
{
/// <summary>
/// Gets or sets the process identifier.
/// </summary>
[Column("processid")]
public int ProcessId { get; set; }
/// <summary>
/// Gets or sets the profile identifier.
/// </summary>
[Column("profileid")]
public byte ProfileId { get; set; }
/// <summary>
/// Gets or sets the voucher type.
/// </summary>
[Column("belegart")]
public string VoucherType { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the voucher number.
/// </summary>
[Column("belegnr")]
public string VoucherNumber { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the voucher date.
/// </summary>
[Column("belegdatum")]
public DateTime VoucherDate { get; set; }
/// <summary>
/// Gets or sets the cost center.
/// </summary>
[Column("kostenstelle")]
public string CostCenter { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the cost center description.
/// </summary>
[Column("kostenstellenbezeichnung")]
public string CostCenterDescription { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the client number.
/// </summary>
[Column("mandantnr")]
public short ClientNumber { get; set; }
/// <summary>
/// Gets or sets the client name.
/// </summary>
[Column("mandantbez")]
public string ClientName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the supplier number.
/// </summary>
[Column("lieferantnr")]
public string SupplierNumber { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the supplier name.
/// </summary>
[Column("lieferantbez")]
public string SupplierName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the net amount.
/// </summary>
[Column("netto")]
public double NetAmount { get; set; }
/// <summary>
/// Gets or sets the gross amount.
/// </summary>
[Column("brutto")]
public double GrossAmount { get; set; }
/// <summary>
/// Gets or sets the discount amount.
/// </summary>
[Column("skontobetrag")]
public double DiscountAmount { get; set; }
/// <summary>
/// Gets or sets the currency.
/// </summary>
[Column("waehrung")]
public string Currency { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the priority.
/// </summary>
[Column("priority")]
public byte Priority { get; set; }
/// <summary>
/// Gets or sets the source group text.
/// </summary>
[Column("GROUP_TEXT")]
public string GroupText { get; set; } = string.Empty;
}

View File

@@ -1,4 +1,4 @@
using DigitalData.TaskFlow.Infrastructure.Persistence.Models; using DigitalData.TaskFlow.Domain.ProcedureResults;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace DigitalData.TaskFlow.Infrastructure.Persistence; namespace DigitalData.TaskFlow.Infrastructure.Persistence;
@@ -9,18 +9,58 @@ namespace DigitalData.TaskFlow.Infrastructure.Persistence;
public sealed class TaskFlowDbContext(DbContextOptions<TaskFlowDbContext> options) : DbContext(options) public sealed class TaskFlowDbContext(DbContextOptions<TaskFlowDbContext> options) : DbContext(options)
{ {
/// <summary> /// <summary>
/// Gets the keyless result model used for workflow listing procedure reads. /// Gets the keyless result model used for workflow procedure reads.
/// </summary> /// </summary>
public DbSet<WorkflowListingReadModel> WorkflowListingReadModels => Set<WorkflowListingReadModel>(); public DbSet<Workflow> Workflows => Set<Workflow>();
/// <summary>
/// Gets the keyless result model used for document procedure reads.
/// </summary>
public DbSet<Document> Documents => Set<Document>();
/// <summary>
/// Gets the keyless result model used for workflow close procedure results.
/// </summary>
public DbSet<WorkflowClosing> WorkflowClosings => Set<WorkflowClosing>();
/// <summary>
/// Gets the keyless result model used for authorized users procedure results.
/// </summary>
public DbSet<AuthorizedUser> AuthorizedUsers => Set<AuthorizedUser>();
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
base.OnModelCreating(modelBuilder); base.OnModelCreating(modelBuilder);
modelBuilder.Entity<WorkflowListingReadModel>(entity => modelBuilder.Entity<Workflow>(entity =>
{ {
entity.HasNoKey(); entity.HasNoKey();
entity.ToView(null); entity.ToView(null);
entity.Property(x => x.Code).HasColumnName("CODE").HasColumnType("int");
entity.Property(x => x.Result).HasColumnName("RESULT").HasColumnType("nvarchar(max)");
});
modelBuilder.Entity<Document>(entity =>
{
entity.HasNoKey();
entity.ToView(null);
entity.Property(x => x.Code).HasColumnName("CODE").HasColumnType("int");
entity.Property(x => x.Result).HasColumnName("RESULT").HasColumnType("nvarchar(max)");
});
modelBuilder.Entity<WorkflowClosing>(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)");
});
modelBuilder.Entity<AuthorizedUser>(entity =>
{
entity.HasNoKey();
entity.ToView(null);
entity.Property(x => x.WisagId).HasColumnName("wisagid").HasColumnType("int");
}); });
} }
} }

View File

@@ -1,46 +0,0 @@
# DigitalData.TaskFlow.Infrastructure
Dieses Projekt implementiert technische Integrationen der Anwendung.
## Zweck
Die Infrastructure-Schicht setzt die in Application definierten Abstraktionen konkret um. Dazu gehoeren Datenbankzugriffe (EF Core, Stored Procedures) und spaeter ggf. DMS- oder externe Service-Anbindungen.
## Aktueller Inhalt
- `DependencyInjection.cs`
- Einstiegspunkt fuer die Registrierung technischer Dienste.
- `Options/`
- Platz fuer Infrastruktur-spezifische Optionen (falls benoetigt).
## Geplante Inhalte (naechste Phasen)
- `Persistence/`
- `TaskFlowDbContext` mit SQL-Server-Konfiguration.
- Entity-Konfigurationen inklusive Feld-Mapping (DB-Namen -> PascalCase-Modelle).
- `Repositories/`
- Implementierungen fuer:
- Workflow-Lesezugriff (u. a. `PRCUST_F19_GET_LISTING_DATA`)
- Workflow-Closing (Write-Procedure)
- Dokument-Binary-Zugriff
- `Persistence/Models/`
- Keyless Modelle fuer Procedure-Ergebnisse.
## Wichtiger Hinweis zu DB-Spaltennamen
- Spaltennamen in `Persistence/Models` (z. B. `WorkflowListingReadModel`) basieren aktuell auf:
- read-only Abfragen auf `sys.columns` (u. a. `TBCUST_F19_LISTING_RESULT`),
- beobachteten Result-Sets von `PRCUST_F19_GET_LISTING_DATA` im `table`-Modus.
- Vor produktiven Aenderungen muss das finale SP-Resultset read-only verifiziert werden, idealerweise mit
`sp_describe_first_result_set` oder einer gleichwertigen Metadata-Pruefung.
- Domain-Modelle bleiben davon getrennt: DB-Feldnamen werden nur in Infrastructure gemappt, nicht in Domain.
## Architektur-Regeln
- Keine Controller- oder HTTP-Logik.
- Keine fachliche Regel-Definition; nur technische Umsetzung.
- SQL-Zugriff stets parameterisiert und sicher.
## Rolle im Gesamtsystem
Infrastructure kapselt alle externen Abhaengigkeiten. Dadurch bleibt die Application-Schicht testbar und von Technologie-Details entkoppelt.

View File

@@ -1,25 +1,22 @@
using DigitalData.TaskFlow.Application.Common.Interfaces; using DigitalData.TaskFlow.Application.Common.Interfaces;
using DigitalData.TaskFlow.Domain.Documents; using DigitalData.TaskFlow.Domain.ProcedureResults;
using DigitalData.TaskFlow.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
namespace DigitalData.TaskFlow.Infrastructure.Repositories; namespace DigitalData.TaskFlow.Infrastructure.Repositories;
/// <summary> /// <summary>
/// Document repository implementation for binary document retrieval. /// Document repository implementation for reading document listing data and applying close operations.
/// </summary> /// </summary>
public sealed class DocumentRepository : IDocumentRepository public sealed class DocumentRepository(TaskFlowDbContext context) : IDocumentRepository
{ {
/// <summary> public async Task<Document?> GetAsync(int userId, long processId, long docId, CancellationToken cancellationToken)
/// Retrieves binary document content by identifier.
/// </summary>
/// <param name="id">Document identifier.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Binary document payload when found; otherwise <see langword="null"/>.</returns>
public Task<DocumentBinaryResult?> GetAsync(string id, CancellationToken cancellationToken)
{ {
_ = id; var rows = await context.Documents
_ = cancellationToken; .FromSqlInterpolated(@$"EXEC [PRCUST_F19_GET_DOCUMENT] @pRESULT_TYPE = 'json', @pOBJECT_TYPE = 'Ferdinand', @pUSER_ID = {userId}, @pPROCESS_ID = {processId}, @pDOC_ID = {docId}")
.AsNoTracking()
.ToListAsync(cancellationToken);
throw new NotSupportedException( return rows.FirstOrDefault();
"Document retrieval procedure/DMS contract is not finalized yet. Configure final integration before enabling GetAsync.");
} }
} }

View File

@@ -0,0 +1,17 @@
using DigitalData.TaskFlow.Application.Common.Interfaces;
using DigitalData.TaskFlow.Domain.ProcedureResults;
using DigitalData.TaskFlow.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
namespace DigitalData.TaskFlow.Infrastructure.Repositories;
public sealed class UserRepository(TaskFlowDbContext context) : IUserRepository
{
public async Task<IEnumerable<AuthorizedUser>> GetAuthorizedAsync(CancellationToken cancellationToken)
{
return await context.AuthorizedUsers
.FromSqlInterpolated($"EXEC [dbo].[PRCUST_F19_GET_AUTHORIZED_USERS]")
.AsNoTracking()
.ToListAsync(cancellationToken);
}
}

View File

@@ -1,254 +1,53 @@
using DigitalData.TaskFlow.Application.Common.Interfaces; using DigitalData.TaskFlow.Application.Common.Interfaces;
using DigitalData.TaskFlow.Domain.Closing; using DigitalData.TaskFlow.Domain.ProcedureResults;
using DigitalData.TaskFlow.Domain.Workflows;
using DigitalData.TaskFlow.Infrastructure.Options;
using DigitalData.TaskFlow.Infrastructure.Persistence; using DigitalData.TaskFlow.Infrastructure.Persistence;
using DigitalData.TaskFlow.Infrastructure.Persistence.Models;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using System.Text.Json;
namespace DigitalData.TaskFlow.Infrastructure.Repositories; namespace DigitalData.TaskFlow.Infrastructure.Repositories;
/// <summary> /// <summary>
/// Workflow repository implementation for reading workflow listing data and applying close operations. /// Workflow repository implementation for reading workflow listing data and applying close operations.
/// </summary> /// </summary>
public sealed class WorkflowRepository(TaskFlowDbContext dbContext, IOptions<DatabaseOptions> databaseOptions) : IWorkflowRepository public sealed class WorkflowRepository(TaskFlowDbContext context) : IWorkflowRepository
{ {
/// <summary> public async Task<Workflow?> GetByWisagIdAsync(int wisagId, CancellationToken cancellationToken)
/// Retrieves grouped workflow data for a user.
/// </summary>
/// <param name="wisagId">WISAG user identifier.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Grouped workflow response.</returns>
public async Task<WorkflowSourcesResponse> GetAsync(int wisagId, CancellationToken cancellationToken)
{ {
var objectType = string.IsNullOrWhiteSpace(databaseOptions.Value.WorkflowListingObjectType) var rows = await context.Workflows
? "Ferdinand" .FromSqlInterpolated(@$"EXEC [PRCUST_F19_GET_LISTING_DATA] @pUSER_ID = {wisagId}, @pRESULT_TYPE = 'json', @pOBJECT_TYPE = 'Ferdinand'")
: databaseOptions.Value.WorkflowListingObjectType;
var jsonPayload = await ExecuteListingJsonAsync(wisagId, objectType, cancellationToken);
if (string.IsNullOrWhiteSpace(jsonPayload))
{
return new WorkflowSourcesResponse { Sources = [] };
}
using var document = JsonDocument.Parse(jsonPayload);
if (!document.RootElement.TryGetProperty("response", out var responseElement))
{
return new WorkflowSourcesResponse { Sources = [] };
}
if (TryReadMetaCode(responseElement) == 2)
{
return new WorkflowSourcesResponse { Sources = [] };
}
var sources = new List<SourceBlock>();
if (!responseElement.TryGetProperty("sources", out var sourcesElement) || sourcesElement.ValueKind != JsonValueKind.Array)
{
return new WorkflowSourcesResponse { Sources = sources };
}
foreach (var sourceElement in sourcesElement.EnumerateArray())
{
if (!sourceElement.TryGetProperty("source", out var sourceNameElement))
{
continue;
}
var sourceName = sourceNameElement.GetString();
if (string.Equals(sourceName, "Ferdinand", StringComparison.OrdinalIgnoreCase))
{
sources.Add(new FerdinandSourceBlock
{
Source = "Ferdinand",
Profile = ReadArray(sourceElement, "profile"),
Listing = ReadArray(sourceElement, "Listing"),
Approvals = ReadArray(sourceElement, "approvals"),
Document = ReadArray(sourceElement, "document"),
ClosingMethod = ReadArray(sourceElement, "closing_method"),
RejectionReason = ReadArray(sourceElement, "rejection_reason")
});
continue;
}
if (string.Equals(sourceName, "Contracts", StringComparison.OrdinalIgnoreCase))
{
sources.Add(new ContractsSourceBlock
{
Source = "Contracts",
Profile = ReadArray(sourceElement, "profile"),
Listing = ReadArray(sourceElement, "Listing"),
Approvals = ReadArray(sourceElement, "approvals"),
Document = ReadArray(sourceElement, "document"),
ClosingMethod = ReadArray(sourceElement, "closing_method")
});
}
}
return new WorkflowSourcesResponse { Sources = sources };
}
/// <summary>
/// Applies a closing decision to a workflow item.
/// </summary>
/// <param name="wisagId">WISAG user identifier.</param>
/// <param name="source">Source system name.</param>
/// <param name="processId">Process identifier.</param>
/// <param name="decision">Closing decision payload.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Result of the close operation.</returns>
public Task<CloseWorkflowResult> CloseAsync(
int wisagId,
string source,
int processId,
CloseWorkflowDecision decision,
CancellationToken cancellationToken)
{
_ = decision;
if (!string.Equals(source, "Ferdinand", StringComparison.OrdinalIgnoreCase))
{
return Task.FromResult(new CloseWorkflowResult
{
ProcessId = processId,
IsClosed = false,
Outcome = CloseWorkflowOutcome.NotFound
});
}
return EvaluateCloseOutcomeAsync(wisagId, source, processId, cancellationToken);
}
private async Task<CloseWorkflowResult> EvaluateCloseOutcomeAsync(
int wisagId,
string source,
int processId,
CancellationToken cancellationToken)
{
var rows = await ExecuteListingTableAsync(wisagId, source, cancellationToken);
if (rows.Any(row => row.ProcessId == processId))
{
return new CloseWorkflowResult
{
ProcessId = processId,
IsClosed = true,
Outcome = CloseWorkflowOutcome.Closed
};
}
var metaCode = await TryGetWorkflowMetaCodeAsync(wisagId, source, cancellationToken);
if (metaCode == 2)
{
return new CloseWorkflowResult
{
ProcessId = processId,
IsClosed = false,
Outcome = CloseWorkflowOutcome.NoAccess
};
}
return new CloseWorkflowResult
{
ProcessId = 0,
IsClosed = false,
Outcome = CloseWorkflowOutcome.NotFound
};
}
private async Task<int?> TryGetWorkflowMetaCodeAsync(int wisagId, string objectType, CancellationToken cancellationToken)
{
var jsonPayload = await ExecuteListingJsonAsync(wisagId, objectType, cancellationToken);
if (string.IsNullOrWhiteSpace(jsonPayload))
{
return null;
}
try
{
using var document = JsonDocument.Parse(jsonPayload);
return document.RootElement.TryGetProperty("response", out var responseElement)
? TryReadMetaCode(responseElement)
: null;
}
catch (JsonException)
{
return null;
}
}
private async Task<IReadOnlyList<WorkflowListingReadModel>> ExecuteListingTableAsync(
int wisagId,
string objectType,
CancellationToken cancellationToken)
{
const string resultType = "table";
return await dbContext
.WorkflowListingReadModels
.FromSqlInterpolated($"EXEC dbo.PRCUST_F19_GET_LISTING_DATA @pUSER_ID={wisagId}, @pRESULT_TYPE={resultType}, @pOBJECT_TYPE={objectType}")
.AsNoTracking() .AsNoTracking()
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
return rows.FirstOrDefault();
} }
private async Task<string?> ExecuteListingJsonAsync(int wisagId, string objectType, CancellationToken cancellationToken) public async Task<WorkflowClosing?> CloseAsync(
int userId,
string source,
long processId,
int closingMethodId,
string? comment,
byte? rejectionReasonId,
CancellationToken cancellationToken)
{ {
const string commandText = "EXEC dbo.PRCUST_F19_GET_LISTING_DATA @pUSER_ID, @pRESULT_TYPE, @pOBJECT_TYPE"; var rows = await context.WorkflowClosings
const string resultType = "json"; .FromSqlInterpolated($@"
DECLARE @ResultCode INT;
DECLARE @ResultMessage NVARCHAR(400);
await using var command = dbContext.Database.GetDbConnection().CreateCommand(); EXEC dbo.PRCUST_F19_CLOSING
command.CommandText = commandText; @UserID = {userId},
@Source = {source},
@ProcessID = {processId},
@ClosingMethodID = {closingMethodId},
@Comment = {comment},
@RejectionReasonID = {rejectionReasonId},
@ResultCode = @ResultCode OUTPUT,
@ResultMessage = @ResultMessage OUTPUT;
command.Parameters.Add(new SqlParameter("@pUSER_ID", wisagId)); SELECT @ResultCode AS CODE, @ResultMessage AS RESULT;")
command.Parameters.Add(new SqlParameter("@pRESULT_TYPE", resultType)); .AsNoTracking()
command.Parameters.Add(new SqlParameter("@pOBJECT_TYPE", objectType)); .ToListAsync(cancellationToken);
if (command.Connection is null) return rows.FirstOrDefault();
{
return null;
}
if (command.Connection.State != System.Data.ConnectionState.Open)
{
await command.Connection.OpenAsync(cancellationToken);
}
await using var reader = await command.ExecuteReaderAsync(cancellationToken);
if (!await reader.ReadAsync(cancellationToken) || reader.FieldCount == 0 || reader.IsDBNull(0))
{
return null;
}
return reader.GetString(0);
}
private static int? TryReadMetaCode(JsonElement responseElement)
{
if (!responseElement.TryGetProperty("meta", out var metaElement) || metaElement.ValueKind != JsonValueKind.Array)
{
return null;
}
if (metaElement.GetArrayLength() == 0 || !metaElement[0].TryGetProperty("code", out var codeElement))
{
return null;
}
return codeElement.GetInt32();
}
private static IReadOnlyList<JsonElement> ReadArray(JsonElement sourceElement, string propertyName)
{
if (!sourceElement.TryGetProperty(propertyName, out var propertyElement) || propertyElement.ValueKind != JsonValueKind.Array)
{
return [];
}
return propertyElement.EnumerateArray().Select(item => item.Clone()).ToList();
} }
} }

View File

@@ -1,16 +0,0 @@
using DigitalData.TaskFlow.Domain.Common;
using System.Text.Json.Serialization;
namespace DigitalData.TaskFlow.API.Contracts.Common;
/// <summary>
/// Represents a contract response that contains only metadata.
/// </summary>
public sealed record MetaOnlyResponse
{
/// <summary>
/// Gets metadata entries.
/// </summary>
[JsonPropertyName("meta")]
public required IReadOnlyList<MetaEntry> Meta { get; init; }
}

View File

@@ -1,27 +0,0 @@
using System.Text.Json.Serialization;
namespace DigitalData.TaskFlow.API.Contracts.Workflows;
/// <summary>
/// Represents the request payload for closing a workflow.
/// </summary>
public sealed class CloseWorkflowRequest
{
/// <summary>
/// Gets or sets the selected closing method identifier.
/// </summary>
[JsonPropertyName("closing_method_id")]
public required int ClosingMethodId { get; init; }
/// <summary>
/// Gets or sets an optional user comment.
/// </summary>
[JsonPropertyName("comment")]
public string? Comment { get; init; }
/// <summary>
/// Gets or sets an optional rejection reason identifier.
/// </summary>
[JsonPropertyName("rejection_reason_id")]
public int? RejectionReasonId { get; init; }
}

View File

@@ -1,22 +0,0 @@
using DigitalData.TaskFlow.Domain.Common;
using System.Text.Json.Serialization;
namespace DigitalData.TaskFlow.API.Contracts.Workflows;
/// <summary>
/// Represents the GET workflows response contract.
/// </summary>
public sealed record WorkflowsResponse
{
/// <summary>
/// Gets metadata entries.
/// </summary>
[JsonPropertyName("meta")]
public required IReadOnlyList<MetaEntry> Meta { get; init; }
/// <summary>
/// Gets grouped source blocks.
/// </summary>
[JsonPropertyName("sources")]
public required IReadOnlyList<object> Sources { get; init; }
}

View File

@@ -0,0 +1,32 @@
using DigitalData.TaskFlow.Application.Features.Documents.Queries;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
namespace DigitalData.TaskFlow.API.Controllers;
/// <summary>
/// Provides workflow read and close endpoints.
/// </summary>
[ApiController]
[Route("api/documents")]
public sealed class DocumentController(ISender sender) : ControllerBase
{
/// <summary>
/// Returns open documents for a WISAG user identifier.
/// </summary>
/// <param name="id">Document identifier.</param>
/// <param name="userId">User identifier.</param>
/// <param name="processId">Process identifier.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Document response envelope grouped by source.</returns>
[HttpGet("{id:int}")]
[ProducesResponseType(typeof(JsonElement), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status502BadGateway)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<JsonElement>> GetAsync([FromRoute] int id, [FromQuery] int userId, [FromQuery] long processId, CancellationToken cancellationToken = default)
{
return Ok(await sender.Send(new GetDocumentQuery(Id: id, UserId: userId, ProcessId: processId), cancellationToken));
}
}

View File

@@ -1,36 +0,0 @@
using DigitalData.TaskFlow.Application.Features.Documents.Queries.GetDocument;
using DigitalData.TaskFlow.API.Contracts.Common;
using DigitalData.TaskFlow.Domain.Common;
using DigitalData.TaskFlow.Domain.Documents;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace DigitalData.TaskFlow.API.Controllers;
/// <summary>
/// Provides document binary download endpoints.
/// </summary>
[ApiController]
[Route("api/documents")]
public sealed class DocumentsController(ISender sender) : ControllerBase
{
/// <summary>
/// Returns binary document content by document identifier.
/// </summary>
/// <param name="id">Document identifier.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Binary stream when available.</returns>
[HttpGet("{id}")]
[ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken)
{
var response = await sender.Send(new GetDocumentQuery(id), cancellationToken);
var data = response.Data ?? throw new InvalidOperationException("Document payload is unexpectedly null.");
return File(data.Content, data.ContentType, data.FileName);
}
}

View File

@@ -0,0 +1,36 @@
using DigitalData.TaskFlow.Application.Features.Users.Queries;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace DigitalData.TaskFlow.API.Controllers;
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
[ApiController]
[Route("api/users")]
public sealed class UsersController(ISender sender) : ControllerBase
{
/// <summary>
///
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("authorized")]
[ProducesResponseType(typeof(GetAuthorizedUsersResult), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(GetAuthorizedUsersResult), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(GetAuthorizedUsersResult), StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> GetAuthorizedAsync(CancellationToken cancellationToken)
{
var result = await sender.Send(new GetAuthorizedUsersQuery(), cancellationToken);
var code = result.Meta.FirstOrDefault()?.Code;
return code switch
{
0 => Ok(result),
4 => Unauthorized(result),
_ => StatusCode(StatusCodes.Status500InternalServerError, result)
};
}
}

View File

@@ -1,9 +1,10 @@
using DigitalData.TaskFlow.API.Contracts.Workflows; using DigitalData.TaskFlow.API.Models;
using DigitalData.TaskFlow.API.Contracts.Common; using DigitalData.TaskFlow.Application.Common.Exceptions;
using DigitalData.TaskFlow.Application.Features.Workflows.Commands.CloseWorkflow; using DigitalData.TaskFlow.Application.Features.Workflows.Commands;
using DigitalData.TaskFlow.Application.Features.Workflows.Queries.GetWorkflows; using DigitalData.TaskFlow.Application.Features.Workflows.Queries;
using MediatR; using MediatR;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
namespace DigitalData.TaskFlow.API.Controllers; namespace DigitalData.TaskFlow.API.Controllers;
@@ -21,64 +22,55 @@ public sealed class WorkflowsController(ISender sender) : ControllerBase
/// <param name="cancellationToken">Cancellation token.</param> /// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Workflow response envelope grouped by source.</returns> /// <returns>Workflow response envelope grouped by source.</returns>
[HttpGet("{wisagId:int}")] [HttpGet("{wisagId:int}")]
[ProducesResponseType(typeof(WorkflowsResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(JsonElement), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status502BadGateway)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status500InternalServerError)] [ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<WorkflowsResponse>> GetAsync( public async Task<ActionResult<JsonElement>> GetAsync([FromRoute] int wisagId, CancellationToken cancellationToken)
[FromRoute] int wisagId,
CancellationToken cancellationToken)
{ {
var response = await sender.Send(new GetWorkflowsQuery(wisagId), cancellationToken); return Ok(await sender.Send(new GetWorkflowsQuery(wisagId), cancellationToken));
var sources = response.Data?.Sources
.Cast<object>()
.ToList()
?? [];
return Ok(new WorkflowsResponse
{
Meta = response.Meta,
Sources = sources
});
} }
/// <summary> /// <summary>
/// Applies a closing decision to a workflow process. /// Closes a workflow for a WISAG user identifier, source, and process identifier.
/// </summary> /// </summary>
/// <param name="wisagId">WISAG user identifier.</param> /// <param name="wisagId"></param>
/// <param name="source">Source system name.</param> /// <param name="processId"></param>
/// <param name="processId">Process identifier.</param> /// <param name="body"></param>
/// <param name="request">Closing request payload.</param> /// <param name="source"></param>
/// <param name="cancellationToken">Cancellation token.</param> /// <param name="cancellationToken"></param>
/// <returns>Close result envelope.</returns> /// <returns></returns>
[HttpPost("{wisagId:int}/{source}/{processId:int}/closing")] [HttpPost("{wisagId:int}/{source}/{processId:long}/closing")]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status409Conflict)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status500InternalServerError)]
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status409Conflict)] public async Task<IActionResult> CloseAsync(
[ProducesResponseType(typeof(MetaOnlyResponse), StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<MetaOnlyResponse>> CloseAsync(
[FromRoute] int wisagId, [FromRoute] int wisagId,
[FromRoute] string source, [FromRoute] long processId,
[FromRoute] int processId, [FromBody] CloseWorkflowReqBody body,
[FromBody] CloseWorkflowRequest request, [FromRoute] string source = "Ferdinand",
CancellationToken cancellationToken) CancellationToken cancellationToken = default)
{ {
var command = new CloseWorkflowCommand( var result = await sender.Send(
wisagId, new CloseWorkflowCommand(
source, WisagId: wisagId,
processId, Source: source,
request.ClosingMethodId, ProcessId: processId,
request.Comment, ClosingMethodId: body.ClosingMethodId,
request.RejectionReasonId); Comment: body.Comment,
RejectionReasonId: body.RejectionReasonId),
cancellationToken);
var response = await sender.Send(command, cancellationToken); var metaResult = new CloseWorkflowReqResponse() { Meta = [result] };
return Ok(new MetaOnlyResponse return result.Code switch
{ {
Meta = response.Meta 0 => Ok(metaResult),
}); 4 => BadRequest(metaResult),
6 => NotFound(metaResult),
7 => Conflict(metaResult),
_ => StatusCode(StatusCodes.Status500InternalServerError, metaResult)
};
} }
} }

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
@@ -10,9 +10,9 @@
<Authors>Digital Data GmbH</Authors> <Authors>Digital Data GmbH</Authors>
<Company>Digital Data GmbH</Company> <Company>Digital Data GmbH</Company>
<Product>DigitalData.TaskFlow.API</Product> <Product>DigitalData.TaskFlow.API</Product>
<Version>1.0.0-beta</Version> <Version>1.4.0-beta</Version>
<FileVersion>1.0.0.0</FileVersion> <FileVersion>1.4.0.0</FileVersion>
<AssemblyVersion>1.0.0.0</AssemblyVersion> <AssemblyVersion>1.4.0.0</AssemblyVersion>
<Copyright>Copyright © 2026 Digital Data GmbH. All rights reserved.</Copyright> <Copyright>Copyright © 2026 Digital Data GmbH. All rights reserved.</Copyright>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile> <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
@@ -30,10 +30,6 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Properties\PublishProfiles\IISProfileNet8.pubxml.user" /> <None Include="Properties\PublishProfiles\IISProfileNet8.pubxml.user" />
</ItemGroup> </ItemGroup>

View File

@@ -1,51 +1,55 @@
using DigitalData.TaskFlow.API.Contracts.Common; using DigitalData.TaskFlow.API.Options;
using DigitalData.TaskFlow.Domain.Common; using Microsoft.Extensions.Options;
using DigitalData.TaskFlow.Domain.Enums;
using System.Text.Json; using System.Text.Json;
namespace DigitalData.TaskFlow.API.Middleware; namespace DigitalData.TaskFlow.API.Middleware;
/// <summary> /// <summary>
/// Validates required API key header for API endpoints. /// Enforces API key authentication for all requests under the /api path prefix.
/// Expects the key to be supplied via the <c>X-Api-Key</c> request header.
/// </summary> /// </summary>
public sealed class ApiKeyAuthMiddleware(RequestDelegate next) public sealed class ApiKeyAuthMiddleware(RequestDelegate next, IOptions<ApiKeyAuthOptions> options)
{ {
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web); private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
/// <summary> // Snapshot at startup; options are not expected to change at runtime.
/// Executes middleware logic. private readonly string? _configuredKey = options.Value.Key;
/// </summary>
/// <param name="context">HTTP context.</param> /// <inheritdoc />
public async Task InvokeAsync(HttpContext context) public async Task InvokeAsync(HttpContext context)
{ {
// Only guard /api/** routes; let non-API paths pass through (e.g. health, swagger).
if (!context.Request.Path.StartsWithSegments("/api", StringComparison.OrdinalIgnoreCase)) if (!context.Request.Path.StartsWithSegments("/api", StringComparison.OrdinalIgnoreCase))
{ {
await next(context); await next(context);
return; return;
} }
if (context.Request.Headers.TryGetValue("X-Api-Key", out var values) // Treat a missing or empty configured key as a misconfiguration — deny all traffic.
&& !string.IsNullOrWhiteSpace(values.FirstOrDefault())) if (!string.IsNullOrWhiteSpace(_configuredKey)
&& context.Request.Headers.TryGetValue("X-Api-Key", out var provided)
&& string.Equals(provided, _configuredKey, StringComparison.Ordinal))
{ {
await next(context); await next(context);
return; return;
} }
context.Response.StatusCode = StatusCodes.Status401Unauthorized; await WriteUnauthorizedAsync(context);
context.Response.ContentType = "application/json";
var response = new MetaOnlyResponse
{
Meta =
[
new MetaEntry
{
Code = (int)MetaCode.InvalidRequest,
Message = "Authentifizierung fehlgeschlagen"
} }
]
private static Task WriteUnauthorizedAsync(HttpContext context)
{
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
context.Response.ContentType = "application/problem+json";
var body = new
{
type = "https://tools.ietf.org/html/rfc7807",
title = "Unauthorized",
status = StatusCodes.Status401Unauthorized,
detail = "A valid API key must be supplied via the X-Api-Key header."
}; };
await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions)); return context.Response.WriteAsync(JsonSerializer.Serialize(body, JsonOptions));
} }
} }

View File

@@ -1,110 +1,98 @@
using DigitalData.TaskFlow.Application.Common.Exceptions; using DigitalData.TaskFlow.Application.Common.Exceptions;
using DigitalData.TaskFlow.API.Contracts.Common;
using DigitalData.TaskFlow.Domain.Common;
using DigitalData.TaskFlow.Domain.Enums;
using FluentValidation; using FluentValidation;
using System.Text.Json; using System.Text.Json;
namespace DigitalData.TaskFlow.API.Middleware; namespace DigitalData.TaskFlow.API.Middleware;
/// <summary> /// <summary>
/// Handles exceptions globally and returns ticket-compatible API envelopes. /// Handles exceptions globally and returns RFC 7807 (Problem Details) compatible API envelopes.
/// </summary> /// </summary>
public sealed class ExceptionHandlingMiddleware(RequestDelegate next, ILogger<ExceptionHandlingMiddleware> logger) public sealed class ExceptionHandlingMiddleware(RequestDelegate next, ILogger<ExceptionHandlingMiddleware> logger)
{ {
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web); private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
/// <summary> /// <summary>
/// Executes the middleware. ///
/// </summary> /// </summary>
/// <param name="context">HTTP context.</param> /// <param name="context"></param>
/// <returns></returns>
public async Task InvokeAsync(HttpContext context) public async Task InvokeAsync(HttpContext context)
{ {
try try
{ {
await next(context); await next(context);
} }
catch (ApiException apiException) catch (ValidationException ex)
{ {
logger.LogWarning(apiException, "API exception intercepted."); logger.LogWarning(ex, "Validation failed for {Method} {Path}",
context.Request.Method, context.Request.Path);
context.Response.StatusCode = apiException.StatusCode; var errors = ex.Errors
context.Response.ContentType = "application/json"; .GroupBy(e => e.PropertyName)
.ToDictionary(
g => g.Key,
g => g.Select(e => e.ErrorMessage).ToArray()
);
var response = new MetaOnlyResponse var response = new
{ {
Meta = type = "https://tools.ietf.org/html/rfc7807",
[ title = "Validation Error",
new MetaEntry status = StatusCodes.Status400BadRequest,
{ errors
Code = (int)apiException.MetaCode,
Message = apiException.Message
}
]
}; };
await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions));
}
catch (ValidationException validationException)
{
logger.LogWarning(validationException, "Validation failed.");
context.Response.StatusCode = StatusCodes.Status400BadRequest; context.Response.StatusCode = StatusCodes.Status400BadRequest;
context.Response.ContentType = "application/json"; context.Response.ContentType = "application/problem+json";
var message = validationException.Errors.FirstOrDefault()?.ErrorMessage
?? "Ungultiger Request";
var response = new MetaOnlyResponse
{
Meta =
[
new MetaEntry
{
Code = (int)MetaCode.InvalidRequest,
Message = message
}
]
};
await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions)); await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions));
} }
catch (NotSupportedException notSupportedException) catch (InvalidWorkflowPayloadException ex)
{ {
logger.LogWarning(notSupportedException, "Operation not supported yet."); logger.LogError(ex, "Invalid upstream payload for {Method} {Path}",
context.Request.Method, context.Request.Path);
context.Response.StatusCode = StatusCodes.Status500InternalServerError; var response = new
context.Response.ContentType = "application/json";
var response = new MetaOnlyResponse
{ {
Meta = type = "https://tools.ietf.org/html/rfc7807",
[ title = "Bad Gateway",
new MetaEntry status = StatusCodes.Status502BadGateway,
{ detail = ex.Message
Code = (int)MetaCode.InternalError,
Message = notSupportedException.Message
}
]
}; };
context.Response.StatusCode = StatusCodes.Status502BadGateway;
context.Response.ContentType = "application/problem+json";
await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions)); await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions));
} }
catch (Exception exception) catch (NotImplementedException ex)
{ {
logger.LogError(exception, "Unhandled exception."); logger.LogWarning(ex, "Not implemented: {Method} {Path}",
context.Request.Method, context.Request.Path);
var response = new
{
type = "https://tools.ietf.org/html/rfc7807",
title = "Not Implemented",
status = StatusCodes.Status501NotImplemented
};
context.Response.StatusCode = StatusCodes.Status501NotImplemented;
context.Response.ContentType = "application/problem+json";
await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions));
}
catch (Exception ex)
{
logger.LogError(ex, "Unhandled exception for {Method} {Path}",
context.Request.Method, context.Request.Path);
var response = new
{
type = "https://tools.ietf.org/html/rfc7807",
title = "Internal Server Error",
status = StatusCodes.Status500InternalServerError
};
context.Response.StatusCode = StatusCodes.Status500InternalServerError; context.Response.StatusCode = StatusCodes.Status500InternalServerError;
context.Response.ContentType = "application/json"; context.Response.ContentType = "application/problem+json";
var response = new MetaOnlyResponse
{
Meta =
[
new MetaEntry
{
Code = (int)MetaCode.InternalError,
Message = "Interner Fehler"
}
]
};
await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions)); await context.Response.WriteAsync(JsonSerializer.Serialize(response, JsonOptions));
} }
} }

View File

@@ -0,0 +1,26 @@
using System.Text.Json.Serialization;
namespace DigitalData.TaskFlow.API.Models;
/// <summary>
///
/// </summary>
public class CloseWorkflowReqBody
{
/// <summary>
///
/// </summary>
[JsonPropertyName("closing_method_id")]
public int ClosingMethodId { get; init; }
/// <summary>
///
/// </summary>
public string? Comment { get; init; }
/// <summary>
///
/// </summary>
[JsonPropertyName("rejection_reason_id")]
public byte? RejectionReasonId { get; init; }
}

View File

@@ -0,0 +1,14 @@
using DigitalData.TaskFlow.Application.Features.Workflows.Commands;
namespace DigitalData.TaskFlow.API.Models;
/// <summary>
///
/// </summary>
public class CloseWorkflowReqResponse
{
/// <summary>
///
/// </summary>
public List<CloseWorkflowResult> Meta { get; init; } = [];
}

View File

@@ -0,0 +1,8 @@
namespace DigitalData.TaskFlow.API.Options;
public sealed class ApiKeyAuthOptions
{
public const string SectionName = "ApiKey";
public string? Key { get; init; }
}

View File

@@ -70,6 +70,8 @@ try
builder.Services.AddControllers(); builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
var apiKeyConfigured = !string.IsNullOrWhiteSpace(config[$"{ApiKeyAuthOptions.SectionName}:Key"]);
builder.Services.AddSwaggerGen(options => builder.Services.AddSwaggerGen(options =>
{ {
options.SwaggerDoc("v1", new OpenApiInfo options.SwaggerDoc("v1", new OpenApiInfo
@@ -77,11 +79,11 @@ try
Title = "DigitalData TaskFlow API", Title = "DigitalData TaskFlow API",
Version = "v1", Version = "v1",
Description = """ Description = """
Integration API for taskFLOW workflow and document operations. Integrations-API für taskFLOW Workflow- und Dokumentenoperationen.
--- ---
- [Serilog Log Viewer](/serilog-ui) - [Serilog Protokoll-Viewer](/serilog-ui)
""", """,
Contact = new OpenApiContact Contact = new OpenApiContact
{ {
@@ -90,12 +92,42 @@ try
Email = "info-flow@digitaldata.works" Email = "info-flow@digitaldata.works"
} }
}); });
if (apiKeyConfigured)
{
options.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme
{
Type = SecuritySchemeType.ApiKey,
In = ParameterLocation.Header,
Name = "X-Api-Key",
Description = "Optionaler API-Schlüssel. Leer lassen, falls nicht erforderlich."
});
options.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "ApiKey"
}
},
[]
}
});
}
}); });
builder.Services builder.Services
.AddOptions<SwaggerOptions>() .AddOptions<SwaggerOptions>()
.Bind(config.GetSection(SwaggerOptions.SectionName)); .Bind(config.GetSection(SwaggerOptions.SectionName));
builder.Services
.AddOptions<ApiKeyAuthOptions>()
.Bind(config.GetSection(ApiKeyAuthOptions.SectionName));
builder.Services.AddSerilogUi(options => builder.Services.AddSerilogUi(options =>
{ {
options.UseSqliteServer(databaseOptions => options.UseSqliteServer(databaseOptions =>
@@ -110,11 +142,18 @@ try
var swaggerOptions = app.Services var swaggerOptions = app.Services
.GetRequiredService<Microsoft.Extensions.Options.IOptions<SwaggerOptions>>() .GetRequiredService<Microsoft.Extensions.Options.IOptions<SwaggerOptions>>()
.Value; .Value;
var apiKeyOptions = app.Services
.GetRequiredService<Microsoft.Extensions.Options.IOptions<ApiKeyAuthOptions>>()
.Value;
var enableSwagger = app.Environment.IsDevelopment() || swaggerOptions.EnabledInProduction; var enableSwagger = app.Environment.IsDevelopment() || swaggerOptions.EnabledInProduction;
var enforceApiKey = !string.IsNullOrWhiteSpace(apiKeyOptions.Key);
app.UseMiddleware<ExceptionHandlingMiddleware>(); app.UseMiddleware<ExceptionHandlingMiddleware>();
if (enforceApiKey)
{
app.UseMiddleware<ApiKeyAuthMiddleware>(); app.UseMiddleware<ApiKeyAuthMiddleware>();
}
app.UseSerilogRequestLogging(); app.UseSerilogRequestLogging();
if (enableSwagger) if (enableSwagger)

View File

@@ -4,8 +4,8 @@
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
"iisExpress": { "iisExpress": {
"applicationUrl": "http://localhost:3557", "applicationUrl": "http://localhost:63206",
"sslPort": 44339 "sslPort": 44315
} }
}, },
"profiles": { "profiles": {
@@ -14,7 +14,7 @@
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger", "launchUrl": "swagger",
"applicationUrl": "http://localhost:5298", "applicationUrl": "http://localhost:5062",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
@@ -24,7 +24,7 @@
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger", "launchUrl": "swagger",
"applicationUrl": "https://localhost:7049;http://localhost:5298", "applicationUrl": "https://localhost:7131;http://localhost:5062",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@@ -1,44 +0,0 @@
# DigitalData.TaskFlow.API
Dieses Projekt stellt die HTTP-Schnittstelle fuer externe Konsumenten bereit.
## Zweck
Die API-Schicht nimmt HTTP-Requests entgegen, leitet diese an die Application-Schicht weiter und liefert standardisierte Responses zurueck.
## Aktueller Inhalt
- `Program.cs`
- Startpunkt der ASP.NET-Core-Anwendung.
- Registriert Application- und Infrastructure-Dienste.
- Enthält Grundkonfiguration fuer Controller und OpenAPI/Swagger.
- `appsettings.json`
- Allgemeine Runtime-Konfiguration (Logging, ConnectionString, MediatR-Lizenz, Swagger-Optionen).
- `Controllers/`
- Zielordner fuer HTTP-Controller (aktuell noch leer).
- `Options/`
- API-spezifische Konfigurationsmodelle (z. B. `SwaggerOptions`).
## Geplante Inhalte (naechste Phasen)
- Controller fuer:
- `GET /workflows/{wisagid}`
- `POST /workflows/{wisagid}/{source}/{processid}/closing`
- `GET /documents/{id}`
- Middleware fuer:
- FluentValidation-Fehlerbehandlung
- Generelle Exception-Behandlung
- OpenAPI-Dokumentation:
- Swagger in Development, optional in Production
- Firmen-/Produkt-Metadaten
- Scalar als alternative UI
## Architektur-Regeln
- Keine direkte SQL- oder EF-Core-Logik im Controller.
- Transport-spezifische Aufgaben bleiben in API; fachliche Verarbeitung erfolgt in Application.
- Einheitliches Response-Schema gemaess Ticket-Vorgabe (`meta.code`, `meta.message`).
## Rolle im Gesamtsystem
Die API ist das Eingangstor fuer externe Systeme (z. B. fabrik19) und sorgt fuer stabile, versionierbare und gut dokumentierte Endpunkte.

View File

@@ -10,6 +10,9 @@
} }
} }
}, },
"ApiKey": {
"Key": "jGXP7m536fnyTVCh4NROu1wgjaSOrJ5"
},
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",

View File

@@ -13,16 +13,13 @@
"ConnectionStrings": { "ConnectionStrings": {
"TaskFlowDb": "Server=SDD-VHP04-SQL19\\DD_TESTING01;Database=DD_ECM;User Id=sa;Password=123456789dD!;Encrypt=false;TrustServerCertificate=True;" "TaskFlowDb": "Server=SDD-VHP04-SQL19\\DD_TESTING01;Database=DD_ECM;User Id=sa;Password=123456789dD!;Encrypt=false;TrustServerCertificate=True;"
}, },
"MediatR": { "ApiKey": {
"LuckyPennySoftLicenseKey": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx1Y2t5UGVubnlTb2Z0d2FyZUxpY2Vuc2VLZXkvYmJiMTNhY2I1OTkwNGQ4OWI0Y2IxYzg1ZjA4OGNjZjkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2x1Y2t5cGVubnlzb2Z0d2FyZS5jb20iLCJhdWQiOiJMdWNreVBlbm55U29mdHdhcmUiLCJleHAiOiIxODE2MTI4MDAwIiwiaWF0IjoiMTc4NDYyNDU1NyIsImFjY291bnRfaWQiOiIwMTk4M2M1OWU0YjM3MjhlYmZkMzEwM2MyYTQ4NmU4NSIsImN1c3RvbWVyX2lkIjoiMDE5ODNjNTllNGIzNzI4ZWJmZDMxMDNjMmE0ODZlODUiLCJzdWJfaWQiOiItIiwiZWRpdGlvbiI6IjAiLCJ0eXBlIjoiMiJ9.IUUO926m9crYGYxMjjKD_n9BnUm-EDyjFIn0YmMUCo7C-QTwvB8WhXP8veTSFsBq-leIIDJ4jyl7Pgc_7ciwg1XhUSIs4mkQroEUaSFCGOxw7Pi41WM8MK5YFSaqLTYYXec9zxgiJbGzABbh3CHTSup3okGnVm_CMoPEs91l2c0A6N1JyZy74urd_tF0KGVKf0MOvzdlQIWLQ8o73S4pTv2N-F6UlzI0fdMtTHMLNNQyr0NdWdnuBk_jMBXO-gy5RE_oCRfMTTYRX2n3XLK6pTfXE0Ct338o9F5sH8Ph2lTXSu56cpdsfZOQZGqCH0LoFp1Dd7RJgIgNmBiTGfvDnA" "Key": "jGXP7m536fnyTVCh4NROu1wgjaSOrJ5"
}, },
"LuckyPennySoftLicenseKey": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx1Y2t5UGVubnlTb2Z0d2FyZUxpY2Vuc2VLZXkvYmJiMTNhY2I1OTkwNGQ4OWI0Y2IxYzg1ZjA4OGNjZjkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2x1Y2t5cGVubnlzb2Z0d2FyZS5jb20iLCJhdWQiOiJMdWNreVBlbm55U29mdHdhcmUiLCJleHAiOiIxODE2MTI4MDAwIiwiaWF0IjoiMTc4NDYyNDU1NyIsImFjY291bnRfaWQiOiIwMTk4M2M1OWU0YjM3MjhlYmZkMzEwM2MyYTQ4NmU4NSIsImN1c3RvbWVyX2lkIjoiMDE5ODNjNTllNGIzNzI4ZWJmZDMxMDNjMmE0ODZlODUiLCJzdWJfaWQiOiItIiwiZWRpdGlvbiI6IjAiLCJ0eXBlIjoiMiJ9.IUUO926m9crYGYxMjjKD_n9BnUm-EDyjFIn0YmMUCo7C-QTwvB8WhXP8veTSFsBq-leIIDJ4jyl7Pgc_7ciwg1XhUSIs4mkQroEUaSFCGOxw7Pi41WM8MK5YFSaqLTYYXec9zxgiJbGzABbh3CHTSup3okGnVm_CMoPEs91l2c0A6N1JyZy74urd_tF0KGVKf0MOvzdlQIWLQ8o73S4pTv2N-F6UlzI0fdMtTHMLNNQyr0NdWdnuBk_jMBXO-gy5RE_oCRfMTTYRX2n3XLK6pTfXE0Ct338o9F5sH8Ph2lTXSu56cpdsfZOQZGqCH0LoFp1Dd7RJgIgNmBiTGfvDnA",
"Swagger": { "Swagger": {
"EnabledInProduction": false "EnabledInProduction": false
}, },
"Database": {
"CommandTimeoutSeconds": 30,
"WorkflowListingObjectType": "Ferdinand"
},
"Application": { "Application": {
"LogDirectory": "logs" "LogDirectory": "logs"
}, },