#262 skeleton for the method to batch convert museum images to webp

This commit is contained in:
Hamid Reza Mohammadi 2021-12-17 11:54:02 +03:30
parent e546293739
commit 5da8dda866
2 changed files with 53 additions and 0 deletions

View File

@ -9933,6 +9933,15 @@
<summary>
IArtifactService implementation
</summary>
<summary>
IArtifactService implementation
</summary>
</member>
<member name="M:RMuseum.Services.Implementation.ArtifactService.StartConvertingOriginalImagesToWebp">
<summary>
convert original images to webp
</summary>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.ArtifactService.StartFillingGanjoorLinkOriginalSources">
<summary>

View File

@ -0,0 +1,44 @@
using Microsoft.EntityFrameworkCore;
using RMuseum.DbContext;
using RSecurityBackend.Models.Generic;
using RSecurityBackend.Services.Implementation;
using System;
namespace RMuseum.Services.Implementation
{
/// <summary>
/// IArtifactService implementation
/// </summary>
public partial class ArtifactService : IArtifactService
{
/// <summary>
/// convert original images to webp
/// </summary>
/// <returns></returns>
public RServiceResult<bool> StartConvertingOriginalImagesToWebp()
{
_backgroundTaskQueue.QueueBackgroundWorkItem
(
async token =>
{
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($"Converting Original Images To Webp", "Query data")).Result;
try
{
await jobProgressServiceEF.UpdateJob(job.Id, 100, "", true);
}
catch (Exception exp)
{
await jobProgressServiceEF.UpdateJob(job.Id, 100, "", false, exp.ToString());
}
}
});
return new RServiceResult<bool>(true);
}
}
}