Compare commits

...

39 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
1c90e693da Deprecate services in favor of MediatR integration
This commit introduces the `[Obsolete("Use MediatR")]` attribute to various service fields and methods across multiple controllers and extension classes, signaling a transition to MediatR for handling requests and commands.

Key changes include:
- Marking `IEnvelopeService`, `IEnvelopeReceiverService`, and `IEnvelopeTypeService` as obsolete in their respective controllers.
- Updating `AddEnvelopeGeneratorInfrastructureServices` to utilize `IRepository`.
- Refactoring `AddCommandManagerRunner` and `CreateHost` methods to indicate obsolescence.
- Replacing `DigitalData.Core.DTO` with `DigitalData.Core.Abstraction.Application.DTO` in using directives.

These changes modernize the codebase and improve command and query handling while cleaning up service dependencies.
2025-06-30 10:05:36 +02:00
e4c6714677 Behebung von Post-Merge-Fehlern.
- CommonServices in den Ordner core verschieben
2025-06-27 14:51:50 +02:00
812b49cfcb Merge master branch 2025-06-27 14:43:47 +02:00
f039437f4c Merge master branch 2025-06-27 14:43:02 +02:00
6f73ba929c Refactor controllers and update envelope status handling
- Updated `TestEnvelopeHistoryController` to use `EnvelopeStatus` for status parameters and marked it as obsolete.
- Modified `TestViewController` with new route attributes, simplified constructor, and improved error handling in HTTP methods.
- Cleaned up `DebugEnvelopes.cshtml` by removing unnecessary using directives and ensuring type safety in envelope grouping.
2025-06-27 13:51:51 +02:00
fcbe956095 Refactor controllers and views for MediatR integration
Updated several C# controllers to use the new
`DigitalData.Core.Abstraction.Application.DTO` namespace
and removed references to `DigitalData.Core.DTO`. Added
`[Obsolete("Use MediatR")]` attributes to indicate a shift
towards MediatR for request handling. Improved error
handling and code organization in key methods. Updated
Razor view files to reflect namespace changes for
consistency across the application.
2025-06-27 13:24:12 +02:00
e628309734 Refactor TestEnvelopeMailController for clarity
Updated using directives, added Obsolete attributes, and improved error handling in SendAccessCode method. Enhanced code clarity while preserving overall structure.
2025-06-27 13:14:14 +02:00
d6cbd0597e Mark TestEnvelopeDocumentController as obsolete
The `TestEnvelopeDocumentController` class has been marked as obsolete, with a recommendation to use MediatR instead. This change reflects a shift in the architecture, promoting the use of MediatR for handling requests and responses in the application.
2025-06-27 13:12:14 +02:00
9d45082bfc Refactor TestEmailTemplateController and update namespaces
- Updated `using` directives to include new namespaces.
- Marked `TestEmailTemplateController` as obsolete with a suggestion to use MediatR.
- Simplified the constructor by removing an empty block.
- Modified `GetAll` method to include `[HttpGet]` and `[Obsolete]` attributes while retaining functionality.
- Added a non-action `GetAll` method that overrides the base implementation.
2025-06-27 13:11:40 +02:00
3304b01d7b Refactor TestDocumentStatusController
Added [Obsolete] attribute to indicate replacement with MediatR. Updated constructor to include logger parameter and removed empty constructor body for clarity.
2025-06-27 13:09:13 +02:00
f5d33846d5 Refactor TestControllerBase and update using directives
Consolidated using directives and removed unnecessary ones.
Added attributes to the namespace declaration for API routing
and deprecation notice. Simplified the class definition by
removing the IUnique<TId> constraint and cleaned up the
constructor by eliminating empty braces.
2025-06-27 12:13:13 +02:00
231140505e Refactor ReadOnlyController to use MediatR
Updated service dependencies to use MediatR, marking
several fields and methods as obsolete. Modified import
statements to include new namespaces and removed old
ones. Adjusted the CreateAsync method to correctly
access IDs and updated the RecordAsync call to use
the new EnvelopeStatus reference. These changes
enhance code maintainability and align with modern
architectural patterns.
2025-06-27 12:08:30 +02:00
62a73e4967 Refactor HomeController for MediatR and domain model
- Added new using directives for domain-driven design.
- Marked several fields and methods as obsolete to transition to MediatR for request handling.
- Updated action methods to use middleware for exception management.
- Changed response type in EnvelopeSigned method for consistency with new domain model.
- Overall improvements for maintainability and adherence to best practices.
2025-06-27 12:06:41 +02:00
dedfb924d8 Refactor EnvelopeController and EnvelopeOldService
Significantly refactored `EnvelopeController.cs` to improve structure, add logging, and enhance error handling in methods. Introduced new private fields and updated constructor parameters, with some marked as obsolete.

Updated `EnvelopeOldService.cs` to add private fields, improve logging, and enhance error handling in key methods. Introduced `ReceiverAlreadySigned` method and marked `GetDocument` as obsolete. Improved overall functionality and maintainability.
2025-06-27 10:59:52 +02:00
08601adc49 Refactor DocumentController for clarity and updates
Updated the DocumentController to use new namespace for constants and added a directive for domain entities. Marked the constructor as obsolete for future MediatR implementation. Refactored Get and Open methods to enhance readability by simplifying error handling. Maintained authorization attributes in their original positions.
2025-06-27 10:26:56 +02:00
2a4255e5a3 Refactor status parameter to use EnvelopeStatus type
Updated IEnvelopeHistoryRepository and IEnvelopeHistoryService
interfaces to replace int? status with Constants.EnvelopeStatus?
status in CountAsync and ReadAsync methods. Adjusted
ReadHistoryQueryHandler and EnvelopeHistoryService methods to
accommodate the new type. Modified EnvelopeHistoryRepository
to accept Constants.EnvelopeStatus? in relevant methods and
marked it as obsolete, suggesting a future refactor.
2025-06-27 09:17:03 +02:00
0800e4d13e refacto(EGUser): rename FormUser 2025-06-26 16:49:56 +02:00
07381e78b4 Refactor name retrieval to use GetFullName method
Updated the `CertificateModel.vb` and `EmailData.vb` files to replace direct access to the `FullName` property with the `GetFullName()` method for retrieving creator, sender, and receiver names. This change enhances flexibility and maintains consistency across the codebase.

Additionally, added a new static `GetFullName` method in the `EGUserExtensions.cs` file to centralize the formatting of user names by concatenating the `Prename` and `Name` properties.
2025-06-26 16:46:55 +02:00
5d29ad889d Refactor EGUser construction and add extension method
Removed constructors from EGUser class and introduced a new
static class EGUserExtensions with a ToEGUser extension method
to facilitate the conversion from User to EGUser. Updated
namespace imports to include DigitalData.UserManager.Domain.Entities.
2025-06-26 16:27:28 +02:00
5ee9efbcd9 Refactor user-related classes and properties
- Added parameterless and user-initializing constructors to `EGUser`.
- Removed unnecessary `using` directives and `#if NETFRAMEWORK` from `EGUser.cs`, `Envelope.cs`, and `EnvelopeHistory.cs`.
- Replaced `EGUser` property with `User` in `Envelope.cs` and `EnvelopeHistory.cs`.
- Retained default value for `CURRENT_WORK_APP` in `Envelope.cs`.
2025-06-26 16:21:22 +02:00
5c48afd8b0 Update package versions and clean up code
- Bump `UserManager` package to version `1.1.1` in
  `EnvelopeGenerator.Application.csproj` and
  `EnvelopeGenerator.Infrastructure.csproj`.
- Add reference to `DigitalData.UserManager.Domain` version
  `3.2.1.0` and `System.ComponentModel.Annotations` version
  `4.7.0` in `EnvelopeGenerator.CommonServices.vbproj`.
- Add reference to `System.Drawing.Common` version `4.7.3`
  in `EnvelopeGenerator.CommonServices.vbproj`.
- Update `UserManager.Domain` package to version `3.2.1`
  in `EnvelopeGenerator.Domain.csproj`.
- Remove unused properties from `EGUser` class in
  `EGUser.cs`.
- Mark `EnvelopeReceiverRepository` as obsolete, suggesting
  to use `Repository` instead.
- Update `packages.config` to include new package versions.
2025-06-26 16:05:16 +02:00
2dbeae24d5 Refactor property name for consistency
Updated the property name `UseridFkIntEcm` to `UserIdFkIntEcm` to adhere to a more consistent naming convention.
2025-06-26 14:27:54 +02:00
ff1e9f27af Replace User class with EGUser across the codebase
This commit introduces the new `EGUser` class, which replaces the existing `User` class in multiple files, including `EnvelopeModel.vb`, `State.vb`, and `UserModel.vb`. The `EGUser` class extends `User`, adding new properties while maintaining existing functionality.

Key changes include:
- Updated property types from `User` to `EGUser` in relevant models.
- Method signatures in `UserModel.vb` modified to accept and return `EGUser`.
- Domain entities in `Envelope.cs` and `EnvelopeHistory.cs` now reference `EGUser`.
- Complete removal of the `User.cs` file.
- Added a new package reference for `UserManager.Domain` in the project file.
- Updated `MYUSER` variable in `ModuleSettings.vb` to use `EGUser`.

These changes enhance the user model to better meet application requirements.
2025-06-26 14:26:21 +02:00
db05183137 Update package versions for UserManager and DigitalData.Core.API
- Updated `UserManager` from `1.0.0` to `1.1.0` in
  `EnvelopeGenerator.Application.csproj` and
  `EnvelopeGenerator.Infrastructure.csproj`.

- Updated `DigitalData.Core.API` from `2.2.0` to `2.2.1` in
  `EnvelopeGenerator.GeneratorAPI.csproj`,
  `EnvelopeGenerator.Tests.Application.csproj`, and
  `EnvelopeGenerator.Web.csproj`.
2025-06-26 14:17:48 +02:00
452077e86a Enhance error reporting for envelope creation failure
Added detailed parameter information to the error message
in `InvalidOperationException` for better debugging context
when envelope creation fails.
2025-06-26 11:56:49 +02:00
f8a7239041 Remove references to EnvelopeGenerator.CommonServices
Refactored multiple files to eliminate dependencies on the
EnvelopeGenerator.CommonServices namespace. This includes
removing using directives in `ReadEmailTemplateQueryHandler.cs`,
`ReadEnvelopeResponse.cs`, and `ReadHistoryResponse.cs`.
Additionally, project references to `EnvelopeGenerator.CommonServices.vbproj`
were removed from both `EnvelopeGenerator.Application.csproj` and
`EnvelopeGenerator.Extensions.csproj`, indicating a shift towards
using only the `EnvelopeGenerator.Domain` project.
2025-06-25 14:24:22 +02:00
Developer01
a1688608ab Exception TFA Null Verweis 2025-06-25 13:49:55 +02:00
Developer01
f1920e16fa MS Job 2025-05-27 14:04:45 +02:00
104 changed files with 1225 additions and 1175 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

@@ -1,4 +1,5 @@
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Domain;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Application.Contracts.Repositories;
@@ -16,7 +17,7 @@ public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, l
/// <param name="userReference"></param>
/// <param name="status"></param>
/// <returns></returns>
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null);
/// <summary>
///
@@ -27,5 +28,5 @@ public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, l
/// <param name="withSender"></param>
/// <param name="withReceiver"></param>
/// <returns></returns>
Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false);
Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false);
}

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

@@ -20,7 +20,7 @@ public interface IEnvelopeHistoryService : ICRUDService<EnvelopeHistoryCreateDto
/// <param name="userReference"></param>
/// <param name="status"></param>
/// <returns></returns>
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null);
/// <summary>
///
@@ -56,7 +56,7 @@ public interface IEnvelopeHistoryService : ICRUDService<EnvelopeHistoryCreateDto
/// <param name="withSender"></param>
/// <param name="withReceiver"></param>
/// <returns></returns>
Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null, bool withSender = false, bool withReceiver = false);
Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false);
/// <summary>
///

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

@@ -1,11 +1,7 @@
using AutoMapper;
using EnvelopeGenerator.Application.Contracts.Repositories;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.CommonServices;
using EnvelopeGenerator.Domain;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
namespace EnvelopeGenerator.Application.EmailTemplates.Queries.Read;
@@ -16,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>
@@ -25,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;
@@ -38,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
@@ -50,4 +49,4 @@ public class ReadEmailTemplateQueryHandler : IRequestHandler<ReadEmailTemplateQu
return res;
}
}
}

View File

@@ -24,11 +24,10 @@
<PackageReference Include="Otp.NET" Version="1.4.0" />
<PackageReference Include="QRCoder" Version="1.6.0" />
<PackageReference Include="QRCoder-ImageSharp" Version="0.10.0" />
<PackageReference Include="UserManager" Version="1.0.0" />
<PackageReference Include="UserManager" Version="1.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EnvelopeGenerator.CommonServices\EnvelopeGenerator.CommonServices.vbproj" />
<ProjectReference Include="..\EnvelopeGenerator.Domain\EnvelopeGenerator.Domain.csproj" />
<ProjectReference Include="..\EnvelopeGenerator.Extensions\EnvelopeGenerator.Extensions.csproj" />
</ItemGroup>

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,5 +1,4 @@
using EnvelopeGenerator.CommonServices;
using EnvelopeGenerator.Domain;
using EnvelopeGenerator.Domain;
namespace EnvelopeGenerator.Application.Envelopes.Queries.Read;

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;
@@ -34,11 +36,11 @@ public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumer
/// <exception cref="NotFoundException"></exception>
public async Task<IEnumerable<ReadHistoryResponse>> Handle(ReadHistoryQuery request, CancellationToken cancellationToken)
{
var hists = await _repository.ReadAsync(request.EnvelopeId, status: request.Status is null ? null : (int) request.Status);
var hists = await _repository.ReadAsync(request.EnvelopeId, status: request.Status is null ? null : request.Status);
if (!hists.Any())
throw new NotFoundException();
return _mapper.Map<IEnumerable<ReadHistoryResponse>>(hists);
}
}
}

View File

@@ -1,5 +1,4 @@
using EnvelopeGenerator.CommonServices;
using EnvelopeGenerator.Domain;
using EnvelopeGenerator.Domain;
namespace EnvelopeGenerator.Application.Histories.Queries.Read;
@@ -21,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

@@ -33,7 +33,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
/// <param name="userReference"></param>
/// <param name="status"></param>
/// <returns></returns>
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null) => await _repository.CountAsync(envelopeId: envelopeId, userReference: userReference, status: status);
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null) => await _repository.CountAsync(envelopeId: envelopeId, userReference: userReference, status: status);
/// <summary>
///
@@ -45,7 +45,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
public async Task<bool> HasStatus(EnvelopeStatus status, int envelopeId, string userReference) => await _repository.CountAsync(
envelopeId: envelopeId,
userReference: userReference,
status: (int) status) > 0;
status: status) > 0;
/// <summary>
///
@@ -56,7 +56,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
public async Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference) => await _repository.CountAsync(
envelopeId: envelopeId,
userReference:userReference,
status: (int) EnvelopeStatus.AccessCodeRequested) > 0;
status: EnvelopeStatus.AccessCodeRequested) > 0;
/// <summary>
///
@@ -67,7 +67,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
public async Task<bool> IsSigned(int envelopeId, string userReference) => await _repository.CountAsync(
envelopeId: envelopeId,
userReference: userReference,
status: (int) EnvelopeStatus.DocumentSigned) > 0;
status: EnvelopeStatus.DocumentSigned) > 0;
/// <summary>
/// Checks if the specified envelope has been rejected.
@@ -81,7 +81,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
return await _repository.CountAsync(
envelopeId: envelopeId,
userReference: userReference,
status: (int)EnvelopeStatus.DocumentRejected) > 0;
status: EnvelopeStatus.DocumentRejected) > 0;
}
/// <summary>
@@ -94,7 +94,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
/// <param name="withSender"></param>
/// <param name="withReceiver"></param>
/// <returns></returns>
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null, bool withSender = false, bool withReceiver = false)
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false)
{
var histDTOs = _mapper.Map<IEnumerable<EnvelopeHistoryDto>>(
await _repository.ReadAsync(
@@ -113,7 +113,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, En
/// <param name="userReference"></param>
/// <returns></returns>
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null) =>
await ReadAsync(envelopeId: envelopeId, userReference: userReference, status: (int)EnvelopeStatus.DocumentRejected, withReceiver:true);
await ReadAsync(envelopeId: envelopeId, userReference: userReference, status: EnvelopeStatus.DocumentRejected, withReceiver:true);
//TODO: use IQueryable in repository to incerease the performance
/// <summary>

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

@@ -84,6 +84,9 @@
<Reference Include="DigitalData.Modules.Logging, Version=2.6.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DigitalData.Modules.Logging.2.6.5\lib\net462\DigitalData.Modules.Logging.dll</HintPath>
</Reference>
<Reference Include="DigitalData.UserManager.Domain, Version=3.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\UserManager.Domain.3.2.1\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>
@@ -207,6 +210,9 @@
<Reference Include="System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.8.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.Data" />
@@ -214,6 +220,9 @@
<HintPath>..\packages\System.Data.Odbc.6.0.1\lib\net461\System.Data.Odbc.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<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.IO.Compression" />
<Reference Include="System.IO.Packaging, Version=8.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Packaging.8.0.1\lib\net462\System.IO.Packaging.dll</HintPath>

View File

@@ -143,7 +143,9 @@ Namespace Jobs
Logger.Debug("Documents merged!")
Dim oOutputDirectoryPath = Path.Combine(Config.ExportPath, ParentFolderUID)
Logger.Debug($"oOutputDirectoryPath is {oOutputDirectoryPath}")
If Not Directory.Exists(oOutputDirectoryPath) Then
Logger.Debug($"Directory not existing. Creating ... ")
Directory.CreateDirectory(oOutputDirectoryPath)
End If
Dim oOutputFilePath = Path.Combine(oOutputDirectoryPath, $"{oEnvelope.Uuid}.pdf")
@@ -172,6 +174,7 @@ Namespace Jobs
Throw New ApplicationException("Envelope could not be finalized")
End If
Catch ex As Exception
Logger.Error(ex)
Logger.Warn(ex, $"Unhandled exception while working envelope [{oId}]")
End Try

View File

@@ -34,7 +34,7 @@ Public Class CertificateModel
oCommand.Parameters.Add("ENVELOPE_UUID", SqlDbType.NVarChar).Value = pEnvelope.Uuid
oCommand.Parameters.Add("ENVELOPE_SUBJECT", SqlDbType.NVarChar).Value = String.Empty
oCommand.Parameters.Add("CREATOR_ID", SqlDbType.Int).Value = pEnvelope.UserId
oCommand.Parameters.Add("CREATOR_NAME", SqlDbType.NVarChar).Value = pEnvelope.User.FullName
oCommand.Parameters.Add("CREATOR_NAME", SqlDbType.NVarChar).Value = pEnvelope.User.GetFullName()
oCommand.Parameters.Add("CREATOR_EMAIL", SqlDbType.NVarChar).Value = pEnvelope.User.Email
oCommand.Parameters.Add("ENVELOPE_STATUS", SqlDbType.Int).Value = pEnvelope.Status

View File

@@ -39,7 +39,7 @@ Public Class EmailData
ReceiverName = pReceiver.Name
ReceiverAccessCode = pReceiver.AccessCode
SenderAdress = pEnvelope.User.Email
SenderName = pEnvelope.User.FullName
SenderName = pEnvelope.User.GetFullName()
EnvelopeTitle = pEnvelope.Title
End Sub
Public Function TextToHtml(input As String) As String
@@ -72,10 +72,10 @@ Public Class EmailData
Message = pEnvelope.Message
ReferenceID = pEnvelope.Id
ReferenceString = pEnvelope.Uuid
ReceiverName = pEnvelope.User.FullName
ReceiverName = pEnvelope.User.GetFullName()
ReceiverAccessCode = String.Empty
SenderAdress = pEnvelope.User.Email
SenderName = pEnvelope.User.FullName
SenderName = pEnvelope.User.GetFullName()
EnvelopeTitle = pEnvelope.Title
End Sub

View File

@@ -37,7 +37,7 @@ Public Class EnvelopeModel
.AddedWhen = pRow.Item("ADDED_WHEN"),
.ChangedWhen = pRow.ItemEx(Of Date)("CHANGED_WHEN", Nothing),
.CertificationType = ObjectEx.ToEnum(Of CertificationType)(pRow.ItemEx("CERTIFICATION_TYPE", CertificationType.AdvancedElectronicSignature.ToString())),
.User = New User(),
.User = New FormUser(),
.ExpiresWhen = pRow.ItemEx(Of Date)("EXPIRES_WHEN", Nothing),
.ExpiresWarningWhen = pRow.ItemEx(Of Date)("EXPIRES_WARNING_WHEN", Nothing),
.ExpiresWhenDays = pRow.ItemEx("EXPIRES_WHEN_DAYS", 0),

View File

@@ -4,7 +4,7 @@ Imports EnvelopeGenerator.Domain.Entities
Public Class State
Public Property UserId As Integer
Public Property User As User
Public Property User As FormUser
Public Property Config As Config
Public Property DbConfig As DbConfig
Public Property LogConfig As LogConfig

View File

@@ -9,8 +9,8 @@ Public Class UserModel
MyBase.New(pState)
End Sub
Private Function ToUser(pRow As DataRow) As User
Dim oUser = New User() With {
Private Function ToUser(pRow As DataRow) As FormUser
Dim oUser = New FormUser() With {
.Id = pRow.ItemEx("GUID", 0),
.Prename = pRow.ItemEx("PRENAME", ""),
.Name = pRow.ItemEx("NAME", ""),
@@ -22,7 +22,7 @@ Public Class UserModel
Return oUser
End Function
Public Function CheckUserLogin(pUser As User) As User
Public Function CheckUserLogin(pUser As FormUser) As FormUser
Try
Dim oSql = $"SELECT * FROM [dbo].[FNDD_LOGIN_USER_MODULE] ('{pUser.Username}', 'SIG_ENV_CR', 1)"
Dim oTable As DataTable = Database.GetDatatable(oSql)
@@ -45,7 +45,7 @@ Public Class UserModel
End Try
End Function
Public Function SelectUser() As User
Public Function SelectUser() As FormUser
Try
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {State.UserId}"
Dim oTable = Database.GetDatatable(oSql)
@@ -58,7 +58,7 @@ Public Class UserModel
End Try
End Function
Public Function SelectUser(pUserID As Integer) As User
Public Function SelectUser(pUserID As Integer) As FormUser
Try
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {pUserID}"
Dim oTable = Database.GetDatatable(oSql)

View File

@@ -30,7 +30,9 @@
<package id="System.Buffers" version="4.6.0" targetFramework="net462" />
<package id="System.CodeDom" version="8.0.0" targetFramework="net462" />
<package id="System.Collections.Immutable" version="8.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.IO.Packaging" version="8.0.1" targetFramework="net462" />
<package id="System.Management" version="8.0.0" targetFramework="net462" />
<package id="System.Memory" version="4.6.0" targetFramework="net462" />
@@ -41,4 +43,5 @@
<package id="System.Text.Json" version="8.0.5" 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.1" targetFramework="net462" />
</packages>

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,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using DigitalData.UserManager.Domain.Entities;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;
@@ -113,7 +114,7 @@ namespace EnvelopeGenerator.Domain.Entities
// TODO: * Check the Form App and remove the default value
[ForeignKey("UserId")]
public User User { get; set; } = new User();
public User User { get; set; }
[ForeignKey("EnvelopeTypeId")]
public EnvelopeType EnvelopeType { get; set; }

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using DigitalData.UserManager.Domain.Entities;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
using System;

View 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}";
}
}

View File

@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations.Schema;
using DigitalData.UserManager.Domain.Entities;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBDD_USER", Schema = "dbo")]
public class FormUser : User
{
[NotMapped]
public bool HasAccess { get; set; }
[NotMapped]
public bool IsAdmin { get; set; }
[NotMapped]
public bool GhostModeActive { get; set; }
[NotMapped]
public string FullName => $"{Prename} {Name}";
}
}

View File

@@ -1,113 +0,0 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
#if NETFRAMEWORK
using System;
#endif
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBDD_USER", Schema = "dbo")]
public class User
{
[Column("GUID")]
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; } = 0;
[StringLength(50)]
[Column("ADDED_WHO")]
public string AddedWho { get; set; }
[StringLength(50)]
[Column("CHANGED_WHO")]
public string ChangedWho { get; set; }
//TODO: assign it to default value in create dto, not here!
[Column("ADDED_WHEN", TypeName = "datetime")]
[DefaultValue("GETDATE()")]
public DateTime AddedWhen { get; set; } = DateTime.Now;
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime ChangedWhen { get; set; }
[Column("PRENAME")]
[StringLength(50)]
public string Prename { get; set; }
[Column("NAME")]
[StringLength(50)]
public string Name { get; set; }
[Required]
[Column("USERNAME")]
[StringLength(50)]
public string Username { get; set; }
[Column("SHORTNAME")]
[StringLength(30)]
public string Shortname { get; set; }
[Column("EMAIL")]
[StringLength(100)]
public string Email { get; set; }
[Required]
[Column("LANGUAGE")]
[StringLength(5)]
[DefaultValue("de-DE")]
public string Language { get; set; }
[Column("COMMENT")]
[StringLength(500)]
public string Comment { get; set; }
[Column("DELETED")]
public bool Deleted { get; set; }
[Required]
[Column("DATE_FORMAT")]
[StringLength(10)]
[DefaultValue("dd.MM.yyyy")]
public string DateFormat { get; set; }
[Required]
[Column("ACTIVE")]
public bool Active { get; set; }
[Required]
[Column("GENERAL_VIEWER")]
[StringLength(30)]
[DefaultValue("NONE")]
public string GeneralViewer { get; set; }
[Required]
[Column("WAN_ENVIRONMENT")]
public bool WanEnvironment { get; set; }
[Required]
[Column("USERID_FK_INT_ECM")]
public int UseridFkIntEcm { get; set; }
[Column("DELETED_WHEN")]
public DateTime DeletedWhen { get; set; }
[Column("DELETED_WHO")]
[StringLength(50)]
public string DeletedWho { get; set; }
#region FORM_APP
[NotMapped]
public bool HasAccess { get; set; }
[NotMapped]
public bool IsAdmin { get; set; }
[NotMapped]
public bool GhostModeActive { get; set; }
[NotMapped]
public string FullName => $"{Prename} {Name}";
#endregion
}
}

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

@@ -33,6 +33,7 @@
<ItemGroup>
<PackageReference Include="DigitalData.EmailProfilerDispatcher.Abstraction.Attributes" Version="1.0.0" />
<PackageReference Include="UserManager.Domain" Version="3.2.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -20,7 +20,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EnvelopeGenerator.CommonServices\EnvelopeGenerator.CommonServices.vbproj" />
<ProjectReference Include="..\EnvelopeGenerator.Domain\EnvelopeGenerator.Domain.csproj" />
</ItemGroup>
</Project>

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

@@ -11,7 +11,7 @@ Module ModuleSettings
Public DB_DD_ECM As MSSQLServer = Nothing
Public DEF_TF_ENABLED As Boolean = False
Public DEF_TF_ENABLED_WITH_PHONE As Boolean = False
Public MYUSER As User
Public MYUSER As FormUser
Public MyTempFiles As TempFiles
Public SQL_REP_ENV_USER_LM As String = ""
Public SQL_REP_ENV_USER_TM As String = ""

View File

@@ -594,31 +594,40 @@ Public Class frmMain
End Sub
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtnitm_ResendInvitation.ItemClick
Dim oView As GridView = GridEnvelopes.FocusedView
Dim selReceiver As Receiver
If oView.Name = ViewReceivers.Name Then
selReceiver = oView.GetRow(oView.FocusedRowHandle)
Else
MsgBox(Resources.Envelope.Please_select_a_recipient_from_the_Recipients_tab, MsgBoxStyle.Information, Text)
End If
If ViewEnvelopes.FocusedRowHandle < 0 Or IsNothing(selReceiver) Then
Exit Sub
End If
Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle)
Dim oController = New EnvelopeEditorController(State, oEnvelope)
Dim Documents As New BindingList(Of EnvelopeDocument)
Dim Receivers As New BindingList(Of Receiver)
Receivers = New BindingList(Of Receiver)(oController.Envelope.Receivers)
For Each oReceiver As Receiver In Receivers
If oReceiver.EmailAddress = selReceiver.EmailAddress Then
If oController.ActionService.ResendReceiver(oEnvelope, oReceiver) = True Then
Dim oMsg = Resources.Envelope.Invitation_successfully_resend.Replace("@Mail", oReceiver.EmailAddress)
MsgBox(oMsg, MsgBoxStyle.Information, Text)
End If
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
Try
Dim oView As GridView = GridEnvelopes.FocusedView
Dim selReceiver As Receiver
If oView.Name = ViewReceivers.Name Then
selReceiver = oView.GetRow(oView.FocusedRowHandle)
Else
MsgBox(Resources.Envelope.Please_select_a_recipient_from_the_Recipients_tab, MsgBoxStyle.Information, Text)
End If
Next
If ViewEnvelopes.FocusedRowHandle < 0 Or IsNothing(selReceiver) Then
Exit Sub
End If
Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle)
Dim oController = New EnvelopeEditorController(State, oEnvelope)
Dim Documents As New BindingList(Of EnvelopeDocument)
Dim Receivers As New BindingList(Of Receiver)
Receivers = New BindingList(Of Receiver)(oController.Envelope.Receivers)
For Each oReceiver As Receiver In Receivers
If oReceiver.EmailAddress = selReceiver.EmailAddress Then
If oController.ActionService.ResendReceiver(oEnvelope, oReceiver) = True Then
Dim oMsg = Resources.Envelope.Invitation_successfully_resend.Replace("@Mail", oReceiver.EmailAddress)
MsgBox(oMsg, MsgBoxStyle.Information, Text)
End If
End If
Next
Catch ex As Exception
Logger.Error(ex)
Finally
End Try
SplashScreenManager.CloseOverlayForm(oHandle)
End Sub

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

@@ -1,4 +1,4 @@
using DigitalData.Core.DTO;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.Envelopes.Commands;
using EnvelopeGenerator.Application.Envelopes.Queries.Read;
@@ -6,8 +6,6 @@ using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
@@ -31,6 +29,7 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers;
public class EnvelopeController : ControllerBase
{
private readonly ILogger<EnvelopeController> _logger;
[Obsolete("Use MediatR")]
private readonly IEnvelopeService _envelopeService;
private readonly IMediator _mediator;
@@ -40,6 +39,7 @@ public class EnvelopeController : ControllerBase
/// <param name="logger">Der Logger, der für das Protokollieren von Informationen verwendet wird.</param>
/// <param name="envelopeService">Der Dienst, der für die Verarbeitung von Umschlägen zuständig ist.</param>
/// <param name="mediator"></param>
[Obsolete("Use MediatR")]
public EnvelopeController(ILogger<EnvelopeController> logger, IEnvelopeService envelopeService, IMediator mediator)
{
_logger = logger;
@@ -59,6 +59,7 @@ public class EnvelopeController : ControllerBase
/// <response code="500">Ein unerwarteter Fehler ist aufgetreten.</response>
[Authorize]
[HttpGet]
[Obsolete("Use MediatR")]
public async Task<IActionResult> GetAsync([FromQuery] ReadEnvelopeQuery envelope)
{
if (User.GetId() is int intId)
@@ -98,6 +99,7 @@ public class EnvelopeController : ControllerBase
/// <response code="404">Das Dokument wurde nicht gefunden oder ist nicht verfügbar.</response>
/// <response code="500">Ein unerwarteter Fehler ist aufgetreten.</response>
[HttpGet("doc-result")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> GetDocResultAsync([FromQuery] int id, [FromQuery] bool view = false)
{
if (User.GetId() is int intId)
@@ -154,4 +156,4 @@ public class EnvelopeController : ControllerBase
else
return Ok(res);
}
}
}

View File

@@ -1,5 +1,5 @@
using AutoMapper;
using DigitalData.Core.DTO;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
using EnvelopeGenerator.Application.DTOs.Receiver;
@@ -31,6 +31,7 @@ public class EnvelopeReceiverController : ControllerBase
{
private readonly ILogger<EnvelopeReceiverController> _logger;
[Obsolete("Use MediatR")]
private readonly IEnvelopeReceiverService _erService;
private readonly IMediator _mediator;
@@ -56,6 +57,7 @@ public class EnvelopeReceiverController : ControllerBase
/// <param name="erExecutor"></param>
/// <param name="documentExecutor"></param>
/// <param name="csOpt"></param>
[Obsolete("Use MediatR")]
public EnvelopeReceiverController(ILogger<EnvelopeReceiverController> logger, IEnvelopeReceiverService envelopeReceiverService, IMediator mediator, IMapper mapper, IEnvelopeExecutor envelopeExecutor, IEnvelopeReceiverExecutor erExecutor, IDocumentExecutor documentExecutor, IOptions<ConnectionString> csOpt)
{
_logger = logger;
@@ -82,6 +84,7 @@ public class EnvelopeReceiverController : ControllerBase
/// <response code="500">Ein unerwarteter Fehler ist aufgetreten.</response>
[Authorize]
[HttpGet]
[Obsolete("Use MediatR")]
public async Task<IActionResult> GetEnvelopeReceiver([FromQuery] ReadEnvelopeReceiverQuery envelopeReceiver)
{
var username = User.GetUsernameOrDefault();
@@ -123,6 +126,7 @@ public class EnvelopeReceiverController : ControllerBase
/// <response code="500">Ein unerwarteter Fehler ist aufgetreten.</response>
[Authorize]
[HttpGet("salute")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> GetReceiverName([FromQuery] ReadReceiverNameQuery receiver)
{
return await _erService.ReadLastUsedReceiverNameByMailAsync(receiver.EmailAddress, receiver.Id, receiver.Signature).ThenAsync(

View File

@@ -1,23 +1,39 @@
using DigitalData.Core.DTO;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Contracts.Services;
using Microsoft.AspNetCore.Mvc;
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
/// <summary>
///
/// </summary>
[ApiExplorerSettings(IgnoreApi = true)]
[Route("api/[controller]")]
[ApiController]
public class EnvelopeTypeController : ControllerBase
{
private readonly ILogger<EnvelopeTypeController> _logger;
[Obsolete("Use MediatR")]
private readonly IEnvelopeTypeService _service;
/// <summary>
///
/// </summary>
/// <param name="logger"></param>
/// <param name="service"></param>
[Obsolete("Use MediatR")]
public EnvelopeTypeController(ILogger<EnvelopeTypeController> logger, IEnvelopeTypeService service)
{
_logger = logger;
_service = service;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[Obsolete("Use MediatR")]
[HttpGet]
public async Task<IActionResult> GetAllAsync()
{

View File

@@ -1,5 +1,5 @@
using DigitalData.Core.API;
using DigitalData.Core.DTO;
using DigitalData.Core.Abstraction.Application.DTO;
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.DTOs.Receiver;
using EnvelopeGenerator.Application.Receivers.Queries.Read;
@@ -19,6 +19,7 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers;
[Route("api/[controller]")]
[ApiController]
[Authorize]
[Obsolete("Use MediatR")]
public class ReceiverController : CRUDControllerBaseWithErrorHandling<IReceiverService, ReceiverCreateDto, ReceiverReadDto, ReceiverUpdateDto, Receiver, int>
{
/// <summary>
@@ -94,4 +95,4 @@ public class ReceiverController : CRUDControllerBaseWithErrorHandling<IReceiverS
return base.GetById(id);
}
#endregion
}
}

View File

@@ -20,7 +20,7 @@
<ItemGroup>
<PackageReference Include="AspNetCore.Scalar" Version="1.1.8" />
<PackageReference Include="DigitalData.Auth.Client" Version="1.3.7" />
<PackageReference Include="DigitalData.Core.API" Version="2.2.0" />
<PackageReference Include="DigitalData.Core.API" Version="2.2.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.4" />
<PackageReference Include="NLog" Version="5.2.5" />

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

@@ -32,6 +32,7 @@ public static class DIExtensions
/// This method ensures that the repositories are registered as scoped services, meaning that a new instance of each repository
/// will be created per HTTP request (or per scope) within the dependency injection container.
/// </remarks>
[Obsolete("Use IRepository")]
public static IServiceCollection AddEnvelopeGeneratorInfrastructureServices(this IServiceCollection services,
Action<IServiceProvider, DbContextOptionsBuilder>? dbContextOptions = null,
IConfiguration? sqlExecutorConfiguration = null,
@@ -157,4 +158,4 @@ public static class DIExtensions
return services;
}
}
}

View File

@@ -12,7 +12,7 @@
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.1.1" />
<PackageReference Include="DigitalData.Core.Infrastructure.AutoMapper" Version="1.0.3" />
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.1.1" />
<PackageReference Include="UserManager" Version="1.0.0" />
<PackageReference Include="UserManager" Version="1.1.1" />
</ItemGroup>
<ItemGroup>

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);
@@ -28,7 +31,7 @@ public class EnvelopeExecutor : SQLExecutor, IEnvelopeExecutor
var envelopes = await connection.QueryAsync<Envelope>(formattedSql);
var envelope = envelopes.FirstOrDefault()
?? throw new InvalidOperationException($"Envelope creation failed. Parameters:" +
$"userId={userId}, title='{title}', message='{message}', tfaEnabled={tfaEnabled}."); ;
$"userId={userId}, title='{title}', message='{message}', tfaEnabled={tfaEnabled}.");
envelope.User = await _userRepository.ReadByIdAsync(envelope.UserId);

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

@@ -2,16 +2,18 @@
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Application.Contracts.Repositories;
using Microsoft.EntityFrameworkCore;
using EnvelopeGenerator.Domain;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use Repository")]
public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, EGDbContext>, IEnvelopeHistoryRepository
{
public EnvelopeHistoryRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeHistories)
{
}
private IQueryable<EnvelopeHistory> By(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false)
private IQueryable<EnvelopeHistory> By(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false)
{
var query = _dbSet.AsNoTracking();
@@ -33,12 +35,12 @@ public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, E
return query;
}
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null) => await By(
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null) => await By(
envelopeId: envelopeId,
userReference: userReference,
status: status).CountAsync();
public async Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false)
public async Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false)
=> await By(
envelopeId: envelopeId,
userReference: userReference,

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

@@ -2,12 +2,11 @@
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Application.Contracts.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Http.HttpResults;
using EnvelopeGenerator.Application.Exceptions;
using EnvelopeGenerator.CommonServices.My.Resources;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use Repository")]
public class EnvelopeReceiverRepository : CRUDRepository<EnvelopeReceiver, (int Envelope, int Receiver), EGDbContext>, IEnvelopeReceiverRepository
{
public EnvelopeReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeReceivers)

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

@@ -67,7 +67,7 @@ Public Class Scheduler_FinishEnvelope
Await Scheduler.Start()
Logger.Info("Scheduler started!")
Logger.Debug("Scheduler started!")
Catch ex As Exception
Logger.Error(ex)
End Try

View File

@@ -34,7 +34,7 @@ Public Class Service
TempFiles.Create()
' === Initialize Databases ===
Logger.Info("Inititalize Database ...")
Logger.Debug("Inititalize Database ...")
If Config.ConnectionString = String.Empty Then
Throw New ApplicationException("Connection String is empty!")

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

@@ -14,6 +14,7 @@ namespace EnvelopeGenerator.Terminal;
public static class DependencyInjection
{
[Obsolete("Use MediatR")]
public static IServiceCollection AddCommandManagerRunner(this IServiceCollection services, IConfiguration configuration, Case @case = Case.KebabCase, string connectionStringKeyName = "Default")
{
var connStr = configuration.GetConnectionString(connectionStringKeyName)
@@ -52,4 +53,4 @@ public static class DependencyInjection
}
public static Task<int> RunCommandManagerRunner(this IHost host, string[] args) => host.Services.RunCommandManagerRunner(args);
}
}

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

@@ -25,7 +25,7 @@
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.0.0" />
<PackageReference Include="DigitalData.Core.Abstractions" Version="4.0.0" />
<PackageReference Include="DigitalData.Core.API" Version="2.2.0" />
<PackageReference Include="DigitalData.Core.API" Version="2.2.1" />
<PackageReference Include="DigitalData.Core.Application" Version="3.3.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.20" />

View File

@@ -10,6 +10,7 @@ namespace EnvelopeGenerator.Tests.Application;
public class Mock
{
[Obsolete("Use MediatR")]
public static IHost CreateHost(Action<HostApplicationBuilder>? builderOptions = null, string configPath = "appsettings.json", bool useRealDb = false, params string[] args)
{
var builder = Host.CreateApplicationBuilder(args.Any() ? args : null);

View File

@@ -3,76 +3,79 @@ using EnvelopeGenerator.CommonServices;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Authorization;
using EnvelopeGenerator.Extensions;
using static EnvelopeGenerator.CommonServices.Constants;
using EnvelopeGenerator.Application.Contracts.Services;
using static EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers
namespace EnvelopeGenerator.Web.Controllers;
[Authorize(Roles = ReceiverRole.FullyAuth)]
[Route("api/[controller]")]
public class DocumentController : BaseController
{
[Authorize(Roles = ReceiverRole.FullyAuth)]
[Route("api/[controller]")]
public class DocumentController : BaseController
private readonly EnvelopeOldService envelopeService;
private readonly ActionService? actionService;
[Obsolete("Use MediatR")]
private readonly IEnvelopeDocumentService _envDocService;
[Obsolete("Use MediatR")]
public DocumentController(DatabaseService database, EnvelopeOldService envelope, IEnvelopeDocumentService envDocService, ILogger<DocumentController> logger) : base(database, logger)
{
private readonly EnvelopeOldService envelopeService;
private readonly ActionService? actionService;
private readonly IEnvelopeDocumentService _envDocService;
public DocumentController(DatabaseService database, EnvelopeOldService envelope, IEnvelopeDocumentService envDocService, ILogger<DocumentController> logger) : base(database, logger)
{
envelopeService = envelope;
actionService = database.Services?.actionService;
_envDocService = envDocService;
}
[NonAction]
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
{
try
{
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
// Load document info
var document = await envelopeService.GetDocument(index, envelopeKey);
// Load the document from disk
var bytes = await envelopeService.GetDocumentContents(document);
// Return the document as bytes
return File(bytes, "application/octet-stream");
}
catch(Exception ex)
{
_logger.LogError(ex, "{Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("{envelopeKey}")]
public async Task<IActionResult> Open(string envelopeKey)
{
try
{
var authSignature = this.GetAuthReceiverSignature();
if (authSignature != envelopeKey.GetReceiverSignature())
return Forbid();
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
actionService?.OpenEnvelope(response.Envelope, response.Receiver);
return Ok(new object());
}
catch(Exception ex)
{
_logger.LogError(ex, "{Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
envelopeService = envelope;
actionService = database.Services?.actionService;
_envDocService = envDocService;
}
}
[Obsolete("Use MediatR")]
[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}")]
[Obsolete("Use MediatR")]
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);
}
}
}

View File

@@ -1,153 +1,161 @@
using DigitalData.Core.DTO;
using EnvelopeGenerator.CommonServices;
using EnvelopeGenerator.CommonServices;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Text.Encodings.Web;
using static EnvelopeGenerator.CommonServices.Constants;
using EnvelopeGenerator.Extensions;
using EnvelopeGenerator.Application.Contracts.Services;
using static EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Domain;
using DigitalData.Core.Abstraction.Application.DTO;
namespace EnvelopeGenerator.Web.Controllers
namespace EnvelopeGenerator.Web.Controllers;
[Authorize(Roles = ReceiverRole.FullyAuth)]
[ApiController]
[Route("api/[controller]")]
public class EnvelopeController : BaseController
{
[Authorize(Roles = ReceiverRole.FullyAuth)]
[ApiController]
[Route("api/[controller]")]
public class EnvelopeController : BaseController
private readonly EnvelopeOldService envelopeService;
private readonly ActionService? actionService;
private readonly UrlEncoder _urlEncoder;
[Obsolete("Use MediatR")]
private readonly IEnvelopeHistoryService _histService;
[Obsolete("Use MediatR")]
private readonly IReceiverService _receiverService;
[Obsolete("Use MediatR")]
private readonly IEnvelopeReceiverService _envRcvService;
[Obsolete("Use MediatR")]
public EnvelopeController(DatabaseService database,
EnvelopeOldService envelope,
ILogger<EnvelopeController> logger, UrlEncoder urlEncoder,
IEnvelopeHistoryService envelopeHistoryService,
IReceiverService receiverService,
IEnvelopeReceiverService envelopeReceiverService) : base(database, logger)
{
private readonly EnvelopeOldService envelopeService;
private readonly ActionService? actionService;
private readonly UrlEncoder _urlEncoder;
private readonly IEnvelopeHistoryService _histService;
private readonly IReceiverService _receiverService;
private readonly IEnvelopeReceiverService _envRcvService;
envelopeService = envelope;
actionService = database?.Services?.actionService;
_urlEncoder = urlEncoder;
_histService = envelopeHistoryService;
_receiverService = receiverService;
_envRcvService = envelopeReceiverService;
}
public EnvelopeController(DatabaseService database,
EnvelopeOldService envelope,
ILogger<EnvelopeController> logger, UrlEncoder urlEncoder,
IEnvelopeHistoryService envelopeHistoryService,
IReceiverService receiverService,
IEnvelopeReceiverService envelopeReceiverService) : base(database, logger)
[NonAction]
[Obsolete("Use MediatR")]
public async Task<IActionResult> Get([FromRoute] string envelopeKey)
{
try
{
envelopeService = envelope;
actionService = database?.Services?.actionService;
_urlEncoder = urlEncoder;
_histService = envelopeHistoryService;
_receiverService = receiverService;
_envRcvService = envelopeReceiverService;
envelopeKey = _urlEncoder.Encode(envelopeKey);
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
if (envelopeService.ReceiverAlreadySigned(response.Envelope, response.Receiver.Id) == true)
{
return Problem(statusCode: 403);
}
_logger.LogInformation("Loaded envelope [{0}] for receiver [{1}]", response.Envelope.Id, response.Envelope.Id);
return Json(response);
}
[NonAction]
public async Task<IActionResult> Get([FromRoute] string envelopeKey)
catch (Exception e)
{
try
{
envelopeKey = _urlEncoder.Encode(envelopeKey);
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
if (envelopeService.ReceiverAlreadySigned(response.Envelope, response.Receiver.Id) == true)
{
return Problem(statusCode: 403);
}
_logger.LogInformation("Loaded envelope [{0}] for receiver [{1}]", response.Envelope.Id, response.Envelope.Id);
return Json(response);
}
catch (Exception e)
{
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("{envelopeKey}")]
public async Task<IActionResult> Update(string envelopeKey, int index)
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("{envelopeKey}")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> Update(string envelopeKey, int index)
{
try
{
try
envelopeKey = _urlEncoder.Encode(envelopeKey);
var authSignature = this.GetAuthReceiverSignature();
if (authSignature != envelopeKey.GetReceiverSignature())
return Unauthorized();
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
// Again check if receiver has already signed
if (envelopeService.ReceiverAlreadySigned(response.Envelope, response.Receiver.Id) == true)
{
envelopeKey = _urlEncoder.Encode(envelopeKey);
return Problem(statusCode: 403);
}
var authSignature = this.GetAuthReceiverSignature();
var document = envelopeService.GetDocument(index, envelopeKey);
if (authSignature != envelopeKey.GetReceiverSignature())
return Unauthorized();
string? annotationData = await envelopeService.EnsureValidAnnotationData(Request);
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeReceiver response = await envelopeService.LoadEnvelope(envelopeKey);
envelopeService.InsertDocumentStatus(new Domain.Entities.DocumentStatus()
{
EnvelopeId = response.Envelope.Id,
ReceiverId = response.Receiver.Id,
Value = annotationData,
Status = Constants.DocumentStatus.Signed
});
// Again check if receiver has already signed
if (envelopeService.ReceiverAlreadySigned(response.Envelope, response.Receiver.Id) == true)
var signResult = actionService?.SignEnvelope(response.Envelope, response.Receiver);
return Ok(new object());
}
catch (Exception e)
{
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("reject")]
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public async Task<IActionResult> Reject([FromBody] string? reason = null)
{
try
{
var signature = this.GetAuthReceiverSignature();
var uuid = this.GetAuthEnvelopeUuid();
var mail = this.GetAuthReceiverMail();
if(uuid is null || signature is null || mail is null)
{
_logger.LogEnvelopeError(uuid: uuid, signature: signature,
message: @$"Unauthorized POST request in api\envelope\reject. One of claims, Envelope, signature or mail ({mail}) is null.");
return Unauthorized();
}
var envRcvRes = await _envRcvService.ReadByUuidSignatureAsync(uuid: uuid, signature: signature);
if (envRcvRes.IsFailed)
{
_logger.LogNotice(envRcvRes.Notices);
return Unauthorized("you are not authirized");
}
return await _histService.RecordAsync(envRcvRes.Data.EnvelopeId, userReference: mail, EnvelopeStatus.DocumentRejected, comment: reason).ThenAsync(
Success: id => NoContent(),
Fail: IActionResult (mssg, ntc) =>
{
return Problem(statusCode: 403);
}
var document = envelopeService.GetDocument(index, envelopeKey);
string? annotationData = await envelopeService.EnsureValidAnnotationData(Request);
envelopeService.InsertDocumentStatus(new Common.DocumentStatus()
{
EnvelopeId = response.Envelope.Id,
ReceiverId = response.Receiver.Id,
Value = annotationData,
Status = Common.Constants.DocumentStatus.Signed
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: "Unexpected error happend in api/envelope/reject");
_logger.LogNotice(ntc);
return this.ViewInnerServiceError();
});
var signResult = actionService?.SignEnvelope(response.Envelope, response.Receiver);
return Ok(new object());
}
catch (Exception e)
{
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("reject")]
public async Task<IActionResult> Reject([FromBody] string? reason = null)
catch (Exception e)
{
try
{
var signature = this.GetAuthReceiverSignature();
var uuid = this.GetAuthEnvelopeUuid();
var mail = this.GetAuthReceiverMail();
if(uuid is null || signature is null || mail is null)
{
_logger.LogEnvelopeError(uuid: uuid, signature: signature,
message: @$"Unauthorized POST request in api\envelope\reject. One of claims, Envelope, signature or mail ({mail}) is null.");
return Unauthorized();
}
var envRcvRes = await _envRcvService.ReadByUuidSignatureAsync(uuid: uuid, signature: signature);
if (envRcvRes.IsFailed)
{
_logger.LogNotice(envRcvRes.Notices);
return Unauthorized("you are not authirized");
}
return await _histService.RecordAsync(envRcvRes.Data.EnvelopeId, userReference: mail, EnvelopeStatus.DocumentRejected, comment: reason).ThenAsync(
Success: id => NoContent(),
Fail: IActionResult (mssg, ntc) =>
{
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: "Unexpected error happend in api/envelope/reject");
_logger.LogNotice(ntc);
return this.ViewInnerServiceError();
});
}
catch (Exception e)
{
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}

View File

@@ -1,5 +1,4 @@
using EnvelopeGenerator.CommonServices;
using EnvelopeGenerator.Web.Services;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
@@ -8,33 +7,40 @@ using Microsoft.AspNetCore.Authorization;
using DigitalData.Core.API;
using EnvelopeGenerator.Extensions;
using Microsoft.Extensions.Localization;
using DigitalData.Core.DTO;
using Microsoft.AspNetCore.Localization;
using EnvelopeGenerator.Web.Models;
using EnvelopeGenerator.Application.Resources;
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
using static EnvelopeGenerator.CommonServices.Constants;
using Ganss.Xss;
using Newtonsoft.Json;
using EnvelopeGenerator.Application.DTOs;
using DigitalData.Core.Client;
using OtpNet;
using EnvelopeGenerator.Application.Contracts.Services;
using static EnvelopeGenerator.Domain.Constants;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers;
public class HomeController : ViewControllerBase
{
private readonly EnvelopeOldService envelopeOldService;
[Obsolete("Use MediatR")]
private readonly IEnvelopeReceiverService _envRcvService;
[Obsolete("Use MediatR")]
private readonly IEnvelopeHistoryService _historyService;
private readonly IConfiguration _configuration;
[Obsolete("Use MediatR")]
private readonly IEnvelopeMailService _mailService;
[Obsolete("Use MediatR")]
private readonly IEnvelopeReceiverReadOnlyService _readOnlyService;
private readonly IAuthenticator _authenticator;
[Obsolete("Use MediatR")]
private readonly IReceiverService _rcvService;
private readonly IEnvelopeSmsHandler _envSmsHandler;
[Obsolete("Use MediatR")]
public HomeController(EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IEnvelopeReceiverService envelopeReceiverService, IEnvelopeHistoryService historyService, IStringLocalizer<Resource> localizer, IConfiguration configuration, HtmlSanitizer sanitizer, Cultures cultures, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverReadOnlyService readOnlyService, IAuthenticator authenticator, IReceiverService receiverService, IEnvelopeSmsHandler envelopeSmsService) : base(logger, sanitizer, cultures, localizer)
{
this.envelopeOldService = envelopeOldService;
@@ -69,6 +75,7 @@ public class HomeController : ViewControllerBase
}
[HttpGet("EnvelopeKey/{envelopeReceiverId}")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> MainAsync([FromRoute] string envelopeReceiverId, [FromQuery] string? culture = null)
{
try
@@ -131,6 +138,7 @@ public class HomeController : ViewControllerBase
}
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Locked")]
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public async Task<IActionResult> EnvelopeLocked([FromRoute] string envelopeReceiverId)
{
try
@@ -163,6 +171,7 @@ public class HomeController : ViewControllerBase
}
}
[Obsolete("Use MediatR")]
private async Task<IActionResult> CreateShowEnvelopeView(string envelopeReceiverId, EnvelopeReceiverDto er)
{
try
@@ -251,6 +260,7 @@ public class HomeController : ViewControllerBase
}
}
[Obsolete("Use MediatR")]
[NonAction]
private async Task<IActionResult?> HandleAccessCodeAsync(Auth auth, EnvelopeReceiverSecretDto er_secret, string envelopeReceiverId)
{
@@ -323,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
@@ -401,6 +412,7 @@ public class HomeController : ViewControllerBase
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Success")]
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public async Task<IActionResult> EnvelopeSigned(string envelopeReceiverId)
{
try
@@ -412,7 +424,7 @@ public class HomeController : ViewControllerBase
if(!isExisting)
return this.ViewEnvelopeNotFound();
Common.EnvelopeReceiver response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
EnvelopeReceiver response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
if (!envelopeOldService.ReceiverAlreadySigned((Envelope)response.Envelope, (int)response.Receiver.Id))
return base.Redirect($"/EnvelopeKey/{envelopeReceiverId}/Locked");
@@ -436,6 +448,7 @@ public class HomeController : ViewControllerBase
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Rejected")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> EnvelopeRejected(string envelopeReceiverId)
{
try
@@ -467,6 +480,7 @@ public class HomeController : ViewControllerBase
}
[HttpGet("EnvelopeKey/{readOnlyKey}/ReadOnly")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> EnvelopeReceiverReadOnly([FromRoute] string readOnlyKey)
{
try

View File

@@ -1,10 +1,10 @@
using DigitalData.Core.DTO;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using static EnvelopeGenerator.CommonServices.Constants;
using static EnvelopeGenerator.Domain.Constants;
namespace EnvelopeGenerator.Web.Controllers
{
@@ -14,12 +14,16 @@ namespace EnvelopeGenerator.Web.Controllers
{
private readonly ILogger<ReadOnlyController> _logger;
[Obsolete("Use MediatR")]
private readonly IEnvelopeReceiverReadOnlyService _erroService;
[Obsolete("Use MediatR")]
private readonly IEnvelopeMailService _mailService;
[Obsolete("Use MediatR")]
private readonly IEnvelopeHistoryService _histService;
[Obsolete("Use MediatR")]
public ReadOnlyController(ILogger<ReadOnlyController> logger, IEnvelopeReceiverReadOnlyService erroService, IEnvelopeMailService mailService, IEnvelopeHistoryService histService)
{
_logger = logger;
@@ -30,6 +34,7 @@ namespace EnvelopeGenerator.Web.Controllers
[HttpPost]
[Authorize(Roles = ReceiverRole.FullyAuth)]
[Obsolete("Use MediatR")]
public async Task<IActionResult> CreateAsync([FromBody] EnvelopeReceiverReadOnlyCreateDto createDto)
{
try
@@ -62,7 +67,7 @@ namespace EnvelopeGenerator.Web.Controllers
}
//read new entity
var read_res = await _erroService.ReadByIdAsync(creation_res.Data);
var read_res = await _erroService.ReadByIdAsync(creation_res.Data.Id);
if (read_res.IsFailed)
{
_logger.LogNotice(creation_res);
@@ -76,7 +81,7 @@ namespace EnvelopeGenerator.Web.Controllers
{
//TODO: implement multi-threading to history process (Task)
//TODO: remove casting after change the id type
var hist_res = await _histService.RecordAsync((int)createDto.EnvelopeId, createDto.AddedWho, Common.Constants.EnvelopeStatus.EnvelopeShared);
var hist_res = await _histService.RecordAsync((int)createDto.EnvelopeId, createDto.AddedWho, EnvelopeStatus.EnvelopeShared);
if (hist_res.IsFailed)
{
_logger.LogError("Although the envelope was sent as read-only, the EnvelopeShared hisotry could not be saved. Create DTO:\n{createDto}", JsonConvert.SerializeObject(createDto));

View File

@@ -4,25 +4,28 @@ using Microsoft.AspNetCore.Mvc;
using EnvelopeGenerator.Extensions;
using Microsoft.Extensions.Localization;
using EnvelopeGenerator.Application.Resources;
using DigitalData.Core.DTO;
using EnvelopeGenerator.Application.Extensions;
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Authorization;
using static EnvelopeGenerator.CommonServices.Constants;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication;
using EnvelopeGenerator.Application.Contracts.Services;
using DigitalData.Core.Abstraction.Application.DTO;
using static EnvelopeGenerator.Domain.Constants;
namespace EnvelopeGenerator.Web.Controllers;
//TODO: Add authorization as well as limiting the link duration (intermediate token with different role) or sign it
public class TFARegController : ViewControllerBase
{
[Obsolete("Use MediatR")]
private readonly IEnvelopeReceiverService _envRcvService;
private readonly IAuthenticator _authenticator;
[Obsolete("Use MediatR")]
private readonly IReceiverService _rcvService;
private readonly TFARegParams _params;
[Obsolete("Use MediatR")]
public TFARegController(ILogger<TFARegController> logger, HtmlSanitizer sanitizer, Cultures cultures, IStringLocalizer<Resource> localizer, IEnvelopeReceiverService erService, IAuthenticator authenticator, IReceiverService receiverService, IOptions<TFARegParams> tfaRegParamsOptions) : base(logger, sanitizer, cultures, localizer)
{
_envRcvService = erService;
@@ -34,6 +37,7 @@ public class TFARegController : ViewControllerBase
//TODO: move under auth route
[Authorize]
[HttpGet("tfa/{envelopeReceiverId}")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> Reg(string envelopeReceiverId)
{
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

@@ -1,18 +1,18 @@
using DigitalData.Core.API;
using DigitalData.Core.Abstraction.Application;
using Microsoft.AspNetCore.Mvc;
using DigitalData.Core.Abstractions;
namespace EnvelopeGenerator.Web.Controllers.Test
namespace EnvelopeGenerator.Web.Controllers.Test;
[ApiController]
[Route("api/test/[controller]")]
[Obsolete("Use MediatR")]
public class TestControllerBase<TCRUDService, TDto, TEntity, TId> : BasicCRUDControllerBase<TCRUDService, TDto, TEntity, TId>
where TCRUDService : ICRUDService<TDto, TDto, TEntity, TId>
where TDto : class
where TEntity : class
{
[ApiController]
[Route("api/test/[controller]")]
public class TestControllerBase<TCRUDService, TDto, TEntity, TId> : BasicCRUDControllerBase<TCRUDService, TDto, TEntity, TId>
where TCRUDService : ICRUDService<TDto, TDto, TEntity, TId>
where TDto : class, IUnique<TId> where TEntity : class, IUnique<TId>
public TestControllerBase(ILogger logger, TCRUDService service) : base(logger, service)
{
public TestControllerBase(ILogger logger, TCRUDService 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

@@ -2,13 +2,12 @@
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers.Test
{
public class TestDocumentStatusController : TestControllerBase<IDocumentStatusService, DocumentStatusDto, DocumentStatus, int>
{
public TestDocumentStatusController(ILogger<TestDocumentStatusController> logger, IDocumentStatusService service) : base(logger, service)
{
namespace EnvelopeGenerator.Web.Controllers.Test;
}
[Obsolete("Use MediatR")]
public class TestDocumentStatusController : TestControllerBase<IDocumentStatusService, DocumentStatusDto, DocumentStatus, int>
{
public TestDocumentStatusController(ILogger<TestDocumentStatusController> logger, IDocumentStatusService service) : base(logger, service)
{
}
}

View File

@@ -1,33 +1,34 @@
using DigitalData.Core.DTO;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.AspNetCore.Mvc;
using static EnvelopeGenerator.CommonServices.Constants;
using static EnvelopeGenerator.Domain.Constants;
namespace EnvelopeGenerator.Web.Controllers.Test
namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")]
public class TestEmailTemplateController : TestControllerBase<IEmailTemplateService, EmailTemplateDto, EmailTemplate, int>
{
public class TestEmailTemplateController : TestControllerBase<IEmailTemplateService, EmailTemplateDto, EmailTemplate, int>
public TestEmailTemplateController(ILogger<TestEmailTemplateController> logger, IEmailTemplateService service) : base(logger, service)
{
public TestEmailTemplateController(ILogger<TestEmailTemplateController> logger, IEmailTemplateService service) : base(logger, service)
{
}
[HttpGet]
public virtual async Task<IActionResult> GetAll([FromQuery] string? tempType = null)
{
return tempType is null
? await base.GetAll()
: await _service.ReadByNameAsync((EmailTemplateType)Enum.Parse(typeof(EmailTemplateType), tempType)).ThenAsync(
Success: Ok,
Fail: IActionResult (messages, notices) =>
{
_logger.LogNotice(notices);
return NotFound(messages);
});
}
[NonAction]
public override Task<IActionResult> GetAll() => base.GetAll();
}
[HttpGet]
[Obsolete("Use MediatR")]
public virtual async Task<IActionResult> GetAll([FromQuery] string? tempType = null)
{
return tempType is null
? await base.GetAll()
: await _service.ReadByNameAsync((EmailTemplateType)Enum.Parse(typeof(EmailTemplateType), tempType)).ThenAsync(
Success: Ok,
Fail: IActionResult (messages, notices) =>
{
_logger.LogNotice(notices);
return NotFound(messages);
});
}
[NonAction]
public override Task<IActionResult> GetAll() => base.GetAll();
}

View File

@@ -2,13 +2,13 @@
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers.Test
{
public class TestEnvelopeCertificateController : TestControllerBase<IEnvelopeCertificateService, EnvelopeCertificateDto, EnvelopeCertificate, int>
{
public TestEnvelopeCertificateController(ILogger<TestEnvelopeCertificateController> logger, IEnvelopeCertificateService service) : base(logger, service)
{
namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")]
public class TestEnvelopeCertificateController : TestControllerBase<IEnvelopeCertificateService, EnvelopeCertificateDto, EnvelopeCertificate, int>
{
public TestEnvelopeCertificateController(ILogger<TestEnvelopeCertificateController> logger, IEnvelopeCertificateService 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

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

View File

@@ -3,9 +3,11 @@ using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.AspNetCore.Mvc;
using static EnvelopeGenerator.Domain.Constants;
namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")]
public class TestEnvelopeHistoryController : CRUDControllerBase<IEnvelopeHistoryService, EnvelopeHistoryCreateDto, EnvelopeHistoryDto, EnvelopeHistoryDto, EnvelopeHistory, long>
{
public TestEnvelopeHistoryController(ILogger<TestEnvelopeHistoryController> logger, IEnvelopeHistoryService service) : base(logger, service)
@@ -13,7 +15,7 @@ public class TestEnvelopeHistoryController : CRUDControllerBase<IEnvelopeHistory
}
[HttpGet("Count")]
public async Task<IActionResult> Count(int? envelopeId = null, string? userReference = null, int? status = null)
public async Task<IActionResult> Count(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null)
{
return Ok(await _service.CountAsync(envelopeId, userReference, status));
}
@@ -25,7 +27,7 @@ public class TestEnvelopeHistoryController : CRUDControllerBase<IEnvelopeHistory
}
[HttpGet]
public async Task<IActionResult> GetAsyncWith(int? envelopeId = null, string? userReference = null, int? status = null)
public async Task<IActionResult> GetAsyncWith(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null)
{
return Ok(await _service.ReadAsync(envelopeId: envelopeId, userReference: userReference, status: status));
}

View File

@@ -1,48 +1,50 @@
using DigitalData.Core.DTO;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
using Microsoft.AspNetCore.Mvc;
using System.Net;
namespace EnvelopeGenerator.Web.Controllers.Test
namespace EnvelopeGenerator.Web.Controllers.Test;
[ApiController]
[Route("api/test/[controller]")]
public class TestEnvelopeMailController : ControllerBase
{
[ApiController]
[Route("api/test/[controller]")]
public class TestEnvelopeMailController : ControllerBase
private readonly ILogger<TestEnvelopeMailController> _logger;
[Obsolete("Use MediatR")]
private readonly IEnvelopeMailService _mailService;
[Obsolete("Use MediatR")]
private readonly IEnvelopeReceiverService _envRcvService;
[Obsolete("Use MediatR")]
public TestEnvelopeMailController(ILogger<TestEnvelopeMailController> logger, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverService envelopeReceiverService)
{
private readonly ILogger<TestEnvelopeMailController> _logger;
private readonly IEnvelopeMailService _mailService;
private readonly IEnvelopeReceiverService _envRcvService;
_logger = logger;
_mailService = envelopeMailService;
_envRcvService = envelopeReceiverService;
}
public TestEnvelopeMailController(ILogger<TestEnvelopeMailController> logger, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverService envelopeReceiverService)
{
_logger = logger;
_mailService = envelopeMailService;
_envRcvService = envelopeReceiverService;
}
[HttpGet]
[Obsolete("Use MediatR")]
public async Task<IActionResult> SendAccessCode([FromQuery] string envelopeReceiverId = "ZDlmYjZmYjctNTBhNS00NTcyLWI5NTQtYzJjYmY4N2UwZmZhOjowRDI3MkEwNTdGMjRBMkY3MEZDMzM3QkRBQzA1MjYxRjU3NTI2QzgxQ0IyMUE5NzE1RjA1NTJFQzdFNjIwNjY1")
{
return await _envRcvService.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelopeReceiverId).ThenAsync<EnvelopeReceiverDto, IActionResult>(
SuccessAsync: async er =>
{
[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);
}
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);
});
}
return Ok();
},
Fail: (messages, notices) =>
{
_logger.LogNotice(notices);
return StatusCode(500, notices);
});
}
}

View File

@@ -1,66 +1,66 @@
using DigitalData.Core.API;
using DigitalData.Core.DTO;
using EnvelopeGenerator.Extensions;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.AspNetCore.Mvc;
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
using EnvelopeGenerator.Application.Contracts.Services;
using DigitalData.Core.Abstraction.Application.DTO;
namespace EnvelopeGenerator.Web.Controllers.Test
namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")]
public class TestEnvelopeReceiverController : ReadControllerBase<IEnvelopeReceiverService, EnvelopeReceiverDto, EnvelopeReceiver, (int Envelope, int Receiver)>
{
public class TestEnvelopeReceiverController : ReadControllerBase<IEnvelopeReceiverService, EnvelopeReceiverDto, EnvelopeReceiver, (int Envelope, int Receiver)>
public TestEnvelopeReceiverController(ILogger<TestEnvelopeReceiverController> logger, IEnvelopeReceiverService service) : base(logger, service)
{
public TestEnvelopeReceiverController(ILogger<TestEnvelopeReceiverController> logger, IEnvelopeReceiverService service) : base(logger, service)
}
[HttpGet("verify-access-code/{envelope_receiver_id}")]
public async Task<IActionResult> VerifyAccessCode([FromRoute] string envelope_receiver_id, [FromQuery] string access_code)
{
var verification = await _service.VerifyAccessCodeAsync(envelopeReceiverId:envelope_receiver_id, accessCode: access_code);
if (verification.IsSuccess)
return Ok(verification);
else if (verification.HasFlag(Flag.SecurityBreach))
return Forbid();
else if (verification.HasFlag(Flag.SecurityBreachOrDataIntegrity))
return Conflict();
else
return this.InnerServiceError(verification);
}
[HttpGet("e-r-id/{envelope_receiver_id}")]
public async Task<IActionResult> GetByEnvelopeReceiverId([FromRoute] string envelope_receiver_id)
{
var er_result = await _service.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelope_receiver_id);
if (er_result.IsSuccess)
return Ok(er_result);
else
return this.InnerServiceError(er_result);
}
[HttpGet("decode")]
public IActionResult DecodeEnvelopeReceiverId(string envelopeReceiverId, bool isReadOnly = false)
{
if (isReadOnly)
{
var readOnlyId = envelopeReceiverId.DecodeEnvelopeReceiverReadOnlyId();
return Ok(new { readOnlyId });
}
[HttpGet("verify-access-code/{envelope_receiver_id}")]
public async Task<IActionResult> VerifyAccessCode([FromRoute] string envelope_receiver_id, [FromQuery] string access_code)
else
{
var verification = await _service.VerifyAccessCodeAsync(envelopeReceiverId:envelope_receiver_id, accessCode: access_code);
if (verification.IsSuccess)
return Ok(verification);
else if (verification.HasFlag(Flag.SecurityBreach))
return Forbid();
else if (verification.HasFlag(Flag.SecurityBreachOrDataIntegrity))
return Conflict();
else
return this.InnerServiceError(verification);
}
[HttpGet("e-r-id/{envelope_receiver_id}")]
public async Task<IActionResult> GetByEnvelopeReceiverId([FromRoute] string envelope_receiver_id)
{
var er_result = await _service.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelope_receiver_id);
if (er_result.IsSuccess)
return Ok(er_result);
else
return this.InnerServiceError(er_result);
}
[HttpGet("decode")]
public IActionResult DecodeEnvelopeReceiverId(string envelopeReceiverId, bool isReadOnly = false)
{
if (isReadOnly)
{
var readOnlyId = envelopeReceiverId.DecodeEnvelopeReceiverReadOnlyId();
return Ok(new { readOnlyId });
}
else
{
var (EnvelopeUuid, ReceiverSignature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
return Ok(new { uuid = EnvelopeUuid, signature = ReceiverSignature });
}
}
[HttpGet("encode")]
public IActionResult EncodeEnvelopeReceiverId(string? uuid = null, string? signature = null, long? readOnlyId = null)
{
if(readOnlyId is long readOnlyId_long)
return Ok(readOnlyId_long.EncodeEnvelopeReceiverId());
else
return Ok((uuid ?? string.Empty, signature ?? string.Empty).EncodeEnvelopeReceiverId());
var (EnvelopeUuid, ReceiverSignature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
return Ok(new { uuid = EnvelopeUuid, signature = ReceiverSignature });
}
}
[HttpGet("encode")]
public IActionResult EncodeEnvelopeReceiverId(string? uuid = null, string? signature = null, long? readOnlyId = null)
{
if(readOnlyId is long readOnlyId_long)
return Ok(readOnlyId_long.EncodeEnvelopeReceiverId());
else
return Ok((uuid ?? string.Empty, signature ?? string.Empty).EncodeEnvelopeReceiverId());
}
}

View File

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

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
{
public class TestUserReceiverController : TestControllerBase< IUserReceiverService, UserReceiverDto, UserReceiver, int>
{
public TestUserReceiverController(ILogger<TestUserReceiverController> logger, IUserReceiverService service) : base(logger, service)
{
}
}
}

View File

@@ -1,56 +1,55 @@
using EnvelopeGenerator.CommonServices;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc;
namespace EnvelopeGenerator.Web.Controllers.Test
namespace EnvelopeGenerator.Web.Controllers.Test;
[Route("api/test/[controller]")]
public class TestViewController : BaseController
{
[Route("api/test/[controller]")]
public class TestViewController : BaseController
private readonly EnvelopeOldService envelopeOldService;
private readonly IConfiguration _config;
public TestViewController(DatabaseService databaseService, EnvelopeOldService envelopeOldService, ILogger<TestViewController> logger, IConfiguration configuration) : base(databaseService, logger)
{
private readonly EnvelopeOldService envelopeOldService;
private readonly IConfiguration _config;
this.envelopeOldService = envelopeOldService;
_config = configuration;
}
public TestViewController(DatabaseService databaseService, EnvelopeOldService envelopeOldService, ILogger<TestViewController> logger, IConfiguration configuration) : base(databaseService, logger)
{
this.envelopeOldService = envelopeOldService;
_config = configuration;
}
[HttpGet]
public IActionResult Index()
{
return View("AnnotationIndex");
}
[HttpGet]
public IActionResult Index()
[HttpPost]
public IActionResult DebugEnvelopes([FromForm] string? password)
{
try
{
return View("AnnotationIndex");
}
var passwordFromConfig = _config["AdminPassword"];
[HttpPost]
public IActionResult DebugEnvelopes([FromForm] string? password)
{
try
if (passwordFromConfig == null)
{
var passwordFromConfig = _config["AdminPassword"];
if (passwordFromConfig == null)
{
ViewData["error"] = "No admin password configured!";
return View("AnnotationIndex");
}
if (password != passwordFromConfig)
{
ViewData["error"] = "Wrong Password!";
return View("AnnotationIndex");
}
List<Envelope> envelopes = envelopeOldService.LoadEnvelopes();
return View("DebugEnvelopes", envelopes);
}
catch(Exception ex)
{
_logger.LogError(ex, "Unexpected error");
ViewData["error"] = "Unknown error!";
ViewData["error"] = "No admin password configured!";
return View("AnnotationIndex");
}
}
}
if (password != passwordFromConfig)
{
ViewData["error"] = "Wrong Password!";
return View("AnnotationIndex");
}
List<Envelope> envelopes = envelopeOldService.LoadEnvelopes();
return View("DebugEnvelopes", envelopes);
}
catch(Exception ex)
{
_logger.LogError(ex, "Unexpected error");
ViewData["error"] = "Unknown error!";
return View("AnnotationIndex");
}
}
}

View File

@@ -2101,7 +2101,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="BuildBundlerMinifier2022" Version="2.9.9" />
<PackageReference Include="DigitalData.Core.API" Version="2.2.0" />
<PackageReference Include="DigitalData.Core.API" Version="2.2.1" />
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.1.1" />
<PackageReference Include="DigitalData.Modules.Base" Version="1.3.8" />
<PackageReference Include="DigitalData.Modules.Config" Version="1.3.0" />

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();

View File

@@ -1,186 +1,190 @@
using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.CommonServices;
using EnvelopeGenerator.Domain.Entities;
using System.Text;
namespace EnvelopeGenerator.Web.Services
namespace EnvelopeGenerator.Web.Services;
public class EnvelopeOldService
{
public class EnvelopeOldService
private readonly ReceiverModel receiverModel;
private readonly EnvelopeModel envelopeModel;
private readonly HistoryModel historyModel;
private readonly DocumentStatusModel documentStatusModel;
[Obsolete("Use MediatR")]
private readonly IConfigService _configService;
private readonly ILogger<EnvelopeOldService> _logger;
[Obsolete("Use MediatR")]
public EnvelopeOldService(DatabaseService database, IConfigService configService, ILogger<EnvelopeOldService> logger)
{
private readonly ReceiverModel receiverModel;
private readonly EnvelopeModel envelopeModel;
private readonly HistoryModel historyModel;
private readonly DocumentStatusModel documentStatusModel;
_logger = logger;
private readonly IConfigService _configService;
private readonly ILogger<EnvelopeOldService> _logger;
if (database.Models is null)
throw new ArgumentNullException("Models not loaded.");
public EnvelopeOldService(DatabaseService database, IConfigService configService, ILogger<EnvelopeOldService> logger)
receiverModel = database.Models.receiverModel;
envelopeModel = database.Models.envelopeModel;
historyModel = database.Models.historyModel;
documentStatusModel = database.Models.documentStatusModel;
_configService = configService;
}
public void EnsureValidEnvelopeKey(string envelopeKey)
{
_logger.LogInformation("Parsing EnvelopeKey..");
if (string.IsNullOrEmpty(envelopeKey))
throw new ArgumentNullException("EnvelopeKey");
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(envelopeKey);
_logger.LogInformation("EnvelopeUUID: [{0}]", result.Item1);
_logger.LogInformation("ReceiverSignature: [{0}]", result.Item2);
if (string.IsNullOrEmpty(result.Item1))
throw new ArgumentNullException("EnvelopeUUID");
if (string.IsNullOrEmpty(result.Item2))
throw new ArgumentNullException("ReceiverSignature");
}
[Obsolete("Use MediatR")]
public async Task<EnvelopeReceiver> LoadEnvelope(string pEnvelopeKey)
{
_logger.LogInformation("Loading Envelope by Key [{0}]", pEnvelopeKey);
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(pEnvelopeKey);
var envelopeUuid = result.Item1;
var receiverSignature = result.Item2;
var receiverId = receiverModel.GetReceiverIdBySignature(receiverSignature);
_logger.LogInformation("Resolved receiver signature to receiverId [{0}]", receiverId);
_logger.LogInformation("Loading envelope..");
Envelope? envelope = envelopeModel.GetByUuid(envelopeUuid);
if (envelope == null)
{
_logger = logger;
if (database.Models is null)
throw new ArgumentNullException("Models not loaded.");
receiverModel = database.Models.receiverModel;
envelopeModel = database.Models.envelopeModel;
historyModel = database.Models.historyModel;
documentStatusModel = database.Models.documentStatusModel;
_configService = configService;
_logger.LogWarning("Envelope not found");
throw new NullReferenceException("Envelope not found");
}
public void EnsureValidEnvelopeKey(string envelopeKey)
_logger.LogInformation("Envelope loaded");
if (envelope.Receivers == null)
{
_logger.LogInformation("Parsing EnvelopeKey..");
if (string.IsNullOrEmpty(envelopeKey))
throw new ArgumentNullException("EnvelopeKey");
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(envelopeKey);
_logger.LogInformation("EnvelopeUUID: [{0}]", result.Item1);
_logger.LogInformation("ReceiverSignature: [{0}]", result.Item2);
if (string.IsNullOrEmpty(result.Item1))
throw new ArgumentNullException("EnvelopeUUID");
if (string.IsNullOrEmpty(result.Item2))
throw new ArgumentNullException("ReceiverSignature");
_logger.LogWarning("Receivers for envelope not loaded");
throw new NullReferenceException("Receivers for envelope not loaded");
}
public async Task<EnvelopeReceiver> LoadEnvelope(string pEnvelopeKey)
_logger.LogInformation("Envelope receivers found: [{0}]", envelope.Receivers.Count);
Receiver? receiver = envelope.Receivers.Where(r => r.Id == receiverId).SingleOrDefault();
if (receiver == null)
{
_logger.LogInformation("Loading Envelope by Key [{0}]", pEnvelopeKey);
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(pEnvelopeKey);
var envelopeUuid = result.Item1;
var receiverSignature = result.Item2;
var receiverId = receiverModel.GetReceiverIdBySignature(receiverSignature);
_logger.LogInformation("Resolved receiver signature to receiverId [{0}]", receiverId);
_logger.LogInformation("Loading envelope..");
Envelope? envelope = envelopeModel.GetByUuid(envelopeUuid);
if (envelope == null)
{
_logger.LogWarning("Envelope not found");
throw new NullReferenceException("Envelope not found");
}
_logger.LogInformation("Envelope loaded");
if (envelope.Receivers == null)
{
_logger.LogWarning("Receivers for envelope not loaded");
throw new NullReferenceException("Receivers for envelope not loaded");
}
_logger.LogInformation("Envelope receivers found: [{0}]", envelope.Receivers.Count);
Receiver? receiver = envelope.Receivers.Where(r => r.Id == receiverId).SingleOrDefault();
if (receiver == null)
{
_logger.LogWarning("Receiver [{0}] not found", receiverId);
throw new NullReferenceException("Receiver not found");
}
_logger.LogInformation("Loading documents for receiver [{0}]", receiver.EmailAddress);
// filter elements by receiver
envelope.Documents = envelope.Documents.Select((document) =>
{
document.Elements = document.Elements.Where((e) => e.ReceiverId == receiverId).ToList();
return document;
}).ToList();
//if documenet_path_dmz is existing in config, replace the path with it
var config = await _configService.ReadDefaultAsync();
return new()
{
Receiver = receiver,
Envelope = envelope
};
_logger.LogWarning("Receiver [{0}] not found", receiverId);
throw new NullReferenceException("Receiver not found");
}
public List<Envelope> LoadEnvelopes()
_logger.LogInformation("Loading documents for receiver [{0}]", receiver.EmailAddress);
// filter elements by receiver
envelope.Documents = envelope.Documents.Select((document) =>
{
var receivers = receiverModel.ListReceivers();
List<Envelope> envelopes = new();
foreach (var receiver in receivers)
{
var envs = (List<Envelope>)envelopeModel.List(receiver.Id);
envelopes.AddRange(envs);
}
return envelopes;
}
public List<Envelope> LoadEnvelopes(int pReceiverId)
{
return (List<Envelope>)envelopeModel.List(pReceiverId);
}
public bool ReceiverAlreadySigned(Envelope envelope, int receiverId)
{
return historyModel.HasReceiverSigned(envelope.Id, receiverId);
}
public async Task<string?> EnsureValidAnnotationData(HttpRequest request)
{
try
{
_logger.LogInformation("Parsing annotation data from request..");
using MemoryStream ms = new();
await request.BodyReader.CopyToAsync(ms);
var bytes = ms.ToArray();
_logger.LogInformation("Annotation data parsed, size: [{0}]", bytes.Length);
return Encoding.UTF8.GetString(bytes);
}
catch (Exception e)
{
_logger.LogError(e, "Inner Service Error");
throw new ArgumentNullException("AnnotationData");
}
}
public async Task<EnvelopeDocument> GetDocument(int documentId, string envelopeKey)
{
EnvelopeReceiver response = await LoadEnvelope(envelopeKey);
_logger.LogInformation("Loading document for Id [{0}]", documentId);
var document = response.Envelope.Documents.
Where(d => d.Id == documentId).
FirstOrDefault();
if (document == null)
throw new ArgumentException("DocumentId");
_logger.LogInformation("Document [{0}] loaded!", documentId);
document.Elements = document.Elements.Where((e) => e.ReceiverId == receiverId).ToList();
return document;
}).ToList();
//if documenet_path_dmz is existing in config, replace the path with it
var config = await _configService.ReadDefaultAsync();
return new()
{
Receiver = receiver,
Envelope = envelope
};
}
public List<Envelope> LoadEnvelopes()
{
var receivers = receiverModel.ListReceivers();
List<Envelope> envelopes = new();
foreach (var receiver in receivers)
{
var envs = (List<Envelope>)envelopeModel.List(receiver.Id);
envelopes.AddRange(envs);
}
public bool InsertDocumentStatus(Common.DocumentStatus documentStatus)
return envelopes;
}
public List<Envelope> LoadEnvelopes(int pReceiverId)
{
return (List<Envelope>)envelopeModel.List(pReceiverId);
}
public bool ReceiverAlreadySigned(Envelope envelope, int receiverId)
{
return historyModel.HasReceiverSigned(envelope.Id, receiverId);
}
public async Task<string?> EnsureValidAnnotationData(HttpRequest request)
{
try
{
_logger.LogInformation("Saving annotation data..");
return documentStatusModel.InsertOrUpdate(documentStatus);
_logger.LogInformation("Parsing annotation data from request..");
using MemoryStream ms = new();
await request.BodyReader.CopyToAsync(ms);
var bytes = ms.ToArray();
_logger.LogInformation("Annotation data parsed, size: [{0}]", bytes.Length);
return Encoding.UTF8.GetString(bytes);
}
public async Task<byte[]> GetDocumentContents(EnvelopeDocument document)
catch (Exception e)
{
_logger.LogInformation("Loading file [{0}]", document.Filepath);
var bytes = await File.ReadAllBytesAsync(document.Filepath);
_logger.LogInformation("File loaded, size: [{0}]", bytes.Length);
return bytes;
_logger.LogError(e, "Inner Service Error");
throw new ArgumentNullException("AnnotationData");
}
}
[Obsolete("Use MediatR")]
public async Task<EnvelopeDocument> GetDocument(int documentId, string envelopeKey)
{
EnvelopeReceiver response = await LoadEnvelope(envelopeKey);
_logger.LogInformation("Loading document for Id [{0}]", documentId);
var document = response.Envelope.Documents.
Where(d => d.Id == documentId).
FirstOrDefault();
if (document == null)
throw new ArgumentException("DocumentId");
_logger.LogInformation("Document [{0}] loaded!", documentId);
return document;
}
public bool InsertDocumentStatus(DocumentStatus documentStatus)
{
_logger.LogInformation("Saving annotation data..");
return documentStatusModel.InsertOrUpdate(documentStatus);
}
public async Task<byte[]> GetDocumentContents(EnvelopeDocument document)
{
_logger.LogInformation("Loading file [{0}]", document.Filepath);
var bytes = await File.ReadAllBytesAsync(document.Filepath);
_logger.LogInformation("File loaded, size: [{0}]", bytes.Length);
return bytes;
}
}

Some files were not shown because too many files have changed in this diff Show More