Compare commits
4 Commits
d8617093ce
...
dd18094deb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd18094deb | ||
|
|
4f61f1b6cb | ||
|
|
efcd254749 | ||
|
|
357866ea44 |
@@ -11,5 +11,7 @@ namespace EnvelopeGenerator.Application.Contracts
|
||||
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
|
||||
|
||||
Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference);
|
||||
|
||||
Task<bool> IsSigned(int envelopeId, string userReference);
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@
|
||||
int DocumentId,
|
||||
int ReceiverId,
|
||||
int ElementType,
|
||||
double PositionX,
|
||||
double PositionY,
|
||||
double X,
|
||||
double Y,
|
||||
double Width,
|
||||
double Height,
|
||||
int Page,
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
(
|
||||
int Id,
|
||||
int EnvelopeId,
|
||||
string Filename,
|
||||
string Filepath,
|
||||
DateTime AddedWhen,
|
||||
string FilenameOriginal,
|
||||
IEnumerable<DocumentReceiverElementDto>? Elements
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs
|
||||
namespace EnvelopeGenerator.Application.DTOs
|
||||
{
|
||||
public record EnvelopeReceiverDto(
|
||||
int EnvelopeId,
|
||||
|
||||
@@ -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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,20 @@ namespace EnvelopeGenerator.Application.Services
|
||||
}
|
||||
|
||||
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null) => await _repository.CountAsync(envelopeId: envelopeId, userReference: userReference, status: status);
|
||||
|
||||
public async Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference) => await _repository.CountAsync(envelopeId: envelopeId, userReference:userReference, status: (int) EnvelopeStatus.AccessCodeRequested) > 0;
|
||||
|
||||
public async Task<bool> HasStatus(EnvelopeStatus status, int envelopeId, string userReference) => await _repository.CountAsync(
|
||||
envelopeId: envelopeId,
|
||||
userReference: userReference,
|
||||
status: (int) status) > 0;
|
||||
|
||||
public async Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference) => await _repository.CountAsync(
|
||||
envelopeId: envelopeId,
|
||||
userReference:userReference,
|
||||
status: (int) EnvelopeStatus.AccessCodeRequested) > 0;
|
||||
|
||||
public async Task<bool> IsSigned(int envelopeId, string userReference) => await _repository.CountAsync(
|
||||
envelopeId: envelopeId,
|
||||
userReference: userReference,
|
||||
status: (int) EnvelopeStatus.DocumentSigned) > 0;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -120,9 +120,7 @@
|
||||
<Compile Include="frmFinalizePDF.Designer.vb">
|
||||
<DependentUpon>frmFinalizePDF.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmFinalizePDF.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmFinalizePDF.vb" />
|
||||
<Compile Include="frmReportViewer.Designer.vb">
|
||||
<DependentUpon>frmReportViewer.vb</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@@ -22,8 +22,6 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
[HttpGet]
|
||||
[Route("api/document/{envelopeKey}")]
|
||||
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
|
||||
{
|
||||
try
|
||||
@@ -47,8 +45,8 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/document/{envelopeKey}")]
|
||||
[Authorize]
|
||||
[HttpPost("api/document/{envelopeKey}")]
|
||||
public async Task<IActionResult> Open(string envelopeKey)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
[HttpGet("api/envelope/{envelopeKey}")]
|
||||
public async Task<IActionResult> Get([FromRoute] string envelopeKey)
|
||||
{
|
||||
try
|
||||
@@ -48,6 +47,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("api/envelope/{envelopeKey}")]
|
||||
public async Task<IActionResult> Update(string envelopeKey, int index)
|
||||
{
|
||||
|
||||
@@ -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,8 +107,8 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
|
||||
if(uuid is null || signature is null)
|
||||
{
|
||||
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: _localizer[MessageKey.WrongEnvelopeReceiverId.ToString()]);
|
||||
return BadRequest(_localizer[MessageKey.WrongEnvelopeReceiverId]);
|
||||
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: _localizer[MessageKey.WrongEnvelopeReceiverId]);
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
_logger.LogInformation($"Envelope UUID: [{uuid}]\nReceiver Signature: [{signature}]");
|
||||
@@ -125,19 +119,18 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
EnvelopeResponse response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
|
||||
if (isVerified)
|
||||
{
|
||||
//todo: write using crud-service (mostlikely history-service) to make it async
|
||||
if (envelopeOldService.ReceiverAlreadySigned(response.Envelope, response.Receiver.Id))
|
||||
{
|
||||
return View("EnvelopeSigned");
|
||||
}
|
||||
|
||||
database.Services.actionService.EnterCorrectAccessCode(response.Envelope, response.Receiver); //for history
|
||||
ViewData["EnvelopeKey"] = envelopeReceiverId;
|
||||
ViewData["EnvelopeResponse"] = response;
|
||||
|
||||
return await _envRcvService.ReadByUuidSignatureAsync(uuid: uuid, signature: signature).ThenAsync<EnvelopeReceiverDto, IActionResult>(
|
||||
SuccessAsync: async er =>
|
||||
{
|
||||
if(await _historyService.IsSigned(envelopeId: er.Envelope!.Id, userReference: er.Receiver!.EmailAddress))
|
||||
return View("EnvelopeSigned");
|
||||
|
||||
database.Services.actionService.EnterCorrectAccessCode(response.Envelope, response.Receiver); //for history
|
||||
ViewData["EnvelopeKey"] = envelopeReceiverId;
|
||||
|
||||
if (response.Envelope.Documents.Count() > 0)
|
||||
{
|
||||
var document = await envelopeOldService.GetDocument(response.Envelope.Documents[0].Id, envelopeReceiverId);
|
||||
@@ -181,7 +174,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
Fail: (messages, notices) =>
|
||||
{
|
||||
_logger.LogNotice(notices);
|
||||
return notices.HasFlag(Flag.SecurityBreach) ? Forbid() : StatusCode(StatusCodes.Status500InternalServerError, messages.Join());
|
||||
return Unauthorized();
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
@@ -233,7 +226,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
return Ok(new { EnvelopeUuid = envelopeUuid, ReceiverSignature = receiverSignature });
|
||||
}
|
||||
|
||||
[HttpGet("lang")]
|
||||
[NonAction]
|
||||
public IActionResult GetLanguage() => Ok(UserLanguage);
|
||||
|
||||
[HttpPost("lang")]
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -50,14 +50,7 @@
|
||||
"logger": "*",
|
||||
"level": "Fatal",
|
||||
"writeTo": "criticalLogs"
|
||||
},
|
||||
{
|
||||
"logger": "EnvelopeGenerator.Web.Controllers.*",
|
||||
"minLevel": "Error",
|
||||
"writeTo": "errorLogs",
|
||||
"final": true
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
"AddTestControllers": true,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user