From 42d7f1f3f0864fb9d7a4c00701b8a525bbe11ea4 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Wed, 19 Jun 2024 22:03:48 +0330 Subject: [PATCH] #444 GanjoorService-CategoryWordCounts --- RMuseum/RMuseum.xml | 3 ++ .../GanjoorService-CategoryWordCounts.cs | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-CategoryWordCounts.cs diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 1dd613f7..0708036e 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -17996,6 +17996,9 @@ IGanjoorService implementation + + IGanjoorService implementation + diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-CategoryWordCounts.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-CategoryWordCounts.cs new file mode 100644 index 00000000..42188715 --- /dev/null +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-CategoryWordCounts.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore; +using RMuseum.Models.Ganjoor; +using System; +using System.Data; +using System.Linq; +using RMuseum.DbContext; +using System.Collections.Generic; +using RSecurityBackend.Services.Implementation; + +namespace RMuseum.Services.Implementation +{ + /// + /// IGanjoorService implementation + /// + public partial class GanjoorService : IGanjoorService + { + public void BuildCategoryWordCounts() + { + _backgroundTaskQueue.QueueBackgroundWorkItem + ( + async token => + { + using (RMuseumDbContext context = new RMuseumDbContext(new DbContextOptions())) //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($"BuildCategoryWordCounts", "Query data")).Result; + try + { + await jobProgressServiceEF.UpdateJob(job.Id, 100); + } + catch (Exception exp) + { + await jobProgressServiceEF.UpdateJob(job.Id, 100, "", false, exp.ToString()); + } + + } + }); + } + } +} \ No newline at end of file