Compare commits
6 Commits
5c48afd8b0
...
08601adc49
| Author | SHA1 | Date | |
|---|---|---|---|
| 08601adc49 | |||
| 2a4255e5a3 | |||
| 0800e4d13e | |||
| 07381e78b4 | |||
| 5d29ad889d | |||
| 5ee9efbcd9 |
@@ -1,4 +1,5 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
@@ -16,7 +17,7 @@ public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, l
|
||||
/// <param name="userReference"></param>
|
||||
/// <param name="status"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
|
||||
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -27,5 +28,5 @@ public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, l
|
||||
/// <param name="withSender"></param>
|
||||
/// <param name="withReceiver"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false);
|
||||
Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false);
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public interface IEnvelopeHistoryService : ICRUDService<EnvelopeHistoryCreateDto
|
||||
/// <param name="userReference"></param>
|
||||
/// <param name="status"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
|
||||
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -56,7 +56,7 @@ public interface IEnvelopeHistoryService : ICRUDService<EnvelopeHistoryCreateDto
|
||||
/// <param name="withSender"></param>
|
||||
/// <param name="withReceiver"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null, bool withSender = false, bool withReceiver = false);
|
||||
Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumer
|
||||
/// <exception cref="NotFoundException"></exception>
|
||||
public async Task<IEnumerable<ReadHistoryResponse>> Handle(ReadHistoryQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var hists = await _repository.ReadAsync(request.EnvelopeId, status: request.Status is null ? null : (int) request.Status);
|
||||
var hists = await _repository.ReadAsync(request.EnvelopeId, status: request.Status is null ? null : request.Status);
|
||||
|
||||
if (!hists.Any())
|
||||
throw new NotFoundException();
|
||||
|
||||
@@ -33,7 +33,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
||||
/// <param name="userReference"></param>
|
||||
/// <param name="status"></param>
|
||||
/// <returns></returns>
|
||||
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<int> CountAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null) => await _repository.CountAsync(envelopeId: envelopeId, userReference: userReference, status: status);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -45,7 +45,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
||||
public async Task<bool> HasStatus(EnvelopeStatus status, int envelopeId, string userReference) => await _repository.CountAsync(
|
||||
envelopeId: envelopeId,
|
||||
userReference: userReference,
|
||||
status: (int) status) > 0;
|
||||
status: status) > 0;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -56,7 +56,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
||||
public async Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference) => await _repository.CountAsync(
|
||||
envelopeId: envelopeId,
|
||||
userReference:userReference,
|
||||
status: (int) EnvelopeStatus.AccessCodeRequested) > 0;
|
||||
status: EnvelopeStatus.AccessCodeRequested) > 0;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -67,7 +67,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
||||
public async Task<bool> IsSigned(int envelopeId, string userReference) => await _repository.CountAsync(
|
||||
envelopeId: envelopeId,
|
||||
userReference: userReference,
|
||||
status: (int) EnvelopeStatus.DocumentSigned) > 0;
|
||||
status: EnvelopeStatus.DocumentSigned) > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified envelope has been rejected.
|
||||
@@ -81,7 +81,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
||||
return await _repository.CountAsync(
|
||||
envelopeId: envelopeId,
|
||||
userReference: userReference,
|
||||
status: (int)EnvelopeStatus.DocumentRejected) > 0;
|
||||
status: EnvelopeStatus.DocumentRejected) > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -94,7 +94,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
||||
/// <param name="withSender"></param>
|
||||
/// <param name="withReceiver"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null, bool withSender = false, bool withReceiver = false)
|
||||
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false)
|
||||
{
|
||||
var histDTOs = _mapper.Map<IEnumerable<EnvelopeHistoryDto>>(
|
||||
await _repository.ReadAsync(
|
||||
@@ -113,7 +113,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
||||
/// <param name="userReference"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null) =>
|
||||
await ReadAsync(envelopeId: envelopeId, userReference: userReference, status: (int)EnvelopeStatus.DocumentRejected, withReceiver:true);
|
||||
await ReadAsync(envelopeId: envelopeId, userReference: userReference, status: EnvelopeStatus.DocumentRejected, withReceiver:true);
|
||||
|
||||
//TODO: use IQueryable in repository to incerease the performance
|
||||
/// <summary>
|
||||
|
||||
@@ -34,7 +34,7 @@ Public Class CertificateModel
|
||||
oCommand.Parameters.Add("ENVELOPE_UUID", SqlDbType.NVarChar).Value = pEnvelope.Uuid
|
||||
oCommand.Parameters.Add("ENVELOPE_SUBJECT", SqlDbType.NVarChar).Value = String.Empty
|
||||
oCommand.Parameters.Add("CREATOR_ID", SqlDbType.Int).Value = pEnvelope.UserId
|
||||
oCommand.Parameters.Add("CREATOR_NAME", SqlDbType.NVarChar).Value = pEnvelope.User.FullName
|
||||
oCommand.Parameters.Add("CREATOR_NAME", SqlDbType.NVarChar).Value = pEnvelope.User.GetFullName()
|
||||
oCommand.Parameters.Add("CREATOR_EMAIL", SqlDbType.NVarChar).Value = pEnvelope.User.Email
|
||||
oCommand.Parameters.Add("ENVELOPE_STATUS", SqlDbType.Int).Value = pEnvelope.Status
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ Public Class EmailData
|
||||
ReceiverName = pReceiver.Name
|
||||
ReceiverAccessCode = pReceiver.AccessCode
|
||||
SenderAdress = pEnvelope.User.Email
|
||||
SenderName = pEnvelope.User.FullName
|
||||
SenderName = pEnvelope.User.GetFullName()
|
||||
EnvelopeTitle = pEnvelope.Title
|
||||
End Sub
|
||||
Public Function TextToHtml(input As String) As String
|
||||
@@ -72,10 +72,10 @@ Public Class EmailData
|
||||
Message = pEnvelope.Message
|
||||
ReferenceID = pEnvelope.Id
|
||||
ReferenceString = pEnvelope.Uuid
|
||||
ReceiverName = pEnvelope.User.FullName
|
||||
ReceiverName = pEnvelope.User.GetFullName()
|
||||
ReceiverAccessCode = String.Empty
|
||||
SenderAdress = pEnvelope.User.Email
|
||||
SenderName = pEnvelope.User.FullName
|
||||
SenderName = pEnvelope.User.GetFullName()
|
||||
EnvelopeTitle = pEnvelope.Title
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ Public Class EnvelopeModel
|
||||
.AddedWhen = pRow.Item("ADDED_WHEN"),
|
||||
.ChangedWhen = pRow.ItemEx(Of Date)("CHANGED_WHEN", Nothing),
|
||||
.CertificationType = ObjectEx.ToEnum(Of CertificationType)(pRow.ItemEx("CERTIFICATION_TYPE", CertificationType.AdvancedElectronicSignature.ToString())),
|
||||
.User = New EGUser(),
|
||||
.User = New FormUser(),
|
||||
.ExpiresWhen = pRow.ItemEx(Of Date)("EXPIRES_WHEN", Nothing),
|
||||
.ExpiresWarningWhen = pRow.ItemEx(Of Date)("EXPIRES_WARNING_WHEN", Nothing),
|
||||
.ExpiresWhenDays = pRow.ItemEx("EXPIRES_WHEN_DAYS", 0),
|
||||
|
||||
@@ -4,7 +4,7 @@ Imports EnvelopeGenerator.Domain.Entities
|
||||
|
||||
Public Class State
|
||||
Public Property UserId As Integer
|
||||
Public Property User As EGUser
|
||||
Public Property User As FormUser
|
||||
Public Property Config As Config
|
||||
Public Property DbConfig As DbConfig
|
||||
Public Property LogConfig As LogConfig
|
||||
|
||||
@@ -9,8 +9,8 @@ Public Class UserModel
|
||||
MyBase.New(pState)
|
||||
End Sub
|
||||
|
||||
Private Function ToUser(pRow As DataRow) As EGUser
|
||||
Dim oUser = New EGUser() With {
|
||||
Private Function ToUser(pRow As DataRow) As FormUser
|
||||
Dim oUser = New FormUser() With {
|
||||
.Id = pRow.ItemEx("GUID", 0),
|
||||
.Prename = pRow.ItemEx("PRENAME", ""),
|
||||
.Name = pRow.ItemEx("NAME", ""),
|
||||
@@ -22,7 +22,7 @@ Public Class UserModel
|
||||
Return oUser
|
||||
End Function
|
||||
|
||||
Public Function CheckUserLogin(pUser As EGUser) As EGUser
|
||||
Public Function CheckUserLogin(pUser As FormUser) As FormUser
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [dbo].[FNDD_LOGIN_USER_MODULE] ('{pUser.Username}', 'SIG_ENV_CR', 1)"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSql)
|
||||
@@ -45,7 +45,7 @@ Public Class UserModel
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function SelectUser() As EGUser
|
||||
Public Function SelectUser() As FormUser
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {State.UserId}"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
@@ -58,7 +58,7 @@ Public Class UserModel
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function SelectUser(pUserID As Integer) As EGUser
|
||||
Public Function SelectUser(pUserID As Integer) As FormUser
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {pUserID}"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
@@ -113,7 +114,7 @@ namespace EnvelopeGenerator.Domain.Entities
|
||||
|
||||
// TODO: * Check the Form App and remove the default value
|
||||
[ForeignKey("UserId")]
|
||||
public EGUser User { get; set; } = new EGUser();
|
||||
public User User { get; set; }
|
||||
|
||||
[ForeignKey("EnvelopeTypeId")]
|
||||
public EnvelopeType EnvelopeType { get; set; }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
@@ -38,7 +39,7 @@ namespace EnvelopeGenerator.Domain.Entities
|
||||
public string Comment { get; set; }
|
||||
|
||||
[ForeignKey("UserReference")]
|
||||
public virtual EGUser Sender { get; set; }
|
||||
public virtual User Sender { get; set; }
|
||||
|
||||
[ForeignKey("UserReference")]
|
||||
public virtual Receiver Receiver { get; set; }
|
||||
|
||||
32
EnvelopeGenerator.Domain/Entities/FormExtensions.cs
Normal file
32
EnvelopeGenerator.Domain/Entities/FormExtensions.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
{
|
||||
public static class FormExtensions
|
||||
{
|
||||
public static FormUser ToEGUser(this User user)
|
||||
{
|
||||
return new FormUser()
|
||||
{
|
||||
Id = user.Id,
|
||||
Prename = user.Prename,
|
||||
Name = user.Name,
|
||||
Username = user.Username,
|
||||
Shortname = user.Shortname,
|
||||
Email = user.Email,
|
||||
Language = user.Language,
|
||||
Comment = user.Comment,
|
||||
Deleted = user.Deleted,
|
||||
DateFormat = user.DateFormat,
|
||||
Active = user.Active,
|
||||
GeneralViewer = user.GeneralViewer,
|
||||
WanEnvironment = user.WanEnvironment,
|
||||
UserIdFkIntEcm = user.UserIdFkIntEcm,
|
||||
DeletedWhen = user.DeletedWhen,
|
||||
DeletedWho = user.DeletedWho
|
||||
};
|
||||
}
|
||||
|
||||
public static string GetFullName(this User user) => $"{user.Prename} {user.Name}";
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
#endif
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
{
|
||||
[Table("TBDD_USER", Schema = "dbo")]
|
||||
public class EGUser : User
|
||||
public class FormUser : User
|
||||
{
|
||||
#region FORM_APP
|
||||
[NotMapped]
|
||||
public bool HasAccess { get; set; }
|
||||
|
||||
@@ -24,6 +17,5 @@ namespace EnvelopeGenerator.Domain.Entities
|
||||
|
||||
[NotMapped]
|
||||
public string FullName => $"{Prename} {Name}";
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ Module ModuleSettings
|
||||
Public DB_DD_ECM As MSSQLServer = Nothing
|
||||
Public DEF_TF_ENABLED As Boolean = False
|
||||
Public DEF_TF_ENABLED_WITH_PHONE As Boolean = False
|
||||
Public MYUSER As EGUser
|
||||
Public MYUSER As FormUser
|
||||
Public MyTempFiles As TempFiles
|
||||
Public SQL_REP_ENV_USER_LM As String = ""
|
||||
Public SQL_REP_ENV_USER_TM As String = ""
|
||||
|
||||
@@ -2,16 +2,18 @@
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||
|
||||
[Obsolete("Use Repository")]
|
||||
public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, EGDbContext>, IEnvelopeHistoryRepository
|
||||
{
|
||||
public EnvelopeHistoryRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeHistories)
|
||||
{
|
||||
}
|
||||
|
||||
private IQueryable<EnvelopeHistory> By(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false)
|
||||
private IQueryable<EnvelopeHistory> By(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false)
|
||||
{
|
||||
var query = _dbSet.AsNoTracking();
|
||||
|
||||
@@ -33,12 +35,12 @@ public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, E
|
||||
return query;
|
||||
}
|
||||
|
||||
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null) => await By(
|
||||
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null) => await By(
|
||||
envelopeId: envelopeId,
|
||||
userReference: userReference,
|
||||
status: status).CountAsync();
|
||||
|
||||
public async Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false)
|
||||
public async Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false)
|
||||
=> await By(
|
||||
envelopeId: envelopeId,
|
||||
userReference: userReference,
|
||||
|
||||
@@ -3,76 +3,77 @@ using EnvelopeGenerator.CommonServices;
|
||||
using EnvelopeGenerator.Web.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using static EnvelopeGenerator.CommonServices.Constants;
|
||||
using EnvelopeGenerator.Application.Contracts.Services;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers
|
||||
namespace EnvelopeGenerator.Web.Controllers;
|
||||
|
||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||
[Route("api/[controller]")]
|
||||
public class DocumentController : BaseController
|
||||
{
|
||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||
[Route("api/[controller]")]
|
||||
public class DocumentController : BaseController
|
||||
private readonly EnvelopeOldService envelopeService;
|
||||
private readonly ActionService? actionService;
|
||||
[Obsolete("Use MediatR")]
|
||||
private readonly IEnvelopeDocumentService _envDocService;
|
||||
|
||||
[Obsolete("Use MediatR")]
|
||||
public DocumentController(DatabaseService database, EnvelopeOldService envelope, IEnvelopeDocumentService envDocService, ILogger<DocumentController> logger) : base(database, logger)
|
||||
{
|
||||
private readonly EnvelopeOldService envelopeService;
|
||||
private readonly ActionService? actionService;
|
||||
private readonly IEnvelopeDocumentService _envDocService;
|
||||
|
||||
public DocumentController(DatabaseService database, EnvelopeOldService envelope, IEnvelopeDocumentService envDocService, ILogger<DocumentController> logger) : base(database, logger)
|
||||
{
|
||||
envelopeService = envelope;
|
||||
actionService = database.Services?.actionService;
|
||||
_envDocService = envDocService;
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Validate Envelope Key and load envelope
|
||||
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
||||
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
|
||||
|
||||
// Load document info
|
||||
var document = await envelopeService.GetDocument(index, envelopeKey);
|
||||
|
||||
// Load the document from disk
|
||||
var bytes = await envelopeService.GetDocumentContents(document);
|
||||
|
||||
// Return the document as bytes
|
||||
return File(bytes, "application/octet-stream");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "{Message}", ex.Message);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||
[HttpPost("{envelopeKey}")]
|
||||
public async Task<IActionResult> Open(string envelopeKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
var authSignature = this.GetAuthReceiverSignature();
|
||||
|
||||
if (authSignature != envelopeKey.GetReceiverSignature())
|
||||
return Forbid();
|
||||
|
||||
// Validate Envelope Key and load envelope
|
||||
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
||||
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
|
||||
|
||||
actionService?.OpenEnvelope(response.Envelope, response.Receiver);
|
||||
|
||||
return Ok(new object());
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "{Message}", ex.Message);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
envelopeService = envelope;
|
||||
actionService = database.Services?.actionService;
|
||||
_envDocService = envDocService;
|
||||
}
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Validate Envelope Key and load envelope
|
||||
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
||||
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
|
||||
|
||||
// Load document info
|
||||
var document = await envelopeService.GetDocument(index, envelopeKey);
|
||||
|
||||
// Load the document from disk
|
||||
var bytes = await envelopeService.GetDocumentContents(document);
|
||||
|
||||
// Return the document as bytes
|
||||
return File(bytes, "application/octet-stream");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "{Message}", ex.Message);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||
[HttpPost("{envelopeKey}")]
|
||||
public async Task<IActionResult> Open(string envelopeKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
var authSignature = this.GetAuthReceiverSignature();
|
||||
|
||||
if (authSignature != envelopeKey.GetReceiverSignature())
|
||||
return Forbid();
|
||||
|
||||
// Validate Envelope Key and load envelope
|
||||
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
||||
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
|
||||
|
||||
actionService?.OpenEnvelope(response.Envelope, response.Receiver);
|
||||
|
||||
return Ok(new object());
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "{Message}", ex.Message);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user