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 DocumentId,
int ReceiverId, int ReceiverId,
int ElementType, int ElementType,
double PositionX, double X,
double PositionY, double Y,
double Width, double Width,
double Height, double Height,
int Page, int Page,

View File

@ -1,6 +1,4 @@
using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.DTOs
namespace EnvelopeGenerator.Application.DTOs
{ {
public record EnvelopeReceiverDto( public record EnvelopeReceiverDto(
int EnvelopeId, 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) 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) if (message is not null)
sb.AppendLine().Append(message); sb.AppendLine(message);
if(exception is null) if(exception is null)
logger.Log(LogLevel.Error, sb.ToString(), args); logger.Log(LogLevel.Error, sb.ToString(), args);
else 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) 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) 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] [Required]
[Column("POSITION_X")] [Column("POSITION_X")]
[DefaultValue(0)] [DefaultValue(0)]
public double PositionX { get; set; } public double X { get; set; }
[Required] [Required]
[Column("POSITION_Y")] [Column("POSITION_Y")]
[DefaultValue(0)] [DefaultValue(0)]
public double PositionY { get; set; } public double Y { get; set; }
[Required] [Required]
[Column("WIDTH")] [Column("WIDTH")]
@ -83,9 +83,9 @@ namespace EnvelopeGenerator.Domain.Entities
public virtual Receiver? Receiver { get; set; } public virtual Receiver? Receiver { get; set; }
[NotMapped] [NotMapped]
public double Top => Math.Round(PositionY, 5); public double Top => Math.Round(Y, 5);
[NotMapped] [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.Resources;
using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Application.DTOs;
using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Localization;
using Newtonsoft.Json.Linq;
using Microsoft.Extensions.Configuration;
using Ganss.Xss;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers namespace EnvelopeGenerator.Web.Controllers
{ {
@ -54,9 +50,7 @@ namespace EnvelopeGenerator.Web.Controllers
{ {
EnvelopeResponse response = await envelopeOldService.LoadEnvelope(envelopeReceiverId); EnvelopeResponse response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
bool accessCodeAlreadyRequested = database.Models.receiverModel.AccessCodeAlreadyRequested(response.Receiver.Email, response.Envelope.Id); bool accessCodeAlreadyRequested = await _historyService.AccessCodeAlreadyRequested(envelopeId: er.Envelope!.Id, userReference: er.Receiver!.EmailAddress);
accessCodeAlreadyRequested = await _historyService.AccessCodeAlreadyRequested(envelopeId: er.Envelope!.Id, userReference: er.Receiver!.EmailAddress);
if (!accessCodeAlreadyRequested) if (!accessCodeAlreadyRequested)
{ {
// Send email with password // Send email with password
@ -113,7 +107,7 @@ namespace EnvelopeGenerator.Web.Controllers
if(uuid is null || signature is null) 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]); return BadRequest(_localizer[MessageKey.WrongEnvelopeReceiverId]);
} }

View File

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

View File

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

View File

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