ImportNaskbanPaperSources
This commit is contained in:
parent
28c2d36c7c
commit
80120da66a
@ -331,6 +331,8 @@
|
||||
|
||||
<p><a role="button" onclick="rebuildRebuildWordCounts(@Model.PageInformation.PoetOrCat.Poet.Id)" class="actionlink" title="شمارش واژگان">شمارش واژگان</a></p>
|
||||
|
||||
<p><a role="button" onclick="discoverNaskbanPaperSources(@Model.PageInformation.PoetOrCat.Poet.Id)" class="actionlink" title="فهرست کردن کتابهای نسکبان">فهرست کردن کتابهای نسکبان</a></p>
|
||||
|
||||
<p><a role="button" onclick="transilerate()" class="actionlink" title="برگردان تاجیکی">برگردان تاجیکی</a></p>
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RSecurityBackend.Models.Auth.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
@ -429,6 +430,35 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
return new OkObjectResult(false);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostImportNaskbanPaperSourcesAsync(int poetId, string username, string password)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
LoginViewModel model = new LoginViewModel()
|
||||
{
|
||||
Username = username,
|
||||
Password = password,
|
||||
ClientAppName = "GanjooRazor",
|
||||
Language = "fa-IR"
|
||||
};
|
||||
var stringContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
|
||||
|
||||
HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/naskban/import/poetbooks/{poetId}", stringContent);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return BadRequest(JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync()));
|
||||
}
|
||||
return new OkObjectResult(true);
|
||||
}
|
||||
}
|
||||
return new OkObjectResult(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -262,6 +262,33 @@
|
||||
});
|
||||
}
|
||||
|
||||
function discoverNaskbanPaperSources(poetId) {
|
||||
var username = window.prompt('username:');
|
||||
var password = window.prompt('password:');
|
||||
|
||||
var url = '?handler=ImportNaskbanPaperSources';
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: {
|
||||
poetId: poetId,
|
||||
username: username,
|
||||
password: password,
|
||||
},
|
||||
url: url,
|
||||
error: function () {
|
||||
alert('خطا رخ داد.')
|
||||
},
|
||||
success: function () {
|
||||
alert('فرایند بازسازی شروع شد.')
|
||||
},
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user