- SQL-SELECT-Anweisungen in Dokumenten aktualisiert, um alle Spalten abzurufen.
- Prioritätsbehandlung für document_path_dmz in EnvelopeService.LoadEnvelopes hinzugefügt. - CRUD-Operationen in EnvlopeDocument und ConfigurationFile Services/Repositories unter Verwendung von WebCoreModules implementiert. - Verschiedene Dateimethoden in [spezifischen Orten oder Klassen, falls zutreffend] auf async umgestellt.
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
using EnvelopeGenerator.Common;
|
||||
using EnvelopeGenerator.Application.Contracts;
|
||||
using EnvelopeGenerator.Common;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using static EnvelopeGenerator.Common.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Services
|
||||
{
|
||||
@@ -14,7 +13,9 @@ namespace EnvelopeGenerator.Web.Services
|
||||
|
||||
private readonly DocumentStatusModel documentStatusModel;
|
||||
|
||||
public EnvelopeService(IConfiguration Config, LoggingService Logging, DatabaseService database) : base(Config, Logging)
|
||||
private IConfigService _configService;
|
||||
|
||||
public EnvelopeService(IConfiguration Config, LoggingService Logging, DatabaseService database, IConfigService configService) : base(Config, Logging)
|
||||
{
|
||||
logger = Logging.LogConfig.GetLogger();
|
||||
|
||||
@@ -27,6 +28,8 @@ namespace EnvelopeGenerator.Web.Services
|
||||
envelopeModel = database.Models.envelopeModel;
|
||||
historyModel = database.Models.historyModel;
|
||||
documentStatusModel = database.Models.documentStatusModel;
|
||||
|
||||
_configService = configService;
|
||||
}
|
||||
|
||||
public void EnsureValidEnvelopeKey(string envelopeKey)
|
||||
@@ -47,7 +50,7 @@ namespace EnvelopeGenerator.Web.Services
|
||||
throw new ArgumentNullException("ReceiverSignature");
|
||||
}
|
||||
|
||||
public EnvelopeResponse LoadEnvelope(string pEnvelopeKey)
|
||||
public async Task<EnvelopeResponse> LoadEnvelope(string pEnvelopeKey)
|
||||
{
|
||||
logger.Debug("Loading Envelope by Key [{0}]", pEnvelopeKey);
|
||||
|
||||
@@ -87,7 +90,30 @@ namespace EnvelopeGenerator.Web.Services
|
||||
|
||||
logger.Debug("Loading documents for receiver [{0}]", receiver.Email);
|
||||
|
||||
envelope.Documents = FilterElementsByReceiver(envelope, receiverId);
|
||||
// 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 configResult = await _configService.ReadDefaultAsync();
|
||||
if (configResult.IsSuccess && configResult.Data is not null)
|
||||
{
|
||||
var config = configResult.Data;
|
||||
|
||||
if(config.DocumentPathDmz is not null && config.DocumentPathDmz != string.Empty)
|
||||
foreach(var doc in envelope.Documents)
|
||||
{
|
||||
doc.Filepath = doc.Filepath.Replace(config.DocumentPath , config.DocumentPathDmz);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Error(configResult.Messages);
|
||||
throw new InvalidOperationException(String.Join(". ", configResult.Messages));
|
||||
}
|
||||
|
||||
return new()
|
||||
{
|
||||
@@ -96,18 +122,6 @@ namespace EnvelopeGenerator.Web.Services
|
||||
};
|
||||
}
|
||||
|
||||
private static List<EnvelopeDocument> FilterElementsByReceiver(Envelope envelope, int receiverId)
|
||||
{
|
||||
return envelope.Documents.
|
||||
Select((document) =>
|
||||
{
|
||||
var elements = document.Elements.Where((e) => e.ReceiverId == receiverId);
|
||||
document.Elements = elements.ToList();
|
||||
return document;
|
||||
}).
|
||||
ToList();
|
||||
}
|
||||
|
||||
public List<Envelope> LoadEnvelopes()
|
||||
{
|
||||
var receivers = receiverModel.ListReceivers();
|
||||
@@ -176,9 +190,9 @@ namespace EnvelopeGenerator.Web.Services
|
||||
return documentIndex;
|
||||
}
|
||||
|
||||
public EnvelopeDocument GetDocument(HttpRequest request, string envelopeKey)
|
||||
public async Task<EnvelopeDocument> GetDocument(HttpRequest request, string envelopeKey)
|
||||
{
|
||||
EnvelopeResponse response = LoadEnvelope(envelopeKey);
|
||||
EnvelopeResponse response = await LoadEnvelope(envelopeKey);
|
||||
int documentId = EnsureValidDocumentIndex(request);
|
||||
|
||||
logger.Debug("Loading document for Id [{0}]", documentId);
|
||||
|
||||
Reference in New Issue
Block a user