docs: UI for regenerating a category poems related sections
This commit is contained in:
parent
27f334bde6
commit
861a1abed4
@ -86,6 +86,31 @@
|
||||
});
|
||||
}
|
||||
|
||||
function regenRelatedSections(catId) {
|
||||
if (!confirm('آیا از شروع کار بازسازی قطعات مرتبط بخش اطمینان دارید؟'))
|
||||
return;
|
||||
|
||||
var url = '?handler=StartRegeneratingRelatedSections';
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: {
|
||||
id: catId,
|
||||
},
|
||||
error: function (e) {
|
||||
if (e.responseText == null)
|
||||
alert(e);
|
||||
else
|
||||
alert(e.responseText);
|
||||
},
|
||||
success: function () {
|
||||
alert('کار بازسازی قطعات مرتبط بخش شروع شد.')
|
||||
},
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function tagPoemsWithLanguage(catId) {
|
||||
|
||||
var lang = document.getElementById('cat-poem-language').value;
|
||||
@ -554,6 +579,9 @@
|
||||
<p><a href="/Admin/CatTrans?id=@Model.Cat.Cat.Id">انتقال بخش</a></p>
|
||||
|
||||
|
||||
<p><a role="button" onclick="regenRelatedSections(@Model.Cat.Cat.Id)" class="actionlink" title="بازسازی قطعات مرتبط">بازسازی قطعات مرتبط</a></p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -299,6 +299,24 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
return new OkObjectResult(false);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostStartRegeneratingRelatedSections(int id)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/{id}/regenrelatedsections", null);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var res = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return new BadRequestObjectResult(res);
|
||||
}
|
||||
return new OkObjectResult(true);
|
||||
}
|
||||
}
|
||||
return new OkObjectResult(false);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSetCategoryLanguageTagAsync(int id, string language)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
|
||||
@ -56,7 +56,7 @@ 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("StartRegeneratingCateoryRelatedSections", "Query data")).Result;
|
||||
var job = (await jobProgressServiceEF.NewJob($"StartRegeneratingCateoryRelatedSections - {catId}", "Query data")).Result;
|
||||
try
|
||||
{
|
||||
var updatePoemListId = await context.GanjoorPoems.AsNoTracking().Where(p => p.CatId == catId).Select(p => p.Id).ToListAsync();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user