Renaming Narration entity name to Recitation

This commit is contained in:
Hamid Reza Mohammadi 2020-11-16 17:13:55 +03:30
parent 7afc7345c1
commit 1caed9209a
20 changed files with 975 additions and 4140 deletions

View File

@ -21,7 +21,7 @@ namespace RMuseum.Controllers
{
[Produces("application/json")]
[Route("api/audio")]
public class AudioNarrationController : Controller
public class RecitationController : Controller
{
/// <summary>
@ -33,7 +33,7 @@ namespace RMuseum.Controllers
/// <returns></returns>
[HttpGet]
[Authorize]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<PoemNarrationViewModel>))]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<RecitationViewModel>))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
@ -87,7 +87,7 @@ namespace RMuseum.Controllers
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public async Task<IActionResult> GetMp3File(int id)
{
RServiceResult<PoemNarrationViewModel> narration =
RServiceResult<RecitationViewModel> narration =
await _audioService.Get(id);
if (!string.IsNullOrEmpty(narration.ExceptionString))
@ -123,7 +123,7 @@ namespace RMuseum.Controllers
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public async Task<IActionResult> GetXMLFile(int id)
{
RServiceResult<PoemNarrationViewModel> narration =
RServiceResult<RecitationViewModel> narration =
await _audioService.Get(id);
if (!string.IsNullOrEmpty(narration.ExceptionString))
@ -155,7 +155,7 @@ namespace RMuseum.Controllers
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public async Task<IActionResult> GetPoemNarrationVerseSyncArray(int id)
{
RServiceResult<NarrationVerseSync[]> verses =
RServiceResult<RecitationVerseSync[]> verses =
await _audioService.GetPoemNarrationVerseSyncArray(id);
if (!string.IsNullOrEmpty(verses.ExceptionString))
return BadRequest(verses.ExceptionString);
@ -176,10 +176,10 @@ namespace RMuseum.Controllers
[HttpPut("{id}")]
[Authorize]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(PoemNarrationViewModel))]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RecitationViewModel))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
public async Task<IActionResult> UpdatePoemNarration(int id, [FromBody] PoemNarrationViewModel metadata)
public async Task<IActionResult> UpdatePoemNarration(int id, [FromBody] RecitationViewModel metadata)
{
@ -237,10 +237,10 @@ namespace RMuseum.Controllers
/// <returns></returns>
[HttpPut("moderate/{id}")]
[Authorize(Policy = RMuseumSecurableItem.AudioNarrationEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(PoemNarrationViewModel))]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RecitationViewModel))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
public async Task<IActionResult> ModeratePoemNarration(int id, [FromBody] PoemNarrationModerateViewModel model)
public async Task<IActionResult> ModeratePoemNarration(int id, [FromBody] RecitationModerateViewModel model)
{
Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
@ -392,7 +392,7 @@ namespace RMuseum.Controllers
/// <returns></returns>
[HttpGet("profile")]
[Authorize]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<UserNarrationProfileViewModel>))]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<UserRecitationProfileViewModel>))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
@ -414,11 +414,11 @@ namespace RMuseum.Controllers
/// <returns></returns>
[HttpPost("profile")]
[Authorize]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(UserNarrationProfileViewModel))]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(UserRecitationProfileViewModel))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
public async Task<IActionResult> AddUserNarrationProfiles([FromBody]UserNarrationProfileViewModel profile)
public async Task<IActionResult> AddUserNarrationProfiles([FromBody]UserRecitationProfileViewModel profile)
{
Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
@ -440,11 +440,11 @@ namespace RMuseum.Controllers
/// <returns></returns>
[HttpPut("profile")]
[Authorize]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(UserNarrationProfileViewModel))]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(UserRecitationProfileViewModel))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
public async Task<IActionResult> UpdateUserNarrationProfiles([FromBody] UserNarrationProfileViewModel profile)
public async Task<IActionResult> UpdateUserNarrationProfiles([FromBody] UserRecitationProfileViewModel profile)
{
Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
@ -490,7 +490,7 @@ namespace RMuseum.Controllers
[HttpGet("publishqueue")]
[Authorize(Policy = RMuseumSecurableItem.AudioNarrationEntityShortName + ":" + RMuseumSecurableItem.ImportOperationShortName)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<NarrationPublishingTracker>))]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<RecitationPublishingTracker>))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(string))]
public async Task<IActionResult> GetPublishingQueueStatus([FromQuery] PagingParameterModel paging, bool inProgress = true, bool finished = true)
@ -509,7 +509,7 @@ namespace RMuseum.Controllers
/// </summary>
/// <param name="audioService"></param>
/// <param name="userPermissionChecker"></param>
public AudioNarrationController(IAudioNarrationService audioService, IUserPermissionChecker userPermissionChecker)
public RecitationController(IRecitationService audioService, IUserPermissionChecker userPermissionChecker)
{
_audioService = audioService;
_userPermissionChecker = userPermissionChecker;
@ -518,7 +518,7 @@ namespace RMuseum.Controllers
/// <summary>
/// Artifact Service
/// </summary>
protected readonly IAudioNarrationService _audioService;
protected readonly IRecitationService _audioService;
/// <summary>
/// IUserPermissionChecker instance

View File

@ -71,12 +71,9 @@ namespace RMuseum.DbContext
builder.Entity<RTagValue>()
.HasIndex(t => t.FriendlyUrl);
builder.Entity<PoemNarration>()
builder.Entity<Recitation>()
.HasIndex(p => p.GanjoorPostId);
builder.Entity<PoemNarration>()
.HasIndex(p => p.UploadDate);
builder.Entity<GanjoorCat>()
.HasIndex(c => c.FullUrl);
@ -145,7 +142,7 @@ namespace RMuseum.DbContext
/// <summary>
/// Ganjoor Audio Files
/// </summary>
public DbSet<PoemNarration> AudioFiles { get; set; }
public DbSet<Recitation> Recitations { get; set; }
/// <summary>
/// Upload Sessions
@ -158,9 +155,9 @@ namespace RMuseum.DbContext
public DbSet<UploadSessionFile> UploadedFiles { get; set; }
/// <summary>
/// User Narration Profiles
/// User Recitation Profiles
/// </summary>
public DbSet<UserNarrationProfile> UserNarrationProfiles { get; set; }
public DbSet<UserRecitationProfile> UserRecitationProfiles { get; set; }
/// <summary>
/// Ganjoor Poets
@ -185,7 +182,7 @@ namespace RMuseum.DbContext
/// <summary>
/// Narration Publishing Tracker
/// </summary>
public DbSet<NarrationPublishingTracker> NarrationPublishingTrackers { get; set; }
public DbSet<RecitationPublishingTracker> RecitationPublishingTrackers { get; set; }
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class PoemNarrationUploadDateIndex : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_UploadDate",
table: "AudioFiles",
column: "UploadDate");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_AudioFiles_UploadDate",
table: "AudioFiles");
}
}
}

View File

@ -1,48 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class NarrationPublishingTrackers : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "NarrationPublishingTrackers",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
PoemNarrationId = table.Column<int>(nullable: false),
StartDate = table.Column<DateTime>(nullable: false),
XmlFileCopied = table.Column<bool>(nullable: false),
Mp3FileCopied = table.Column<bool>(nullable: false),
FirstDbUpdated = table.Column<bool>(nullable: false),
SecondDbUpdated = table.Column<bool>(nullable: false),
Finished = table.Column<bool>(nullable: false),
FinishDate = table.Column<DateTime>(nullable: false),
LastException = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_NarrationPublishingTrackers", x => x.Id);
table.ForeignKey(
name: "FK_NarrationPublishingTrackers_AudioFiles_PoemNarrationId",
column: x => x.PoemNarrationId,
principalTable: "AudioFiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_NarrationPublishingTrackers_PoemNarrationId",
table: "NarrationPublishingTrackers",
column: "PoemNarrationId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "NarrationPublishingTrackers");
}
}
}

View File

@ -10,8 +10,8 @@ using RMuseum.DbContext;
namespace RMuseum.Migrations
{
[DbContext(typeof(RMuseumDbContext))]
[Migration("20201113112838_NarrationPublishingTrackers")]
partial class NarrationPublishingTrackers
[Migration("20201116132909_Recitations")]
partial class Recitations
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -440,47 +440,7 @@ namespace RMuseum.Migrations
b.ToTable("GanjoorVerses");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.NarrationPublishingTracker", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("FinishDate")
.HasColumnType("datetime2");
b.Property<bool>("Finished")
.HasColumnType("bit");
b.Property<bool>("FirstDbUpdated")
.HasColumnType("bit");
b.Property<string>("LastException")
.HasColumnType("nvarchar(max)");
b.Property<bool>("Mp3FileCopied")
.HasColumnType("bit");
b.Property<int>("PoemNarrationId")
.HasColumnType("int");
b.Property<bool>("SecondDbUpdated")
.HasColumnType("bit");
b.Property<DateTime>("StartDate")
.HasColumnType("datetime2");
b.Property<bool>("XmlFileCopied")
.HasColumnType("bit");
b.HasKey("Id");
b.HasIndex("PoemNarrationId");
b.ToTable("NarrationPublishingTrackers");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.PoemNarration", b =>
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.Recitation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -567,12 +527,50 @@ namespace RMuseum.Migrations
b.HasIndex("ReviewerId");
b.HasIndex("UploadDate");
b.ToTable("AudioFiles");
b.ToTable("Recitations");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserNarrationProfile", b =>
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.RecitationPublishingTracker", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("FinishDate")
.HasColumnType("datetime2");
b.Property<bool>("Finished")
.HasColumnType("bit");
b.Property<bool>("FirstDbUpdated")
.HasColumnType("bit");
b.Property<string>("LastException")
.HasColumnType("nvarchar(max)");
b.Property<bool>("Mp3FileCopied")
.HasColumnType("bit");
b.Property<int>("PoemNarrationId")
.HasColumnType("int");
b.Property<bool>("SecondDbUpdated")
.HasColumnType("bit");
b.Property<DateTime>("StartDate")
.HasColumnType("datetime2");
b.Property<bool>("XmlFileCopied")
.HasColumnType("bit");
b.HasKey("Id");
b.HasIndex("PoemNarrationId");
b.ToTable("RecitationPublishingTrackers");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserRecitationProfile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@ -606,7 +604,7 @@ namespace RMuseum.Migrations
b.HasIndex("UserId");
b.ToTable("UserNarrationProfiles");
b.ToTable("UserRecitationProfiles");
});
modelBuilder.Entity("RMuseum.Models.GanjoorIntegration.GanjoorLink", b =>
@ -1441,16 +1439,7 @@ namespace RMuseum.Migrations
.IsRequired();
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.NarrationPublishingTracker", b =>
{
b.HasOne("RMuseum.Models.GanjoorAudio.PoemNarration", "PoemNarration")
.WithMany()
.HasForeignKey("PoemNarrationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.PoemNarration", b =>
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.Recitation", b =>
{
b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "Owner")
.WithMany()
@ -1463,7 +1452,16 @@ namespace RMuseum.Migrations
.HasForeignKey("ReviewerId");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserNarrationProfile", b =>
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.RecitationPublishingTracker", b =>
{
b.HasOne("RMuseum.Models.GanjoorAudio.Recitation", "PoemNarration")
.WithMany()
.HasForeignKey("PoemNarrationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserRecitationProfile", b =>
{
b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "User")
.WithMany()

View File

@ -3,12 +3,25 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class AudioNarrations : Migration
public partial class Recitations : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AudioFiles",
name: "GanjoorPoets",
columns: table => new
{
Id = table.Column<int>(nullable: false),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorPoets", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Recitations",
columns: table => new
{
Id = table.Column<int>(nullable: false)
@ -40,34 +53,21 @@ namespace RMuseum.Migrations
},
constraints: table =>
{
table.PrimaryKey("PK_AudioFiles", x => x.Id);
table.PrimaryKey("PK_Recitations", x => x.Id);
table.ForeignKey(
name: "FK_AudioFiles_AspNetUsers_OwnerId",
name: "FK_Recitations_AspNetUsers_OwnerId",
column: x => x.OwnerId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AudioFiles_AspNetUsers_ReviewerId",
name: "FK_Recitations_AspNetUsers_ReviewerId",
column: x => x.ReviewerId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "GanjoorPoets",
columns: table => new
{
Id = table.Column<int>(nullable: false),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GanjoorPoets", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UploadSessions",
columns: table => new
@ -95,7 +95,7 @@ namespace RMuseum.Migrations
});
migrationBuilder.CreateTable(
name: "UserNarrationProfiles",
name: "UserRecitationProfiles",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
@ -110,9 +110,9 @@ namespace RMuseum.Migrations
},
constraints: table =>
{
table.PrimaryKey("PK_UserNarrationProfiles", x => x.Id);
table.PrimaryKey("PK_UserRecitationProfiles", x => x.Id);
table.ForeignKey(
name: "FK_UserNarrationProfiles_AspNetUsers_UserId",
name: "FK_UserRecitationProfiles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
@ -147,6 +147,32 @@ namespace RMuseum.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RecitationPublishingTrackers",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
PoemNarrationId = table.Column<int>(nullable: false),
StartDate = table.Column<DateTime>(nullable: false),
XmlFileCopied = table.Column<bool>(nullable: false),
Mp3FileCopied = table.Column<bool>(nullable: false),
FirstDbUpdated = table.Column<bool>(nullable: false),
SecondDbUpdated = table.Column<bool>(nullable: false),
Finished = table.Column<bool>(nullable: false),
FinishDate = table.Column<DateTime>(nullable: false),
LastException = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RecitationPublishingTrackers", x => x.Id);
table.ForeignKey(
name: "FK_RecitationPublishingTrackers_Recitations_PoemNarrationId",
column: x => x.PoemNarrationId,
principalTable: "Recitations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UploadedFiles",
columns: table => new
@ -218,21 +244,6 @@ namespace RMuseum.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_GanjoorPostId",
table: "AudioFiles",
column: "GanjoorPostId");
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_OwnerId",
table: "AudioFiles",
column: "OwnerId");
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_ReviewerId",
table: "AudioFiles",
column: "ReviewerId");
migrationBuilder.CreateIndex(
name: "IX_GanjoorCategories_FullUrl",
table: "GanjoorCategories",
@ -263,6 +274,26 @@ namespace RMuseum.Migrations
table: "GanjoorVerses",
column: "PoemId");
migrationBuilder.CreateIndex(
name: "IX_RecitationPublishingTrackers_PoemNarrationId",
table: "RecitationPublishingTrackers",
column: "PoemNarrationId");
migrationBuilder.CreateIndex(
name: "IX_Recitations_GanjoorPostId",
table: "Recitations",
column: "GanjoorPostId");
migrationBuilder.CreateIndex(
name: "IX_Recitations_OwnerId",
table: "Recitations",
column: "OwnerId");
migrationBuilder.CreateIndex(
name: "IX_Recitations_ReviewerId",
table: "Recitations",
column: "ReviewerId");
migrationBuilder.CreateIndex(
name: "IX_UploadedFiles_UploadSessionId",
table: "UploadedFiles",
@ -274,28 +305,31 @@ namespace RMuseum.Migrations
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserNarrationProfiles_UserId",
table: "UserNarrationProfiles",
name: "IX_UserRecitationProfiles_UserId",
table: "UserRecitationProfiles",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AudioFiles");
name: "GanjoorVerses");
migrationBuilder.DropTable(
name: "GanjoorVerses");
name: "RecitationPublishingTrackers");
migrationBuilder.DropTable(
name: "UploadedFiles");
migrationBuilder.DropTable(
name: "UserNarrationProfiles");
name: "UserRecitationProfiles");
migrationBuilder.DropTable(
name: "GanjoorPoems");
migrationBuilder.DropTable(
name: "Recitations");
migrationBuilder.DropTable(
name: "UploadSessions");

View File

@ -438,47 +438,7 @@ namespace RMuseum.Migrations
b.ToTable("GanjoorVerses");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.NarrationPublishingTracker", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("FinishDate")
.HasColumnType("datetime2");
b.Property<bool>("Finished")
.HasColumnType("bit");
b.Property<bool>("FirstDbUpdated")
.HasColumnType("bit");
b.Property<string>("LastException")
.HasColumnType("nvarchar(max)");
b.Property<bool>("Mp3FileCopied")
.HasColumnType("bit");
b.Property<int>("PoemNarrationId")
.HasColumnType("int");
b.Property<bool>("SecondDbUpdated")
.HasColumnType("bit");
b.Property<DateTime>("StartDate")
.HasColumnType("datetime2");
b.Property<bool>("XmlFileCopied")
.HasColumnType("bit");
b.HasKey("Id");
b.HasIndex("PoemNarrationId");
b.ToTable("NarrationPublishingTrackers");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.PoemNarration", b =>
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.Recitation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -565,12 +525,50 @@ namespace RMuseum.Migrations
b.HasIndex("ReviewerId");
b.HasIndex("UploadDate");
b.ToTable("AudioFiles");
b.ToTable("Recitations");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserNarrationProfile", b =>
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.RecitationPublishingTracker", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("FinishDate")
.HasColumnType("datetime2");
b.Property<bool>("Finished")
.HasColumnType("bit");
b.Property<bool>("FirstDbUpdated")
.HasColumnType("bit");
b.Property<string>("LastException")
.HasColumnType("nvarchar(max)");
b.Property<bool>("Mp3FileCopied")
.HasColumnType("bit");
b.Property<int>("PoemNarrationId")
.HasColumnType("int");
b.Property<bool>("SecondDbUpdated")
.HasColumnType("bit");
b.Property<DateTime>("StartDate")
.HasColumnType("datetime2");
b.Property<bool>("XmlFileCopied")
.HasColumnType("bit");
b.HasKey("Id");
b.HasIndex("PoemNarrationId");
b.ToTable("RecitationPublishingTrackers");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserRecitationProfile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@ -604,7 +602,7 @@ namespace RMuseum.Migrations
b.HasIndex("UserId");
b.ToTable("UserNarrationProfiles");
b.ToTable("UserRecitationProfiles");
});
modelBuilder.Entity("RMuseum.Models.GanjoorIntegration.GanjoorLink", b =>
@ -1439,16 +1437,7 @@ namespace RMuseum.Migrations
.IsRequired();
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.NarrationPublishingTracker", b =>
{
b.HasOne("RMuseum.Models.GanjoorAudio.PoemNarration", "PoemNarration")
.WithMany()
.HasForeignKey("PoemNarrationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.PoemNarration", b =>
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.Recitation", b =>
{
b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "Owner")
.WithMany()
@ -1461,7 +1450,16 @@ namespace RMuseum.Migrations
.HasForeignKey("ReviewerId");
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserNarrationProfile", b =>
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.RecitationPublishingTracker", b =>
{
b.HasOne("RMuseum.Models.GanjoorAudio.Recitation", "PoemNarration")
.WithMany()
.HasForeignKey("PoemNarrationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserRecitationProfile", b =>
{
b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "User")
.WithMany()

View File

@ -7,7 +7,7 @@ namespace RMuseum.Models.GanjoorAudio
/// <summary>
/// Poem Narration
/// </summary>
public class PoemNarration
public class Recitation
{
/// <summary>
/// Id

View File

@ -5,7 +5,7 @@ namespace RMuseum.Models.GanjoorAudio
/// <summary>
/// Narration Publishing Tracker
/// </summary>
public class NarrationPublishingTracker
public class RecitationPublishingTracker
{
/// <summary>
/// Id
@ -20,7 +20,7 @@ namespace RMuseum.Models.GanjoorAudio
/// <summary>
/// Poem Narration
/// </summary>
public PoemNarration PoemNarration { get; set; }
public Recitation PoemNarration { get; set; }
/// <summary>
/// Start Date

View File

@ -6,7 +6,7 @@ namespace RMuseum.Models.GanjoorAudio
/// <summary>
/// Narration Profiles for users
/// </summary>
public class UserNarrationProfile
public class UserRecitationProfile
{
/// <summary>
/// Id

View File

@ -22,7 +22,7 @@
/// <summary>
/// Poem Narration Moderation View Model
/// </summary>
public class PoemNarrationModerateViewModel
public class RecitationModerateViewModel
{
/// <summary>
/// Moderation Result

View File

@ -3,7 +3,7 @@
/// <summary>
/// Verse Sync Range
/// </summary>
public class NarrationVerseSync
public class RecitationVerseSync
{
/// <summary>
/// Verse Order

View File

@ -9,12 +9,12 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
/// <summary>
/// Poem Narration view model
/// </summary>
public class PoemNarrationViewModel
public class RecitationViewModel
{
/// <summary>
/// parameterless constructor for deserialization support
/// </summary>
public PoemNarrationViewModel()
public RecitationViewModel()
{
}
@ -24,7 +24,7 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
/// <param name="src"></param>
/// <param name="owner"></param>
/// <param name="poem"></param>
public PoemNarrationViewModel(PoemNarration src, RAppUser owner, GanjoorPoem poem)
public RecitationViewModel(Recitation src, RAppUser owner, GanjoorPoem poem)
{
Id = src.Id;
Owner = new PublicRAppUser(owner);

View File

@ -6,12 +6,12 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
/// <summary>
/// UserNarrationProfile View Model
/// </summary>
public class UserNarrationProfileViewModel
public class UserRecitationProfileViewModel
{
/// <summary>
/// parameterless constructor
/// </summary>
public UserNarrationProfileViewModel()
public UserRecitationProfileViewModel()
{
}
@ -19,7 +19,7 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
/// constructor
/// </summary>
/// <param name="src"></param>
public UserNarrationProfileViewModel(UserNarrationProfile src)
public UserRecitationProfileViewModel(UserRecitationProfile src)
{
Id = src.Id;
User = src.User == null ? null : new PublicRAppUser(src.User);

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ namespace RMuseum.Services
/// <summary>
/// Audio Narration Service
/// </summary>
public interface IAudioNarrationService
public interface IRecitationService
{
/// <summary>
/// returns list of narrations
@ -21,21 +21,21 @@ namespace RMuseum.Services
/// <param name="filteredUserId">send Guid.Empty if you want all narrations</param>
/// <param name="status"></param>
/// <returns></returns>
public Task<RServiceResult<(PaginationMetadata PagingMeta, PoemNarrationViewModel[] Items)>> GetAll(PagingParameterModel paging, Guid filteredUserId, AudioReviewStatus status);
public Task<RServiceResult<(PaginationMetadata PagingMeta, RecitationViewModel[] Items)>> GetAll(PagingParameterModel paging, Guid filteredUserId, AudioReviewStatus status);
/// <summary>
/// return selected narration information
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<RServiceResult<PoemNarrationViewModel>> Get(int id);
Task<RServiceResult<RecitationViewModel>> Get(int id);
/// <summary>
/// Gets Verse Sync Range Information
/// </summary>
/// <param name="id">narration id</param>
/// <returns></returns>
Task<RServiceResult<NarrationVerseSync[]>> GetPoemNarrationVerseSyncArray(int id);
Task<RServiceResult<RecitationVerseSync[]>> GetPoemNarrationVerseSyncArray(int id);
/// <summary>
/// updates metadata for narration
@ -43,7 +43,7 @@ namespace RMuseum.Services
/// <param name="id"></param>
/// <param name="metadata"></param>
/// <returns></returns>
Task<RServiceResult<PoemNarrationViewModel>> UpdatePoemNarration(int id, PoemNarrationViewModel metadata);
Task<RServiceResult<RecitationViewModel>> UpdatePoemNarration(int id, RecitationViewModel metadata);
/// <summary>
/// imports narration data from ganjoor MySql database
@ -88,7 +88,7 @@ namespace RMuseum.Services
/// <param name="moderatorId"></param>
/// <param name="model"></param>
/// <returns></returns>
Task<RServiceResult<PoemNarrationViewModel>> ModeratePoemNarration(int id, Guid moderatorId, PoemNarrationModerateViewModel model);
Task<RServiceResult<RecitationViewModel>> ModeratePoemNarration(int id, Guid moderatorId, RecitationModerateViewModel model);
/// <summary>
/// Get Upload Session (including files)
@ -102,21 +102,21 @@ namespace RMuseum.Services
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
Task<RServiceResult<UserNarrationProfileViewModel[]>> GetUserNarrationProfiles(Guid userId);
Task<RServiceResult<UserRecitationProfileViewModel[]>> GetUserNarrationProfiles(Guid userId);
/// <summary>
/// Add a narration profile
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
Task<RServiceResult<UserNarrationProfileViewModel>> AddUserNarrationProfiles(UserNarrationProfileViewModel profile);
Task<RServiceResult<UserRecitationProfileViewModel>> AddUserNarrationProfiles(UserRecitationProfileViewModel profile);
/// <summary>
/// Update a narration profile
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
Task<RServiceResult<UserNarrationProfileViewModel>> UpdateUserNarrationProfiles(UserNarrationProfileViewModel profile);
Task<RServiceResult<UserRecitationProfileViewModel>> UpdateUserNarrationProfiles(UserRecitationProfileViewModel profile);
/// <summary>
/// Delete a narration profile
@ -146,6 +146,6 @@ namespace RMuseum.Services
/// <param name="inProgress"></param>
/// <param name="finished"></param>
/// <returns></returns>
Task<RServiceResult<(PaginationMetadata PagingMeta, NarrationPublishingTracker[] Items)>> GetPublishingQueueStatus(PagingParameterModel paging, bool inProgress, bool finished);
Task<RServiceResult<(PaginationMetadata PagingMeta, RecitationPublishingTracker[] Items)>> GetPublishingQueueStatus(PagingParameterModel paging, bool inProgress, bool finished);
}
}

View File

@ -28,7 +28,7 @@ namespace RMuseum.Services.Implementation
/// <summary>
/// Audio Narration Service Implementation
/// </summary>
public class AudioNarrationService : IAudioNarrationService
public class RecitationService : IRecitationService
{
@ -41,13 +41,13 @@ namespace RMuseum.Services.Implementation
/// <param name="filteredUserId">send Guid.Empty if you want all narrations</param>
/// <param name="status"></param>
/// <returns></returns>
public async Task<RServiceResult<(PaginationMetadata PagingMeta, PoemNarrationViewModel[] Items)>> GetAll(PagingParameterModel paging, Guid filteredUserId, AudioReviewStatus status)
public async Task<RServiceResult<(PaginationMetadata PagingMeta, RecitationViewModel[] Items)>> GetAll(PagingParameterModel paging, Guid filteredUserId, AudioReviewStatus status)
{
try
{
//whenever I had not a reference to audio.Owner in the final selection it became null, so this strange arrangement is not all because of my stupidity!
var source =
from audio in _context.AudioFiles
from audio in _context.Recitations
.Include(a => a.Owner)
.Where(a =>
(filteredUserId == Guid.Empty || a.OwnerId == filteredUserId)
@ -57,16 +57,16 @@ namespace RMuseum.Services.Implementation
.OrderByDescending(a => a.UploadDate)
join poem in _context.GanjoorPoems
on audio.GanjoorPostId equals poem.Id
select new PoemNarrationViewModel(audio, audio.Owner, poem);
select new RecitationViewModel(audio, audio.Owner, poem);
(PaginationMetadata PagingMeta, PoemNarrationViewModel[] Items) paginatedResult =
await QueryablePaginator<PoemNarrationViewModel>.Paginate(source, paging);
(PaginationMetadata PagingMeta, RecitationViewModel[] Items) paginatedResult =
await QueryablePaginator<RecitationViewModel>.Paginate(source, paging);
return new RServiceResult<(PaginationMetadata PagingMeta, PoemNarrationViewModel[] Items)>(paginatedResult);
return new RServiceResult<(PaginationMetadata PagingMeta, RecitationViewModel[] Items)>(paginatedResult);
}
catch (Exception exp)
{
return new RServiceResult<(PaginationMetadata PagingMeta, PoemNarrationViewModel[] Items)>((PagingMeta: null, Items: null), exp.ToString());
return new RServiceResult<(PaginationMetadata PagingMeta, RecitationViewModel[] Items)>((PagingMeta: null, Items: null), exp.ToString());
}
}
@ -75,25 +75,25 @@ namespace RMuseum.Services.Implementation
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<RServiceResult<PoemNarrationViewModel>> Get(int id)
public async Task<RServiceResult<RecitationViewModel>> Get(int id)
{
try
{
//whenever I had not a reference to audio.Owner in the final selection it became null, so this strange arrangement is not all because of my stupidity!
var source =
from audio in _context.AudioFiles
from audio in _context.Recitations
.Include(a => a.Owner)
.Where(a => a.Id == id)
join poem in _context.GanjoorPoems
on audio.GanjoorPostId equals poem.Id
select new PoemNarrationViewModel(audio, audio.Owner, poem);
select new RecitationViewModel(audio, audio.Owner, poem);
var narration = await source.SingleOrDefaultAsync();
return new RServiceResult<PoemNarrationViewModel>(narration);
return new RServiceResult<RecitationViewModel>(narration);
}
catch (Exception exp)
{
return new RServiceResult<PoemNarrationViewModel>(null, exp.ToString());
return new RServiceResult<RecitationViewModel>(null, exp.ToString());
}
}
@ -102,16 +102,16 @@ namespace RMuseum.Services.Implementation
/// </summary>
/// <param name="id">narration id</param>
/// <returns></returns>
public async Task<RServiceResult<NarrationVerseSync[]>> GetPoemNarrationVerseSyncArray(int id)
public async Task<RServiceResult<RecitationVerseSync[]>> GetPoemNarrationVerseSyncArray(int id)
{
try
{
var narration = await _context.AudioFiles.Where(a => a.Id == id).SingleOrDefaultAsync();
var narration = await _context.Recitations.Where(a => a.Id == id).SingleOrDefaultAsync();
var verses = await _context.GanjoorVerses.Where(v => v.PoemId == narration.GanjoorPostId).OrderBy(v => v.VOrder).ToListAsync();
string xml = File.ReadAllText(narration.LocalXmlFilePath);
List<NarrationVerseSync> verseSyncs = new List<NarrationVerseSync>();
List<RecitationVerseSync> verseSyncs = new List<RecitationVerseSync>();
XElement elObject = XDocument.Parse(xml).Root;
foreach (var syncInfo in elObject.Element("PoemAudio").Element("SyncArray").Elements("SyncInfo"))
@ -123,7 +123,7 @@ namespace RMuseum.Services.Implementation
var verse = verses.Where(v => v.VOrder == verseOrder).SingleOrDefault();
if(verse != null)
{
verseSyncs.Add(new NarrationVerseSync()
verseSyncs.Add(new RecitationVerseSync()
{
VerseOrder = verseOrder,
VerseText = verse.Text,
@ -132,11 +132,11 @@ namespace RMuseum.Services.Implementation
}
}
return new RServiceResult<NarrationVerseSync[]>(verseSyncs.ToArray());
return new RServiceResult<RecitationVerseSync[]>(verseSyncs.ToArray());
}
catch (Exception exp)
{
return new RServiceResult<NarrationVerseSync[]>(null, exp.ToString());
return new RServiceResult<RecitationVerseSync[]>(null, exp.ToString());
}
}
@ -145,7 +145,7 @@ namespace RMuseum.Services.Implementation
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
private static string GetPoemNarrationValidationError(PoemNarrationViewModel p)
private static string GetPoemNarrationValidationError(RecitationViewModel p)
{
if (p.AudioArtist.Length < 3)
{
@ -190,7 +190,7 @@ namespace RMuseum.Services.Implementation
/// <param name="id"></param>
/// <param name="metadata"></param>
/// <returns></returns>
public async Task<RServiceResult<PoemNarrationViewModel>> UpdatePoemNarration(int id, PoemNarrationViewModel metadata)
public async Task<RServiceResult<RecitationViewModel>> UpdatePoemNarration(int id, RecitationViewModel metadata)
{
try
{
@ -204,25 +204,25 @@ namespace RMuseum.Services.Implementation
string err = GetPoemNarrationValidationError(metadata);
if(!string.IsNullOrEmpty(err))
{
return new RServiceResult<PoemNarrationViewModel>(null, err);
return new RServiceResult<RecitationViewModel>(null, err);
}
PoemNarration narration = await _context.AudioFiles.Include(a => a.Owner).Where(a => a.Id == id).SingleOrDefaultAsync();
Recitation narration = await _context.Recitations.Include(a => a.Owner).Where(a => a.Id == id).SingleOrDefaultAsync();
if(narration == null)
return new RServiceResult<PoemNarrationViewModel>(null, "404");
return new RServiceResult<RecitationViewModel>(null, "404");
narration.AudioTitle = metadata.AudioTitle;
narration.AudioArtist = metadata.AudioArtist;
narration.AudioArtistUrl = metadata.AudioArtistUrl;
narration.AudioSrc = metadata.AudioSrc;
narration.AudioSrcUrl = metadata.AudioSrcUrl;
narration.ReviewStatus = metadata.ReviewStatus;
_context.AudioFiles.Update(narration);
_context.Recitations.Update(narration);
await _context.SaveChangesAsync();
return new RServiceResult<PoemNarrationViewModel>(new PoemNarrationViewModel(narration, narration.Owner, await _context.GanjoorPoems.Where(p => p.Id == narration.GanjoorPostId).SingleOrDefaultAsync()));
return new RServiceResult<RecitationViewModel>(new RecitationViewModel(narration, narration.Owner, await _context.GanjoorPoems.Where(p => p.Id == narration.GanjoorPostId).SingleOrDefaultAsync()));
}
catch (Exception exp)
{
return new RServiceResult<PoemNarrationViewModel>(null, exp.ToString());
return new RServiceResult<RecitationViewModel>(null, exp.ToString());
}
}
@ -235,7 +235,7 @@ namespace RMuseum.Services.Implementation
{
try
{
PoemNarration sampleCheck = await _context.AudioFiles.FirstOrDefaultAsync();
Recitation sampleCheck = await _context.Recitations.FirstOrDefaultAsync();
if(sampleCheck != null)
{
return new RServiceResult<bool>(false, "OneTimeImport is a one time operation and cannot be called multiple times.");
@ -267,7 +267,7 @@ namespace RMuseum.Services.Implementation
foreach (DataRow row in srcData.Rows)
{
PoemNarration newRecord = new PoemNarration()
Recitation newRecord = new Recitation()
{
OwnerId = ownerRAppUserId,
GanjoorAudioId = int.Parse(row["audio_ID"].ToString()),
@ -299,7 +299,7 @@ namespace RMuseum.Services.Implementation
newRecord.LocalMp3FilePath = Path.Combine(targetForAudioFile, $"{newRecord.FileNameWithoutExtension}.mp3");
newRecord.LocalXmlFilePath = Path.Combine(targetForXmlAudioFile, $"{newRecord.FileNameWithoutExtension}.xml");
_context.AudioFiles.Add(newRecord);
_context.Recitations.Add(newRecord);
await _context.SaveChangesAsync(); //this logically should be outside this loop,
//but it messes with the order of records so I decided
//to wait a little longer and have an ordered set of records
@ -328,11 +328,11 @@ namespace RMuseum.Services.Implementation
{
try
{
List<UserNarrationProfile> profiles =
await _context.AudioFiles
List<UserRecitationProfile> profiles =
await _context.Recitations
.GroupBy(audio => new { audio.AudioArtist, audio.AudioArtistUrl, audio.AudioSrc, audio.AudioSrcUrl })
.OrderByDescending(g => g.Count())
.Select(g => new UserNarrationProfile()
.Select(g => new UserRecitationProfile()
{
UserId = ownerRAppUserId,
ArtistName = g.Key.AudioArtist,
@ -342,10 +342,10 @@ namespace RMuseum.Services.Implementation
IsDefault = false
}
).ToListAsync();
foreach(UserNarrationProfile profile in profiles)
foreach(UserRecitationProfile profile in profiles)
{
PoemNarration narration =
await _context.AudioFiles.Where(audio =>
Recitation narration =
await _context.Recitations.Where(audio =>
audio.AudioArtist == profile.ArtistName
&&
audio.AudioArtistUrl == profile.ArtistUrl
@ -384,12 +384,12 @@ namespace RMuseum.Services.Implementation
profile.FileSuffixWithoutDash = ext;
profile.Name = profile.ArtistName;
int pIndex = 1;
while((await _context.UserNarrationProfiles.Where(p => p.UserId == ownerRAppUserId && p.Name == profile.Name).SingleOrDefaultAsync())!=null)
while((await _context.UserRecitationProfiles.Where(p => p.UserId == ownerRAppUserId && p.Name == profile.Name).SingleOrDefaultAsync())!=null)
{
pIndex++;
profile.Name = $"{profile.ArtistName} {GPersianTextSync.Sync(pIndex.ToString())}";
}
_context.UserNarrationProfiles.Add(profile);
_context.UserRecitationProfiles.Add(profile);
await _context.SaveChangesAsync(); //this logically should be outside this loop,
//but it messes with the order of records so I decided
//to wait a little longer and have an ordered set of records
@ -411,7 +411,7 @@ namespace RMuseum.Services.Implementation
{
try
{
UserNarrationProfile defProfile = await _context.UserNarrationProfiles.Where(p => p.UserId == userId && p.IsDefault == true).FirstOrDefaultAsync();
UserRecitationProfile defProfile = await _context.UserRecitationProfiles.Where(p => p.UserId == userId && p.IsDefault == true).FirstOrDefaultAsync();
if (defProfile == null)
{
return new RServiceResult<UploadSession>(null, "نمایهٔ پیش‌فرض شما مشخص نیست. لطفا پیش از ارسال خوانش نمایهٔ پیش‌فرض خود را تعریف کنید.");
@ -541,7 +541,7 @@ namespace RMuseum.Services.Implementation
}
}
UserNarrationProfile defProfile = await context.UserNarrationProfiles.Where(p => p.UserId == session.UseId && p.IsDefault == true).FirstOrDefaultAsync(); //this should not be null
UserRecitationProfile defProfile = await context.UserRecitationProfiles.Where(p => p.UserId == session.UseId && p.IsDefault == true).FirstOrDefaultAsync(); //this should not be null
foreach (UploadSessionFile file in session.UploadedFiles.Where(file => Path.GetExtension(file.FilePath) == ".xml").ToList())
{
@ -553,7 +553,7 @@ namespace RMuseum.Services.Implementation
//the code would fail!
foreach (PoemAudio audio in PoemAudioListProcessor.Load(file.FilePath))
{
if( await context.AudioFiles.Where(a => a.Mp3FileCheckSum == audio.FileCheckSum).SingleOrDefaultAsync() != null)
if( await context.Recitations.Where(a => a.Mp3FileCheckSum == audio.FileCheckSum).SingleOrDefaultAsync() != null)
{
session.UploadedFiles.Where(f => f.Id == file.Id).SingleOrDefault().ProcessResultMsg = "فایل صوتیی همسان با فایل ارسالی پیشتر آپلود شده است.";
context.UploadSessions.Update(session);
@ -608,19 +608,19 @@ namespace RMuseum.Services.Implementation
Guid legacyAudioGuid = audio.SyncGuid;
while (
(await context.AudioFiles.Where(a => a.LegacyAudioGuid == legacyAudioGuid).FirstOrDefaultAsync()) != null
(await context.Recitations.Where(a => a.LegacyAudioGuid == legacyAudioGuid).FirstOrDefaultAsync()) != null
)
{
legacyAudioGuid = Guid.NewGuid();
}
PoemNarration narration = new PoemNarration()
Recitation narration = new Recitation()
{
GanjoorPostId = audio.PoemId,
OwnerId = session.UseId,
GanjoorAudioId = 1 + await context.AudioFiles.OrderByDescending(a => a.GanjoorAudioId).Select(a => a.GanjoorAudioId).FirstOrDefaultAsync(),
AudioOrder = 1 + await context.AudioFiles.Where(a => a.GanjoorPostId == audio.PoemId).OrderByDescending(a => a.GanjoorAudioId).Select(a => a.GanjoorAudioId).FirstOrDefaultAsync(),
GanjoorAudioId = 1 + await context.Recitations.OrderByDescending(a => a.GanjoorAudioId).Select(a => a.GanjoorAudioId).FirstOrDefaultAsync(),
AudioOrder = 1 + await context.Recitations.Where(a => a.GanjoorPostId == audio.PoemId).OrderByDescending(a => a.GanjoorAudioId).Select(a => a.GanjoorAudioId).FirstOrDefaultAsync(),
FileNameWithoutExtension = fileNameWithoutExtension,
SoundFilesFolder = currentTargetFolder,
AudioTitle = string.IsNullOrEmpty(audio.PoemTitle) ? audio.Description : audio.PoemTitle,
@ -652,7 +652,7 @@ namespace RMuseum.Services.Implementation
context.AudioFiles.Add(narration);
context.Recitations.Add(narration);
session.UploadedFiles.Where(f => f.Id == file.Id).SingleOrDefault().ProcessResultMsg = "";
@ -731,15 +731,15 @@ namespace RMuseum.Services.Implementation
/// <param name="moderatorId"></param>
/// <param name="model"></param>
/// <returns></returns>
public async Task<RServiceResult<PoemNarrationViewModel>> ModeratePoemNarration(int id, Guid moderatorId, PoemNarrationModerateViewModel model)
public async Task<RServiceResult<RecitationViewModel>> ModeratePoemNarration(int id, Guid moderatorId, RecitationModerateViewModel model)
{
try
{
PoemNarration narration = await _context.AudioFiles.Include(a => a.Owner).Where(a => a.Id == id).SingleOrDefaultAsync();
Recitation narration = await _context.Recitations.Include(a => a.Owner).Where(a => a.Id == id).SingleOrDefaultAsync();
if (narration == null)
return new RServiceResult<PoemNarrationViewModel>(null, "404");
return new RServiceResult<RecitationViewModel>(null, "404");
if (narration.ReviewStatus != AudioReviewStatus.Draft && narration.ReviewStatus != AudioReviewStatus.Pending)
return new RServiceResult<PoemNarrationViewModel>(null, "خوانش می‌بایست در وضعیت پیش‌نویس یا در انتظار بازبینی باشد.");
return new RServiceResult<RecitationViewModel>(null, "خوانش می‌بایست در وضعیت پیش‌نویس یا در انتظار بازبینی باشد.");
narration.ReviewDate = DateTime.Now;
narration.ReviewerId = moderatorId;
if(model.Result != PoemNarrationModerationResult.MetadataNeedsFixation)
@ -752,7 +752,7 @@ namespace RMuseum.Services.Implementation
//TODO: delete rejected items files passed a certain period of time in a maintenance job
}
narration.ReviewMsg = model.Message;
_context.AudioFiles.Update(narration);
_context.Recitations.Update(narration);
await _context.SaveChangesAsync();
if (model.Result == PoemNarrationModerationResult.MetadataNeedsFixation)
@ -792,19 +792,19 @@ namespace RMuseum.Services.Implementation
return new RServiceResult<PoemNarrationViewModel>(new PoemNarrationViewModel(narration, narration.Owner, await _context.GanjoorPoems.Where(p => p.Id == narration.GanjoorPostId).SingleOrDefaultAsync()));
return new RServiceResult<RecitationViewModel>(new RecitationViewModel(narration, narration.Owner, await _context.GanjoorPoems.Where(p => p.Id == narration.GanjoorPostId).SingleOrDefaultAsync()));
}
catch (Exception exp)
{
return new RServiceResult<PoemNarrationViewModel>(null, exp.ToString());
return new RServiceResult<RecitationViewModel>(null, exp.ToString());
}
}
private async Task _PublishNarration(PoemNarration narration, RMuseumDbContext context)
private async Task _PublishNarration(Recitation narration, RMuseumDbContext context)
{
NarrationPublishingTracker tracker = new NarrationPublishingTracker()
RecitationPublishingTracker tracker = new RecitationPublishingTracker()
{
PoemNarrationId = narration.Id,
StartDate = DateTime.Now,
@ -813,7 +813,7 @@ namespace RMuseum.Services.Implementation
FirstDbUpdated = false,
SecondDbUpdated = false,
};
context.NarrationPublishingTrackers.Add(tracker);
context.RecitationPublishingTrackers.Add(tracker);
await context.SaveChangesAsync();
using var client = new SftpClient
@ -831,14 +831,14 @@ namespace RMuseum.Services.Implementation
client.UploadFile(x, $"{Configuration.GetSection("AudioSFPServer")["RootPath"]}{narration.RemoteXMLFilePath}", true);
tracker.XmlFileCopied = true;
context.NarrationPublishingTrackers.Update(tracker);
context.RecitationPublishingTrackers.Update(tracker);
await context.SaveChangesAsync();
using var s = File.OpenRead(narration.LocalMp3FilePath);
client.UploadFile(s, $"{Configuration.GetSection("AudioSFPServer")["RootPath"]}{narration.RemoteMp3FilePath}", true);
tracker.Mp3FileCopied = true;
context.NarrationPublishingTrackers.Update(tracker);
context.RecitationPublishingTrackers.Update(tracker);
await context.SaveChangesAsync();
string sql = $"INSERT INTO ganja_gaudio (audio_post_ID,audio_order,audio_xml,audio_ogg,audio_mp3,audio_title,audio_artist," +
@ -856,7 +856,7 @@ namespace RMuseum.Services.Implementation
}
tracker.FirstDbUpdated = true;
context.NarrationPublishingTrackers.Update(tracker);
context.RecitationPublishingTrackers.Update(tracker);
await context.SaveChangesAsync();
//We are using two database for different purposes on the remote
@ -870,11 +870,11 @@ namespace RMuseum.Services.Implementation
}
tracker.SecondDbUpdated = true;
context.NarrationPublishingTrackers.Update(tracker);
context.RecitationPublishingTrackers.Update(tracker);
await context.SaveChangesAsync();
narration.AudioSyncStatus = (int)AudioSyncStatus.SynchronizedOrRejected;
context.AudioFiles.Update(narration);
context.Recitations.Update(narration);
await context.SaveChangesAsync();
@ -889,7 +889,7 @@ namespace RMuseum.Services.Implementation
tracker.Finished = true;
tracker.FinishDate = DateTime.Now;
context.NarrationPublishingTrackers.Update(tracker);
context.RecitationPublishingTrackers.Update(tracker);
await context.SaveChangesAsync();
@ -898,7 +898,7 @@ namespace RMuseum.Services.Implementation
{
//if an error occurs, narration.AudioSyncStatus is not updated and narration can be idetified later to do "retrypublish" attempts
tracker.LastException = exp.ToString();
context.NarrationPublishingTrackers.Update(tracker);
context.RecitationPublishingTrackers.Update(tracker);
await context.SaveChangesAsync();
}
finally
@ -918,8 +918,8 @@ namespace RMuseum.Services.Implementation
{
using (RMuseumDbContext context = new RMuseumDbContext(Configuration)) //this is long running job, so _context might be already been freed/collected by GC
{
var list = await context.AudioFiles.Where(a => a.ReviewStatus == AudioReviewStatus.Approved && a.AudioSyncStatus != (int)AudioSyncStatus.SynchronizedOrRejected).ToListAsync();
foreach (PoemNarration narration in list)
var list = await context.Recitations.Where(a => a.ReviewStatus == AudioReviewStatus.Approved && a.AudioSyncStatus != (int)AudioSyncStatus.SynchronizedOrRejected).ToListAsync();
foreach (Recitation narration in list)
{
await _PublishNarration(narration, context);
}
@ -954,22 +954,22 @@ namespace RMuseum.Services.Implementation
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<RServiceResult<UserNarrationProfileViewModel[]>> GetUserNarrationProfiles(Guid userId)
public async Task<RServiceResult<UserRecitationProfileViewModel[]>> GetUserNarrationProfiles(Guid userId)
{
try
{
List<UserNarrationProfileViewModel> profiles = new List<UserNarrationProfileViewModel>();
List<UserRecitationProfileViewModel> profiles = new List<UserRecitationProfileViewModel>();
foreach(UserNarrationProfile p in (await _context.UserNarrationProfiles.Include(p => p.User).Where(p => p.UserId == userId).ToArrayAsync()))
foreach(UserRecitationProfile p in (await _context.UserRecitationProfiles.Include(p => p.User).Where(p => p.UserId == userId).ToArrayAsync()))
{
profiles.Add(new UserNarrationProfileViewModel(p));
profiles.Add(new UserRecitationProfileViewModel(p));
}
return new RServiceResult<UserNarrationProfileViewModel[]>(profiles.ToArray());
return new RServiceResult<UserRecitationProfileViewModel[]>(profiles.ToArray());
}
catch (Exception exp)
{
return new RServiceResult<UserNarrationProfileViewModel[]>(null, exp.ToString());
return new RServiceResult<UserRecitationProfileViewModel[]>(null, exp.ToString());
}
}
@ -978,7 +978,7 @@ namespace RMuseum.Services.Implementation
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
private static string GetUserProfileValidationError(UserNarrationProfile p)
private static string GetUserProfileValidationError(UserRecitationProfile p)
{
if(string.IsNullOrEmpty(p.Name))
{
@ -1048,11 +1048,11 @@ namespace RMuseum.Services.Implementation
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
public async Task<RServiceResult<UserNarrationProfileViewModel>> AddUserNarrationProfiles(UserNarrationProfileViewModel profile)
public async Task<RServiceResult<UserRecitationProfileViewModel>> AddUserNarrationProfiles(UserRecitationProfileViewModel profile)
{
try
{
var p = new UserNarrationProfile()
var p = new UserRecitationProfile()
{
UserId = profile.UserId,
Name = profile.Name.Trim(),
@ -1067,31 +1067,31 @@ namespace RMuseum.Services.Implementation
string error = GetUserProfileValidationError(p);
if(error != "")
{
return new RServiceResult<UserNarrationProfileViewModel>(null, error);
return new RServiceResult<UserRecitationProfileViewModel>(null, error);
}
if((await _context.UserNarrationProfiles.Where(e => e.UserId == p.Id && e.Name == p.Name).SingleOrDefaultAsync())!=null)
if((await _context.UserRecitationProfiles.Where(e => e.UserId == p.Id && e.Name == p.Name).SingleOrDefaultAsync())!=null)
{
return new RServiceResult<UserNarrationProfileViewModel>(null, "شما نمایهٔ دیگری با همین نام دارید.");
return new RServiceResult<UserRecitationProfileViewModel>(null, "شما نمایهٔ دیگری با همین نام دارید.");
}
await _context.UserNarrationProfiles.AddAsync(p);
await _context.UserRecitationProfiles.AddAsync(p);
await _context.SaveChangesAsync();
if(p.IsDefault)
{
foreach(var o in _context.UserNarrationProfiles.Where(o => o.Id != p.Id && o.IsDefault).Select(o => o))
foreach(var o in _context.UserRecitationProfiles.Where(o => o.Id != p.Id && o.IsDefault).Select(o => o))
{
o.IsDefault = false;
_context.UserNarrationProfiles.Update(o);
_context.UserRecitationProfiles.Update(o);
}
await _context.SaveChangesAsync();
}
return new RServiceResult<UserNarrationProfileViewModel>(new UserNarrationProfileViewModel(p));
return new RServiceResult<UserRecitationProfileViewModel>(new UserRecitationProfileViewModel(p));
}
catch (Exception exp)
{
return new RServiceResult<UserNarrationProfileViewModel>(null, exp.ToString());
return new RServiceResult<UserRecitationProfileViewModel>(null, exp.ToString());
}
}
@ -1100,15 +1100,15 @@ namespace RMuseum.Services.Implementation
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
public async Task<RServiceResult<UserNarrationProfileViewModel>> UpdateUserNarrationProfiles(UserNarrationProfileViewModel profile)
public async Task<RServiceResult<UserRecitationProfileViewModel>> UpdateUserNarrationProfiles(UserRecitationProfileViewModel profile)
{
try
{
var p = await _context.UserNarrationProfiles.Where(p => p.Id == profile.Id).SingleOrDefaultAsync();
var p = await _context.UserRecitationProfiles.Where(p => p.Id == profile.Id).SingleOrDefaultAsync();
if (p.UserId != profile.UserId)
return new RServiceResult<UserNarrationProfileViewModel>(null, "permission error");
return new RServiceResult<UserRecitationProfileViewModel>(null, "permission error");
p.Name = profile.Name.Trim();
p.ArtistName = profile.ArtistName.Trim();
@ -1121,31 +1121,31 @@ namespace RMuseum.Services.Implementation
string error = GetUserProfileValidationError(p);
if (error != "")
{
return new RServiceResult<UserNarrationProfileViewModel>(null, error);
return new RServiceResult<UserRecitationProfileViewModel>(null, error);
}
if ((await _context.UserNarrationProfiles.Where(e => e.UserId == p.Id && e.Name == p.Name && e.Id != p.Id).SingleOrDefaultAsync()) != null)
if ((await _context.UserRecitationProfiles.Where(e => e.UserId == p.Id && e.Name == p.Name && e.Id != p.Id).SingleOrDefaultAsync()) != null)
{
return new RServiceResult<UserNarrationProfileViewModel>(null, "شما نمایهٔ دیگری با همین نام دارید.");
return new RServiceResult<UserRecitationProfileViewModel>(null, "شما نمایهٔ دیگری با همین نام دارید.");
}
_context.UserNarrationProfiles.Update(p);
_context.UserRecitationProfiles.Update(p);
await _context.SaveChangesAsync();
if (p.IsDefault)
{
foreach (var o in _context.UserNarrationProfiles.Where(o => o.Id != p.Id && o.IsDefault).Select(o => o))
foreach (var o in _context.UserRecitationProfiles.Where(o => o.Id != p.Id && o.IsDefault).Select(o => o))
{
o.IsDefault = false;
_context.UserNarrationProfiles.Update(o);
_context.UserRecitationProfiles.Update(o);
}
await _context.SaveChangesAsync();
}
return new RServiceResult<UserNarrationProfileViewModel>(new UserNarrationProfileViewModel(p));
return new RServiceResult<UserRecitationProfileViewModel>(new UserRecitationProfileViewModel(p));
}
catch (Exception exp)
{
return new RServiceResult<UserNarrationProfileViewModel>(null, exp.ToString());
return new RServiceResult<UserRecitationProfileViewModel>(null, exp.ToString());
}
}
@ -1160,12 +1160,12 @@ namespace RMuseum.Services.Implementation
try
{
var p = await _context.UserNarrationProfiles.Where(p => p.Id == id).SingleOrDefaultAsync();
var p = await _context.UserRecitationProfiles.Where(p => p.Id == id).SingleOrDefaultAsync();
if (p.UserId != userId)
return new RServiceResult<bool>(false);
_context.UserNarrationProfiles.Remove(p);
_context.UserRecitationProfiles.Remove(p);
await _context.SaveChangesAsync();
@ -1218,12 +1218,12 @@ namespace RMuseum.Services.Implementation
/// <param name="inProgress"></param>
/// <param name="finished"></param>
/// <returns></returns>
public async Task<RServiceResult<(PaginationMetadata PagingMeta, NarrationPublishingTracker[] Items)>> GetPublishingQueueStatus(PagingParameterModel paging, bool inProgress, bool finished)
public async Task<RServiceResult<(PaginationMetadata PagingMeta, RecitationPublishingTracker[] Items)>> GetPublishingQueueStatus(PagingParameterModel paging, bool inProgress, bool finished)
{
try
{
var source =
from tracker in _context.NarrationPublishingTrackers
from tracker in _context.RecitationPublishingTrackers
.Include(t => t.PoemNarration)
.Where(a =>
(inProgress && !a.Finished)
@ -1233,14 +1233,14 @@ namespace RMuseum.Services.Implementation
.OrderByDescending(a => a.StartDate)
select tracker;
(PaginationMetadata PagingMeta, NarrationPublishingTracker[] Items) paginatedResult =
await QueryablePaginator<NarrationPublishingTracker>.Paginate(source, paging);
(PaginationMetadata PagingMeta, RecitationPublishingTracker[] Items) paginatedResult =
await QueryablePaginator<RecitationPublishingTracker>.Paginate(source, paging);
return new RServiceResult<(PaginationMetadata PagingMeta, NarrationPublishingTracker[] Items)>(paginatedResult);
return new RServiceResult<(PaginationMetadata PagingMeta, RecitationPublishingTracker[] Items)>(paginatedResult);
}
catch (Exception exp)
{
return new RServiceResult<(PaginationMetadata PagingMeta, NarrationPublishingTracker[] Items)>((PagingMeta: null, Items: null), exp.ToString());
return new RServiceResult<(PaginationMetadata PagingMeta, RecitationPublishingTracker[] Items)>((PagingMeta: null, Items: null), exp.ToString());
}
}
@ -1272,7 +1272,7 @@ namespace RMuseum.Services.Implementation
/// <param name="configuration"></param>
/// <param name="backgroundTaskQueue"></param>
/// <param name="notificationService"></param>
public AudioNarrationService(RMuseumDbContext context, IConfiguration configuration, IBackgroundTaskQueue backgroundTaskQueue, IRNotificationService notificationService)
public RecitationService(RMuseumDbContext context, IConfiguration configuration, IBackgroundTaskQueue backgroundTaskQueue, IRNotificationService notificationService)
{
_context = context;
Configuration = configuration;

View File

@ -253,7 +253,7 @@ namespace RMuseum
services.AddTransient<IArtifactService, ArtifactService>();
//audio service
services.AddTransient<IAudioNarrationService, AudioNarrationService>();
services.AddTransient<IRecitationService, RecitationService>();
//ganjoor service
services.AddTransient<IGanjoorService, GanjoorService>();