ganjoor museum: fix uploading
This commit is contained in:
parent
5f5f480f98
commit
89c2a08feb
@ -2264,20 +2264,20 @@ namespace RMuseum.Controllers
|
||||
/// <summary>
|
||||
/// upload artifact to external server
|
||||
/// </summary>
|
||||
/// <param name="artifactId"></param>
|
||||
/// <param name="friendlyUrl"></param>
|
||||
/// <param name="skipUpload"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpPut("upload/external/{artifactId}")]
|
||||
[HttpPut("upload/external/{friendlyUrl}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.ArtifactEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.Unauthorized)]
|
||||
public IActionResult StartUploadingArtifactToExternalServer(Guid artifactId, bool skipUpload)
|
||||
public IActionResult StartUploadingArtifactToExternalServer(string friendlyUrl, bool skipUpload)
|
||||
{
|
||||
try
|
||||
{
|
||||
var res = _artifactService.StartUploadingArtifactToExternalServer(artifactId, skipUpload);
|
||||
var res = _artifactService.StartUploadingArtifactToExternalServer(friendlyUrl, skipUpload);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
|
||||
@ -674,11 +674,11 @@
|
||||
<param name="artifactId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.ArtifactController.StartUploadingArtifactToExternalServer(System.Guid,System.Boolean)">
|
||||
<member name="M:RMuseum.Controllers.ArtifactController.StartUploadingArtifactToExternalServer(System.String,System.Boolean)">
|
||||
<summary>
|
||||
upload artifact to external server
|
||||
</summary>
|
||||
<param name="artifactId"></param>
|
||||
<param name="friendlyUrl"></param>
|
||||
<param name="skipUpload"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
@ -15375,11 +15375,11 @@
|
||||
<param name="artifactId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IArtifactService.StartUploadingArtifactToExternalServer(System.Guid,System.Boolean)">
|
||||
<member name="M:RMuseum.Services.IArtifactService.StartUploadingArtifactToExternalServer(System.String,System.Boolean)">
|
||||
<summary>
|
||||
upload artifact to external server
|
||||
</summary>
|
||||
<param name="artifactId"></param>
|
||||
<param name="friendlyUrl"></param>
|
||||
<param name="skipUpload"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
@ -17772,11 +17772,11 @@
|
||||
<param name="skipUpload"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.ArtifactService.StartUploadingArtifactToExternalServer(System.Guid,System.Boolean)">
|
||||
<member name="M:RMuseum.Services.Implementation.ArtifactService.StartUploadingArtifactToExternalServer(System.String,System.Boolean)">
|
||||
<summary>
|
||||
upload artifact to external server
|
||||
</summary>
|
||||
<param name="artifactId"></param>
|
||||
<param name="friendlyUrl"></param>
|
||||
<param name="skipUpload"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
|
||||
@ -633,10 +633,10 @@ namespace RMuseum.Services
|
||||
/// <summary>
|
||||
/// upload artifact to external server
|
||||
/// </summary>
|
||||
/// <param name="artifactId"></param>
|
||||
/// <param name="friendlyUrl"></param>
|
||||
/// <param name="skipUpload"></param>
|
||||
/// <returns></returns>
|
||||
RServiceResult<bool> StartUploadingArtifactToExternalServer(Guid artifactId, bool skipUpload);
|
||||
RServiceResult<bool> StartUploadingArtifactToExternalServer(string friendlyUrl, bool skipUpload);
|
||||
|
||||
/// <summary>
|
||||
/// create images for ganjoor
|
||||
|
||||
@ -1299,10 +1299,10 @@ namespace RMuseum.Services.Implementation
|
||||
/// <summary>
|
||||
/// upload artifact to external server
|
||||
/// </summary>
|
||||
/// <param name="artifactId"></param>
|
||||
/// <param name="friendlyUrl"></param>
|
||||
/// <param name="skipUpload"></param>
|
||||
/// <returns></returns>
|
||||
public RServiceResult<bool> StartUploadingArtifactToExternalServer(Guid artifactId, bool skipUpload)
|
||||
public RServiceResult<bool> StartUploadingArtifactToExternalServer(string friendlyUrl, bool skipUpload)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -1313,11 +1313,11 @@ namespace RMuseum.Services.Implementation
|
||||
using (RMuseumDbContext context = new RMuseumDbContext(new DbContextOptions<RMuseumDbContext>())) //this is long running job, so _context might be already been freed/collected by GC
|
||||
{
|
||||
LongRunningJobProgressServiceEF jobProgressServiceEF = new LongRunningJobProgressServiceEF(context);
|
||||
var job = (await jobProgressServiceEF.NewJob($"StartUploadingArtifactToExternalServer : {artifactId}", "Query data")).Result;
|
||||
var job = (await jobProgressServiceEF.NewJob($"StartUploadingArtifactToExternalServer : {friendlyUrl}", "Query data")).Result;
|
||||
|
||||
try
|
||||
{
|
||||
var book = await context.Artifacts.Include(a => a.Items).ThenInclude(i => i.Images).Include(a => a.CoverImage).SingleAsync();
|
||||
var book = await context.Artifacts.Include(a => a.Items).ThenInclude(i => i.Images).Include(a => a.CoverImage).Where(a => a.FriendlyUrl == friendlyUrl).SingleAsync();
|
||||
await jobProgressServiceEF.UpdateJob(job.Id, 2, $"بارگذاری {book.Name}");
|
||||
var resUpload = await _UploadArtifactToExternalServer(book, context, skipUpload);
|
||||
if (!string.IsNullOrEmpty(resUpload.ExceptionString))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user