#69 GanjoorLink => DisplayOnPage (untested)

This commit is contained in:
Hamid Reza Mohammadi 2021-01-27 20:38:44 +03:30
parent 2b39f37db7
commit 9ac211bdb7
7 changed files with 2145 additions and 1 deletions

View File

@ -138,7 +138,6 @@ namespace RMuseum.DbContext
/// </summary>
public DbSet<GanjoorLink> GanjoorLinks { get; set; }
/// <summary>
/// Pinterest Links

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class GanjoorLinkDisplayOnPage : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "DisplayOnPage",
table: "GanjoorLinks",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DisplayOnPage",
table: "GanjoorLinks");
}
}
}

View File

@ -795,6 +795,9 @@ namespace RMuseum.Migrations
b.Property<Guid>("ArtifactId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("DisplayOnPage")
.HasColumnType("bit");
b.Property<int>("GanjoorPostId")
.HasColumnType("int");

View File

@ -88,5 +88,10 @@ namespace RMuseum.Models.GanjoorIntegration
/// Synchronized with ganjoor
/// </summary>
public bool Synchronized { get; set; }
/// <summary>
/// display this image on poem page
/// </summary>
public bool DisplayOnPage { get; set; }
}
}

View File

@ -2948,6 +2948,11 @@
Synchronized with ganjoor
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorLink.DisplayOnPage">
<summary>
display this image on poem page
</summary>
</member>
<member name="T:RMuseum.Models.GanjoorIntegration.LinkType">
<summary>
Link Type

View File

@ -437,6 +437,8 @@ namespace RMuseum.Services.Implementation
join poem in _context.GanjoorPoems
on link.GanjoorPostId equals poem.Id
where
link.DisplayOnPage == true
&&
link.ReviewResult == Models.GanjoorIntegration.ReviewResult.Approved
&&
poem.Id == id
@ -1373,6 +1375,47 @@ namespace RMuseum.Services.Implementation
await jobProgressServiceEF.UpdateJob(job.Id, job.Progress, "", false, resPendingPoemSongs.ExceptionString);
}
using (MySqlConnection connection = new MySqlConnection
(
$"server={Configuration.GetSection("AudioMySqlServer")["Server"]};uid={Configuration.GetSection("AudioMySqlServer")["Username"]};pwd={Configuration.GetSection("AudioMySqlServer")["Password"]};database={Configuration.GetSection("AudioMySqlServer")["Database"]};charset=utf8;convert zero datetime=True"
))
{
connection.Open();
using (MySqlDataAdapter src = new MySqlDataAdapter(
"SELECT poem_id, mimage_id FROM ganja_mimages",
connection))
{
job = (await jobProgressServiceEF.UpdateJob(job.Id, 0, "phase N - mysql N")).Result;
using (DataTable srcData = new DataTable())
{
await src.FillAsync(srcData);
job = (await jobProgressServiceEF.UpdateJob(job.Id, 0, "phase N - processing meta data")).Result;
int r = 0;
foreach (DataRow row in srcData.Rows)
{
job = (await jobProgressServiceEF.UpdateJob(job.Id, r++, "phase N - processing meta data")).Result;
int poemId = int.Parse(row["poem_id"].ToString());
Guid imageId = Guid.Parse(row["mimage_id"].ToString());
var link = await context.GanjoorLinks.Include(l => l.Item).ThenInclude(i => i.Images).
Where(l => l.GanjoorPostId == poemId && l.Item.Images.First().Id == imageId)
.FirstOrDefaultAsync();
if(link != null)
{
link.DisplayOnPage = true;
context.GanjoorLinks.Update(link);
}
}
}
}
}
job = (await jobProgressServiceEF.UpdateJob(job.Id, 0, "phase N - finalizing meta data")).Result;
await context.SaveChangesAsync();
await jobProgressServiceEF.UpdateJob(job.Id, 100, "Finished", true);
}
catch(Exception jobExp)