EmailDispatcher ist integriert.
This commit is contained in:
parent
0268756cf9
commit
38aa6a6217
@ -10,6 +10,9 @@ namespace EnvelopeGenerator.Application.Contracts
|
||||
{
|
||||
Task<DataResult<ConfigDto>> ReadFirstAsync();
|
||||
|
||||
async Task<DataResult<ConfigDto>> ReadDefaultAsync() => await ReadFirstAsync();
|
||||
Task<ConfigDto> ReadDefaultAsync();
|
||||
|
||||
Task<string> ReadDefaultSignatureHost();
|
||||
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,8 @@ namespace EnvelopeGenerator.Application.Contracts
|
||||
|
||||
Task<DataResult<EnvelopeReceiverDto>> ReadByEnvelopeReceiverIdAsync(string envelopeReceiverId, bool withEnvelope = true, bool withReceiver = true);
|
||||
|
||||
Task<DataResult<string>> ReadAccessCodeByIdAsync(int envelopeId, int receiverId);
|
||||
|
||||
Task<DataResult<bool>> VerifyAccessCodeAsync(string uuid, string signature, string accessCode);
|
||||
|
||||
Task<DataResult<bool>> VerifyAccessCodeAsync(string envelopeReceiverId, string accessCode);
|
||||
|
||||
@ -1,38 +1,66 @@
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using DigitalData.EmailProfilerDispatcher.Domain.Attributes;
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs
|
||||
{
|
||||
public record EnvelopeDto(
|
||||
int Id,
|
||||
int UserId,
|
||||
int Status,
|
||||
string Uuid,
|
||||
string Message,
|
||||
DateTime? ExpiresWhen,
|
||||
DateTime? ExpiresWarningWhen,
|
||||
DateTime AddedWhen,
|
||||
DateTime? ChangedWhen,
|
||||
string Title,
|
||||
int? ContractType,
|
||||
string Language,
|
||||
bool? SendReminderEmails,
|
||||
int? FirstReminderDays,
|
||||
int? ReminderIntervalDays,
|
||||
int? EnvelopeTypeId,
|
||||
int? CertificationType,
|
||||
bool? UseAccessCode,
|
||||
int? FinalEmailToCreator,
|
||||
int? FinalEmailToReceivers,
|
||||
int? ExpiresWhenDays,
|
||||
int? ExpiresWarningWhenDays,
|
||||
bool DmzMoved,
|
||||
User? User,
|
||||
EnvelopeType? EnvelopeType,
|
||||
string? EnvelopeTypeTitle,
|
||||
bool IsAlreadySent,
|
||||
string? StatusTranslated,
|
||||
string? ContractTypeTranslated,
|
||||
IEnumerable<EnvelopeDocumentDto>? Documents);
|
||||
public record EnvelopeDto()
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
public int Status { get; set; }
|
||||
|
||||
public string Uuid { get; set; }
|
||||
|
||||
[TemplatePlaceholder("[MESSAGE]")]
|
||||
public string Message { get; set; }
|
||||
public DateTime? ExpiresWhen { get; set; }
|
||||
public DateTime? ExpiresWarningWhen { get; set; }
|
||||
public DateTime AddedWhen { get; set; }
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
[TemplatePlaceholder("[DOCUMENT_TITLE]")]
|
||||
public string Title { get; set; }
|
||||
|
||||
public int? ContractType { get; set; }
|
||||
|
||||
public string Language { get; set; }
|
||||
|
||||
public bool? SendReminderEmails { get; set; }
|
||||
|
||||
public int? FirstReminderDays { get; set; }
|
||||
|
||||
public int? ReminderIntervalDays { get; set; }
|
||||
|
||||
public int? EnvelopeTypeId { get; set; }
|
||||
|
||||
public int? CertificationType { get; set; }
|
||||
|
||||
public bool? UseAccessCode { get; set; }
|
||||
|
||||
public int? FinalEmailToCreator { get; set; }
|
||||
|
||||
public int? FinalEmailToReceivers { get; set; }
|
||||
|
||||
public int? ExpiresWhenDays { get; set; }
|
||||
|
||||
public int? ExpiresWarningWhenDays { get; set; }
|
||||
|
||||
public bool DmzMoved { get; set; }
|
||||
public UserReadDto? User { get; set; }
|
||||
public EnvelopeType? EnvelopeType { get; set; }
|
||||
|
||||
public string? EnvelopeTypeTitle { get; set; }
|
||||
|
||||
public bool IsAlreadySent { get; set; }
|
||||
|
||||
public string? StatusTranslated { get; set; }
|
||||
|
||||
public string? ContractTypeTranslated { get; set; }
|
||||
public IEnumerable<EnvelopeDocumentDto>? Documents { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,32 @@
|
||||
namespace EnvelopeGenerator.Application.DTOs
|
||||
using DigitalData.EmailProfilerDispatcher.Domain.Attributes;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs
|
||||
{
|
||||
public record EnvelopeReceiverDto(
|
||||
int EnvelopeId,
|
||||
int ReceiverId,
|
||||
int Sequence,
|
||||
string? Name,
|
||||
string? JobTitle,
|
||||
string? CompanyName,
|
||||
string? PrivateMessage,
|
||||
DateTime AddedWhen,
|
||||
DateTime? ChangedWhen,
|
||||
EnvelopeDto? Envelope,
|
||||
ReceiverDto? Receiver);
|
||||
public record EnvelopeReceiverDto()
|
||||
{
|
||||
public int EnvelopeId { get; set; }
|
||||
|
||||
public int ReceiverId { get; set; }
|
||||
|
||||
public int Sequence { get; set; }
|
||||
|
||||
[TemplatePlaceholder("[NAME_RECEIVER]")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string? JobTitle { get; set; }
|
||||
|
||||
public string? CompanyName { get; set; }
|
||||
|
||||
public string? PrivateMessage { get; set; }
|
||||
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
public EnvelopeDto? Envelope { get; set; }
|
||||
|
||||
public ReceiverDto? Receiver { get; set; }
|
||||
}
|
||||
}
|
||||
13
EnvelopeGenerator.Application/DispatcherConfig.cs
Normal file
13
EnvelopeGenerator.Application/DispatcherConfig.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace EnvelopeGenerator.Application
|
||||
{
|
||||
public class DispatcherConfig
|
||||
{
|
||||
public int SendingProfile { get; init; } = 1;
|
||||
|
||||
public string AddedWho { get; init; } = "DDEnvelopGenerator";
|
||||
|
||||
public int ReminderTypeId { get; init; } = 202377;
|
||||
|
||||
public string EmailAttmt1 { get; init; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@ -102,6 +102,15 @@ namespace EnvelopeGenerator.Application
|
||||
/// <returns>The receiver signature.</returns>
|
||||
public static string? GetReceiverSignature(this string envelopeReceiverId) => envelopeReceiverId.DecodeEnvelopeReceiverId().ReceiverSignature;
|
||||
|
||||
public static string EncodeEnvelopeReceiverId(this (string envelopeUuid, string receiverSignature) input)
|
||||
{
|
||||
string combinedString = $"{input.envelopeUuid}::{input.receiverSignature}";
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(combinedString);
|
||||
string base64String = Convert.ToBase64String(bytes);
|
||||
|
||||
return base64String;
|
||||
}
|
||||
|
||||
public static void LogEnvelopeError(this ILogger logger, string envelopeReceiverId, Exception? exception = null, string? message = null, params object?[] args)
|
||||
{
|
||||
var sb = new StringBuilder().AppendLine(envelopeReceiverId.DecodeEnvelopeReceiverId().ToTitle());
|
||||
|
||||
@ -6,22 +6,57 @@ using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Application.Resources;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
namespace EnvelopeGenerator.Application.Services
|
||||
{
|
||||
public class ConfigService : BasicCRUDService<IConfigRepository, ConfigDto, Config, int>, IConfigService
|
||||
{
|
||||
public ConfigService(IConfigRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper) : base(repository, localizer, mapper)
|
||||
private static readonly Guid DefaultConfigCacheId = Guid.NewGuid();
|
||||
|
||||
private readonly IMemoryCache _cache;
|
||||
private readonly ILogger<ConfigService> _logger;
|
||||
public ConfigService(IConfigRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper, IMemoryCache memoryCache, ILogger<ConfigService> logger) : base(repository, localizer, mapper)
|
||||
{
|
||||
_cache = memoryCache;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<DataResult<ConfigDto>> ReadFirstAsync()
|
||||
{
|
||||
var config = await _repository.ReadFirstAsync();
|
||||
return config is null ? Result.Fail<ConfigDto>().Message("There is no configuration in DB.") : Result.Success(_mapper.MapOrThrow<ConfigDto>(config));
|
||||
return config is null
|
||||
? Result.Fail<ConfigDto>().Notice(LogLevel.Error, Flag.DataIntegrityIssue, "There is no configuration in DB.")
|
||||
: Result.Success(_mapper.MapOrThrow<ConfigDto>(config));
|
||||
}
|
||||
|
||||
public async Task<DataResult<ConfigDto>> ReadDefaultAsync() => await ReadFirstAsync();
|
||||
/// <summary>
|
||||
/// Reads the default configuration asynchronously.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The configuration is cached in memory upon the first retrieval. If the configuration is updated,
|
||||
/// the application needs to be restarted for the changes to take effect as the memory cache will not be updated automatically.
|
||||
/// </remarks>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous read operation. The task result contains the default configuration as a <see cref="ConfigDto"/>.
|
||||
/// </returns>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown when the default configuration cannot be found.
|
||||
/// </exception>
|
||||
public async Task<ConfigDto> ReadDefaultAsync()
|
||||
{
|
||||
var config = await _cache.GetOrCreateAsync(DefaultConfigCacheId, _ => ReadFirstAsync().ThenAsync(
|
||||
Success: config => config,
|
||||
Fail: (mssg, ntc) =>
|
||||
{
|
||||
_logger.LogNotice(ntc);
|
||||
throw new InvalidOperationException("Default configuration cannot find.");
|
||||
}));
|
||||
|
||||
return config!;
|
||||
}
|
||||
|
||||
public async Task<string> ReadDefaultSignatureHost() => (await ReadDefaultAsync()).SignatureHost;
|
||||
}
|
||||
}
|
||||
@ -7,30 +7,93 @@ using DigitalData.UserManager.Application;
|
||||
using EnvelopeGenerator.Application.Contracts;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Common;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using static EnvelopeGenerator.Common.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Services
|
||||
{
|
||||
public class EnvelopeMailService : EmailOutService<Resource>, IEnvelopeMailService
|
||||
{
|
||||
private readonly IEmailTemplateService _tempService;
|
||||
private readonly IMemoryCache _cache;
|
||||
private readonly IEnvelopeReceiverService _envRcvService;
|
||||
private readonly DispatcherConfig _dConfig;
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
public EnvelopeMailService(IEmailOutRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper, IEmailTemplateService tempService, IMemoryCache cache) : base(repository, localizer, mapper)
|
||||
public EnvelopeMailService(IEmailOutRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper, IEmailTemplateService tempService, IEnvelopeReceiverService envelopeReceiverService, IOptions<DispatcherConfig> dispatcherConfigOptions, IConfigService configService) : base(repository, localizer, mapper)
|
||||
{
|
||||
_tempService = tempService;
|
||||
_cache = cache;
|
||||
_envRcvService = envelopeReceiverService;
|
||||
_dConfig = dispatcherConfigOptions.Value;
|
||||
_configService = configService;
|
||||
}
|
||||
|
||||
public Task<DataResult<int>> SendAccessCodeAsync(EnvelopeReceiverDto envelopeReceiverDto)
|
||||
//TODO: create ioptions and implement TemplatePlaceHolderAttribute instead of this method
|
||||
private async Task<Dictionary<string, string>> CreatePlaceholders(string? accessCode = null, EnvelopeReceiverDto? envelopeReceiverDto = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Dictionary<string, string> placeholders = new() {
|
||||
{ "[NAME_PORTAL]", "signFlow" },
|
||||
{ "[SIGNATURE_TYPE]" , "signieren"},
|
||||
{ "[REASON]", string.Empty } };
|
||||
|
||||
if (accessCode is not null)
|
||||
placeholders["[DOCUMENT_ACCESS_CODE]"] = accessCode;
|
||||
|
||||
if(envelopeReceiverDto is not null && envelopeReceiverDto.Envelope is not null && envelopeReceiverDto.Receiver is not null)
|
||||
{
|
||||
var erId = (envelopeReceiverDto.Envelope.Uuid, envelopeReceiverDto.Receiver.Signature).EncodeEnvelopeReceiverId();
|
||||
var sigHost = await _configService.ReadDefaultSignatureHost();
|
||||
var linkToDoc = $"{sigHost}/envelope/{erId}";
|
||||
placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc;
|
||||
placeholders["[LINK_TO_DOCUMENT_TEXT]"] = linkToDoc[..Math.Min(40, linkToDoc.Length)];
|
||||
}
|
||||
|
||||
public Task<DataResult<int>> SendAsync(EnvelopeReceiverDto envelopeReceiverDto, Constants.EmailTemplateType tempType)
|
||||
return placeholders;
|
||||
}
|
||||
|
||||
public async Task<DataResult<int>> SendAccessCodeAsync(EnvelopeReceiverDto dto) => await SendAsync(dto: dto, tempType: Constants.EmailTemplateType.DocumentAccessCodeReceived);
|
||||
|
||||
public async Task<DataResult<int>> SendAsync(EnvelopeReceiverDto dto, Constants.EmailTemplateType tempType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var tempSerResult = await _tempService.ReadByNameAsync(tempType);
|
||||
if (tempSerResult.IsFailed)
|
||||
return tempSerResult.ToFail<int>().Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"The email cannot send because '{tempType}' template cannot found.");
|
||||
var temp = tempSerResult.Data;
|
||||
|
||||
var mail = new EmailOutCreateDto()
|
||||
{
|
||||
EmailAddress = dto.Receiver!.EmailAddress,
|
||||
EmailSubj = temp.Subject,
|
||||
EmailBody = temp.Body,
|
||||
//email_type = envelope_status,
|
||||
//message = envelope_message,
|
||||
ReferenceId = dto.EnvelopeId, //REFERENCE_ID = ENVELOPE_ID
|
||||
ReferenceString = dto!.Envelope!.Uuid, //REFERENCE_STRING = ENVELOPE_UUID
|
||||
//receiver_name = receiver.name,
|
||||
//receiver_access_code = receiver.access_code,
|
||||
//sender_adress = envelope.user.email,
|
||||
//sender_name = envelope.user.full_name,
|
||||
//envelope_title = envelope.title,
|
||||
ReminderTypeId = _dConfig.ReminderTypeId,
|
||||
SendingProfile = _dConfig.SendingProfile,
|
||||
EntityId = null,
|
||||
WfId = (int) EnvelopeStatus.MessageAccessCodeSent,
|
||||
WfReference = null,
|
||||
AddedWho = _dConfig.AddedWho,
|
||||
EmailAttmt1 = _dConfig.EmailAttmt1
|
||||
};
|
||||
|
||||
//get acccess code
|
||||
var acResult = await _envRcvService.ReadAccessCodeByIdAsync(envelopeId: dto.EnvelopeId, receiverId: dto.ReceiverId);
|
||||
if (acResult.IsFailed)
|
||||
return acResult.ToFail<int>().Notice(LogLevel.Error, "Therefore, access code cannot be sent");
|
||||
var accessCode = acResult.Data;
|
||||
|
||||
var placeholders = await CreatePlaceholders(accessCode: accessCode, envelopeReceiverDto: dto);
|
||||
|
||||
return await CreateWithTemplateAsync(createDto: mail,placeholders: placeholders,
|
||||
dto, dto.Envelope.User!, dto.Envelope);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -104,5 +104,13 @@ namespace EnvelopeGenerator.Application.Services
|
||||
int count = await _repository.CountAsync(uuid:uuid, signature:signature);
|
||||
return Result.Success(count > 0);
|
||||
}
|
||||
|
||||
public async Task<DataResult<string>> ReadAccessCodeByIdAsync(int envelopeId, int receiverId)
|
||||
{
|
||||
var code = await _repository.ReadAccessCodeByIdAsync(envelopeId: envelopeId, receiverId: receiverId);
|
||||
return code is null ?
|
||||
Result.Fail<string>().Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"Access code is null. Envelope ID is {envelopeId} and receiver ID {receiverId}")
|
||||
: Result.Success(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
||||
using EnvelopeGenerator.Application.Resources;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Services
|
||||
{
|
||||
|
||||
@ -14,5 +14,9 @@ namespace EnvelopeGenerator.Infrastructure.Contracts
|
||||
Task<string?> ReadAccessCodeAsync(string uuid, string signature);
|
||||
|
||||
Task<int> CountAsync(string uuid, string signature);
|
||||
|
||||
Task<EnvelopeReceiver?> ReadByIdAsync(int envelopeId, int receiverId);
|
||||
|
||||
Task<string?> ReadAccessCodeByIdAsync(int envelopeId, int receiverId);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using DigitalData.EmailProfilerDispatcher.Domain.Entities;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DigitalData.UserManager.Infrastructure.Repositories
|
||||
@ -26,6 +27,7 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
|
||||
modelBuilder.Entity<EnvelopeType>();
|
||||
modelBuilder.Entity<Receiver>();
|
||||
modelBuilder.Entity<UserReceiver>();
|
||||
modelBuilder.Entity<EmailOut>();
|
||||
|
||||
// Configure the one-to-many relationship of Envelope
|
||||
modelBuilder.Entity<Envelope>()
|
||||
|
||||
@ -26,6 +26,9 @@
|
||||
<Reference Include="DigitalData.Core.Infrastructure">
|
||||
<HintPath>..\..\WebCoreModules\DigitalData.Core.Infrastructure\bin\Debug\net7.0\DigitalData.Core.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DigitalData.EmailProfilerDispatcher.Domain">
|
||||
<HintPath>..\..\EmailProfilerDispatcher\DigitalData.EmailProfilerDispatcher.Application\bin\Debug\net7.0\DigitalData.EmailProfilerDispatcher.Domain.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DigitalData.UserManager.Domain">
|
||||
<HintPath>..\..\WebUserManager\DigitalData.UserManager.Domain\bin\Debug\net7.0\DigitalData.UserManager.Domain.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
@ -49,5 +49,17 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
public async Task<int> CountAsync(string uuid, string signature) => await ReadWhere(uuid: uuid, signature: signature).CountAsync();
|
||||
|
||||
public IQueryable<EnvelopeReceiver> ReadById(int envelopeId, int receiverId) => _dbSet
|
||||
.Where(er => er.EnvelopeId == envelopeId && er.ReceiverId == receiverId);
|
||||
|
||||
public async Task<EnvelopeReceiver?> ReadByIdAsync(int envelopeId, int receiverId)
|
||||
=> await ReadById(envelopeId: envelopeId, receiverId: receiverId)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
public async Task<string?> ReadAccessCodeByIdAsync(int envelopeId, int receiverId)
|
||||
=> await ReadById(envelopeId: envelopeId, receiverId: receiverId)
|
||||
.Select(er => er.AccessCode)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
}
|
||||
@ -42,6 +42,13 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
Body = "Wenn Sie diese URL in Ihrer E-Mail erhalten haben, wenden Sie sich bitte an das IT-Team."
|
||||
});
|
||||
|
||||
public static ViewResult ViewAccessCodeNotSent(this Controller controller) => controller.ViewError(new()
|
||||
{
|
||||
Title = "500",
|
||||
Subtitle = "Der Zugangscode konnte nicht gesendet werden",
|
||||
Body = "Bitte kontaktieren Sie das IT-Team."
|
||||
});
|
||||
|
||||
public static ViewResult ViewInnerServiceError(this Controller controller) => controller.ViewError(new()
|
||||
{
|
||||
Title = "500",
|
||||
|
||||
@ -27,8 +27,8 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly UrlEncoder _urlEncoder;
|
||||
private readonly Cultures _cultures;
|
||||
|
||||
public HomeController(DatabaseService databaseService, EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IEnvelopeReceiverService envelopeReceiverService, IEnvelopeHistoryService historyService, IStringLocalizer<Resource> localizer, IConfiguration configuration, UrlEncoder urlEncoder, Cultures cultures) : base(databaseService, logger)
|
||||
private readonly IEnvelopeMailService _mailService;
|
||||
public HomeController(DatabaseService databaseService, EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IEnvelopeReceiverService envelopeReceiverService, IEnvelopeHistoryService historyService, IStringLocalizer<Resource> localizer, IConfiguration configuration, UrlEncoder urlEncoder, Cultures cultures, IEnvelopeMailService envelopeMailService) : base(databaseService, logger)
|
||||
{
|
||||
this.envelopeOldService = envelopeOldService;
|
||||
_envRcvService = envelopeReceiverService;
|
||||
@ -37,6 +37,8 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
_configuration = configuration;
|
||||
_urlEncoder = urlEncoder;
|
||||
_cultures = cultures;
|
||||
_mailService = envelopeMailService;
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}")]
|
||||
@ -57,7 +59,12 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
{
|
||||
await _historyService.RecordAsync(er.EnvelopeId, er.Receiver.EmailAddress, Constants.EnvelopeStatus.AccessCodeRequested);
|
||||
|
||||
bool result = database.Services.emailService.SendDocumentAccessCodeReceivedEmail(response.Envelope, response.Receiver);
|
||||
var mailRes = await _mailService.SendAccessCodeAsync(envelopeReceiverDto: er);
|
||||
if (mailRes.IsFailed)
|
||||
{
|
||||
_logger.LogNotice(mailRes);
|
||||
return this.ViewAccessCodeNotSent();
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect($"{envelopeReceiverId}/Locked");
|
||||
|
||||
@ -42,5 +42,16 @@ namespace EnvelopeGenerator.Web.Controllers.Test
|
||||
}
|
||||
return NotFound(result);
|
||||
}
|
||||
|
||||
[HttpGet("decode")]
|
||||
public IActionResult DecodeEnvelopeReceiverId(string envelopeReceiverId, int type = 0)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
1 => Ok(envelopeReceiverId.GetEnvelopeUuid()),
|
||||
2 => Ok(envelopeReceiverId.GetReceiverSignature()),
|
||||
_ => Ok(envelopeReceiverId.DecodeEnvelopeReceiverId()),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
using DigitalData.Core.DTO;
|
||||
using EnvelopeGenerator.Application.Contracts;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Net;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers.Test
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/test/[controller]")]
|
||||
public class TestEnvelopeMailController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<TestEnvelopeMailController> _logger;
|
||||
private readonly IEnvelopeMailService _mailService;
|
||||
private readonly IEnvelopeReceiverService _envRcvService;
|
||||
|
||||
public TestEnvelopeMailController(ILogger<TestEnvelopeMailController> logger, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverService envelopeReceiverService)
|
||||
{
|
||||
_logger = logger;
|
||||
_mailService = envelopeMailService;
|
||||
_envRcvService = envelopeReceiverService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> SendAccessCode([FromQuery] string envelopeReceiverId = "ZDlmYjZmYjctNTBhNS00NTcyLWI5NTQtYzJjYmY4N2UwZmZhOjowRDI3MkEwNTdGMjRBMkY3MEZDMzM3QkRBQzA1MjYxRjU3NTI2QzgxQ0IyMUE5NzE1RjA1NTJFQzdFNjIwNjY1")
|
||||
{
|
||||
return await _envRcvService.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelopeReceiverId).ThenAsync<EnvelopeReceiverDto, IActionResult>(
|
||||
SuccessAsync: async er =>
|
||||
{
|
||||
|
||||
|
||||
var mailRes = await _mailService.SendAccessCodeAsync(envelopeReceiverDto: er);
|
||||
if (mailRes.IsFailed)
|
||||
{
|
||||
_logger.LogNotice(mailRes);
|
||||
return StatusCode(500, mailRes.Notices);
|
||||
}
|
||||
|
||||
return Ok();
|
||||
},
|
||||
Fail: (messages, notices) =>
|
||||
{
|
||||
_logger.LogNotice(notices);
|
||||
return StatusCode(500, notices);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,6 +178,8 @@ try
|
||||
|
||||
builder.Services.AddMemoryCache();
|
||||
|
||||
builder.ConfigureBySection<DispatcherConfig>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
||||
@ -96,23 +96,15 @@ namespace EnvelopeGenerator.Web.Services
|
||||
}).ToList();
|
||||
|
||||
//if documenet_path_dmz is existing in config, replace the path with it
|
||||
var configResult = await _configService.ReadDefaultAsync();
|
||||
if (configResult.IsSuccess && configResult.Data is not null)
|
||||
{
|
||||
var config = configResult.Data;
|
||||
var config = await _configService.ReadDefaultAsync();
|
||||
|
||||
if(config.DocumentPathDmz is not null && config.DocumentPathDmz != string.Empty)
|
||||
foreach(var doc in envelope.Documents)
|
||||
if (config.DocumentPathDmz is not null && config.DocumentPathDmz != string.Empty)
|
||||
foreach (var doc in envelope.Documents)
|
||||
{
|
||||
doc.Filepath = doc.Filepath.Replace(config.DocumentPath , config.DocumentPathDmz);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogError(string.Join(". ", configResult.Messages));
|
||||
throw new InvalidOperationException(String.Join(". ", configResult.Messages));
|
||||
doc.Filepath = doc.Filepath.Replace(config.DocumentPath, config.DocumentPathDmz);
|
||||
}
|
||||
|
||||
|
||||
return new()
|
||||
{
|
||||
Receiver = receiver,
|
||||
|
||||
@ -113,5 +113,11 @@
|
||||
"FIClass": "fi-us"
|
||||
}
|
||||
],
|
||||
"DisableMultiLanguage": false
|
||||
"DisableMultiLanguage": false,
|
||||
"DispatcherConfig": {
|
||||
"SendingProfile": 1,
|
||||
"AddedWho": "DDEnvelopGenerator",
|
||||
"ReminderTypeId": 202377,
|
||||
"EmailAttmt1" : ""
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user