Compare commits
16 Commits
08601adc49
...
e4c6714677
| Author | SHA1 | Date | |
|---|---|---|---|
| e4c6714677 | |||
| 812b49cfcb | |||
| f039437f4c | |||
| 6f73ba929c | |||
| fcbe956095 | |||
| e628309734 | |||
| d6cbd0597e | |||
| 9d45082bfc | |||
| 3304b01d7b | |||
| f5d33846d5 | |||
| 231140505e | |||
| 62a73e4967 | |||
| dedfb924d8 | |||
| 452077e86a | |||
|
|
a1688608ab | ||
|
|
f1920e16fa |
@@ -143,7 +143,9 @@ Namespace Jobs
|
|||||||
Logger.Debug("Documents merged!")
|
Logger.Debug("Documents merged!")
|
||||||
|
|
||||||
Dim oOutputDirectoryPath = Path.Combine(Config.ExportPath, ParentFolderUID)
|
Dim oOutputDirectoryPath = Path.Combine(Config.ExportPath, ParentFolderUID)
|
||||||
|
Logger.Debug($"oOutputDirectoryPath is {oOutputDirectoryPath}")
|
||||||
If Not Directory.Exists(oOutputDirectoryPath) Then
|
If Not Directory.Exists(oOutputDirectoryPath) Then
|
||||||
|
Logger.Debug($"Directory not existing. Creating ... ")
|
||||||
Directory.CreateDirectory(oOutputDirectoryPath)
|
Directory.CreateDirectory(oOutputDirectoryPath)
|
||||||
End If
|
End If
|
||||||
Dim oOutputFilePath = Path.Combine(oOutputDirectoryPath, $"{oEnvelope.Uuid}.pdf")
|
Dim oOutputFilePath = Path.Combine(oOutputDirectoryPath, $"{oEnvelope.Uuid}.pdf")
|
||||||
@@ -172,6 +174,7 @@ Namespace Jobs
|
|||||||
Throw New ApplicationException("Envelope could not be finalized")
|
Throw New ApplicationException("Envelope could not be finalized")
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
Logger.Warn(ex, $"Unhandled exception while working envelope [{oId}]")
|
Logger.Warn(ex, $"Unhandled exception while working envelope [{oId}]")
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
|
|||||||
@@ -594,31 +594,40 @@ Public Class frmMain
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtnitm_ResendInvitation.ItemClick
|
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtnitm_ResendInvitation.ItemClick
|
||||||
Dim oView As GridView = GridEnvelopes.FocusedView
|
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
|
||||||
Dim selReceiver As Receiver
|
Try
|
||||||
If oView.Name = ViewReceivers.Name Then
|
Dim oView As GridView = GridEnvelopes.FocusedView
|
||||||
selReceiver = oView.GetRow(oView.FocusedRowHandle)
|
Dim selReceiver As Receiver
|
||||||
Else
|
If oView.Name = ViewReceivers.Name Then
|
||||||
MsgBox(Resources.Envelope.Please_select_a_recipient_from_the_Recipients_tab, MsgBoxStyle.Information, Text)
|
selReceiver = oView.GetRow(oView.FocusedRowHandle)
|
||||||
End If
|
Else
|
||||||
If ViewEnvelopes.FocusedRowHandle < 0 Or IsNothing(selReceiver) Then
|
MsgBox(Resources.Envelope.Please_select_a_recipient_from_the_Recipients_tab, MsgBoxStyle.Information, Text)
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle)
|
|
||||||
|
|
||||||
Dim oController = New EnvelopeEditorController(State, oEnvelope)
|
|
||||||
Dim Documents As New BindingList(Of EnvelopeDocument)
|
|
||||||
Dim Receivers As New BindingList(Of Receiver)
|
|
||||||
Receivers = New BindingList(Of Receiver)(oController.Envelope.Receivers)
|
|
||||||
For Each oReceiver As Receiver In Receivers
|
|
||||||
If oReceiver.EmailAddress = selReceiver.EmailAddress Then
|
|
||||||
If oController.ActionService.ResendReceiver(oEnvelope, oReceiver) = True Then
|
|
||||||
Dim oMsg = Resources.Envelope.Invitation_successfully_resend.Replace("@Mail", oReceiver.EmailAddress)
|
|
||||||
MsgBox(oMsg, MsgBoxStyle.Information, Text)
|
|
||||||
|
|
||||||
End If
|
|
||||||
End If
|
End If
|
||||||
Next
|
If ViewEnvelopes.FocusedRowHandle < 0 Or IsNothing(selReceiver) Then
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle)
|
||||||
|
|
||||||
|
Dim oController = New EnvelopeEditorController(State, oEnvelope)
|
||||||
|
Dim Documents As New BindingList(Of EnvelopeDocument)
|
||||||
|
Dim Receivers As New BindingList(Of Receiver)
|
||||||
|
Receivers = New BindingList(Of Receiver)(oController.Envelope.Receivers)
|
||||||
|
For Each oReceiver As Receiver In Receivers
|
||||||
|
If oReceiver.EmailAddress = selReceiver.EmailAddress Then
|
||||||
|
If oController.ActionService.ResendReceiver(oEnvelope, oReceiver) = True Then
|
||||||
|
Dim oMsg = Resources.Envelope.Invitation_successfully_resend.Replace("@Mail", oReceiver.EmailAddress)
|
||||||
|
MsgBox(oMsg, MsgBoxStyle.Information, Text)
|
||||||
|
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Finally
|
||||||
|
|
||||||
|
|
||||||
|
End Try
|
||||||
|
SplashScreenManager.CloseOverlayForm(oHandle)
|
||||||
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class EnvelopeExecutor : SQLExecutor, IEnvelopeExecutor
|
|||||||
var envelopes = await connection.QueryAsync<Envelope>(formattedSql);
|
var envelopes = await connection.QueryAsync<Envelope>(formattedSql);
|
||||||
var envelope = envelopes.FirstOrDefault()
|
var envelope = envelopes.FirstOrDefault()
|
||||||
?? throw new InvalidOperationException($"Envelope creation failed. Parameters:" +
|
?? throw new InvalidOperationException($"Envelope creation failed. Parameters:" +
|
||||||
$"userId={userId}, title='{title}', message='{message}', tfaEnabled={tfaEnabled}."); ;
|
$"userId={userId}, title='{title}', message='{message}', tfaEnabled={tfaEnabled}.");
|
||||||
|
|
||||||
envelope.User = await _userRepository.ReadByIdAsync(envelope.UserId);
|
envelope.User = await _userRepository.ReadByIdAsync(envelope.UserId);
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ Public Class Scheduler_FinishEnvelope
|
|||||||
|
|
||||||
Await Scheduler.Start()
|
Await Scheduler.Start()
|
||||||
|
|
||||||
Logger.Info("Scheduler started!")
|
Logger.Debug("Scheduler started!")
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Logger.Error(ex)
|
Logger.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ Public Class Service
|
|||||||
TempFiles.Create()
|
TempFiles.Create()
|
||||||
|
|
||||||
' === Initialize Databases ===
|
' === Initialize Databases ===
|
||||||
Logger.Info("Inititalize Database ...")
|
Logger.Debug("Inititalize Database ...")
|
||||||
|
|
||||||
If Config.ConnectionString = String.Empty Then
|
If Config.ConnectionString = String.Empty Then
|
||||||
Throw New ApplicationException("Connection String is empty!")
|
Throw New ApplicationException("Connection String is empty!")
|
||||||
|
|||||||
@@ -1,153 +1,161 @@
|
|||||||
using DigitalData.Core.DTO;
|
using EnvelopeGenerator.CommonServices;
|
||||||
using EnvelopeGenerator.CommonServices;
|
|
||||||
using EnvelopeGenerator.Web.Services;
|
using EnvelopeGenerator.Web.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using static EnvelopeGenerator.CommonServices.Constants;
|
|
||||||
using EnvelopeGenerator.Extensions;
|
using EnvelopeGenerator.Extensions;
|
||||||
using EnvelopeGenerator.Application.Contracts.Services;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
using static EnvelopeGenerator.Domain.Constants;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using EnvelopeGenerator.Domain;
|
||||||
|
using DigitalData.Core.Abstraction.Application.DTO;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers
|
namespace EnvelopeGenerator.Web.Controllers;
|
||||||
|
|
||||||
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class EnvelopeController : BaseController
|
||||||
{
|
{
|
||||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
private readonly EnvelopeOldService envelopeService;
|
||||||
[ApiController]
|
private readonly ActionService? actionService;
|
||||||
[Route("api/[controller]")]
|
private readonly UrlEncoder _urlEncoder;
|
||||||
public class EnvelopeController : BaseController
|
[Obsolete("Use MediatR")]
|
||||||
|
private readonly IEnvelopeHistoryService _histService;
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
private readonly IReceiverService _receiverService;
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
private readonly IEnvelopeReceiverService _envRcvService;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public EnvelopeController(DatabaseService database,
|
||||||
|
EnvelopeOldService envelope,
|
||||||
|
ILogger<EnvelopeController> logger, UrlEncoder urlEncoder,
|
||||||
|
IEnvelopeHistoryService envelopeHistoryService,
|
||||||
|
IReceiverService receiverService,
|
||||||
|
IEnvelopeReceiverService envelopeReceiverService) : base(database, logger)
|
||||||
{
|
{
|
||||||
private readonly EnvelopeOldService envelopeService;
|
envelopeService = envelope;
|
||||||
private readonly ActionService? actionService;
|
actionService = database?.Services?.actionService;
|
||||||
private readonly UrlEncoder _urlEncoder;
|
_urlEncoder = urlEncoder;
|
||||||
private readonly IEnvelopeHistoryService _histService;
|
_histService = envelopeHistoryService;
|
||||||
private readonly IReceiverService _receiverService;
|
_receiverService = receiverService;
|
||||||
private readonly IEnvelopeReceiverService _envRcvService;
|
_envRcvService = envelopeReceiverService;
|
||||||
|
}
|
||||||
|
|
||||||
public EnvelopeController(DatabaseService database,
|
[NonAction]
|
||||||
EnvelopeOldService envelope,
|
[Obsolete("Use MediatR")]
|
||||||
ILogger<EnvelopeController> logger, UrlEncoder urlEncoder,
|
public async Task<IActionResult> Get([FromRoute] string envelopeKey)
|
||||||
IEnvelopeHistoryService envelopeHistoryService,
|
{
|
||||||
IReceiverService receiverService,
|
try
|
||||||
IEnvelopeReceiverService envelopeReceiverService) : base(database, logger)
|
|
||||||
{
|
{
|
||||||
envelopeService = envelope;
|
envelopeKey = _urlEncoder.Encode(envelopeKey);
|
||||||
actionService = database?.Services?.actionService;
|
|
||||||
_urlEncoder = urlEncoder;
|
// Validate Envelope Key and load envelope
|
||||||
_histService = envelopeHistoryService;
|
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
||||||
_receiverService = receiverService;
|
|
||||||
_envRcvService = envelopeReceiverService;
|
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
|
||||||
|
|
||||||
|
if (envelopeService.ReceiverAlreadySigned(response.Envelope, response.Receiver.Id) == true)
|
||||||
|
{
|
||||||
|
return Problem(statusCode: 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Loaded envelope [{0}] for receiver [{1}]", response.Envelope.Id, response.Envelope.Id);
|
||||||
|
return Json(response);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
[NonAction]
|
|
||||||
public async Task<IActionResult> Get([FromRoute] string envelopeKey)
|
|
||||||
{
|
{
|
||||||
try
|
_logger.LogError(e, "{Message}", e.Message);
|
||||||
{
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
envelopeKey = _urlEncoder.Encode(envelopeKey);
|
|
||||||
|
|
||||||
// Validate Envelope Key and load envelope
|
|
||||||
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
|
||||||
|
|
||||||
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
|
|
||||||
|
|
||||||
if (envelopeService.ReceiverAlreadySigned(response.Envelope, response.Receiver.Id) == true)
|
|
||||||
{
|
|
||||||
return Problem(statusCode: 403);
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Loaded envelope [{0}] for receiver [{1}]", response.Envelope.Id, response.Envelope.Id);
|
|
||||||
return Json(response);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.LogError(e, "{Message}", e.Message);
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||||
[HttpPost("{envelopeKey}")]
|
[HttpPost("{envelopeKey}")]
|
||||||
public async Task<IActionResult> Update(string envelopeKey, int index)
|
[Obsolete("Use MediatR")]
|
||||||
|
public async Task<IActionResult> Update(string envelopeKey, int index)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
envelopeKey = _urlEncoder.Encode(envelopeKey);
|
||||||
|
|
||||||
|
var authSignature = this.GetAuthReceiverSignature();
|
||||||
|
|
||||||
|
if (authSignature != envelopeKey.GetReceiverSignature())
|
||||||
|
return Unauthorized();
|
||||||
|
|
||||||
|
// Validate Envelope Key and load envelope
|
||||||
|
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
||||||
|
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
|
||||||
|
|
||||||
|
// Again check if receiver has already signed
|
||||||
|
if (envelopeService.ReceiverAlreadySigned(response.Envelope, response.Receiver.Id) == true)
|
||||||
{
|
{
|
||||||
envelopeKey = _urlEncoder.Encode(envelopeKey);
|
return Problem(statusCode: 403);
|
||||||
|
}
|
||||||
|
|
||||||
var authSignature = this.GetAuthReceiverSignature();
|
var document = envelopeService.GetDocument(index, envelopeKey);
|
||||||
|
|
||||||
if (authSignature != envelopeKey.GetReceiverSignature())
|
string? annotationData = await envelopeService.EnsureValidAnnotationData(Request);
|
||||||
return Unauthorized();
|
|
||||||
|
|
||||||
// Validate Envelope Key and load envelope
|
envelopeService.InsertDocumentStatus(new Domain.Entities.DocumentStatus()
|
||||||
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
{
|
||||||
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
|
EnvelopeId = response.Envelope.Id,
|
||||||
|
ReceiverId = response.Receiver.Id,
|
||||||
|
Value = annotationData,
|
||||||
|
Status = Constants.DocumentStatus.Signed
|
||||||
|
});
|
||||||
|
|
||||||
// Again check if receiver has already signed
|
var signResult = actionService?.SignEnvelope(response.Envelope, response.Receiver);
|
||||||
if (envelopeService.ReceiverAlreadySigned(response.Envelope, response.Receiver.Id) == true)
|
|
||||||
|
return Ok(new object());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError(e, "{Message}", e.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||||
|
[HttpPost("reject")]
|
||||||
|
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||||
|
public async Task<IActionResult> Reject([FromBody] string? reason = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var signature = this.GetAuthReceiverSignature();
|
||||||
|
var uuid = this.GetAuthEnvelopeUuid();
|
||||||
|
var mail = this.GetAuthReceiverMail();
|
||||||
|
if(uuid is null || signature is null || mail is null)
|
||||||
|
{
|
||||||
|
_logger.LogEnvelopeError(uuid: uuid, signature: signature,
|
||||||
|
message: @$"Unauthorized POST request in api\envelope\reject. One of claims, Envelope, signature or mail ({mail}) is null.");
|
||||||
|
return Unauthorized();
|
||||||
|
}
|
||||||
|
|
||||||
|
var envRcvRes = await _envRcvService.ReadByUuidSignatureAsync(uuid: uuid, signature: signature);
|
||||||
|
|
||||||
|
if (envRcvRes.IsFailed)
|
||||||
|
{
|
||||||
|
_logger.LogNotice(envRcvRes.Notices);
|
||||||
|
return Unauthorized("you are not authirized");
|
||||||
|
}
|
||||||
|
|
||||||
|
return await _histService.RecordAsync(envRcvRes.Data.EnvelopeId, userReference: mail, EnvelopeStatus.DocumentRejected, comment: reason).ThenAsync(
|
||||||
|
Success: id => NoContent(),
|
||||||
|
Fail: IActionResult (mssg, ntc) =>
|
||||||
{
|
{
|
||||||
return Problem(statusCode: 403);
|
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: "Unexpected error happend in api/envelope/reject");
|
||||||
}
|
_logger.LogNotice(ntc);
|
||||||
|
return this.ViewInnerServiceError();
|
||||||
var document = envelopeService.GetDocument(index, envelopeKey);
|
|
||||||
|
|
||||||
string? annotationData = await envelopeService.EnsureValidAnnotationData(Request);
|
|
||||||
|
|
||||||
envelopeService.InsertDocumentStatus(new Common.DocumentStatus()
|
|
||||||
{
|
|
||||||
EnvelopeId = response.Envelope.Id,
|
|
||||||
ReceiverId = response.Receiver.Id,
|
|
||||||
Value = annotationData,
|
|
||||||
Status = Common.Constants.DocumentStatus.Signed
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var signResult = actionService?.SignEnvelope(response.Envelope, response.Receiver);
|
|
||||||
|
|
||||||
return Ok(new object());
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.LogError(e, "{Message}", e.Message);
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
|
||||||
[HttpPost("reject")]
|
|
||||||
public async Task<IActionResult> Reject([FromBody] string? reason = null)
|
|
||||||
{
|
{
|
||||||
try
|
_logger.LogError(e, "{Message}", e.Message);
|
||||||
{
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
var signature = this.GetAuthReceiverSignature();
|
|
||||||
var uuid = this.GetAuthEnvelopeUuid();
|
|
||||||
var mail = this.GetAuthReceiverMail();
|
|
||||||
if(uuid is null || signature is null || mail is null)
|
|
||||||
{
|
|
||||||
_logger.LogEnvelopeError(uuid: uuid, signature: signature,
|
|
||||||
message: @$"Unauthorized POST request in api\envelope\reject. One of claims, Envelope, signature or mail ({mail}) is null.");
|
|
||||||
return Unauthorized();
|
|
||||||
}
|
|
||||||
|
|
||||||
var envRcvRes = await _envRcvService.ReadByUuidSignatureAsync(uuid: uuid, signature: signature);
|
|
||||||
|
|
||||||
if (envRcvRes.IsFailed)
|
|
||||||
{
|
|
||||||
_logger.LogNotice(envRcvRes.Notices);
|
|
||||||
return Unauthorized("you are not authirized");
|
|
||||||
}
|
|
||||||
|
|
||||||
return await _histService.RecordAsync(envRcvRes.Data.EnvelopeId, userReference: mail, EnvelopeStatus.DocumentRejected, comment: reason).ThenAsync(
|
|
||||||
Success: id => NoContent(),
|
|
||||||
Fail: IActionResult (mssg, ntc) =>
|
|
||||||
{
|
|
||||||
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: "Unexpected error happend in api/envelope/reject");
|
|
||||||
_logger.LogNotice(ntc);
|
|
||||||
return this.ViewInnerServiceError();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.LogError(e, "{Message}", e.Message);
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using EnvelopeGenerator.CommonServices;
|
using EnvelopeGenerator.Web.Services;
|
||||||
using EnvelopeGenerator.Web.Services;
|
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -8,33 +7,40 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using DigitalData.Core.API;
|
using DigitalData.Core.API;
|
||||||
using EnvelopeGenerator.Extensions;
|
using EnvelopeGenerator.Extensions;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using DigitalData.Core.DTO;
|
|
||||||
using Microsoft.AspNetCore.Localization;
|
using Microsoft.AspNetCore.Localization;
|
||||||
using EnvelopeGenerator.Web.Models;
|
using EnvelopeGenerator.Web.Models;
|
||||||
using EnvelopeGenerator.Application.Resources;
|
using EnvelopeGenerator.Application.Resources;
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||||
using static EnvelopeGenerator.CommonServices.Constants;
|
|
||||||
using Ganss.Xss;
|
using Ganss.Xss;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using DigitalData.Core.Client;
|
using DigitalData.Core.Client;
|
||||||
using OtpNet;
|
using OtpNet;
|
||||||
using EnvelopeGenerator.Application.Contracts.Services;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
using static EnvelopeGenerator.Domain.Constants;
|
||||||
|
using DigitalData.Core.Abstraction.Application.DTO;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers;
|
namespace EnvelopeGenerator.Web.Controllers;
|
||||||
|
|
||||||
public class HomeController : ViewControllerBase
|
public class HomeController : ViewControllerBase
|
||||||
{
|
{
|
||||||
private readonly EnvelopeOldService envelopeOldService;
|
private readonly EnvelopeOldService envelopeOldService;
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
private readonly IEnvelopeReceiverService _envRcvService;
|
private readonly IEnvelopeReceiverService _envRcvService;
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
private readonly IEnvelopeHistoryService _historyService;
|
private readonly IEnvelopeHistoryService _historyService;
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
private readonly IEnvelopeMailService _mailService;
|
private readonly IEnvelopeMailService _mailService;
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
private readonly IEnvelopeReceiverReadOnlyService _readOnlyService;
|
private readonly IEnvelopeReceiverReadOnlyService _readOnlyService;
|
||||||
private readonly IAuthenticator _authenticator;
|
private readonly IAuthenticator _authenticator;
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
private readonly IReceiverService _rcvService;
|
private readonly IReceiverService _rcvService;
|
||||||
private readonly IEnvelopeSmsHandler _envSmsHandler;
|
private readonly IEnvelopeSmsHandler _envSmsHandler;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public HomeController(EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IEnvelopeReceiverService envelopeReceiverService, IEnvelopeHistoryService historyService, IStringLocalizer<Resource> localizer, IConfiguration configuration, HtmlSanitizer sanitizer, Cultures cultures, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverReadOnlyService readOnlyService, IAuthenticator authenticator, IReceiverService receiverService, IEnvelopeSmsHandler envelopeSmsService) : base(logger, sanitizer, cultures, localizer)
|
public HomeController(EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IEnvelopeReceiverService envelopeReceiverService, IEnvelopeHistoryService historyService, IStringLocalizer<Resource> localizer, IConfiguration configuration, HtmlSanitizer sanitizer, Cultures cultures, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverReadOnlyService readOnlyService, IAuthenticator authenticator, IReceiverService receiverService, IEnvelopeSmsHandler envelopeSmsService) : base(logger, sanitizer, cultures, localizer)
|
||||||
{
|
{
|
||||||
this.envelopeOldService = envelopeOldService;
|
this.envelopeOldService = envelopeOldService;
|
||||||
@@ -69,6 +75,7 @@ public class HomeController : ViewControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}")]
|
[HttpGet("EnvelopeKey/{envelopeReceiverId}")]
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public async Task<IActionResult> MainAsync([FromRoute] string envelopeReceiverId, [FromQuery] string? culture = null)
|
public async Task<IActionResult> MainAsync([FromRoute] string envelopeReceiverId, [FromQuery] string? culture = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -131,6 +138,7 @@ public class HomeController : ViewControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Locked")]
|
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Locked")]
|
||||||
|
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||||
public async Task<IActionResult> EnvelopeLocked([FromRoute] string envelopeReceiverId)
|
public async Task<IActionResult> EnvelopeLocked([FromRoute] string envelopeReceiverId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -401,6 +409,7 @@ public class HomeController : ViewControllerBase
|
|||||||
|
|
||||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Success")]
|
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Success")]
|
||||||
|
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||||
public async Task<IActionResult> EnvelopeSigned(string envelopeReceiverId)
|
public async Task<IActionResult> EnvelopeSigned(string envelopeReceiverId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -412,7 +421,7 @@ public class HomeController : ViewControllerBase
|
|||||||
if(!isExisting)
|
if(!isExisting)
|
||||||
return this.ViewEnvelopeNotFound();
|
return this.ViewEnvelopeNotFound();
|
||||||
|
|
||||||
Common.EnvelopeReceiver response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
|
EnvelopeReceiver response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
|
||||||
if (!envelopeOldService.ReceiverAlreadySigned((Envelope)response.Envelope, (int)response.Receiver.Id))
|
if (!envelopeOldService.ReceiverAlreadySigned((Envelope)response.Envelope, (int)response.Receiver.Id))
|
||||||
return base.Redirect($"/EnvelopeKey/{envelopeReceiverId}/Locked");
|
return base.Redirect($"/EnvelopeKey/{envelopeReceiverId}/Locked");
|
||||||
|
|
||||||
@@ -436,6 +445,7 @@ public class HomeController : ViewControllerBase
|
|||||||
|
|
||||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Rejected")]
|
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Rejected")]
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public async Task<IActionResult> EnvelopeRejected(string envelopeReceiverId)
|
public async Task<IActionResult> EnvelopeRejected(string envelopeReceiverId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -467,6 +477,7 @@ public class HomeController : ViewControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("EnvelopeKey/{readOnlyKey}/ReadOnly")]
|
[HttpGet("EnvelopeKey/{readOnlyKey}/ReadOnly")]
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public async Task<IActionResult> EnvelopeReceiverReadOnly([FromRoute] string readOnlyKey)
|
public async Task<IActionResult> EnvelopeReceiverReadOnly([FromRoute] string readOnlyKey)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.Abstraction.Application.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts.Services;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using static EnvelopeGenerator.CommonServices.Constants;
|
using static EnvelopeGenerator.Domain.Constants;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers
|
namespace EnvelopeGenerator.Web.Controllers
|
||||||
{
|
{
|
||||||
@@ -14,12 +14,16 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
{
|
{
|
||||||
private readonly ILogger<ReadOnlyController> _logger;
|
private readonly ILogger<ReadOnlyController> _logger;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
private readonly IEnvelopeReceiverReadOnlyService _erroService;
|
private readonly IEnvelopeReceiverReadOnlyService _erroService;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
private readonly IEnvelopeMailService _mailService;
|
private readonly IEnvelopeMailService _mailService;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
private readonly IEnvelopeHistoryService _histService;
|
private readonly IEnvelopeHistoryService _histService;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public ReadOnlyController(ILogger<ReadOnlyController> logger, IEnvelopeReceiverReadOnlyService erroService, IEnvelopeMailService mailService, IEnvelopeHistoryService histService)
|
public ReadOnlyController(ILogger<ReadOnlyController> logger, IEnvelopeReceiverReadOnlyService erroService, IEnvelopeMailService mailService, IEnvelopeHistoryService histService)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@@ -30,6 +34,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public async Task<IActionResult> CreateAsync([FromBody] EnvelopeReceiverReadOnlyCreateDto createDto)
|
public async Task<IActionResult> CreateAsync([FromBody] EnvelopeReceiverReadOnlyCreateDto createDto)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -62,7 +67,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//read new entity
|
//read new entity
|
||||||
var read_res = await _erroService.ReadByIdAsync(creation_res.Data);
|
var read_res = await _erroService.ReadByIdAsync(creation_res.Data.Id);
|
||||||
if (read_res.IsFailed)
|
if (read_res.IsFailed)
|
||||||
{
|
{
|
||||||
_logger.LogNotice(creation_res);
|
_logger.LogNotice(creation_res);
|
||||||
@@ -76,7 +81,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
{
|
{
|
||||||
//TODO: implement multi-threading to history process (Task)
|
//TODO: implement multi-threading to history process (Task)
|
||||||
//TODO: remove casting after change the id type
|
//TODO: remove casting after change the id type
|
||||||
var hist_res = await _histService.RecordAsync((int)createDto.EnvelopeId, createDto.AddedWho, Common.Constants.EnvelopeStatus.EnvelopeShared);
|
var hist_res = await _histService.RecordAsync((int)createDto.EnvelopeId, createDto.AddedWho, EnvelopeStatus.EnvelopeShared);
|
||||||
if (hist_res.IsFailed)
|
if (hist_res.IsFailed)
|
||||||
{
|
{
|
||||||
_logger.LogError("Although the envelope was sent as read-only, the EnvelopeShared hisotry could not be saved. Create DTO:\n{createDto}", JsonConvert.SerializeObject(createDto));
|
_logger.LogError("Although the envelope was sent as read-only, the EnvelopeShared hisotry could not be saved. Create DTO:\n{createDto}", JsonConvert.SerializeObject(createDto));
|
||||||
|
|||||||
@@ -4,25 +4,28 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using EnvelopeGenerator.Extensions;
|
using EnvelopeGenerator.Extensions;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using EnvelopeGenerator.Application.Resources;
|
using EnvelopeGenerator.Application.Resources;
|
||||||
using DigitalData.Core.DTO;
|
|
||||||
using EnvelopeGenerator.Application.Extensions;
|
using EnvelopeGenerator.Application.Extensions;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using static EnvelopeGenerator.CommonServices.Constants;
|
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using EnvelopeGenerator.Application.Contracts.Services;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
using DigitalData.Core.Abstraction.Application.DTO;
|
||||||
|
using static EnvelopeGenerator.Domain.Constants;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers;
|
namespace EnvelopeGenerator.Web.Controllers;
|
||||||
|
|
||||||
//TODO: Add authorization as well as limiting the link duration (intermediate token with different role) or sign it
|
//TODO: Add authorization as well as limiting the link duration (intermediate token with different role) or sign it
|
||||||
public class TFARegController : ViewControllerBase
|
public class TFARegController : ViewControllerBase
|
||||||
{
|
{
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
private readonly IEnvelopeReceiverService _envRcvService;
|
private readonly IEnvelopeReceiverService _envRcvService;
|
||||||
private readonly IAuthenticator _authenticator;
|
private readonly IAuthenticator _authenticator;
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
private readonly IReceiverService _rcvService;
|
private readonly IReceiverService _rcvService;
|
||||||
private readonly TFARegParams _params;
|
private readonly TFARegParams _params;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public TFARegController(ILogger<TFARegController> logger, HtmlSanitizer sanitizer, Cultures cultures, IStringLocalizer<Resource> localizer, IEnvelopeReceiverService erService, IAuthenticator authenticator, IReceiverService receiverService, IOptions<TFARegParams> tfaRegParamsOptions) : base(logger, sanitizer, cultures, localizer)
|
public TFARegController(ILogger<TFARegController> logger, HtmlSanitizer sanitizer, Cultures cultures, IStringLocalizer<Resource> localizer, IEnvelopeReceiverService erService, IAuthenticator authenticator, IReceiverService receiverService, IOptions<TFARegParams> tfaRegParamsOptions) : base(logger, sanitizer, cultures, localizer)
|
||||||
{
|
{
|
||||||
_envRcvService = erService;
|
_envRcvService = erService;
|
||||||
@@ -34,6 +37,7 @@ public class TFARegController : ViewControllerBase
|
|||||||
//TODO: move under auth route
|
//TODO: move under auth route
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[HttpGet("tfa/{envelopeReceiverId}")]
|
[HttpGet("tfa/{envelopeReceiverId}")]
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public async Task<IActionResult> Reg(string envelopeReceiverId)
|
public async Task<IActionResult> Reg(string envelopeReceiverId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
using DigitalData.Core.API;
|
using DigitalData.Core.API;
|
||||||
using DigitalData.Core.Abstraction.Application;
|
using DigitalData.Core.Abstraction.Application;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using DigitalData.Core.Abstractions;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/test/[controller]")]
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public class TestControllerBase<TCRUDService, TDto, TEntity, TId> : BasicCRUDControllerBase<TCRUDService, TDto, TEntity, TId>
|
||||||
|
where TCRUDService : ICRUDService<TDto, TDto, TEntity, TId>
|
||||||
|
where TDto : class
|
||||||
|
where TEntity : class
|
||||||
{
|
{
|
||||||
[ApiController]
|
public TestControllerBase(ILogger logger, TCRUDService service) : base(logger, service)
|
||||||
[Route("api/test/[controller]")]
|
|
||||||
public class TestControllerBase<TCRUDService, TDto, TEntity, TId> : BasicCRUDControllerBase<TCRUDService, TDto, TEntity, TId>
|
|
||||||
where TCRUDService : ICRUDService<TDto, TDto, TEntity, TId>
|
|
||||||
where TDto : class, IUnique<TId> where TEntity : class, IUnique<TId>
|
|
||||||
{
|
{
|
||||||
public TestControllerBase(ILogger logger, TCRUDService service) : base(logger, service)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,12 @@
|
|||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
{
|
|
||||||
public class TestDocumentStatusController : TestControllerBase<IDocumentStatusService, DocumentStatusDto, DocumentStatus, int>
|
|
||||||
{
|
|
||||||
public TestDocumentStatusController(ILogger<TestDocumentStatusController> logger, IDocumentStatusService service) : base(logger, service)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
[Obsolete("Use MediatR")]
|
||||||
|
public class TestDocumentStatusController : TestControllerBase<IDocumentStatusService, DocumentStatusDto, DocumentStatus, int>
|
||||||
|
{
|
||||||
|
public TestDocumentStatusController(ILogger<TestDocumentStatusController> logger, IDocumentStatusService service) : base(logger, service)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,33 +1,34 @@
|
|||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.Abstraction.Application.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts.Services;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using static EnvelopeGenerator.CommonServices.Constants;
|
using static EnvelopeGenerator.Domain.Constants;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public class TestEmailTemplateController : TestControllerBase<IEmailTemplateService, EmailTemplateDto, EmailTemplate, int>
|
||||||
{
|
{
|
||||||
public class TestEmailTemplateController : TestControllerBase<IEmailTemplateService, EmailTemplateDto, EmailTemplate, int>
|
public TestEmailTemplateController(ILogger<TestEmailTemplateController> logger, IEmailTemplateService service) : base(logger, service)
|
||||||
{
|
{
|
||||||
public TestEmailTemplateController(ILogger<TestEmailTemplateController> logger, IEmailTemplateService service) : base(logger, service)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public virtual async Task<IActionResult> GetAll([FromQuery] string? tempType = null)
|
|
||||||
{
|
|
||||||
return tempType is null
|
|
||||||
? await base.GetAll()
|
|
||||||
: await _service.ReadByNameAsync((EmailTemplateType)Enum.Parse(typeof(EmailTemplateType), tempType)).ThenAsync(
|
|
||||||
Success: Ok,
|
|
||||||
Fail: IActionResult (messages, notices) =>
|
|
||||||
{
|
|
||||||
_logger.LogNotice(notices);
|
|
||||||
return NotFound(messages);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[NonAction]
|
|
||||||
public override Task<IActionResult> GetAll() => base.GetAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public virtual async Task<IActionResult> GetAll([FromQuery] string? tempType = null)
|
||||||
|
{
|
||||||
|
return tempType is null
|
||||||
|
? await base.GetAll()
|
||||||
|
: await _service.ReadByNameAsync((EmailTemplateType)Enum.Parse(typeof(EmailTemplateType), tempType)).ThenAsync(
|
||||||
|
Success: Ok,
|
||||||
|
Fail: IActionResult (messages, notices) =>
|
||||||
|
{
|
||||||
|
_logger.LogNotice(notices);
|
||||||
|
return NotFound(messages);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public override Task<IActionResult> GetAll() => base.GetAll();
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
{
|
|
||||||
public class TestEnvelopeCertificateController : TestControllerBase<IEnvelopeCertificateService, EnvelopeCertificateDto, EnvelopeCertificate, int>
|
[Obsolete("Use MediatR")]
|
||||||
{
|
public class TestEnvelopeCertificateController : TestControllerBase<IEnvelopeCertificateService, EnvelopeCertificateDto, EnvelopeCertificate, int>
|
||||||
public TestEnvelopeCertificateController(ILogger<TestEnvelopeCertificateController> logger, IEnvelopeCertificateService service) : base(logger, service)
|
{
|
||||||
{
|
public TestEnvelopeCertificateController(ILogger<TestEnvelopeCertificateController> logger, IEnvelopeCertificateService service) : base(logger, service)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ using EnvelopeGenerator.Domain.Entities;
|
|||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test;
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public class TestEnvelopeDocumentController : TestControllerBase<IEnvelopeDocumentService, EnvelopeDocumentDto, EnvelopeDocument, int>
|
public class TestEnvelopeDocumentController : TestControllerBase<IEnvelopeDocumentService, EnvelopeDocumentDto, EnvelopeDocument, int>
|
||||||
{
|
{
|
||||||
public TestEnvelopeDocumentController(ILogger<TestEnvelopeDocumentController> logger, IEnvelopeDocumentService service) : base(logger, service)
|
public TestEnvelopeDocumentController(ILogger<TestEnvelopeDocumentController> logger, IEnvelopeDocumentService service) : base(logger, service)
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ using EnvelopeGenerator.Application.Contracts.Services;
|
|||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using static EnvelopeGenerator.Domain.Constants;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test;
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public class TestEnvelopeHistoryController : CRUDControllerBase<IEnvelopeHistoryService, EnvelopeHistoryCreateDto, EnvelopeHistoryDto, EnvelopeHistoryDto, EnvelopeHistory, long>
|
public class TestEnvelopeHistoryController : CRUDControllerBase<IEnvelopeHistoryService, EnvelopeHistoryCreateDto, EnvelopeHistoryDto, EnvelopeHistoryDto, EnvelopeHistory, long>
|
||||||
{
|
{
|
||||||
public TestEnvelopeHistoryController(ILogger<TestEnvelopeHistoryController> logger, IEnvelopeHistoryService service) : base(logger, service)
|
public TestEnvelopeHistoryController(ILogger<TestEnvelopeHistoryController> logger, IEnvelopeHistoryService service) : base(logger, service)
|
||||||
@@ -13,7 +15,7 @@ public class TestEnvelopeHistoryController : CRUDControllerBase<IEnvelopeHistory
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("Count")]
|
[HttpGet("Count")]
|
||||||
public async Task<IActionResult> Count(int? envelopeId = null, string? userReference = null, int? status = null)
|
public async Task<IActionResult> Count(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null)
|
||||||
{
|
{
|
||||||
return Ok(await _service.CountAsync(envelopeId, userReference, status));
|
return Ok(await _service.CountAsync(envelopeId, userReference, status));
|
||||||
}
|
}
|
||||||
@@ -25,7 +27,7 @@ public class TestEnvelopeHistoryController : CRUDControllerBase<IEnvelopeHistory
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> GetAsyncWith(int? envelopeId = null, string? userReference = null, int? status = null)
|
public async Task<IActionResult> GetAsyncWith(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null)
|
||||||
{
|
{
|
||||||
return Ok(await _service.ReadAsync(envelopeId: envelopeId, userReference: userReference, status: status));
|
return Ok(await _service.ReadAsync(envelopeId: envelopeId, userReference: userReference, status: status));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +1,50 @@
|
|||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.Abstraction.Application.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts.Services;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/test/[controller]")]
|
||||||
|
public class TestEnvelopeMailController : ControllerBase
|
||||||
{
|
{
|
||||||
[ApiController]
|
private readonly ILogger<TestEnvelopeMailController> _logger;
|
||||||
[Route("api/test/[controller]")]
|
[Obsolete("Use MediatR")]
|
||||||
public class TestEnvelopeMailController : ControllerBase
|
private readonly IEnvelopeMailService _mailService;
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
private readonly IEnvelopeReceiverService _envRcvService;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public TestEnvelopeMailController(ILogger<TestEnvelopeMailController> logger, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverService envelopeReceiverService)
|
||||||
{
|
{
|
||||||
private readonly ILogger<TestEnvelopeMailController> _logger;
|
_logger = logger;
|
||||||
private readonly IEnvelopeMailService _mailService;
|
_mailService = envelopeMailService;
|
||||||
private readonly IEnvelopeReceiverService _envRcvService;
|
_envRcvService = envelopeReceiverService;
|
||||||
|
}
|
||||||
|
|
||||||
public TestEnvelopeMailController(ILogger<TestEnvelopeMailController> logger, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverService envelopeReceiverService)
|
[HttpGet]
|
||||||
{
|
[Obsolete("Use MediatR")]
|
||||||
_logger = logger;
|
public async Task<IActionResult> SendAccessCode([FromQuery] string envelopeReceiverId = "ZDlmYjZmYjctNTBhNS00NTcyLWI5NTQtYzJjYmY4N2UwZmZhOjowRDI3MkEwNTdGMjRBMkY3MEZDMzM3QkRBQzA1MjYxRjU3NTI2QzgxQ0IyMUE5NzE1RjA1NTJFQzdFNjIwNjY1")
|
||||||
_mailService = envelopeMailService;
|
{
|
||||||
_envRcvService = envelopeReceiverService;
|
return await _envRcvService.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelopeReceiverId).ThenAsync<EnvelopeReceiverDto, IActionResult>(
|
||||||
}
|
SuccessAsync: async er =>
|
||||||
|
{
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public async Task<IActionResult> SendAccessCode([FromQuery] string envelopeReceiverId = "ZDlmYjZmYjctNTBhNS00NTcyLWI5NTQtYzJjYmY4N2UwZmZhOjowRDI3MkEwNTdGMjRBMkY3MEZDMzM3QkRBQzA1MjYxRjU3NTI2QzgxQ0IyMUE5NzE1RjA1NTJFQzdFNjIwNjY1")
|
var mailRes = await _mailService.SendAccessCodeAsync(envelopeReceiverDto: er);
|
||||||
{
|
if (mailRes.IsFailed)
|
||||||
return await _envRcvService.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelopeReceiverId).ThenAsync<EnvelopeReceiverDto, IActionResult>(
|
|
||||||
SuccessAsync: async er =>
|
|
||||||
{
|
{
|
||||||
|
_logger.LogNotice(mailRes);
|
||||||
|
return StatusCode(500, mailRes.Notices);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok();
|
||||||
var mailRes = await _mailService.SendAccessCodeAsync(envelopeReceiverDto: er);
|
},
|
||||||
if (mailRes.IsFailed)
|
Fail: (messages, notices) =>
|
||||||
{
|
{
|
||||||
_logger.LogNotice(mailRes);
|
_logger.LogNotice(notices);
|
||||||
return StatusCode(500, mailRes.Notices);
|
return StatusCode(500, notices);
|
||||||
}
|
});
|
||||||
|
|
||||||
return Ok();
|
|
||||||
},
|
|
||||||
Fail: (messages, notices) =>
|
|
||||||
{
|
|
||||||
_logger.LogNotice(notices);
|
|
||||||
return StatusCode(500, notices);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,66 +1,66 @@
|
|||||||
using DigitalData.Core.API;
|
using DigitalData.Core.API;
|
||||||
using DigitalData.Core.DTO;
|
|
||||||
using EnvelopeGenerator.Extensions;
|
using EnvelopeGenerator.Extensions;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||||
using EnvelopeGenerator.Application.Contracts.Services;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
using DigitalData.Core.Abstraction.Application.DTO;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public class TestEnvelopeReceiverController : ReadControllerBase<IEnvelopeReceiverService, EnvelopeReceiverDto, EnvelopeReceiver, (int Envelope, int Receiver)>
|
||||||
{
|
{
|
||||||
public class TestEnvelopeReceiverController : ReadControllerBase<IEnvelopeReceiverService, EnvelopeReceiverDto, EnvelopeReceiver, (int Envelope, int Receiver)>
|
public TestEnvelopeReceiverController(ILogger<TestEnvelopeReceiverController> logger, IEnvelopeReceiverService service) : base(logger, service)
|
||||||
{
|
{
|
||||||
public TestEnvelopeReceiverController(ILogger<TestEnvelopeReceiverController> logger, IEnvelopeReceiverService service) : base(logger, service)
|
}
|
||||||
|
|
||||||
|
[HttpGet("verify-access-code/{envelope_receiver_id}")]
|
||||||
|
public async Task<IActionResult> VerifyAccessCode([FromRoute] string envelope_receiver_id, [FromQuery] string access_code)
|
||||||
|
{
|
||||||
|
var verification = await _service.VerifyAccessCodeAsync(envelopeReceiverId:envelope_receiver_id, accessCode: access_code);
|
||||||
|
|
||||||
|
if (verification.IsSuccess)
|
||||||
|
return Ok(verification);
|
||||||
|
else if (verification.HasFlag(Flag.SecurityBreach))
|
||||||
|
return Forbid();
|
||||||
|
else if (verification.HasFlag(Flag.SecurityBreachOrDataIntegrity))
|
||||||
|
return Conflict();
|
||||||
|
else
|
||||||
|
return this.InnerServiceError(verification);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("e-r-id/{envelope_receiver_id}")]
|
||||||
|
public async Task<IActionResult> GetByEnvelopeReceiverId([FromRoute] string envelope_receiver_id)
|
||||||
|
{
|
||||||
|
var er_result = await _service.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelope_receiver_id);
|
||||||
|
if (er_result.IsSuccess)
|
||||||
|
return Ok(er_result);
|
||||||
|
else
|
||||||
|
return this.InnerServiceError(er_result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("decode")]
|
||||||
|
public IActionResult DecodeEnvelopeReceiverId(string envelopeReceiverId, bool isReadOnly = false)
|
||||||
|
{
|
||||||
|
if (isReadOnly)
|
||||||
{
|
{
|
||||||
|
var readOnlyId = envelopeReceiverId.DecodeEnvelopeReceiverReadOnlyId();
|
||||||
|
return Ok(new { readOnlyId });
|
||||||
}
|
}
|
||||||
|
else
|
||||||
[HttpGet("verify-access-code/{envelope_receiver_id}")]
|
|
||||||
public async Task<IActionResult> VerifyAccessCode([FromRoute] string envelope_receiver_id, [FromQuery] string access_code)
|
|
||||||
{
|
{
|
||||||
var verification = await _service.VerifyAccessCodeAsync(envelopeReceiverId:envelope_receiver_id, accessCode: access_code);
|
var (EnvelopeUuid, ReceiverSignature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
||||||
|
return Ok(new { uuid = EnvelopeUuid, signature = ReceiverSignature });
|
||||||
if (verification.IsSuccess)
|
|
||||||
return Ok(verification);
|
|
||||||
else if (verification.HasFlag(Flag.SecurityBreach))
|
|
||||||
return Forbid();
|
|
||||||
else if (verification.HasFlag(Flag.SecurityBreachOrDataIntegrity))
|
|
||||||
return Conflict();
|
|
||||||
else
|
|
||||||
return this.InnerServiceError(verification);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("e-r-id/{envelope_receiver_id}")]
|
|
||||||
public async Task<IActionResult> GetByEnvelopeReceiverId([FromRoute] string envelope_receiver_id)
|
|
||||||
{
|
|
||||||
var er_result = await _service.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelope_receiver_id);
|
|
||||||
if (er_result.IsSuccess)
|
|
||||||
return Ok(er_result);
|
|
||||||
else
|
|
||||||
return this.InnerServiceError(er_result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("decode")]
|
|
||||||
public IActionResult DecodeEnvelopeReceiverId(string envelopeReceiverId, bool isReadOnly = false)
|
|
||||||
{
|
|
||||||
if (isReadOnly)
|
|
||||||
{
|
|
||||||
var readOnlyId = envelopeReceiverId.DecodeEnvelopeReceiverReadOnlyId();
|
|
||||||
return Ok(new { readOnlyId });
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var (EnvelopeUuid, ReceiverSignature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
|
||||||
return Ok(new { uuid = EnvelopeUuid, signature = ReceiverSignature });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("encode")]
|
|
||||||
public IActionResult EncodeEnvelopeReceiverId(string? uuid = null, string? signature = null, long? readOnlyId = null)
|
|
||||||
{
|
|
||||||
if(readOnlyId is long readOnlyId_long)
|
|
||||||
return Ok(readOnlyId_long.EncodeEnvelopeReceiverId());
|
|
||||||
else
|
|
||||||
return Ok((uuid ?? string.Empty, signature ?? string.Empty).EncodeEnvelopeReceiverId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("encode")]
|
||||||
|
public IActionResult EncodeEnvelopeReceiverId(string? uuid = null, string? signature = null, long? readOnlyId = null)
|
||||||
|
{
|
||||||
|
if(readOnlyId is long readOnlyId_long)
|
||||||
|
return Ok(readOnlyId_long.EncodeEnvelopeReceiverId());
|
||||||
|
else
|
||||||
|
return Ok((uuid ?? string.Empty, signature ?? string.Empty).EncodeEnvelopeReceiverId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ using EnvelopeGenerator.Domain.Entities;
|
|||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test;
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
public class TestEnvelopeTypeController : TestControllerBase<IEnvelopeTypeService, EnvelopeTypeDto, EnvelopeType, int>
|
public class TestEnvelopeTypeController : TestControllerBase<IEnvelopeTypeService, EnvelopeTypeDto, EnvelopeType, int>
|
||||||
{
|
{
|
||||||
public TestEnvelopeTypeController(ILogger<TestEnvelopeTypeController> logger, IEnvelopeTypeService service) : base(logger, service)
|
public TestEnvelopeTypeController(ILogger<TestEnvelopeTypeController> logger, IEnvelopeTypeService service) : base(logger, service)
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
{
|
|
||||||
public class TestUserReceiverController : TestControllerBase< IUserReceiverService, UserReceiverDto, UserReceiver, int>
|
[Obsolete("Use MediatR")]
|
||||||
{
|
public class TestUserReceiverController : TestControllerBase< IUserReceiverService, UserReceiverDto, UserReceiver, int>
|
||||||
public TestUserReceiverController(ILogger<TestUserReceiverController> logger, IUserReceiverService service) : base(logger, service)
|
{
|
||||||
{
|
public TestUserReceiverController(ILogger<TestUserReceiverController> logger, IUserReceiverService service) : base(logger, service)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,56 +1,55 @@
|
|||||||
using EnvelopeGenerator.CommonServices;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Web.Services;
|
using EnvelopeGenerator.Web.Services;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
|
|
||||||
|
[Route("api/test/[controller]")]
|
||||||
|
public class TestViewController : BaseController
|
||||||
{
|
{
|
||||||
[Route("api/test/[controller]")]
|
private readonly EnvelopeOldService envelopeOldService;
|
||||||
public class TestViewController : BaseController
|
private readonly IConfiguration _config;
|
||||||
|
|
||||||
|
public TestViewController(DatabaseService databaseService, EnvelopeOldService envelopeOldService, ILogger<TestViewController> logger, IConfiguration configuration) : base(databaseService, logger)
|
||||||
{
|
{
|
||||||
private readonly EnvelopeOldService envelopeOldService;
|
this.envelopeOldService = envelopeOldService;
|
||||||
private readonly IConfiguration _config;
|
_config = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
public TestViewController(DatabaseService databaseService, EnvelopeOldService envelopeOldService, ILogger<TestViewController> logger, IConfiguration configuration) : base(databaseService, logger)
|
[HttpGet]
|
||||||
{
|
public IActionResult Index()
|
||||||
this.envelopeOldService = envelopeOldService;
|
{
|
||||||
_config = configuration;
|
return View("AnnotationIndex");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpPost]
|
||||||
public IActionResult Index()
|
public IActionResult DebugEnvelopes([FromForm] string? password)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return View("AnnotationIndex");
|
var passwordFromConfig = _config["AdminPassword"];
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
if (passwordFromConfig == null)
|
||||||
public IActionResult DebugEnvelopes([FromForm] string? password)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var passwordFromConfig = _config["AdminPassword"];
|
ViewData["error"] = "No admin password configured!";
|
||||||
|
|
||||||
if (passwordFromConfig == null)
|
|
||||||
{
|
|
||||||
ViewData["error"] = "No admin password configured!";
|
|
||||||
return View("AnnotationIndex");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (password != passwordFromConfig)
|
|
||||||
{
|
|
||||||
ViewData["error"] = "Wrong Password!";
|
|
||||||
return View("AnnotationIndex");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Envelope> envelopes = envelopeOldService.LoadEnvelopes();
|
|
||||||
|
|
||||||
return View("DebugEnvelopes", envelopes);
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Unexpected error");
|
|
||||||
ViewData["error"] = "Unknown error!";
|
|
||||||
return View("AnnotationIndex");
|
return View("AnnotationIndex");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (password != passwordFromConfig)
|
||||||
|
{
|
||||||
|
ViewData["error"] = "Wrong Password!";
|
||||||
|
return View("AnnotationIndex");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Envelope> envelopes = envelopeOldService.LoadEnvelopes();
|
||||||
|
|
||||||
|
return View("DebugEnvelopes", envelopes);
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Unexpected error");
|
||||||
|
ViewData["error"] = "Unknown error!";
|
||||||
|
return View("AnnotationIndex");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,186 +1,190 @@
|
|||||||
using EnvelopeGenerator.Application.Contracts.Services;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.CommonServices;
|
using EnvelopeGenerator.CommonServices;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Services
|
namespace EnvelopeGenerator.Web.Services;
|
||||||
|
|
||||||
|
public class EnvelopeOldService
|
||||||
{
|
{
|
||||||
public class EnvelopeOldService
|
private readonly ReceiverModel receiverModel;
|
||||||
|
private readonly EnvelopeModel envelopeModel;
|
||||||
|
private readonly HistoryModel historyModel;
|
||||||
|
|
||||||
|
private readonly DocumentStatusModel documentStatusModel;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
private readonly IConfigService _configService;
|
||||||
|
private readonly ILogger<EnvelopeOldService> _logger;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public EnvelopeOldService(DatabaseService database, IConfigService configService, ILogger<EnvelopeOldService> logger)
|
||||||
{
|
{
|
||||||
private readonly ReceiverModel receiverModel;
|
_logger = logger;
|
||||||
private readonly EnvelopeModel envelopeModel;
|
|
||||||
private readonly HistoryModel historyModel;
|
|
||||||
|
|
||||||
private readonly DocumentStatusModel documentStatusModel;
|
|
||||||
|
|
||||||
private readonly IConfigService _configService;
|
if (database.Models is null)
|
||||||
private readonly ILogger<EnvelopeOldService> _logger;
|
throw new ArgumentNullException("Models not loaded.");
|
||||||
|
|
||||||
public EnvelopeOldService(DatabaseService database, IConfigService configService, ILogger<EnvelopeOldService> logger)
|
receiverModel = database.Models.receiverModel;
|
||||||
|
envelopeModel = database.Models.envelopeModel;
|
||||||
|
historyModel = database.Models.historyModel;
|
||||||
|
documentStatusModel = database.Models.documentStatusModel;
|
||||||
|
|
||||||
|
_configService = configService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnsureValidEnvelopeKey(string envelopeKey)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Parsing EnvelopeKey..");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(envelopeKey))
|
||||||
|
throw new ArgumentNullException("EnvelopeKey");
|
||||||
|
|
||||||
|
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(envelopeKey);
|
||||||
|
_logger.LogInformation("EnvelopeUUID: [{0}]", result.Item1);
|
||||||
|
_logger.LogInformation("ReceiverSignature: [{0}]", result.Item2);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(result.Item1))
|
||||||
|
throw new ArgumentNullException("EnvelopeUUID");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(result.Item2))
|
||||||
|
throw new ArgumentNullException("ReceiverSignature");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public async Task<EnvelopeReceiver> LoadEnvelope(string pEnvelopeKey)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Loading Envelope by Key [{0}]", pEnvelopeKey);
|
||||||
|
|
||||||
|
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(pEnvelopeKey);
|
||||||
|
var envelopeUuid = result.Item1;
|
||||||
|
var receiverSignature = result.Item2;
|
||||||
|
var receiverId = receiverModel.GetReceiverIdBySignature(receiverSignature);
|
||||||
|
|
||||||
|
_logger.LogInformation("Resolved receiver signature to receiverId [{0}]", receiverId);
|
||||||
|
|
||||||
|
_logger.LogInformation("Loading envelope..");
|
||||||
|
Envelope? envelope = envelopeModel.GetByUuid(envelopeUuid);
|
||||||
|
|
||||||
|
if (envelope == null)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger.LogWarning("Envelope not found");
|
||||||
|
throw new NullReferenceException("Envelope not found");
|
||||||
if (database.Models is null)
|
|
||||||
throw new ArgumentNullException("Models not loaded.");
|
|
||||||
|
|
||||||
receiverModel = database.Models.receiverModel;
|
|
||||||
envelopeModel = database.Models.envelopeModel;
|
|
||||||
historyModel = database.Models.historyModel;
|
|
||||||
documentStatusModel = database.Models.documentStatusModel;
|
|
||||||
|
|
||||||
_configService = configService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnsureValidEnvelopeKey(string envelopeKey)
|
_logger.LogInformation("Envelope loaded");
|
||||||
|
|
||||||
|
if (envelope.Receivers == null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Parsing EnvelopeKey..");
|
_logger.LogWarning("Receivers for envelope not loaded");
|
||||||
|
throw new NullReferenceException("Receivers for envelope not loaded");
|
||||||
if (string.IsNullOrEmpty(envelopeKey))
|
|
||||||
throw new ArgumentNullException("EnvelopeKey");
|
|
||||||
|
|
||||||
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(envelopeKey);
|
|
||||||
_logger.LogInformation("EnvelopeUUID: [{0}]", result.Item1);
|
|
||||||
_logger.LogInformation("ReceiverSignature: [{0}]", result.Item2);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(result.Item1))
|
|
||||||
throw new ArgumentNullException("EnvelopeUUID");
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(result.Item2))
|
|
||||||
throw new ArgumentNullException("ReceiverSignature");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<EnvelopeReceiver> LoadEnvelope(string pEnvelopeKey)
|
_logger.LogInformation("Envelope receivers found: [{0}]", envelope.Receivers.Count);
|
||||||
|
|
||||||
|
Receiver? receiver = envelope.Receivers.Where(r => r.Id == receiverId).SingleOrDefault();
|
||||||
|
|
||||||
|
if (receiver == null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Loading Envelope by Key [{0}]", pEnvelopeKey);
|
_logger.LogWarning("Receiver [{0}] not found", receiverId);
|
||||||
|
throw new NullReferenceException("Receiver not found");
|
||||||
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(pEnvelopeKey);
|
|
||||||
var envelopeUuid = result.Item1;
|
|
||||||
var receiverSignature = result.Item2;
|
|
||||||
var receiverId = receiverModel.GetReceiverIdBySignature(receiverSignature);
|
|
||||||
|
|
||||||
_logger.LogInformation("Resolved receiver signature to receiverId [{0}]", receiverId);
|
|
||||||
|
|
||||||
_logger.LogInformation("Loading envelope..");
|
|
||||||
Envelope? envelope = envelopeModel.GetByUuid(envelopeUuid);
|
|
||||||
|
|
||||||
if (envelope == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Envelope not found");
|
|
||||||
throw new NullReferenceException("Envelope not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Envelope loaded");
|
|
||||||
|
|
||||||
if (envelope.Receivers == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Receivers for envelope not loaded");
|
|
||||||
throw new NullReferenceException("Receivers for envelope not loaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Envelope receivers found: [{0}]", envelope.Receivers.Count);
|
|
||||||
|
|
||||||
Receiver? receiver = envelope.Receivers.Where(r => r.Id == receiverId).SingleOrDefault();
|
|
||||||
|
|
||||||
if (receiver == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Receiver [{0}] not found", receiverId);
|
|
||||||
throw new NullReferenceException("Receiver not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Loading documents for receiver [{0}]", receiver.EmailAddress);
|
|
||||||
|
|
||||||
// filter elements by receiver
|
|
||||||
envelope.Documents = envelope.Documents.Select((document) =>
|
|
||||||
{
|
|
||||||
document.Elements = document.Elements.Where((e) => e.ReceiverId == receiverId).ToList();
|
|
||||||
return document;
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
//if documenet_path_dmz is existing in config, replace the path with it
|
|
||||||
var config = await _configService.ReadDefaultAsync();
|
|
||||||
|
|
||||||
return new()
|
|
||||||
{
|
|
||||||
Receiver = receiver,
|
|
||||||
Envelope = envelope
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Envelope> LoadEnvelopes()
|
_logger.LogInformation("Loading documents for receiver [{0}]", receiver.EmailAddress);
|
||||||
|
|
||||||
|
// filter elements by receiver
|
||||||
|
envelope.Documents = envelope.Documents.Select((document) =>
|
||||||
{
|
{
|
||||||
var receivers = receiverModel.ListReceivers();
|
document.Elements = document.Elements.Where((e) => e.ReceiverId == receiverId).ToList();
|
||||||
List<Envelope> envelopes = new();
|
|
||||||
|
|
||||||
foreach (var receiver in receivers)
|
|
||||||
{
|
|
||||||
var envs = (List<Envelope>)envelopeModel.List(receiver.Id);
|
|
||||||
envelopes.AddRange(envs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return envelopes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Envelope> LoadEnvelopes(int pReceiverId)
|
|
||||||
{
|
|
||||||
return (List<Envelope>)envelopeModel.List(pReceiverId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ReceiverAlreadySigned(Envelope envelope, int receiverId)
|
|
||||||
{
|
|
||||||
return historyModel.HasReceiverSigned(envelope.Id, receiverId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string?> EnsureValidAnnotationData(HttpRequest request)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Parsing annotation data from request..");
|
|
||||||
|
|
||||||
using MemoryStream ms = new();
|
|
||||||
await request.BodyReader.CopyToAsync(ms);
|
|
||||||
var bytes = ms.ToArray();
|
|
||||||
|
|
||||||
_logger.LogInformation("Annotation data parsed, size: [{0}]", bytes.Length);
|
|
||||||
|
|
||||||
return Encoding.UTF8.GetString(bytes);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.LogError(e, "Inner Service Error");
|
|
||||||
throw new ArgumentNullException("AnnotationData");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<EnvelopeDocument> GetDocument(int documentId, string envelopeKey)
|
|
||||||
{
|
|
||||||
EnvelopeReceiver response = await LoadEnvelope(envelopeKey);
|
|
||||||
|
|
||||||
_logger.LogInformation("Loading document for Id [{0}]", documentId);
|
|
||||||
|
|
||||||
var document = response.Envelope.Documents.
|
|
||||||
Where(d => d.Id == documentId).
|
|
||||||
FirstOrDefault();
|
|
||||||
|
|
||||||
if (document == null)
|
|
||||||
throw new ArgumentException("DocumentId");
|
|
||||||
|
|
||||||
_logger.LogInformation("Document [{0}] loaded!", documentId);
|
|
||||||
|
|
||||||
return document;
|
return document;
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
//if documenet_path_dmz is existing in config, replace the path with it
|
||||||
|
var config = await _configService.ReadDefaultAsync();
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Receiver = receiver,
|
||||||
|
Envelope = envelope
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Envelope> LoadEnvelopes()
|
||||||
|
{
|
||||||
|
var receivers = receiverModel.ListReceivers();
|
||||||
|
List<Envelope> envelopes = new();
|
||||||
|
|
||||||
|
foreach (var receiver in receivers)
|
||||||
|
{
|
||||||
|
var envs = (List<Envelope>)envelopeModel.List(receiver.Id);
|
||||||
|
envelopes.AddRange(envs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool InsertDocumentStatus(Common.DocumentStatus documentStatus)
|
return envelopes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Envelope> LoadEnvelopes(int pReceiverId)
|
||||||
|
{
|
||||||
|
return (List<Envelope>)envelopeModel.List(pReceiverId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ReceiverAlreadySigned(Envelope envelope, int receiverId)
|
||||||
|
{
|
||||||
|
return historyModel.HasReceiverSigned(envelope.Id, receiverId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string?> EnsureValidAnnotationData(HttpRequest request)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Saving annotation data..");
|
_logger.LogInformation("Parsing annotation data from request..");
|
||||||
return documentStatusModel.InsertOrUpdate(documentStatus);
|
|
||||||
|
using MemoryStream ms = new();
|
||||||
|
await request.BodyReader.CopyToAsync(ms);
|
||||||
|
var bytes = ms.ToArray();
|
||||||
|
|
||||||
|
_logger.LogInformation("Annotation data parsed, size: [{0}]", bytes.Length);
|
||||||
|
|
||||||
|
return Encoding.UTF8.GetString(bytes);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
public async Task<byte[]> GetDocumentContents(EnvelopeDocument document)
|
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Loading file [{0}]", document.Filepath);
|
_logger.LogError(e, "Inner Service Error");
|
||||||
var bytes = await File.ReadAllBytesAsync(document.Filepath);
|
throw new ArgumentNullException("AnnotationData");
|
||||||
_logger.LogInformation("File loaded, size: [{0}]", bytes.Length);
|
|
||||||
|
|
||||||
return bytes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public async Task<EnvelopeDocument> GetDocument(int documentId, string envelopeKey)
|
||||||
|
{
|
||||||
|
EnvelopeReceiver response = await LoadEnvelope(envelopeKey);
|
||||||
|
|
||||||
|
_logger.LogInformation("Loading document for Id [{0}]", documentId);
|
||||||
|
|
||||||
|
var document = response.Envelope.Documents.
|
||||||
|
Where(d => d.Id == documentId).
|
||||||
|
FirstOrDefault();
|
||||||
|
|
||||||
|
if (document == null)
|
||||||
|
throw new ArgumentException("DocumentId");
|
||||||
|
|
||||||
|
_logger.LogInformation("Document [{0}] loaded!", documentId);
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool InsertDocumentStatus(DocumentStatus documentStatus)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Saving annotation data..");
|
||||||
|
return documentStatusModel.InsertOrUpdate(documentStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<byte[]> GetDocumentContents(EnvelopeDocument document)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Loading file [{0}]", document.Filepath);
|
||||||
|
var bytes = await File.ReadAllBytesAsync(document.Filepath);
|
||||||
|
_logger.LogInformation("File loaded, size: [{0}]", bytes.Length);
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
@{
|
@{
|
||||||
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
|
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
|
||||||
}
|
}
|
||||||
@using DigitalData.Core.DTO;
|
@using DigitalData.Core.Abstraction.Application.DTO;
|
||||||
@using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver
|
@using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver
|
||||||
@using Newtonsoft.Json
|
@using Newtonsoft.Json
|
||||||
@using Newtonsoft.Json.Serialization
|
@using Newtonsoft.Json.Serialization
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
|
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
|
||||||
var cImg = _cImgOpt.Value;
|
var cImg = _cImgOpt.Value;
|
||||||
}
|
}
|
||||||
@using DigitalData.Core.DTO;
|
@using DigitalData.Core.Abstraction.Application;
|
||||||
@using EnvelopeGenerator.Application.DTOs;
|
@using EnvelopeGenerator.Application.DTOs;
|
||||||
@using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver
|
@using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver
|
||||||
@using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly
|
@using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
@using EnvelopeGenerator.CommonServices;
|
@using EnvelopeGenerator.CommonServices;
|
||||||
@using static EnvelopeGenerator.CommonServices.Constants;
|
@using EnvelopeGenerator.Domain.Entities;
|
||||||
|
@using static EnvelopeGenerator.Domain.Constants;
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Debug";
|
ViewData["Title"] = "Debug";
|
||||||
}
|
}
|
||||||
@@ -11,9 +12,9 @@
|
|||||||
return Helpers.EncodeEnvelopeReceiverId(envelope.Uuid, receiver.Signature);
|
return Helpers.EncodeEnvelopeReceiverId(envelope.Uuid, receiver.Signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IGrouping<EnvelopeStatus, Envelope>> groupEnvelopes(List<Envelope> envelopes)
|
IEnumerable<IGrouping<EnvelopeStatus, Envelope>> groupEnvelopes(List<Envelope> envelopes)
|
||||||
{
|
{
|
||||||
return envelopes.GroupBy(item => item.Status).OrderBy(item => (int)item.Key);
|
return envelopes.GroupBy(item => (EnvelopeStatus) item.Status).OrderBy(item => item.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ Global
|
|||||||
{6D56C01F-D6CB-4D8A-BD3D-4FD34326998C}.Release|Any CPU.Build.0 = Debug|Any CPU
|
{6D56C01F-D6CB-4D8A-BD3D-4FD34326998C}.Release|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Release|Any CPU.Build.0 = Debug|Any CPU
|
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{5E0E17C0-FF5A-4246-BF87-1ADD85376A27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{5E0E17C0-FF5A-4246-BF87-1ADD85376A27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{5E0E17C0-FF5A-4246-BF87-1ADD85376A27}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{5E0E17C0-FF5A-4246-BF87-1ADD85376A27}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{5E0E17C0-FF5A-4246-BF87-1ADD85376A27}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
{5E0E17C0-FF5A-4246-BF87-1ADD85376A27}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
|||||||
Reference in New Issue
Block a user