- 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.
74 lines
2.5 KiB
C#
74 lines
2.5 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using EnvelopeGenerator.Common;
|
|
using EnvelopeGenerator.Web.Services;
|
|
using static EnvelopeGenerator.Common.Constants;
|
|
using EnvelopeGenerator.Application.Contracts;
|
|
|
|
namespace EnvelopeGenerator.Web.Controllers
|
|
{
|
|
public class DocumentController : BaseController
|
|
{
|
|
private readonly EnvelopeService envelopeService;
|
|
private readonly ActionService? actionService;
|
|
private readonly IEnvelopeDocumentService _envDocService;
|
|
|
|
public DocumentController(DatabaseService database, LoggingService logging, EnvelopeService envelope, IEnvelopeDocumentService envDocService) : base(database, logging)
|
|
{
|
|
envelopeService = envelope;
|
|
actionService = database.Services?.actionService;
|
|
_envDocService = envDocService;
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("api/document/{envelopeKey}")]
|
|
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
|
|
{
|
|
try
|
|
{
|
|
logger.Info("DocumentController/Get");
|
|
|
|
// Validate Envelope Key and load envelope
|
|
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
|
EnvelopeResponse response = await envelopeService.LoadEnvelope(envelopeKey);
|
|
|
|
// Load document info
|
|
var Request = ControllerContext.HttpContext.Request;
|
|
var document = await envelopeService.GetDocument(Request, 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 e)
|
|
{
|
|
return ErrorResponse(e);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("api/document/{envelopeKey}")]
|
|
public async Task<IActionResult> Open(string envelopeKey)
|
|
{
|
|
try
|
|
{
|
|
logger.Info("DocumentController/Open");
|
|
|
|
// Validate Envelope Key and load envelope
|
|
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
|
EnvelopeResponse response = await envelopeService.LoadEnvelope(envelopeKey);
|
|
|
|
actionService.OpenEnvelope(response.Envelope, response.Receiver);
|
|
|
|
return Ok(new object());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return ErrorResponse(e);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|