remove old envelope srrvice dependencies
This commit is contained in:
@@ -1,17 +0,0 @@
|
|||||||
using EnvelopeGenerator.Web.Services;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers;
|
|
||||||
|
|
||||||
public class BaseController : Controller
|
|
||||||
{
|
|
||||||
protected readonly DatabaseService database;
|
|
||||||
|
|
||||||
protected readonly ILogger _logger;
|
|
||||||
|
|
||||||
public BaseController(DatabaseService database, ILogger logger)
|
|
||||||
{
|
|
||||||
this.database = database;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using EnvelopeGenerator.CommonServices;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using EnvelopeGenerator.Web.Services;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using EnvelopeGenerator.Application.Extensions;
|
using EnvelopeGenerator.Application.Extensions;
|
||||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||||
@@ -98,7 +96,7 @@ public class EnvelopeController : ControllerBase
|
|||||||
{
|
{
|
||||||
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: "Unexpected error happend in api/envelope/reject");
|
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: "Unexpected error happend in api/envelope/reject");
|
||||||
_logger.LogNotice(ntc);
|
_logger.LogNotice(ntc);
|
||||||
return this.ViewInnerServiceError();
|
return StatusCode(500, mssg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
using EnvelopeGenerator.Web.Services;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers.Test;
|
|
||||||
|
|
||||||
[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)
|
|
||||||
{
|
|
||||||
this.envelopeOldService = envelopeOldService;
|
|
||||||
_config = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Index()
|
|
||||||
{
|
|
||||||
return View("AnnotationIndex");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult DebugEnvelopes([FromForm] string? password)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
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!";
|
|
||||||
return View("AnnotationIndex");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2104,9 +2104,6 @@
|
|||||||
<PackageReference Include="DigitalData.Core.API" Version="2.2.1" />
|
<PackageReference Include="DigitalData.Core.API" Version="2.2.1" />
|
||||||
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />
|
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />
|
||||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.1.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" />
|
|
||||||
<PackageReference Include="DigitalData.Modules.Database" Version="2.3.5.4" />
|
|
||||||
<PackageReference Include="HtmlSanitizer" Version="8.0.865" />
|
<PackageReference Include="HtmlSanitizer" Version="8.0.865" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.4" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.4" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
|
||||||
@@ -2135,7 +2132,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\EnvelopeGenerator.Application\EnvelopeGenerator.Application.csproj" />
|
<ProjectReference Include="..\EnvelopeGenerator.Application\EnvelopeGenerator.Application.csproj" />
|
||||||
<ProjectReference Include="..\EnvelopeGenerator.CommonServices\EnvelopeGenerator.CommonServices.vbproj" />
|
|
||||||
<ProjectReference Include="..\EnvelopeGenerator.Infrastructure\EnvelopeGenerator.Infrastructure.csproj" />
|
<ProjectReference Include="..\EnvelopeGenerator.Infrastructure\EnvelopeGenerator.Infrastructure.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using EnvelopeGenerator.Application.Services;
|
using EnvelopeGenerator.Application.Services;
|
||||||
using EnvelopeGenerator.Web.Services;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NLog;
|
using NLog;
|
||||||
using Quartz;
|
using Quartz;
|
||||||
@@ -50,12 +49,6 @@ try
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add base services
|
|
||||||
builder.Services.AddScoped<DatabaseService>();
|
|
||||||
|
|
||||||
// Add higher order services
|
|
||||||
builder.Services.AddScoped<EnvelopeOldService>();
|
|
||||||
|
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
builder.ConfigureBySection<TFARegParams>();
|
builder.ConfigureBySection<TFARegParams>();
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
using DigitalData.Modules.Database;
|
|
||||||
using DigitalData.Modules.Logging;
|
|
||||||
using EnvelopeGenerator.Application;
|
|
||||||
using EnvelopeGenerator.CommonServices;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Services
|
|
||||||
{
|
|
||||||
public class DatabaseService
|
|
||||||
{
|
|
||||||
public MSSQLServer MSSQL { get; set; }
|
|
||||||
|
|
||||||
ILogger<DatabaseService> _logger;
|
|
||||||
|
|
||||||
public State? State { get; set; }
|
|
||||||
|
|
||||||
public class ServiceContainer
|
|
||||||
{
|
|
||||||
public ActionService actionService;
|
|
||||||
public EmailService emailService;
|
|
||||||
|
|
||||||
public ServiceContainer(State state, MSSQLServer MSSQL)
|
|
||||||
{
|
|
||||||
actionService = new(state, MSSQL);
|
|
||||||
emailService = new(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ModelContainer
|
|
||||||
{
|
|
||||||
public EnvelopeModel envelopeModel;
|
|
||||||
public DocumentModel documentModel;
|
|
||||||
public ReceiverModel receiverModel;
|
|
||||||
public ElementModel elementModel;
|
|
||||||
public HistoryModel historyModel;
|
|
||||||
public DocumentStatusModel documentStatusModel;
|
|
||||||
public EmailModel emailModel;
|
|
||||||
public ConfigModel configModel;
|
|
||||||
|
|
||||||
public ModelContainer(State state)
|
|
||||||
{
|
|
||||||
envelopeModel = new(state);
|
|
||||||
documentModel = new(state);
|
|
||||||
receiverModel = new(state);
|
|
||||||
elementModel = new(state);
|
|
||||||
historyModel = new(state);
|
|
||||||
documentStatusModel = new(state);
|
|
||||||
emailModel = new(state);
|
|
||||||
configModel = new(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public readonly ModelContainer? Models;
|
|
||||||
public readonly ServiceContainer? Services;
|
|
||||||
|
|
||||||
public DatabaseService(ILogger<DatabaseService> logger, IConfiguration config)
|
|
||||||
{
|
|
||||||
LogConfig logConfig = new LogConfig(LogConfig.PathType.CustomPath, config["NLog:variables:logDirectory"], null, "Digital Data", "ECM.EnvelopeGenerator.Web");
|
|
||||||
_logger = logger;
|
|
||||||
|
|
||||||
_logger.LogInformation("Establishing MSSQL Database connection..");
|
|
||||||
MSSQL = new MSSQLServer(logConfig, config.GetConnectionString("Default"));
|
|
||||||
|
|
||||||
if (MSSQL.DBInitialized == true)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("MSSQL Connection established: [{0}]", MSSQL.MaskedConnectionString);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// There is a circular dependency between state and models
|
|
||||||
/// All models need a state object, including the config Model
|
|
||||||
/// The state object needs to be filled with the DbConfig property,
|
|
||||||
/// which is obtained by the config Model.
|
|
||||||
/// So first, the config model is initialized with an incomplete state object,
|
|
||||||
/// then all the other models with the DbConfig property filled.
|
|
||||||
/// </summary>
|
|
||||||
State = new State
|
|
||||||
{
|
|
||||||
Database = MSSQL,
|
|
||||||
LogConfig = logConfig,
|
|
||||||
UserId = 0,
|
|
||||||
DbConfig = null
|
|
||||||
};
|
|
||||||
var configModel = new ConfigModel(State);
|
|
||||||
State.DbConfig = configModel.LoadConfiguration();
|
|
||||||
|
|
||||||
Models = new(State);
|
|
||||||
Services = new(State, MSSQL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Connection could not be established!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
|
||||||
using EnvelopeGenerator.CommonServices;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Services;
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
[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.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.ReceiverId == receiverId).SingleOrDefault()?.Receiver;
|
|
||||||
|
|
||||||
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
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return envelopes;
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
@using EnvelopeGenerator.CommonServices;
|
@using EnvelopeGenerator.Domain.Entities;
|
||||||
@using EnvelopeGenerator.Domain.Entities;
|
|
||||||
@using EnvelopeGenerator.Domain.Constants;
|
@using EnvelopeGenerator.Domain.Constants;
|
||||||
|
@using EnvelopeGenerator.Application.Extensions;
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Debug";
|
ViewData["Title"] = "Debug";
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
string encodeEnvelopeKey(Envelope envelope)
|
string encodeEnvelopeKey(Envelope envelope)
|
||||||
{
|
{
|
||||||
var receiver = envelope.Receivers!.First();
|
var receiver = envelope.Receivers!.First();
|
||||||
return Helpers.EncodeEnvelopeReceiverId(envelope.Uuid, receiver.Receiver!.Signature);
|
return (envelope.Uuid, receiver.Receiver!.Signature).ToEnvelopeKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IGrouping<EnvelopeStatus, Envelope>> groupEnvelopes(List<Envelope> envelopes)
|
IEnumerable<IGrouping<EnvelopeStatus, Envelope>> groupEnvelopes(List<Envelope> envelopes)
|
||||||
|
|||||||
Reference in New Issue
Block a user