Aktualisiert, um EnvelopeReceiverDto anstelle von EnvelopeResponse zu verwenden

This commit is contained in:
Developer 02 2024-05-08 12:10:24 +02:00
parent d8617093ce
commit 357866ea44
8 changed files with 21 additions and 39 deletions

View File

@ -5,8 +5,8 @@
int DocumentId,
int ReceiverId,
int ElementType,
double PositionX,
double PositionY,
double X,
double Y,
double Width,
double Height,
int Page,

View File

@ -1,6 +1,4 @@
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Application.DTOs
namespace EnvelopeGenerator.Application.DTOs
{
public record EnvelopeReceiverDto(
int EnvelopeId,

View File

@ -8,15 +8,15 @@ namespace EnvelopeGenerator.Application
{
public static void LogEnvelopeError(this ILogger logger, string envelopeEeceiverId, Exception? exception = null, string? message = null, params object?[] args)
{
var sb = new StringBuilder(envelopeEeceiverId.DecodeEnvelopeReceiverId().ToTitle());
var sb = new StringBuilder().AppendLine(envelopeEeceiverId.DecodeEnvelopeReceiverId().ToTitle());
if (message is not null)
sb.AppendLine().Append(message);
sb.AppendLine(message);
if(exception is null)
logger.Log(LogLevel.Error, sb.ToString(), args);
else
logger.Log(LogLevel.Error, exception, sb.ToString(), args);
logger.Log(LogLevel.Error, exception, sb.AppendLine(exception.Message).ToString(), args);
}
public static void LogEnvelopeError(this ILogger logger, string? uuid, string? signature = null, Exception? exception = null, string? message = null, params object?[] args)
@ -37,7 +37,7 @@ namespace EnvelopeGenerator.Application
public static string ToTitle(this (string? UUID, string? Signature) envelopeReceiverTuple)
{
return $"UUID is {envelopeReceiverTuple.UUID} and \n signature is {envelopeReceiverTuple.Signature}";
return $"UUID is {envelopeReceiverTuple.UUID} and signature is {envelopeReceiverTuple.Signature}";
}
}
}

View File

@ -28,12 +28,12 @@ namespace EnvelopeGenerator.Domain.Entities
[Required]
[Column("POSITION_X")]
[DefaultValue(0)]
public double PositionX { get; set; }
public double X { get; set; }
[Required]
[Column("POSITION_Y")]
[DefaultValue(0)]
public double PositionY { get; set; }
public double Y { get; set; }
[Required]
[Column("WIDTH")]
@ -83,9 +83,9 @@ namespace EnvelopeGenerator.Domain.Entities
public virtual Receiver? Receiver { get; set; }
[NotMapped]
public double Top => Math.Round(PositionY, 5);
public double Top => Math.Round(Y, 5);
[NotMapped]
public double Left => Math.Round(PositionX, 5);
public double Left => Math.Round(X, 5);
}
}

View File

@ -14,11 +14,7 @@ using DigitalData.Core.DTO;
using EnvelopeGenerator.Application.Resources;
using EnvelopeGenerator.Application.DTOs;
using Microsoft.AspNetCore.Localization;
using Newtonsoft.Json.Linq;
using Microsoft.Extensions.Configuration;
using Ganss.Xss;
using System.Text.Encodings.Web;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers
{
@ -54,9 +50,7 @@ namespace EnvelopeGenerator.Web.Controllers
{
EnvelopeResponse response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
bool accessCodeAlreadyRequested = database.Models.receiverModel.AccessCodeAlreadyRequested(response.Receiver.Email, response.Envelope.Id);
accessCodeAlreadyRequested = await _historyService.AccessCodeAlreadyRequested(envelopeId: er.Envelope!.Id, userReference: er.Receiver!.EmailAddress);
bool accessCodeAlreadyRequested = await _historyService.AccessCodeAlreadyRequested(envelopeId: er.Envelope!.Id, userReference: er.Receiver!.EmailAddress);
if (!accessCodeAlreadyRequested)
{
// Send email with password
@ -113,7 +107,7 @@ namespace EnvelopeGenerator.Web.Controllers
if(uuid is null || signature is null)
{
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: _localizer[MessageKey.WrongEnvelopeReceiverId.ToString()]);
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: _localizer[MessageKey.WrongEnvelopeReceiverId]);
return BadRequest(_localizer[MessageKey.WrongEnvelopeReceiverId]);
}

View File

@ -57,13 +57,11 @@
</script>
@if (ViewData["DocumentBytes"] is byte[] documentBytes)
{
var envelopeResponse = ViewData["EnvelopeResponse"];
var settings = new Newtonsoft.Json.JsonSerializerSettings
{
ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
};
var envelopeResponseJson = Newtonsoft.Json.JsonConvert.SerializeObject(envelopeResponse, settings);
var envelopeReceiverJson = Newtonsoft.Json.JsonConvert.SerializeObject(Model, settings);
var documentBase64String = Convert.ToBase64String(documentBytes);
var envelopeKey = ViewData["EnvelopeKey"] as string;
@ -78,9 +76,8 @@
var byteArray = new Uint8Array(byteNumbers);
var documentArrayBuffer = byteArray.buffer;
var envelopeResponse = @Html.Raw(envelopeResponseJson.TrySanitize(_sanitizer));
document.addEventListener("DOMContentLoaded", async () => {
const app = new App("#app", "@envelopeKey.TrySanitize(_sanitizer)", envelopeResponse, documentArrayBuffer, "@ViewData["PSPDFKitLicenseKey"]");
const app = new App("#app", "@envelopeKey.TrySanitize(_sanitizer)", @Html.Raw(envelopeReceiverJson.TrySanitize(_sanitizer)), documentArrayBuffer, "@ViewData["PSPDFKitLicenseKey"]");
await app.init();
})
</script>

View File

@ -50,14 +50,7 @@
"logger": "*",
"level": "Fatal",
"writeTo": "criticalLogs"
},
{
"logger": "EnvelopeGenerator.Web.Controllers.*",
"minLevel": "Error",
"writeTo": "errorLogs",
"final": true
}
]
},
"AddTestControllers": true,

View File

@ -10,7 +10,7 @@ const ActionType = {
}
class App {
constructor(container, envelopeKey, envelopeResponse, documentBytes, licenseKey) {
constructor(container, envelopeKey, envelopeReceiver, documentBytes, licenseKey) {
this.container = container
this.envelopeKey = envelopeKey
@ -21,8 +21,8 @@ class App {
this.Instance = null
this.currentDocument = null
this.currentReceiver = null
this.signatureCount = 0
this.envelopeResponse = envelopeResponse;
this.signatureCount = 0;
this.envelopeReceiver = envelopeReceiver;
this.documentBytes = documentBytes;
this.licenseKey = licenseKey;
}
@ -31,8 +31,8 @@ class App {
// and will trigger loading of the Editor Interface
async init() {
// Load the envelope from the database
this.currentDocument = this.envelopeResponse.envelope.documents[0]
this.currentReceiver = this.envelopeResponse.receiver
this.currentDocument = this.envelopeReceiver.envelope.documents[0]
this.currentReceiver = this.envelopeReceiver.receiver
// Load the document from the filestore
const documentResponse = this.documentBytes
@ -109,7 +109,7 @@ class App {
const timestamp = new Date()
const imageUrl = await this.Annotation.createAnnotationFrameBlob(
this.currentReceiver.name,
this.envelopeReceiver.name,
this.currentReceiver.signature,
timestamp,
width,