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 DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using EnvelopeGenerator.Domain;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
@@ -16,7 +17,7 @@ public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, l
|
|||||||
/// <param name="userReference"></param>
|
/// <param name="userReference"></param>
|
||||||
/// <param name="status"></param>
|
/// <param name="status"></param>
|
||||||
/// <returns></returns>
|
/// <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>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -27,5 +28,5 @@ public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, l
|
|||||||
/// <param name="withSender"></param>
|
/// <param name="withSender"></param>
|
||||||
/// <param name="withReceiver"></param>
|
/// <param name="withReceiver"></param>
|
||||||
/// <returns></returns>
|
/// <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="userReference"></param>
|
||||||
/// <param name="status"></param>
|
/// <param name="status"></param>
|
||||||
/// <returns></returns>
|
/// <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>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -56,7 +56,7 @@ public interface IEnvelopeHistoryService : ICRUDService<EnvelopeHistoryCreateDto
|
|||||||
/// <param name="withSender"></param>
|
/// <param name="withSender"></param>
|
||||||
/// <param name="withReceiver"></param>
|
/// <param name="withReceiver"></param>
|
||||||
/// <returns></returns>
|
/// <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>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumer
|
|||||||
/// <exception cref="NotFoundException"></exception>
|
/// <exception cref="NotFoundException"></exception>
|
||||||
public async Task<IEnumerable<ReadHistoryResponse>> Handle(ReadHistoryQuery request, CancellationToken cancellationToken)
|
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())
|
if (!hists.Any())
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
|||||||
/// <param name="userReference"></param>
|
/// <param name="userReference"></param>
|
||||||
/// <param name="status"></param>
|
/// <param name="status"></param>
|
||||||
/// <returns></returns>
|
/// <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>
|
/// <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(
|
public async Task<bool> HasStatus(EnvelopeStatus status, int envelopeId, string userReference) => await _repository.CountAsync(
|
||||||
envelopeId: envelopeId,
|
envelopeId: envelopeId,
|
||||||
userReference: userReference,
|
userReference: userReference,
|
||||||
status: (int) status) > 0;
|
status: status) > 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -56,7 +56,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
|||||||
public async Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference) => await _repository.CountAsync(
|
public async Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference) => await _repository.CountAsync(
|
||||||
envelopeId: envelopeId,
|
envelopeId: envelopeId,
|
||||||
userReference:userReference,
|
userReference:userReference,
|
||||||
status: (int) EnvelopeStatus.AccessCodeRequested) > 0;
|
status: EnvelopeStatus.AccessCodeRequested) > 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -67,7 +67,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
|||||||
public async Task<bool> IsSigned(int envelopeId, string userReference) => await _repository.CountAsync(
|
public async Task<bool> IsSigned(int envelopeId, string userReference) => await _repository.CountAsync(
|
||||||
envelopeId: envelopeId,
|
envelopeId: envelopeId,
|
||||||
userReference: userReference,
|
userReference: userReference,
|
||||||
status: (int) EnvelopeStatus.DocumentSigned) > 0;
|
status: EnvelopeStatus.DocumentSigned) > 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the specified envelope has been rejected.
|
/// Checks if the specified envelope has been rejected.
|
||||||
@@ -81,7 +81,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
|||||||
return await _repository.CountAsync(
|
return await _repository.CountAsync(
|
||||||
envelopeId: envelopeId,
|
envelopeId: envelopeId,
|
||||||
userReference: userReference,
|
userReference: userReference,
|
||||||
status: (int)EnvelopeStatus.DocumentRejected) > 0;
|
status: EnvelopeStatus.DocumentRejected) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -94,7 +94,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
|||||||
/// <param name="withSender"></param>
|
/// <param name="withSender"></param>
|
||||||
/// <param name="withReceiver"></param>
|
/// <param name="withReceiver"></param>
|
||||||
/// <returns></returns>
|
/// <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>>(
|
var histDTOs = _mapper.Map<IEnumerable<EnvelopeHistoryDto>>(
|
||||||
await _repository.ReadAsync(
|
await _repository.ReadAsync(
|
||||||
@@ -113,7 +113,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
|
|||||||
/// <param name="userReference"></param>
|
/// <param name="userReference"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null) =>
|
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
|
//TODO: use IQueryable in repository to incerease the performance
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ Public Class CertificateModel
|
|||||||
oCommand.Parameters.Add("ENVELOPE_UUID", SqlDbType.NVarChar).Value = pEnvelope.Uuid
|
oCommand.Parameters.Add("ENVELOPE_UUID", SqlDbType.NVarChar).Value = pEnvelope.Uuid
|
||||||
oCommand.Parameters.Add("ENVELOPE_SUBJECT", SqlDbType.NVarChar).Value = String.Empty
|
oCommand.Parameters.Add("ENVELOPE_SUBJECT", SqlDbType.NVarChar).Value = String.Empty
|
||||||
oCommand.Parameters.Add("CREATOR_ID", SqlDbType.Int).Value = pEnvelope.UserId
|
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("CREATOR_EMAIL", SqlDbType.NVarChar).Value = pEnvelope.User.Email
|
||||||
oCommand.Parameters.Add("ENVELOPE_STATUS", SqlDbType.Int).Value = pEnvelope.Status
|
oCommand.Parameters.Add("ENVELOPE_STATUS", SqlDbType.Int).Value = pEnvelope.Status
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ Public Class EmailData
|
|||||||
ReceiverName = pReceiver.Name
|
ReceiverName = pReceiver.Name
|
||||||
ReceiverAccessCode = pReceiver.AccessCode
|
ReceiverAccessCode = pReceiver.AccessCode
|
||||||
SenderAdress = pEnvelope.User.Email
|
SenderAdress = pEnvelope.User.Email
|
||||||
SenderName = pEnvelope.User.FullName
|
SenderName = pEnvelope.User.GetFullName()
|
||||||
EnvelopeTitle = pEnvelope.Title
|
EnvelopeTitle = pEnvelope.Title
|
||||||
End Sub
|
End Sub
|
||||||
Public Function TextToHtml(input As String) As String
|
Public Function TextToHtml(input As String) As String
|
||||||
@@ -72,10 +72,10 @@ Public Class EmailData
|
|||||||
Message = pEnvelope.Message
|
Message = pEnvelope.Message
|
||||||
ReferenceID = pEnvelope.Id
|
ReferenceID = pEnvelope.Id
|
||||||
ReferenceString = pEnvelope.Uuid
|
ReferenceString = pEnvelope.Uuid
|
||||||
ReceiverName = pEnvelope.User.FullName
|
ReceiverName = pEnvelope.User.GetFullName()
|
||||||
ReceiverAccessCode = String.Empty
|
ReceiverAccessCode = String.Empty
|
||||||
SenderAdress = pEnvelope.User.Email
|
SenderAdress = pEnvelope.User.Email
|
||||||
SenderName = pEnvelope.User.FullName
|
SenderName = pEnvelope.User.GetFullName()
|
||||||
EnvelopeTitle = pEnvelope.Title
|
EnvelopeTitle = pEnvelope.Title
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ Public Class EnvelopeModel
|
|||||||
.AddedWhen = pRow.Item("ADDED_WHEN"),
|
.AddedWhen = pRow.Item("ADDED_WHEN"),
|
||||||
.ChangedWhen = pRow.ItemEx(Of Date)("CHANGED_WHEN", Nothing),
|
.ChangedWhen = pRow.ItemEx(Of Date)("CHANGED_WHEN", Nothing),
|
||||||
.CertificationType = ObjectEx.ToEnum(Of CertificationType)(pRow.ItemEx("CERTIFICATION_TYPE", CertificationType.AdvancedElectronicSignature.ToString())),
|
.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),
|
.ExpiresWhen = pRow.ItemEx(Of Date)("EXPIRES_WHEN", Nothing),
|
||||||
.ExpiresWarningWhen = pRow.ItemEx(Of Date)("EXPIRES_WARNING_WHEN", Nothing),
|
.ExpiresWarningWhen = pRow.ItemEx(Of Date)("EXPIRES_WARNING_WHEN", Nothing),
|
||||||
.ExpiresWhenDays = pRow.ItemEx("EXPIRES_WHEN_DAYS", 0),
|
.ExpiresWhenDays = pRow.ItemEx("EXPIRES_WHEN_DAYS", 0),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Imports EnvelopeGenerator.Domain.Entities
|
|||||||
|
|
||||||
Public Class State
|
Public Class State
|
||||||
Public Property UserId As Integer
|
Public Property UserId As Integer
|
||||||
Public Property User As EGUser
|
Public Property User As FormUser
|
||||||
Public Property Config As Config
|
Public Property Config As Config
|
||||||
Public Property DbConfig As DbConfig
|
Public Property DbConfig As DbConfig
|
||||||
Public Property LogConfig As LogConfig
|
Public Property LogConfig As LogConfig
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ Public Class UserModel
|
|||||||
MyBase.New(pState)
|
MyBase.New(pState)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Function ToUser(pRow As DataRow) As EGUser
|
Private Function ToUser(pRow As DataRow) As FormUser
|
||||||
Dim oUser = New EGUser() With {
|
Dim oUser = New FormUser() With {
|
||||||
.Id = pRow.ItemEx("GUID", 0),
|
.Id = pRow.ItemEx("GUID", 0),
|
||||||
.Prename = pRow.ItemEx("PRENAME", ""),
|
.Prename = pRow.ItemEx("PRENAME", ""),
|
||||||
.Name = pRow.ItemEx("NAME", ""),
|
.Name = pRow.ItemEx("NAME", ""),
|
||||||
@@ -22,7 +22,7 @@ Public Class UserModel
|
|||||||
Return oUser
|
Return oUser
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function CheckUserLogin(pUser As EGUser) As EGUser
|
Public Function CheckUserLogin(pUser As FormUser) As FormUser
|
||||||
Try
|
Try
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[FNDD_LOGIN_USER_MODULE] ('{pUser.Username}', 'SIG_ENV_CR', 1)"
|
Dim oSql = $"SELECT * FROM [dbo].[FNDD_LOGIN_USER_MODULE] ('{pUser.Username}', 'SIG_ENV_CR', 1)"
|
||||||
Dim oTable As DataTable = Database.GetDatatable(oSql)
|
Dim oTable As DataTable = Database.GetDatatable(oSql)
|
||||||
@@ -45,7 +45,7 @@ Public Class UserModel
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function SelectUser() As EGUser
|
Public Function SelectUser() As FormUser
|
||||||
Try
|
Try
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {State.UserId}"
|
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {State.UserId}"
|
||||||
Dim oTable = Database.GetDatatable(oSql)
|
Dim oTable = Database.GetDatatable(oSql)
|
||||||
@@ -58,7 +58,7 @@ Public Class UserModel
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function SelectUser(pUserID As Integer) As EGUser
|
Public Function SelectUser(pUserID As Integer) As FormUser
|
||||||
Try
|
Try
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {pUserID}"
|
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {pUserID}"
|
||||||
Dim oTable = Database.GetDatatable(oSql)
|
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;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
using System;
|
using System;
|
||||||
@@ -113,7 +114,7 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
// TODO: * Check the Form App and remove the default value
|
||||||
[ForeignKey("UserId")]
|
[ForeignKey("UserId")]
|
||||||
public EGUser User { get; set; } = new EGUser();
|
public User User { get; set; }
|
||||||
|
|
||||||
[ForeignKey("EnvelopeTypeId")]
|
[ForeignKey("EnvelopeTypeId")]
|
||||||
public EnvelopeType EnvelopeType { get; set; }
|
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;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
using System;
|
using System;
|
||||||
@@ -38,7 +39,7 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
public string Comment { get; set; }
|
public string Comment { get; set; }
|
||||||
|
|
||||||
[ForeignKey("UserReference")]
|
[ForeignKey("UserReference")]
|
||||||
public virtual EGUser Sender { get; set; }
|
public virtual User Sender { get; set; }
|
||||||
|
|
||||||
[ForeignKey("UserReference")]
|
[ForeignKey("UserReference")]
|
||||||
public virtual Receiver Receiver { get; set; }
|
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.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using DigitalData.UserManager.Domain.Entities;
|
using DigitalData.UserManager.Domain.Entities;
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
|
||||||
using System;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Domain.Entities
|
namespace EnvelopeGenerator.Domain.Entities
|
||||||
{
|
{
|
||||||
[Table("TBDD_USER", Schema = "dbo")]
|
[Table("TBDD_USER", Schema = "dbo")]
|
||||||
public class EGUser : User
|
public class FormUser : User
|
||||||
{
|
{
|
||||||
#region FORM_APP
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public bool HasAccess { get; set; }
|
public bool HasAccess { get; set; }
|
||||||
|
|
||||||
@@ -24,6 +17,5 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string FullName => $"{Prename} {Name}";
|
public string FullName => $"{Prename} {Name}";
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ Module ModuleSettings
|
|||||||
Public DB_DD_ECM As MSSQLServer = Nothing
|
Public DB_DD_ECM As MSSQLServer = Nothing
|
||||||
Public DEF_TF_ENABLED As Boolean = False
|
Public DEF_TF_ENABLED As Boolean = False
|
||||||
Public DEF_TF_ENABLED_WITH_PHONE 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 MyTempFiles As TempFiles
|
||||||
Public SQL_REP_ENV_USER_LM As String = ""
|
Public SQL_REP_ENV_USER_LM As String = ""
|
||||||
Public SQL_REP_ENV_USER_TM As String = ""
|
Public SQL_REP_ENV_USER_TM As String = ""
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Application.Contracts.Repositories;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using EnvelopeGenerator.Domain;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
[Obsolete("Use Repository")]
|
||||||
public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, EGDbContext>, IEnvelopeHistoryRepository
|
public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, EGDbContext>, IEnvelopeHistoryRepository
|
||||||
{
|
{
|
||||||
public EnvelopeHistoryRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeHistories)
|
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();
|
var query = _dbSet.AsNoTracking();
|
||||||
|
|
||||||
@@ -33,12 +35,12 @@ public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, E
|
|||||||
return query;
|
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,
|
envelopeId: envelopeId,
|
||||||
userReference: userReference,
|
userReference: userReference,
|
||||||
status: status).CountAsync();
|
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(
|
=> await By(
|
||||||
envelopeId: envelopeId,
|
envelopeId: envelopeId,
|
||||||
userReference: userReference,
|
userReference: userReference,
|
||||||
|
|||||||
@@ -3,76 +3,77 @@ using EnvelopeGenerator.CommonServices;
|
|||||||
using EnvelopeGenerator.Web.Services;
|
using EnvelopeGenerator.Web.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using EnvelopeGenerator.Extensions;
|
using EnvelopeGenerator.Extensions;
|
||||||
using static EnvelopeGenerator.CommonServices.Constants;
|
|
||||||
using EnvelopeGenerator.Application.Contracts.Services;
|
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)]
|
private readonly EnvelopeOldService envelopeService;
|
||||||
[Route("api/[controller]")]
|
private readonly ActionService? actionService;
|
||||||
public class DocumentController : BaseController
|
[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;
|
envelopeService = envelope;
|
||||||
private readonly ActionService? actionService;
|
actionService = database.Services?.actionService;
|
||||||
private readonly IEnvelopeDocumentService _envDocService;
|
_envDocService = 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
[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