Compare commits

...

11 Commits

Author SHA1 Message Date
425d21084b Refactor TestSanitizeController for improved clarity
- Updated namespace for consistency.
- Changed constructor and method parameters to non-nullable strings.
- Enhanced method signatures for `Sanitize` and `Encoder`.
- Improved overall class structure and formatting for better readability.
2025-06-30 14:13:36 +02:00
6aeba4d1e7 Deprecate methods and streamline controller code
Added [Obsolete("Use MediatR")] attribute to several methods
across `DocumentController`, `HomeController`,
`TestConfigController`, `TestDocumentReceiverElementController`,
and `TestEnvelopeController` to indicate they should no longer
be used.

Refactored constructors in `TestConfigController` and
`TestEnvelopeController` to remove unnecessary empty blocks.

Improved formatting and structure of the `GetAll` method in
`TestEnvelopeController` for better clarity while maintaining
functionality.

Updated `Program.cs` to suppress warnings about obsolete
types/members during service registrations, indicating a
transition to newer implementations.
2025-06-30 14:11:56 +02:00
6930d7a431 Mark CommandManager as obsolete; add warning suppression
Updated `CommandManager` to mark the `_envelopeReceiverService` field and its constructor as obsolete, recommending the use of `MediatR`. Added a new obsolete property `EnvelopeReceiver` for accessing the service. In `Program.cs`, added warning suppression for the obsolete member during command manager runner registration.
2025-06-30 14:07:39 +02:00
c453a1650a Suppress obsolete warnings and update auth options
Added pragma directives to suppress warnings for obsolete
types when configuring user manager and envelope generator
services. Also set a logout path and enabled sliding
expiration for authentication options.
2025-06-30 14:06:26 +02:00
b9f5ae826a Deprecate user service interfaces in controllers
Added [Obsolete] attributes to _userService in AuthController,
_repository in EmailTemplateController, and _userRepository
in EnvelopeExecutor. These changes guide developers to
transition to using MediatR and IRepository.
2025-06-30 14:05:36 +02:00
532dc41004 Remove DocumentPath, add SignatureHost to Config
Removed the `DocumentPath` property from the `Config` class. Added a new required property `SignatureHost` of type `string`, mapped to the database column `SIGNATURE_HOST` (nvarchar(128)). Other properties remain unchanged.
2025-06-30 14:01:30 +02:00
13899cf70a Refactor ConfigDto class and update properties
- Change namespace to `EnvelopeGenerator.Application.DTOs`
- Remove `DocumentPath` property
- Update `SignatureHost` to be a required string
2025-06-30 13:59:18 +02:00
9756303d6e Refactor repositories and enhance documentation
- Mark `IEmailTemplateRepository` and `_repository` in `ReadEmailTemplateQueryHandler` as obsolete, suggesting the use of `IRepository`.
- Update `ResetEmailTemplateCommand` with additional documentation and examples for `Type`.
- Change return type of `CreateEnvelopeReceiverCommand` to `IRequest<CreateEnvelopeReceiverResponse>`.
- Improve caching methods in `CacheExtensions.cs` for better functionality and clarity.
- Add XML documentation to the `Ok` method in `MappingExtensions`.
- Make `UserReference` property required in `ReadHistoryResponse`.
2025-06-30 13:56:49 +02:00
1c51fafb69 Remove UserReceiver functionality and related components
This commit marks the `IUserReceiverRepository` and `IUserReceiverService` as obsolete and removes their implementations. The `UserReceiverDto`, `UserReceiver`, `UserReceiverService`, and `UserReceiverRepository` classes have been deleted, along with their mappings in the `MappingProfile`. Additionally, the `TestUserReceiverController` has been removed, reflecting the complete removal of user receiver functionality from the codebase.
2025-06-30 13:44:43 +02:00
94d43bce24 Deprecate repositories and update service interfaces
- Marked `IEnvelopeReceiverRepository` and several repository classes as obsolete, recommending the use of `IRepository`.
- Corrected `using` directive in `IReceiverService.cs`.
- Removed `UpdateAsync` method from `IReceiverService`.
- Enhanced `ISmsSender` interface with new properties and methods.
- Updated `ReceiverCreateDto`, `ReceiverReadDto`, and `UserReceiverDto` to enforce non-nullable properties.
- Refactored `TestReceiverController` to suggest using `MediatR`.
2025-06-30 13:37:54 +02:00
e3cb2ec219 Add new library references and update packages
- Added references to `DigitalData.UserManager.Domain` v3.2.2.0, `System.ComponentModel.Annotations` v4.2.1.0, and `System.Drawing.Common` v4.0.0.2 in `EnvelopeGenerator.Form.vbproj`.
- Updated `packages.config` to include `System.ComponentModel.Annotations` v4.7.0, `System.Drawing.Common` v4.7.3, and `UserManager.Domain` v3.2.2.
2025-06-30 11:27:26 +02:00
49 changed files with 450 additions and 427 deletions

View File

@@ -7,7 +7,7 @@ namespace EnvelopeGenerator.Application.Contracts.Repositories;
/// <summary>
///
/// </summary>
[Obsolete("Use Read-method returning IReadQuery<TEntity> instead.")]
[Obsolete("Use IRepository")]
public interface IEmailTemplateRepository : ICRUDRepository<EmailTemplate, int>
{
/// <summary>

View File

@@ -6,6 +6,7 @@ namespace EnvelopeGenerator.Application.Contracts.Repositories;
/// <summary>
///
/// </summary>
[Obsolete("Use IRepository")]
public interface IEnvelopeReceiverRepository : ICRUDRepository<EnvelopeReceiver, (int Envelope, int Receiver)>
{
/// <summary>

View File

@@ -1,12 +0,0 @@
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Application.Contracts.Repositories;
/// <summary>
///
/// </summary>
[Obsolete("Use IRepository")]
public interface IUserReceiverRepository : ICRUDRepository<UserReceiver, int>
{
}

View File

@@ -1,5 +1,4 @@
using DigitalData.Core.Abstractions;
using DigitalData.Core.Abstraction.Application;
using DigitalData.Core.Abstraction.Application;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.DTOs.Receiver;
using EnvelopeGenerator.Domain.Entities;
@@ -27,12 +26,4 @@ public interface IReceiverService : ICRUDService<ReceiverCreateDto, ReceiverRead
/// <param name="signature"></param>
/// <returns></returns>
Task<Result> DeleteByAsync(string? emailAddress = null, string? signature = null);
/// <summary>
///
/// </summary>
/// <typeparam name="TUpdateDto"></typeparam>
/// <param name="updateDto"></param>
/// <returns></returns>
Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto);
}

View File

@@ -3,9 +3,21 @@
namespace EnvelopeGenerator.Application.Contracts.Services;
//TODO: move to DigitalData.Core
/// <summary>
///
/// </summary>
public interface ISmsSender
{
/// <summary>
///
/// </summary>
string ServiceProvider { get; }
/// <summary>
///
/// </summary>
/// <param name="recipient"></param>
/// <param name="message"></param>
/// <returns></returns>
Task<SmsResponse> SendSmsAsync(string recipient, string message);
}

View File

@@ -1,13 +0,0 @@
using DigitalData.Core.Abstraction.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Application.Contracts.Services;
/// <summary>
///
/// </summary>
[Obsolete("Use MediatR")]
public interface IUserReceiverService : IBasicCRUDService<UserReceiverDto, UserReceiver, int>
{
}

View File

@@ -8,11 +8,6 @@ namespace EnvelopeGenerator.Application.DTOs;
[ApiExplorerSettings(IgnoreApi = true)]
public class ConfigDto
{
/// <summary>
/// Gets or sets the path to the document.
/// </summary>
public string? DocumentPath { get; set; }
/// <summary>
/// Gets or sets the sending profile identifier.
/// </summary>
@@ -21,7 +16,7 @@ public class ConfigDto
/// <summary>
/// Gets or sets the signature host URL or name.
/// </summary>
public string? SignatureHost { get; set; }
public required string SignatureHost { get; set; }
/// <summary>
/// Gets or sets the name of the external program.

View File

@@ -37,7 +37,6 @@ public class MappingProfile : Profile
CreateMap<Domain.Entities.Receiver, ReceiverReadDto>();
CreateMap<Domain.Entities.Receiver, ReceiverCreateDto>();
CreateMap<Domain.Entities.Receiver, ReceiverUpdateDto>();
CreateMap<UserReceiver, UserReceiverDto>();
CreateMap<Domain.Entities.EnvelopeReceiverReadOnly, EnvelopeReceiverReadOnlyDto>();
// DTO to Entity mappings
@@ -55,7 +54,6 @@ public class MappingProfile : Profile
CreateMap<ReceiverReadDto, Domain.Entities.Receiver>().ForMember(rcv => rcv.EnvelopeReceivers, rcvReadDto => rcvReadDto.Ignore());
CreateMap<ReceiverCreateDto, Domain.Entities.Receiver>();
CreateMap<ReceiverUpdateDto, Domain.Entities.Receiver>();
CreateMap<UserReceiverDto, UserReceiver>();
CreateMap<EnvelopeReceiverBase, EnvelopeReceiverBasicDto>();
CreateMap<EnvelopeReceiverReadOnlyCreateDto, Domain.Entities.EnvelopeReceiverReadOnly>();
CreateMap<EnvelopeReceiverReadOnlyUpdateDto, Domain.Entities.EnvelopeReceiverReadOnly>();

View File

@@ -18,7 +18,7 @@ public record ReceiverCreateDto
{
_sha256HexOfMail = new(() =>
{
var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress.ToUpper());
var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress!.ToUpper());
var hash_arr = SHA256.HashData(bytes_arr);
var hexa_str = BitConverter.ToString(hash_arr);
return hexa_str.Replace("-", string.Empty);
@@ -37,7 +37,7 @@ public record ReceiverCreateDto
public string? TotpSecretkey { get; init; }
/// <summary>
/// var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress.ToUpper());<br>
/// var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress.ToUpper());<br/>
/// var hash_arr = SHA256.HashData(bytes_arr);
/// var hexa_str = BitConverter.ToString(hash_arr);
/// return hexa_str.Replace("-", string.Empty);

View File

@@ -4,26 +4,57 @@ using System.Text.Json.Serialization;
namespace EnvelopeGenerator.Application.DTOs.Receiver;
/// <summary>
///
/// </summary>
[ApiExplorerSettings(IgnoreApi = true)]
public class ReceiverReadDto
{
/// <summary>
///
/// </summary>
public int Id { get; set; }
public string EmailAddress { get; set; }
/// <summary>
///
/// </summary>
public required string EmailAddress { get; set; }
public string Signature { get; set; }
/// <summary>
///
/// </summary>
public required string Signature { get; set; }
/// <summary>
///
/// </summary>
public DateTime AddedWhen { get; set; }
/// <summary>
///
/// </summary>
[JsonIgnore]
public IEnumerable<EnvelopeReceiverBasicDto>? EnvelopeReceivers { get; set; }
/// <summary>
///
/// </summary>
public string? LastUsedName => EnvelopeReceivers?.LastOrDefault()?.Name;
/// <summary>
///
/// </summary>
public string? TotpSecretkey { get; set; } = null;
/// <summary>
///
/// </summary>
public DateTime? TfaRegDeadline { get; set; }
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return Id.GetHashCode();

View File

@@ -1,45 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace EnvelopeGenerator.Application.DTOs;
/// <summary>
/// Data Transfer Object representing a user receiver with associated details.
/// </summary>
[ApiExplorerSettings(IgnoreApi = true)]
public class UserReceiverDto
{
/// <summary>
/// Gets or sets the unique identifier of the user receiver.
/// </summary>
public int Id { get; set; }
/// <summary>
/// Gets or sets the identifier of the user associated with the receiver.
/// </summary>
public int UserId { get; set; }
/// <summary>
/// Gets or sets the identifier of the receiver.
/// </summary>
public int ReceiverId { get; set; }
/// <summary>
/// Gets or sets the name of the receiver.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or sets the company name of the receiver.
/// </summary>
public string CompanyName { get; set; }
/// <summary>
/// Gets or sets the job title of the receiver.
/// </summary>
public string JobTitle { get; set; }
/// <summary>
/// Gets or sets the timestamp when the user receiver was added.
/// </summary>
public DateTime AddedWhen { get; set; }
}

View File

@@ -5,20 +5,19 @@ namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Reset;
/// <summary>
/// Ein Befehl zum Zurücksetzen einer E-Mail-Vorlage auf die Standardwerte.
/// Erbt von <see cref="EmailTemplateQuery"/> und ermöglicht die Angabe einer optionalen ID und eines Typs der E-Mail-Vorlage.
/// Erbt von <see cref="EmailTemplateQuery"/> und ermöglicht die Angabe einer optionalen ID und eines Typs der E-Mail-Vorlage.<br/><br/>
/// Beispiele:<br/>
/// 0 - DocumentReceived: Benachrichtigung über den Empfang eines Dokuments.<br/>
/// 1 - DocumentSigned: Benachrichtigung über die Unterzeichnung eines Dokuments.<br/>
/// 2 - DocumentDeleted: Benachrichtigung über das Löschen eines Dokuments.<br/>
/// 3 - DocumentCompleted: Benachrichtigung über den Abschluss eines Dokuments.<br/>
/// 4 - DocumentAccessCodeReceived: Benachrichtigung über den Erhalt eines Zugangscodes.<br/>
/// 5 - DocumentShared: Benachrichtigung über das Teilen eines Dokuments.<br/>
/// 6 - TotpSecret: Benachrichtigung über ein TOTP-Geheimnis.<br/>
/// 7 - DocumentRejected_ADM (Für den Absender): Mail an den Absender, wenn das Dokument abgelehnt wird.<br/>
/// 8 - DocumentRejected_REC (Für den ablehnenden Empfänger): Mail an den ablehnenden Empfänger, wenn das Dokument abgelehnt wird.<br/>
/// 9 - DocumentRejected_REC_2 (Für sonstige Empfänger): Mail an andere Empfänger (Brief), wenn das Dokument abgelehnt wird.<br/>
/// </summary>
/// Beispiele:
/// 0 - DocumentReceived: Benachrichtigung über den Empfang eines Dokuments.
/// 1 - DocumentSigned: Benachrichtigung über die Unterzeichnung eines Dokuments.
/// 2 - DocumentDeleted: Benachrichtigung über das Löschen eines Dokuments.
/// 3 - DocumentCompleted: Benachrichtigung über den Abschluss eines Dokuments.
/// 4 - DocumentAccessCodeReceived: Benachrichtigung über den Erhalt eines Zugangscodes.
/// 5 - DocumentShared: Benachrichtigung über das Teilen eines Dokuments.
/// 6 - TotpSecret: Benachrichtigung über ein TOTP-Geheimnis.
/// 7 - DocumentRejected_ADM (Für den Absender): Mail an den Absender, wenn das Dokument abgelehnt wird.
/// 8 - DocumentRejected_REC (Für den ablehnenden Empfänger): Mail an den ablehnenden Empfänger, wenn das Dokument abgelehnt wird.
/// 9 - DocumentRejected_REC_2 (Für sonstige Empfänger): Mail an andere Empfänger (Brief), wenn das Dokument abgelehnt wird.
/// </param>
public record ResetEmailTemplateCommand : EmailTemplateQuery, IRequest
{
/// <summary>
@@ -34,7 +33,7 @@ public record ResetEmailTemplateCommand : EmailTemplateQuery, IRequest
///
/// </summary>
/// <param name="Id">Die optionale ID der E-Mail-Vorlage, die zurückgesetzt werden soll.</param>
/// <param name="Type">Der Typ der E-Mail-Vorlage, z. B. <see cref="Constants.EmailTemplateType"/> (optional).
/// <param name="Type">Der Typ der E-Mail-Vorlage, z. B. <see cref="Constants.EmailTemplateType"/> (optional).</param>
public ResetEmailTemplateCommand(int? Id = null, Constants.EmailTemplateType? Type = null) : base(Id, Type)
{
}

View File

@@ -12,6 +12,7 @@ public class ReadEmailTemplateQueryHandler : IRequestHandler<ReadEmailTemplateQu
{
private readonly IMapper _mapper;
[Obsolete("Use Read-method returning IReadQuery<TEntity> instead.")]
private readonly IEmailTemplateRepository _repository;
/// <summary>
@@ -21,6 +22,7 @@ public class ReadEmailTemplateQueryHandler : IRequestHandler<ReadEmailTemplateQu
/// <param name="repository">
/// Die AutoMapper-Instanz, die zum Zuordnen von Objekten verwendet wird.
/// </param>
[Obsolete("Use Read-method returning IReadQuery<TEntity> instead.")]
public ReadEmailTemplateQueryHandler(IMapper mapper, IEmailTemplateRepository repository)
{
_mapper = mapper;
@@ -34,6 +36,7 @@ public class ReadEmailTemplateQueryHandler : IRequestHandler<ReadEmailTemplateQu
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
[Obsolete("Use IRepository")]
public async Task<ReadEmailTemplateResponse?> Handle(ReadEmailTemplateQuery request, CancellationToken cancellationToken)
{
var temp = request.Id is int id
@@ -46,4 +49,4 @@ public class ReadEmailTemplateQueryHandler : IRequestHandler<ReadEmailTemplateQu
return res;
}
}
}

View File

@@ -18,4 +18,4 @@ public record CreateEnvelopeReceiverCommand(
[Required] DocumentCreateCommand Document,
[Required] IEnumerable<ReceiverGetOrCreateCommand> Receivers,
bool TFAEnabled = false
) : CreateEnvelopeCommand(Title, Message, TFAEnabled), IRequest<CreateEnvelopeReceiverResponse?>;
) : CreateEnvelopeCommand(Title, Message, TFAEnabled), IRequest<CreateEnvelopeReceiverResponse>;

View File

@@ -64,4 +64,4 @@ public class CreateEnvelopeReceiverCommandHandler : IRequestHandler<CreateEnvelo
res.SentReceiver = _mapper.Map<IEnumerable<ReceiverReadDto>>(sentRecipients);
return res;
}
}
}

View File

@@ -1,131 +1,222 @@
using Microsoft.Extensions.Caching.Distributed;
namespace EnvelopeGenerator.Application.Extensions
namespace EnvelopeGenerator.Application.Extensions;
/// <summary>
///
/// </summary>
public static class CacheExtensions
{
public static class CacheExtensions
/// <summary>
///
/// </summary>
/// <param name="cache"></param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="options"></param>
/// <param name="cToken"></param>
/// <returns></returns>
public static Task SetLongAsync(this IDistributedCache cache, string key, long value, DistributedCacheEntryOptions? options = null, CancellationToken cToken = default)
=> options is null
? cache.SetAsync(key, BitConverter.GetBytes(value), token: cToken)
: cache.SetAsync(key, BitConverter.GetBytes(value), options: options, token: cToken);
/// <summary>
///
/// </summary>
/// <param name="cache"></param>
/// <param name="key"></param>
/// <param name="cToken"></param>
/// <returns></returns>
public static async Task<long?> GetLongAsync(this IDistributedCache cache, string key, CancellationToken cToken = default)
{
public static Task SetLongAsync(this IDistributedCache cache, string key, long value, DistributedCacheEntryOptions? options = null, CancellationToken cToken = default)
=> options is null
? cache.SetAsync(key, BitConverter.GetBytes(value), token: cToken)
: cache.SetAsync(key, BitConverter.GetBytes(value), options: options, token: cToken);
public static async Task<long?> GetLongAsync(this IDistributedCache cache, string key, CancellationToken cToken = default)
{
var value = await cache.GetAsync(key, cToken);
return value is null ? null : BitConverter.ToInt64(value, 0);
}
public static Task SetDateTimeAsync(this IDistributedCache cache, string key, DateTime value, DistributedCacheEntryOptions? options = null, CancellationToken cToken = default)
=> cache.SetLongAsync(key: key, value: value.Ticks, options: options, cToken: cToken);
public static async Task<DateTime?> GetDateTimeAsync(this IDistributedCache cache, string key, CancellationToken cToken = default)
{
var value = await cache.GetAsync(key, cToken);
return value is null ? null : new(BitConverter.ToInt64(value, 0));
}
public static Task SetTimeSpanAsync(this IDistributedCache cache, string key, TimeSpan value, DistributedCacheEntryOptions? options = null, CancellationToken cToken = default)
=> cache.SetLongAsync(key: key, value: value.Ticks, options: options, cToken);
public static async Task<TimeSpan?> GetTimeSpanAsync(this IDistributedCache cache, string key, CancellationToken cToken = default)
{
var value = await cache.GetAsync(key, cToken);
return value is null ? null : new(BitConverter.ToInt64(value, 0));
}
//TODO: use code generator
#region GetOrSetAsync
#region string
public static async Task<string> GetOrSetAsync(this IDistributedCache cache, string key, Func<string> factory, DistributedCacheEntryOptions? options = null, bool cacheInBackground = false, CancellationToken cToken = default)
{
var value = await cache.GetStringAsync(key, cToken);
if (value is null)
{
// create new and save
value = factory();
Task CacheAsync() => options is null
? cache.SetStringAsync(key, value, cToken)
: cache.SetStringAsync(key, value, options, cToken);
if (cacheInBackground)
_ = Task.Run(async () => await CacheAsync(), cToken);
else
await CacheAsync();
}
return value;
}
public static async Task<string> GetOrSetAsync(this IDistributedCache cache, string key, Func<Task<string>> factoryAsync, DistributedCacheEntryOptions? options = null, bool cacheInBackground = false, CancellationToken cToken = default)
{
var value = await cache.GetStringAsync(key, cToken);
if(value is null)
{
// create new and save
value = await factoryAsync();
Task CacheAsync() => options is null
? cache.SetStringAsync(key: key, value: value, token: cToken)
: cache.SetStringAsync(key: key, value: value, options: options, token: cToken);
if (cacheInBackground)
_ = Task.Run(async () => await CacheAsync(), cToken);
else
await CacheAsync();
}
return value;
}
#endregion
#region DateTime
public static async Task<DateTime> GetOrSetAsync(this IDistributedCache cache, string key, Func<DateTime> factory, DistributedCacheEntryOptions? options = null, bool cacheInBackground = false, CancellationToken cToken = default)
{
if (await cache.GetDateTimeAsync(key, cToken) is DateTime dateTimeValue)
return dateTimeValue;
else
{
// create new and save
var newValue = factory();
Task CacheAsync() => options is null
? cache.SetDateTimeAsync(key, newValue, cToken: cToken)
: cache.SetDateTimeAsync(key, newValue, options, cToken);
if (cacheInBackground)
_ = Task.Run(async () => await CacheAsync(), cToken);
else
await CacheAsync();
return newValue;
}
}
public static async Task<DateTime> GetOrSetAsync(this IDistributedCache cache, string key, Func<Task<DateTime>> factory, DistributedCacheEntryOptions? options = null, bool cacheInBackground = false, CancellationToken cToken = default)
{
if (await cache.GetDateTimeAsync(key, cToken) is DateTime dateTimeValue)
return dateTimeValue;
else
{
// create new and save
var newValue = await factory();
Task CacheAsync() => options is null
? cache.SetDateTimeAsync(key, newValue, cToken: cToken)
: cache.SetDateTimeAsync(key, newValue, options, cToken);
if (cacheInBackground)
_ = Task.Run(async () => await CacheAsync(), cToken);
else
await CacheAsync();
return newValue;
}
}
#endregion
#endregion
var value = await cache.GetAsync(key, cToken);
return value is null ? null : BitConverter.ToInt64(value, 0);
}
/// <summary>
///
/// </summary>
/// <param name="cache"></param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="options"></param>
/// <param name="cToken"></param>
/// <returns></returns>
public static Task SetDateTimeAsync(this IDistributedCache cache, string key, DateTime value, DistributedCacheEntryOptions? options = null, CancellationToken cToken = default)
=> cache.SetLongAsync(key: key, value: value.Ticks, options: options, cToken: cToken);
/// <summary>
///
/// </summary>
/// <param name="cache"></param>
/// <param name="key"></param>
/// <param name="cToken"></param>
/// <returns></returns>
public static async Task<DateTime?> GetDateTimeAsync(this IDistributedCache cache, string key, CancellationToken cToken = default)
{
var value = await cache.GetAsync(key, cToken);
return value is null ? null : new(BitConverter.ToInt64(value, 0));
}
/// <summary>
///
/// </summary>
/// <param name="cache"></param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="options"></param>
/// <param name="cToken"></param>
/// <returns></returns>
public static Task SetTimeSpanAsync(this IDistributedCache cache, string key, TimeSpan value, DistributedCacheEntryOptions? options = null, CancellationToken cToken = default)
=> cache.SetLongAsync(key: key, value: value.Ticks, options: options, cToken);
/// <summary>
///
/// </summary>
/// <param name="cache"></param>
/// <param name="key"></param>
/// <param name="cToken"></param>
/// <returns></returns>
public static async Task<TimeSpan?> GetTimeSpanAsync(this IDistributedCache cache, string key, CancellationToken cToken = default)
{
var value = await cache.GetAsync(key, cToken);
return value is null ? null : new(BitConverter.ToInt64(value, 0));
}
//TODO: use code generator
#region GetOrSetAsync
#region string
/// <summary>
///
/// </summary>
/// <param name="cache"></param>
/// <param name="key"></param>
/// <param name="factory"></param>
/// <param name="options"></param>
/// <param name="cacheInBackground"></param>
/// <param name="cToken"></param>
/// <returns></returns>
public static async Task<string> GetOrSetAsync(this IDistributedCache cache, string key, Func<string> factory, DistributedCacheEntryOptions? options = null, bool cacheInBackground = false, CancellationToken cToken = default)
{
var value = await cache.GetStringAsync(key, cToken);
if (value is null)
{
// create new and save
value = factory();
Task CacheAsync() => options is null
? cache.SetStringAsync(key, value, cToken)
: cache.SetStringAsync(key, value, options, cToken);
if (cacheInBackground)
_ = Task.Run(async () => await CacheAsync(), cToken);
else
await CacheAsync();
}
return value;
}
/// <summary>
///
/// </summary>
/// <param name="cache"></param>
/// <param name="key"></param>
/// <param name="factoryAsync"></param>
/// <param name="options"></param>
/// <param name="cacheInBackground"></param>
/// <param name="cToken"></param>
/// <returns></returns>
public static async Task<string> GetOrSetAsync(this IDistributedCache cache, string key, Func<Task<string>> factoryAsync, DistributedCacheEntryOptions? options = null, bool cacheInBackground = false, CancellationToken cToken = default)
{
var value = await cache.GetStringAsync(key, cToken);
if(value is null)
{
// create new and save
value = await factoryAsync();
Task CacheAsync() => options is null
? cache.SetStringAsync(key: key, value: value, token: cToken)
: cache.SetStringAsync(key: key, value: value, options: options, token: cToken);
if (cacheInBackground)
_ = Task.Run(async () => await CacheAsync(), cToken);
else
await CacheAsync();
}
return value;
}
#endregion
#region DateTime
/// <summary>
///
/// </summary>
/// <param name="cache"></param>
/// <param name="key"></param>
/// <param name="factory"></param>
/// <param name="options"></param>
/// <param name="cacheInBackground"></param>
/// <param name="cToken"></param>
/// <returns></returns>
public static async Task<DateTime> GetOrSetAsync(this IDistributedCache cache, string key, Func<DateTime> factory, DistributedCacheEntryOptions? options = null, bool cacheInBackground = false, CancellationToken cToken = default)
{
if (await cache.GetDateTimeAsync(key, cToken) is DateTime dateTimeValue)
return dateTimeValue;
else
{
// create new and save
var newValue = factory();
Task CacheAsync() => options is null
? cache.SetDateTimeAsync(key, newValue, cToken: cToken)
: cache.SetDateTimeAsync(key, newValue, options, cToken);
if (cacheInBackground)
_ = Task.Run(async () => await CacheAsync(), cToken);
else
await CacheAsync();
return newValue;
}
}
/// <summary>
///
/// </summary>
/// <param name="cache"></param>
/// <param name="key"></param>
/// <param name="factory"></param>
/// <param name="options"></param>
/// <param name="cacheInBackground"></param>
/// <param name="cToken"></param>
/// <returns></returns>
public static async Task<DateTime> GetOrSetAsync(this IDistributedCache cache, string key, Func<Task<DateTime>> factory, DistributedCacheEntryOptions? options = null, bool cacheInBackground = false, CancellationToken cToken = default)
{
if (await cache.GetDateTimeAsync(key, cToken) is DateTime dateTimeValue)
return dateTimeValue;
else
{
// create new and save
var newValue = await factory();
Task CacheAsync() => options is null
? cache.SetDateTimeAsync(key, newValue, cToken: cToken)
: cache.SetDateTimeAsync(key, newValue, options, cToken);
if (cacheInBackground)
_ = Task.Run(async () => await CacheAsync(), cToken);
else
await CacheAsync();
return newValue;
}
}
#endregion
#endregion
}

View File

@@ -1,14 +1,27 @@
using EnvelopeGenerator.Application.DTOs.Messaging;
namespace EnvelopeGenerator.Application.Extensions
{
public static class MappingExtensions
{
public static bool Ok(this GtxMessagingResponse gtxMessagingResponse)
=> gtxMessagingResponse.TryGetValue("message-status", out var status)
&& status?.ToString()?.ToLower() == "ok";
namespace EnvelopeGenerator.Application.Extensions;
public static string ToBase64String(this byte[] bytes)
=> Convert.ToBase64String(bytes);
}
/// <summary>
/// Provides extension methods for common mapping and conversion operations.
/// </summary>
public static class MappingExtensions
{
/// <summary>
/// Determines whether the response indicates a successful "OK" message status.
/// </summary>
/// <param name="gtxMessagingResponse">The response object to evaluate.</param>
/// <returns><see langword="true"/> if the response contains a "message-status" key with a value of "ok" (case-insensitive);
/// otherwise, <see langword="false"/>.</returns>
public static bool Ok(this GtxMessagingResponse gtxMessagingResponse)
=> gtxMessagingResponse.TryGetValue("message-status", out var status)
&& status?.ToString()?.ToLower() == "ok";
/// <summary>
/// Converts the specified byte array to its equivalent string representation encoded in base-64.
/// </summary>
/// <param name="bytes">The byte array to encode.</param>
/// <returns>A base-64 encoded string representation of the input byte array.</returns>
public static string ToBase64String(this byte[] bytes)
=> Convert.ToBase64String(bytes);
}

View File

@@ -10,6 +10,7 @@ namespace EnvelopeGenerator.Application.Histories.Queries.Read;
/// </summary>
public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumerable<ReadHistoryResponse>>
{
[Obsolete("Use IRepository")]
private readonly IEnvelopeHistoryRepository _repository;
private readonly IMapper _mapper;
@@ -19,6 +20,7 @@ public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumer
/// </summary>
/// <param name="repository"></param>
/// <param name="mapper"></param>
[Obsolete("Use IRepository")]
public ReadHistoryQueryHandler(IEnvelopeHistoryRepository repository, IMapper mapper)
{
_repository = repository;
@@ -41,4 +43,4 @@ public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumer
return _mapper.Map<IEnumerable<ReadHistoryResponse>>(hists);
}
}
}

View File

@@ -20,7 +20,7 @@ public class ReadHistoryResponse
/// <summary>
/// Gets or sets the reference identifier of the user who performed the action.
/// </summary>
public string UserReference { get; set; }
public required string UserReference { get; set; }
/// <summary>
/// Gets or sets the status code of the envelope.

View File

@@ -1,25 +0,0 @@
using AutoMapper;
using DigitalData.Core.Application;
using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Application.Contracts.Repositories;
namespace EnvelopeGenerator.Application.Services;
/// <summary>
///
/// </summary>
[Obsolete("Use MediatR")]
public class UserReceiverService : BasicCRUDService<IUserReceiverRepository, UserReceiverDto, UserReceiver, int>, IUserReceiverService
{
/// <summary>
///
/// </summary>
/// <param name="repository"></param>
/// <param name="mapper"></param>
public UserReceiverService(IUserReceiverRepository repository, IMapper mapper)
: base(repository, mapper)
{
}
}

View File

@@ -6,14 +6,12 @@ namespace EnvelopeGenerator.Domain.Entities
[Table("TBSIG_CONFIG", Schema = "dbo")]
public class Config
{
[Column("DOCUMENT_PATH", TypeName = "nvarchar(256)")]
public string DocumentPath { get; set; }
[Column("SENDING_PROFILE", TypeName = "int")]
[Required]
public int SendingProfile { get; set; }
[Column("SIGNATURE_HOST", TypeName = "nvarchar(128)")]
[Required]
public string SignatureHost { get; set; }
[Column("EXTERNAL_PROGRAM_NAME", TypeName = "nvarchar(30)")]

View File

@@ -1,39 +0,0 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;
#endif
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_USER_RECEIVER", Schema = "dbo")]
public class UserReceiver
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Id { get; set; }
[Required]
[Column("USER_ID")]
public int UserId { get; set; }
[Required]
[Column("RECEIVER_ID")]
public int ReceiverId { get; set; }
[Required]
[Column("NAME", TypeName = "nvarchar(128)")]
public string Name { get; set; }
[Column("COMPANY_NAME", TypeName = "nvarchar(128)")]
public string CompanyName { get; set; }
[Column("JOB_TITLE", TypeName = "nvarchar(128)")]
public string JobTitle { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
}
}

View File

@@ -101,6 +101,9 @@
<Reference Include="DigitalData.Modules.Messaging, Version=1.9.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Modules.Messaging.1.9.8\lib\net462\DigitalData.Modules.Messaging.dll</HintPath>
</Reference>
<Reference Include="DigitalData.UserManager.Domain, Version=3.2.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\UserManager.Domain.3.2.2\lib\net462\DigitalData.UserManager.Domain.dll</HintPath>
</Reference>
<Reference Include="DocumentFormat.OpenXml, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>..\packages\DocumentFormat.OpenXml.3.2.0\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
</Reference>
@@ -238,6 +241,9 @@
<Reference Include="System.Collections.Immutable, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.9.0.0\lib\net462\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.ComponentModel.Annotations.4.7.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
@@ -245,6 +251,9 @@
<Reference Include="System.Data.Odbc, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.Odbc.6.0.1\lib\net461\System.Data.Odbc.dll</HintPath>
</Reference>
<Reference Include="System.Drawing.Common, Version=4.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Drawing.Common.4.7.3\lib\net461\System.Drawing.Common.dll</HintPath>
</Reference>
<Reference Include="System.Formats.Asn1, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Formats.Asn1.9.0.0\lib\net462\System.Formats.Asn1.dll</HintPath>
</Reference>

View File

@@ -35,7 +35,9 @@
<package id="System.Buffers" version="4.6.0" targetFramework="net462" />
<package id="System.CodeDom" version="9.0.0" targetFramework="net462" />
<package id="System.Collections.Immutable" version="9.0.0" targetFramework="net462" />
<package id="System.ComponentModel.Annotations" version="4.7.0" targetFramework="net462" />
<package id="System.Data.Odbc" version="6.0.1" targetFramework="net462" />
<package id="System.Drawing.Common" version="4.7.3" targetFramework="net462" />
<package id="System.Formats.Asn1" version="9.0.0" targetFramework="net462" />
<package id="System.IO.Packaging" version="9.0.0" targetFramework="net462" />
<package id="System.IO.Pipelines" version="9.0.0" targetFramework="net462" />
@@ -48,4 +50,5 @@
<package id="System.Text.Json" version="9.0.0" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
<package id="UserManager.Domain" version="3.2.2" targetFramework="net462" />
</packages>

View File

@@ -16,6 +16,7 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers;
public partial class AuthController : ControllerBase
{
private readonly ILogger<AuthController> _logger;
[Obsolete("Use MediatR")]
private readonly IUserService _userService;
private readonly IDirectorySearchService _dirSearchService;
@@ -25,6 +26,7 @@ public partial class AuthController : ControllerBase
/// <param name="logger">The logger instance.</param>
/// <param name="userService">The user service instance.</param>
/// <param name="dirSearchService">The directory search service instance.</param>
[Obsolete("Use MediatR")]
public AuthController(ILogger<AuthController> logger, IUserService userService, IDirectorySearchService dirSearchService)
{
_logger = logger;

View File

@@ -27,6 +27,7 @@ public class EmailTemplateController : ControllerBase
private readonly IMapper _mapper;
[Obsolete("Use IRepository")]
private readonly IEmailTemplateRepository _repository;
private readonly IMediator _mediator;
@@ -38,6 +39,7 @@ public class EmailTemplateController : ControllerBase
/// <param name="repository">
/// Die AutoMapper-Instanz, die zum Zuordnen von Objekten verwendet wird.
/// </param>
[Obsolete("Use IRepository")]
public EmailTemplateController(IMapper mapper, IEmailTemplateRepository repository, ILogger<EmailTemplateController> logger, IMediator mediator)
{
_mapper = mapper;
@@ -115,4 +117,4 @@ public class EmailTemplateController : ControllerBase
return Ok();
}
}
}
}

View File

@@ -167,7 +167,9 @@ try
});
// User manager
#pragma warning disable CS0618 // Type or member is obsolete
builder.Services.AddUserManager<EGDbContext>();
#pragma warning restore CS0618 // Type or member is obsolete
// LDAP
builder.ConfigureBySection<DirectorySearchOptions>();
@@ -177,9 +179,11 @@ try
builder.Services.AddCookieBasedLocalizer();
// Envelope generator serives
#pragma warning disable CS0618 // Type or member is obsolete
builder.Services
.AddEnvelopeGeneratorInfrastructureServices(sqlExecutorConfigureOptions: executor => executor.ConnectionString = connStr)
.AddEnvelopeGeneratorServices(config);
#pragma warning restore CS0618 // Type or member is obsolete
var app = builder.Build();

View File

@@ -12,13 +12,16 @@ namespace EnvelopeGenerator.Infrastructure.Executor;
public class EnvelopeExecutor : SQLExecutor, IEnvelopeExecutor
{
[Obsolete("Use IRepository")]
private readonly IUserRepository _userRepository;
[Obsolete("Use IRepository")]
public EnvelopeExecutor(IServiceProvider provider, IOptions<SQLExecutorParams> sqlExecutorParamsOptions, IUserRepository userRepository) : base(provider, sqlExecutorParamsOptions)
{
_userRepository = userRepository;
}
[Obsolete("Use IRepository")]
public async Task<Envelope> CreateEnvelopeAsync(int userId, string title = "", string message = "", bool tfaEnabled = false, CancellationToken cancellation = default)
{
using var connection = new SqlConnection(Params.ConnectionString);

View File

@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")]
public class ConfigRepository : CRUDRepository<Config, int, EGDbContext>, IConfigRepository
{
public ConfigRepository(EGDbContext dbContext) : base(dbContext, dbContext.Configs)

View File

@@ -4,6 +4,7 @@ using EnvelopeGenerator.Application.Contracts.Repositories;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")]
public class DocumentReceiverElementRepository : CRUDRepository<DocumentReceiverElement, int, EGDbContext>, IDocumentReceiverElementRepository
{
public DocumentReceiverElementRepository(EGDbContext dbContext) : base(dbContext, dbContext.DocumentReceiverElements)

View File

@@ -1,10 +1,10 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Application.Contracts.Repositories;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")]
public class DocumentStatusRepository : CRUDRepository<DocumentStatus, int, EGDbContext>, IDocumentStatusRepository
{
public DocumentStatusRepository(EGDbContext dbContext) : base(dbContext, dbContext.DocumentStatus)

View File

@@ -4,6 +4,7 @@ using EnvelopeGenerator.Application.Contracts.Repositories;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")]
public class EnvelopeCertificateRepository : CRUDRepository<EnvelopeCertificate, int, EGDbContext>, IEnvelopeCertificateRepository
{
public EnvelopeCertificateRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeCertificates)

View File

@@ -4,6 +4,7 @@ using EnvelopeGenerator.Application.Contracts.Repositories;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")]
public class EnvelopeDocumentRepository : CRUDRepository<EnvelopeDocument, int, EGDbContext>, IEnvelopeDocumentRepository
{
public EnvelopeDocumentRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeDocument)

View File

@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")]
public class EnvelopeReceiverReadOnlyRepository : CRUDRepository<EnvelopeReceiverReadOnly, long, EGDbContext>, IEnvelopeReceiverReadOnlyRepository
{
private readonly IEnvelopeRepository _envRepo;

View File

@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")]
public class EnvelopeRepository : CRUDRepository<Envelope, int, EGDbContext>, IEnvelopeRepository
{
public EnvelopeRepository(EGDbContext dbContext) : base(dbContext, dbContext.Envelopes)

View File

@@ -4,6 +4,7 @@ using EnvelopeGenerator.Application.Contracts.Repositories;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")]
public class EnvelopeTypeRepository : CRUDRepository<EnvelopeType, int, EGDbContext>, IEnvelopeTypeRepository
{
public EnvelopeTypeRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeTypes)

View File

@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")]
public class ReceiverRepository : CRUDRepository<Receiver, int, EGDbContext>, IReceiverRepository
{
public ReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.Receivers)

View File

@@ -1,12 +0,0 @@
using DigitalData.Core.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Application.Contracts.Repositories;
namespace EnvelopeGenerator.Infrastructure.Repositories;
public class UserReceiverRepository : CRUDRepository<UserReceiver, int, EGDbContext>, IUserReceiverRepository
{
public UserReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.UserReceivers)
{
}
}

View File

@@ -13,9 +13,11 @@ public class CommandManager
{
WriteIndented = true
};
[Obsolete("Use MediatR")]
private readonly IEnvelopeReceiverService _envelopeReceiverService;
private readonly IMediator _mediator;
[Obsolete("Use MediatR")]
public CommandManager(IEnvelopeReceiverService envelopeReceiverService, IMediator mediator)
{
_envelopeReceiverService = envelopeReceiverService;
@@ -29,6 +31,7 @@ public class CommandManager
Console.WriteLine($"v{Assembly.GetExecutingAssembly().GetName().Version}");
}
[Obsolete("Use MediatR")]
[Subcommand]
public IEnvelopeReceiverService EnvelopeReceiver => _envelopeReceiverService;
@@ -55,4 +58,4 @@ public class CommandManager
File.WriteAllBytes(path, document?.ByteData ?? Array.Empty<byte>());
}
}
}
}

View File

@@ -15,7 +15,9 @@ public class Program
var config = builder.Configuration;
#pragma warning disable CS0618 // Type or member is obsolete
builder.Services.AddCommandManagerRunner(config);
#pragma warning restore CS0618 // Type or member is obsolete
var app = builder.Build();

View File

@@ -26,6 +26,7 @@ public class DocumentController : BaseController
_envDocService = envDocService;
}
[Obsolete("Use MediatR")]
[NonAction]
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
{
@@ -53,6 +54,7 @@ public class DocumentController : BaseController
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("{envelopeKey}")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> Open(string envelopeKey)
{
try

View File

@@ -171,6 +171,7 @@ public class HomeController : ViewControllerBase
}
}
[Obsolete("Use MediatR")]
private async Task<IActionResult> CreateShowEnvelopeView(string envelopeReceiverId, EnvelopeReceiverDto er)
{
try
@@ -259,6 +260,7 @@ public class HomeController : ViewControllerBase
}
}
[Obsolete("Use MediatR")]
[NonAction]
private async Task<IActionResult?> HandleAccessCodeAsync(Auth auth, EnvelopeReceiverSecretDto er_secret, string envelopeReceiverId)
{
@@ -331,6 +333,7 @@ public class HomeController : ViewControllerBase
#endregion
[HttpPost("EnvelopeKey/{envelopeReceiverId}/Locked")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> LogInEnvelope([FromRoute] string envelopeReceiverId, [FromForm] Auth auth)
{
try

View File

@@ -3,13 +3,13 @@ using EnvelopeGenerator.Domain.Entities;
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts.Services;
namespace EnvelopeGenerator.Web.Controllers.Test
{
public class TestConfigController : ReadControllerBase<IConfigService, ConfigDto, Config, int>
{
public TestConfigController(ILogger<TestConfigController> logger, IConfigService service) : base(logger, service)
{
namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")]
public class TestConfigController : ReadControllerBase<IConfigService, ConfigDto, Config, int>
{
public TestConfigController(ILogger<TestConfigController> logger, IConfigService service) : base(logger, service)
{
}
}
}

View File

@@ -4,6 +4,7 @@ using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")]
public class TestDocumentReceiverElementController : TestControllerBase<IDocumentReceiverElementService, DocumentReceiverElementDto, DocumentReceiverElement, int>
{
public TestDocumentReceiverElementController(ILogger<TestDocumentReceiverElementController> logger, IDocumentReceiverElementService service) : base(logger, service)

View File

@@ -4,53 +4,53 @@ using Microsoft.AspNetCore.Mvc;
using EnvelopeGenerator.Extensions;
using EnvelopeGenerator.Application.Contracts.Services;
namespace EnvelopeGenerator.Web.Controllers.Test
namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")]
public class TestEnvelopeController : TestControllerBase<IEnvelopeService, EnvelopeDto, Envelope, int>
{
public class TestEnvelopeController : TestControllerBase<IEnvelopeService, EnvelopeDto, Envelope, int>
public TestEnvelopeController(ILogger<TestEnvelopeController> logger, IEnvelopeService service) : base(logger, service)
{
public TestEnvelopeController(ILogger<TestEnvelopeController> logger, IEnvelopeService service) : base(logger, service)
}
[NonAction]
public override Task<IActionResult> GetAll() => base.GetAll();
[HttpGet]
public async Task<IActionResult> GetAll([FromQuery] string? envelopeKey = default, [FromQuery] bool withDocuments = false, [FromQuery] bool withHistory = false, [FromQuery] bool withDocumentReceiverElement = false, [FromQuery] bool withUser = false, [FromQuery] bool withAll = true)
{
if (envelopeKey is not null)
{
(var uuid, var signature) = envelopeKey.DecodeEnvelopeReceiverId();
if (uuid is null)
return BadRequest("UUID is null");
var envlopeServiceResult = await _service.ReadByUuidAsync(
uuid: uuid,
withDocuments: withDocuments, withHistory: withHistory, withDocumentReceiverElement: withDocumentReceiverElement, withUser: withUser, withAll: withAll);
if (envlopeServiceResult.IsSuccess)
{
return Ok(envlopeServiceResult.Data);
}
return NotFound();
}
[NonAction]
public override Task<IActionResult> GetAll() => base.GetAll();
[HttpGet]
public async Task<IActionResult> GetAll([FromQuery] string? envelopeKey = default, [FromQuery] bool withDocuments = false, [FromQuery] bool withHistory = false, [FromQuery] bool withDocumentReceiverElement = false, [FromQuery] bool withUser = false, [FromQuery] bool withAll = true)
var result = await _service.ReadAllWithAsync(documents: withDocuments, history: withHistory);
if (result.IsSuccess)
{
if(envelopeKey is not null)
{
(var uuid, var signature) = envelopeKey.DecodeEnvelopeReceiverId();
if (uuid is null)
return BadRequest("UUID is null");
var envlopeServiceResult = await _service.ReadByUuidAsync(
uuid: uuid,
withDocuments: withDocuments, withHistory: withHistory, withDocumentReceiverElement:withDocumentReceiverElement, withUser:withUser, withAll:withAll);
if (envlopeServiceResult.IsSuccess)
{
return Ok(envlopeServiceResult.Data);
}
return NotFound();
}
var result = await _service.ReadAllWithAsync(documents: withDocuments, history: withHistory);
if (result.IsSuccess)
{
return Ok(result);
}
return NotFound(result);
return Ok(result);
}
return NotFound(result);
}
[HttpGet("decode")]
public IActionResult DecodeEnvelopeReceiverId(string envelopeReceiverId, int type = 0)
[HttpGet("decode")]
public IActionResult DecodeEnvelopeReceiverId(string envelopeReceiverId, int type = 0)
{
return type switch
{
return type switch
{
1 => Ok(envelopeReceiverId.GetEnvelopeUuid()),
2 => Ok(envelopeReceiverId.GetReceiverSignature()),
_ => Ok(envelopeReceiverId.DecodeEnvelopeReceiverId()),
};
}
}
1 => Ok(envelopeReceiverId.GetEnvelopeUuid()),
2 => Ok(envelopeReceiverId.GetReceiverSignature()),
_ => Ok(envelopeReceiverId.DecodeEnvelopeReceiverId()),
};
}
}

View File

@@ -3,13 +3,13 @@ using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.DTOs.Receiver;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers.Test
{
public class TestReceiverController : CRUDControllerBase<IReceiverService, ReceiverCreateDto, ReceiverReadDto, ReceiverUpdateDto, Receiver, int>
{
public TestReceiverController(ILogger<TestReceiverController> logger, IReceiverService service) : base(logger, service)
{
namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")]
public class TestReceiverController : CRUDControllerBase<IReceiverService, ReceiverCreateDto, ReceiverReadDto, ReceiverUpdateDto, Receiver, int>
{
public TestReceiverController(ILogger<TestReceiverController> logger, IReceiverService service) : base(logger, service)
{
}
}
}

View File

@@ -2,36 +2,34 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Encodings.Web;
namespace EnvelopeGenerator.Web.Controllers.Test
namespace EnvelopeGenerator.Web.Controllers.Test;
[ApiController]
[Route("api/test/[controller]")]
public class TestSanitizeController : ControllerBase
{
[ApiController]
[Route("api/test/[controller]")]
public class TestSanitizeController : ControllerBase
private readonly HtmlEncoder _htmlEncoder;
private readonly HtmlSanitizer _sanitizer;
public TestSanitizeController(HtmlEncoder htmlEncoder, HtmlSanitizer sanitizer)
{
private readonly HtmlEncoder _htmlEncoder;
private readonly HtmlSanitizer _sanitizer;
public TestSanitizeController(HtmlEncoder htmlEncoder, HtmlSanitizer sanitizer)
{
_htmlEncoder = htmlEncoder;
_sanitizer = sanitizer;
}
[HttpGet("sanitize")]
public IActionResult Sanitize([FromQuery] string? input = null) => Ok(new
{
input,
Sanitized = _sanitizer.Sanitize(input),
SanitizedDocument = _sanitizer.SanitizeDocument(input),
SanitizedDom = _sanitizer.SanitizeDom(input)
});
[HttpGet("encode")]
public IActionResult Encoder([FromQuery] string? input = null) => Ok(new
{
input,
Encoded = _htmlEncoder.Encode(input)
});
_htmlEncoder = htmlEncoder;
_sanitizer = sanitizer;
}
}
[HttpGet("sanitize")]
public IActionResult Sanitize([FromQuery] string input) => Ok(new
{
input,
Sanitized = _sanitizer.Sanitize(input),
SanitizedDocument = _sanitizer.SanitizeDocument(input),
SanitizedDom = _sanitizer.SanitizeDom(input)
});
[HttpGet("encode")]
public IActionResult Encoder([FromQuery] string input) => Ok(new
{
input,
Encoded = _htmlEncoder.Encode(input)
});
}

View File

@@ -1,14 +0,0 @@
using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")]
public class TestUserReceiverController : TestControllerBase< IUserReceiverService, UserReceiverDto, UserReceiver, int>
{
public TestUserReceiverController(ILogger<TestUserReceiverController> logger, IUserReceiverService service) : base(logger, service)
{
}
}

View File

@@ -98,6 +98,7 @@ try
});
// Add envelope generator services
#pragma warning disable CS0618 // Type or member is obsolete
builder.Services.AddEnvelopeGeneratorInfrastructureServices((provider, options) =>
{
var logger = provider.GetRequiredService<ILogger<EGDbContext>>();
@@ -106,8 +107,11 @@ try
.EnableSensitiveDataLogging()
.EnableDetailedErrors();
});
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
builder.Services.AddEnvelopeGeneratorServices(config);
#pragma warning restore CS0618 // Type or member is obsolete
builder.Services.Configure<CookiePolicyOptions>(options =>
{
@@ -174,7 +178,10 @@ try
builder.Services.AddSingleton(sp => sp.GetRequiredService<IOptions<Cultures>>().Value);
// Register mail services
#pragma warning disable CS0618 // Type or member is obsolete
builder.Services.AddScoped<IEnvelopeMailService, EnvelopeMailService>();
#pragma warning restore CS0618 // Type or member is obsolete
builder.Services.AddDispatcher<EGDbContext>();
builder.Services.AddMemoryCache();
@@ -183,7 +190,9 @@ try
builder.ConfigureBySection<AnnotationParams>();
#pragma warning disable CS0618 // Type or member is obsolete
builder.Services.AddUserManager<EGDbContext>();
#pragma warning restore CS0618 // Type or member is obsolete
var app = builder.Build();