#69 GanjoorLink => DisplayOnPage (untested)
This commit is contained in:
parent
2b39f37db7
commit
9ac211bdb7
@ -138,7 +138,6 @@ namespace RMuseum.DbContext
|
||||
/// </summary>
|
||||
public DbSet<GanjoorLink> GanjoorLinks { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pinterest Links
|
||||
|
||||
2066
RMuseum/Migrations/20210127170611_GanjoorLink-DisplayOnPage.Designer.cs
generated
Normal file
2066
RMuseum/Migrations/20210127170611_GanjoorLink-DisplayOnPage.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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");
|
||||
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user