Compare commits

..

6 Commits

Author SHA1 Message Date
Developer 02
09a231d01f Add GetDocResultAsync method to EnvelopeController
Implemented a new asynchronous method `GetDocResultAsync` in the `EnvelopeController` class to retrieve document results by ID. Added XML documentation for clarity on parameters and responses. Enhanced user authorization handling and error logging for improved reliability.
2025-05-08 16:36:26 +02:00
Developer 02
2007ae91fb Add DocResult property and update EnvelopeController
- Introduced a new `DocResult` property in `EnvelopeDto.cs` and `Envelope.cs` for handling binary data.
- Rearranged properties in `EnvelopeDto.cs` for better organization.
- Modified `EnvelopeController` to return a collection of envelopes instead of a single envelope.
2025-05-08 15:46:02 +02:00
Developer 02
8d118308cd Remove Procedures folder and update configurations
- Removed folder reference for "Procedures" in the project file.
- Added `DocumentMod_Rotation` to the `Constants.vb` enum.
- Replaced `NonHistStatuses` with a new `Status` class containing `NonHist` and `RelatedToFormApp` lists.
- Updated `TimeLimit` in `appsettings.json` from "00:30:00" to "90.00:00:00".
2025-05-08 15:15:01 +02:00
Developer 02
1a978c0ab7 Update Constants.vb with new statuses and cleanup
Removed comment for SignatureConfirmed. Added a new shared read-only list, NonHistStatuses, containing EnvelopeStatus values: Invalid, EnvelopeSaved, EnvelopeSent, and EnvelopePartlySigned. Added TODO for standardization in xwiki. ReferenceType enum remains unchanged.
2025-05-08 14:26:36 +02:00
Developer 02
ce0b1f1785 Comment out unused constants in Constants.vb
The `SignatureConfirmed` and `DocumentMod_Rotation` constants have been commented out to indicate that they are no longer active or used in the code. This helps to clean up the codebase and improve maintainability.
2025-05-08 13:53:16 +02:00
Developer 02
0698b44b68 Refactor MemoryCacheExtensions and clean up HistoryController
- Introduced a static readonly field `BaseId` in `MemoryCacheExtensions.cs`.
- Refactored `GetEnumAsDictionary<TEnum>` to use expression-bodied syntax and LINQ for improved readability and efficiency.
- Removed the import statement for `Microsoft.IdentityModel.Tokens` in `HistoryController.cs`, indicating a potential shift in authentication/authorization handling.
2025-05-08 13:52:57 +02:00
8 changed files with 83 additions and 20 deletions

View File

@@ -66,6 +66,9 @@ namespace EnvelopeGenerator.Application.DTOs
public string? StatusTranslated { get; set; }
public string? ContractTypeTranslated { get; set; }
public IEnumerable<EnvelopeDocumentDto>? Documents { get; set; }
public byte[]? DocResult { get; init; }
public IEnumerable<EnvelopeDocumentDto>? Documents { get; set; }
}
}

View File

@@ -82,8 +82,4 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Procedures\" />
</ItemGroup>
</Project>

View File

@@ -21,7 +21,6 @@
DocumentOpened = 2004
DocumentSigned = 2005
DocumentForwarded = 4001
SignatureConfirmed = 2006
DocumentRejected = 2007
EnvelopeShared = 2008
EnvelopeViewed = 2009
@@ -33,6 +32,20 @@
DocumentMod_Rotation = 4001
End Enum
Public Class Status
Public Shared ReadOnly NonHist As IReadOnlyList(Of EnvelopeStatus) = New List(Of EnvelopeStatus) From {
EnvelopeStatus.Invalid,
EnvelopeStatus.EnvelopeSaved,
EnvelopeStatus.EnvelopeSent,
EnvelopeStatus.EnvelopePartlySigned
}
Public Shared ReadOnly RelatedToFormApp As IReadOnlyList(Of EnvelopeStatus) = New List(Of EnvelopeStatus) From {
EnvelopeStatus.EnvelopeCreated,
EnvelopeStatus.DocumentMod_Rotation
}
End Class
'TODO: standardize in xwiki
Public Enum ReferenceType
Receiver = 0

View File

@@ -86,6 +86,9 @@ namespace EnvelopeGenerator.Domain.Entities
[Column("TFA_ENABLED", TypeName = "bit")]
public bool TFAEnabled { get; set; }
[Column("DOC_RESULT", TypeName = "varbinary(max)")]
public byte[]? DocResult { get; init; }
/// <summary>
/// The sender of envelope
/// </summary>

View File

@@ -1,20 +1,16 @@
using Microsoft.Extensions.Caching.Memory;
using System;
namespace EnvelopeGenerator.Extensions;
public static class MemoryCacheExtensions
{
private static readonly Guid BaseId = Guid.NewGuid();
public static IDictionary<string, int> GetEnumAsDictionary<TEnum>(this IMemoryCache memoryCache)
where TEnum : Enum
{
var dict = new Dictionary<string, int>();
foreach (TEnum role in Enum.GetValues(typeof(TEnum)))
{
dict[role.ToString()] = Convert.ToInt32(role);
}
return dict;
}
=> memoryCache.GetOrCreate(BaseId + typeof(TEnum).FullName, _ =>
Enum.GetValues(typeof(TEnum))
.Cast<TEnum>()
.ToDictionary(e => e.ToString(), e => Convert.ToInt32(e)))
?? throw new InvalidOperationException($"Failed to cache or retrieve enum dictionary for type '{typeof(TEnum).FullName}'.");
}

View File

@@ -76,7 +76,60 @@ public class EnvelopeController : ControllerBase
if (envelope.Uuid is string uuid)
envelopes = envelopes.Where(e => e.Uuid == uuid);
return Ok(envelope);
return Ok(envelopes);
},
Fail: IActionResult (msg, ntc) =>
{
_logger.LogNotice(ntc);
return StatusCode(StatusCodes.Status500InternalServerError);
});
else
{
_logger.LogError("Trotz erfolgreicher Autorisierung wurde die Benutzer-ID nicht als Ganzzahl erkannt. Dies könnte auf eine fehlerhafte Erstellung der Anspruchsliste zurückzuführen sein.");
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
catch (Exception ex)
{
_logger.LogError(ex, "{Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
/// <summary>
/// Ruft das Ergebnis eines Dokuments basierend auf der ID ab.
/// </summary>
/// <param name="id">Die eindeutige ID des Umschlags.</param>
/// <param name="view">Gibt an, ob das Dokument inline angezeigt werden soll (true) oder als Download bereitgestellt wird (false).</param>
/// <returns>Eine IActionResult-Instanz, die das Dokument oder einen Fehlerstatus enthält.</returns>
/// <response code="200">Das Dokument wurde erfolgreich abgerufen.</response>
/// <response code="404">Das Dokument wurde nicht gefunden oder ist nicht verfügbar.</response>
/// <response code="500">Ein unerwarteter Fehler ist aufgetreten.</response>
[HttpGet("doc-result")]
public async Task<IActionResult> GetDocResultAsync([FromQuery] int id, [FromQuery] bool view = false)
{
try
{
if (User.GetId() is int intId)
return await _envelopeService.ReadByUserAsync(intId).ThenAsync(
Success: envelopes =>
{
var envelope = envelopes.Where(e => e.Id == id).FirstOrDefault();
if (envelope is null)
return NotFound("Envelope not available.");
else if (envelope?.DocResult is null)
return NotFound("The document has not been fully signed or the result has not yet been released.");
else
{
if (view)
{
Response.Headers.Append("Content-Disposition", "inline; filename=\"" + envelope.Uuid + ".pdf\"");
return File(envelope.DocResult, "application/pdf");
}
else
return File(envelope.DocResult, "application/pdf", $"{envelope.Uuid}.pdf");
}
},
Fail: IActionResult (msg, ntc) =>
{

View File

@@ -5,7 +5,6 @@ using EnvelopeGenerator.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.IdentityModel.Tokens;
using static EnvelopeGenerator.Common.Constants;

View File

@@ -140,7 +140,7 @@
}
},
"TFARegParams": {
"TimeLimit": "00:30:00"
"TimeLimit": "90.00:00:00"
},
"DbTriggerParams": {
"Envelope": [ "TBSIG_ENVELOPE_HISTORY_AFT_INS" ],