using System; using System.Threading.Tasks; using BO.AppServer.Business.Services; using BO.AppServer.Metadata.Dto; using BO.AppServer.Metadata.Enums; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Quadarax.Foundation.Core.Data.Interface.Entity.Dto; namespace BO.AppServer.Web.Services { [Authorize] [Route("api/[controller]")] [ApiController] public class PS : Base { #region *** Properties *** protected override RoleEnum LoginRoleAllowed => RoleEnum.System; #endregion #region *** Private fields *** private DocumentService _srvDocument; #endregion #region *** Constructors *** public PS(ILoggerFactory logger, AccessService srvAccess) : base(logger, srvAccess) { } #endregion #region *** Registrations *** [HttpPost("{ticket}/register")] public async Task> Register(string ticket, [FromBody] RegistrationCDto registration) { CheckAccess(ticket); //return await Call(async () => await _srvUsers.CreateUserAsync(user)); return null; } [HttpPatch("{ticket}/register")] public async Task> Register(string ticket, [FromBody] RegistrationUDto registration) { CheckAccess(ticket); //return await Call(async () => await _srvUsers.CreateUserAsync(user)); return null; } #endregion #region *** Document gathering *** [HttpGet("{ticket}/ps/{registrationId}/new")] public async Task> GetQueueNew(string ticket, long registrationId) { CheckAccess(ticket); //return await Call(async () => await _srvUsers.CreateUserAsync(user)); return null; } [HttpGet("{ticket}/ps/{registrationId}/pending")] public async Task> GetQueuePending(string ticket, long registrationId) { CheckAccess(ticket); //return await Call(async () => await _srvUsers.CreateUserAsync(user)); return null; } [HttpGet("{ticket}/ps/{registrationId}/document/{documentId}/artifact/{artifactId}")] public async Task GetDocumentArtifactContent(string ticket, long documentId, long artifactId) { // TODO: May wrap to better way try { CheckAccess(ticket); //var id = await _srvWorkspace.GetWorkspaceIdByAPIAccess(wrkspApiKey, apiKeyPassword, context); //var content = await _srvDocument.GetArtifactAsync(id, documentId, artifactId); //return new FileStreamResult(content.Item1, content.Item2); return null; } catch (Exception e) { return Problem(e.Message); } } #endregion #region *** Document state operations *** [HttpPatch("{ticket}/ps/{registrationId}/document/{documentId}/status")] public async Task> SetDocumentProcessingStatus(string ticket, long registrationId, long documentId) { CheckAccess(ticket); //return await Call(async () => await _srvUsers.CreateUserAsync(user)); return null; } [HttpPatch("{ticket}/ps/{registrationId}/document/{documentId}/free")] public async Task> SetFreeDocument(string ticket, long registrationId, long documentId) { CheckAccess(ticket); //return await Call(async () => await _srvUsers.CreateUserAsync(user)); return null; } #endregion #region *** Document uploading *** [HttpPatch("{ticket}/ps/{registrationId}/document/{documentId}")] public async Task> UploadDocumentArtifact(string ticket, long registrationId, long documentId, [FromBody] ArtifactCDto artifact, IFormFile content) { CheckAccess(ticket); //return await Call(async () => await _srvUsers.CreateUserAsync(user)); return null; } #endregion } }