diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs new file mode 100644 index 00000000..a581770a --- /dev/null +++ b/RMuseum/Controllers/GanjoorController.cs @@ -0,0 +1,48 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using RMuseum.Models.Auth.Memory; +using RMuseum.Services; +using RSecurityBackend.Models.Generic; +using System.Net; +using System.Threading.Tasks; + +namespace RMuseum.Controllers +{ + [Produces("application/json")] + [Route("api/ganjoor")] + public class GanjoorController : Controller + { + /// + /// imports data from ganjoor SQLite database + /// + /// + [HttpPost] + [Route("sqliteimport")] + [Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.ImportOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public async Task ImportLocalSQLiteDb() + { + RServiceResult res = + await _ganjoorService.ImportLocalSQLiteDb(); + if (res.Result) + return Ok(); + return BadRequest(res.ExceptionString); + } + + /// + /// Ganjoor Service + /// + + protected readonly IGanjoorService _ganjoorService; + + /// + /// constructor + /// + /// + public GanjoorController(IGanjoorService ganjoorService) + { + _ganjoorService = ganjoorService; + } + } +} diff --git a/RMuseum/Migrations/20201022150541_GanjoorStructures.Designer.cs b/RMuseum/Migrations/20201022150541_GanjoorStructures.Designer.cs new file mode 100644 index 00000000..ef1dc0eb --- /dev/null +++ b/RMuseum/Migrations/20201022150541_GanjoorStructures.Designer.cs @@ -0,0 +1,1541 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using RMuseum.DbContext; + +namespace RMuseum.Migrations +{ + [DbContext(typeof(RMuseumDbContext))] + [Migration("20201022150541_GanjoorStructures")] + partial class GanjoorStructures + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("RMuseum.Models.Artifact.RArtifactItemRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CoverImageIndex") + .HasColumnType("int"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DescriptionInEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("FriendlyUrl") + .HasColumnType("nvarchar(450)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("NameInEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("RArtifactMasterRecordId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RArtifactMasterRecordId", "FriendlyUrl") + .IsUnique() + .HasFilter("[FriendlyUrl] IS NOT NULL"); + + b.HasIndex("RArtifactMasterRecordId", "Order") + .IsUnique(); + + b.ToTable("Items"); + }); + + modelBuilder.Entity("RMuseum.Models.Artifact.RArtifactMasterRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CoverImageId") + .HasColumnType("uniqueidentifier"); + + b.Property("CoverItemIndex") + .HasColumnType("int"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DescriptionInEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("FriendlyUrl") + .HasColumnType("nvarchar(450)"); + + b.Property("ItemCount") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("NameInEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CoverImageId"); + + b.HasIndex("FriendlyUrl") + .IsUnique() + .HasFilter("[FriendlyUrl] IS NOT NULL"); + + b.ToTable("Artifacts"); + }); + + modelBuilder.Entity("RMuseum.Models.Artifact.RTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("FriendlyUrl") + .HasColumnType("nvarchar(450)"); + + b.Property("GlobalValue") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("NameInEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("PluralName") + .HasColumnType("nvarchar(max)"); + + b.Property("PluralNameInEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TagType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FriendlyUrl"); + + b.ToTable("Tags"); + }); + + modelBuilder.Entity("RMuseum.Models.Artifact.RTagValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("FriendlyUrl") + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("RArtifactItemRecordId") + .HasColumnType("uniqueidentifier"); + + b.Property("RArtifactMasterRecordId") + .HasColumnType("uniqueidentifier"); + + b.Property("RTagId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.Property("ValueInEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("ValueSupplement") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("FriendlyUrl"); + + b.HasIndex("RArtifactItemRecordId"); + + b.HasIndex("RArtifactMasterRecordId"); + + b.HasIndex("RTagId"); + + b.ToTable("TagValues"); + }); + + modelBuilder.Entity("RMuseum.Models.Bookmark.RUserBookmark", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("Note") + .HasColumnType("nvarchar(max)"); + + b.Property("RAppUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("RArtifactItemRecordId") + .HasColumnType("uniqueidentifier"); + + b.Property("RArtifactMasterRecordId") + .HasColumnType("uniqueidentifier"); + + b.Property("RBookmarkType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RAppUserId"); + + b.HasIndex("RArtifactItemRecordId"); + + b.HasIndex("RArtifactMasterRecordId"); + + b.ToTable("UserBookmarks"); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCat", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("ParentId") + .HasColumnType("int"); + + b.Property("PoetId") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlSlug") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("PoetId"); + + b.ToTable("GanjoorCategories"); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorPoem", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("CatId") + .HasColumnType("int"); + + b.Property("FullTitle") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlSlug") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CatId"); + + b.ToTable("GanjoorPoems"); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorPoet", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("GanjoorPoets"); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorVerse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("PoemId") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("nvarchar(max)"); + + b.Property("VOrder") + .HasColumnType("int"); + + b.Property("VersePosition") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PoemId"); + + b.ToTable("GanjoorVerses"); + }); + + modelBuilder.Entity("RMuseum.Models.GanjoorAudio.PoemNarration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AudioArtist") + .HasColumnType("nvarchar(max)"); + + b.Property("AudioArtistUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("AudioOrder") + .HasColumnType("int"); + + b.Property("AudioSrc") + .HasColumnType("nvarchar(max)"); + + b.Property("AudioSrcUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("AudioSyncStatus") + .HasColumnType("int"); + + b.Property("AudioTitle") + .HasColumnType("nvarchar(max)"); + + b.Property("FileNameWithoutExtension") + .HasColumnType("nvarchar(max)"); + + b.Property("GanjoorAudioId") + .HasColumnType("int"); + + b.Property("GanjoorPostId") + .HasColumnType("int"); + + b.Property("LegacyAudioGuid") + .HasColumnType("uniqueidentifier"); + + b.Property("LocalMp3FilePath") + .HasColumnType("nvarchar(max)"); + + b.Property("LocalXmlFilePath") + .HasColumnType("nvarchar(max)"); + + b.Property("Mp3FileCheckSum") + .HasColumnType("nvarchar(max)"); + + b.Property("Mp3SizeInBytes") + .HasColumnType("int"); + + b.Property("OggSizeInBytes") + .HasColumnType("int"); + + b.Property("OwnerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ReviewDate") + .HasColumnType("datetime2"); + + b.Property("ReviewMsg") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewStatus") + .HasColumnType("int"); + + b.Property("ReviewerId") + .HasColumnType("uniqueidentifier"); + + b.Property("SoundFilesFolder") + .HasColumnType("nvarchar(max)"); + + b.Property("UploadDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ReviewerId"); + + b.ToTable("AudioFiles"); + }); + + modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserNarrationProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ArtistName") + .HasColumnType("nvarchar(max)"); + + b.Property("ArtistUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("AudioSrc") + .HasColumnType("nvarchar(max)"); + + b.Property("AudioSrcUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("FileSuffixWithoutDash") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserNarrationProfiles"); + }); + + modelBuilder.Entity("RMuseum.Models.GanjoorIntegration.GanjoorLink", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ArtifactId") + .HasColumnType("uniqueidentifier"); + + b.Property("GanjoorPostId") + .HasColumnType("int"); + + b.Property("GanjoorTitle") + .HasColumnType("nvarchar(max)"); + + b.Property("GanjoorUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("ItemId") + .HasColumnType("uniqueidentifier"); + + b.Property("ReviewDate") + .HasColumnType("datetime2"); + + b.Property("ReviewResult") + .HasColumnType("int"); + + b.Property("ReviewerId") + .HasColumnType("uniqueidentifier"); + + b.Property("SuggestedById") + .HasColumnType("uniqueidentifier"); + + b.Property("SuggestionDate") + .HasColumnType("datetime2"); + + b.Property("Synchronized") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("ArtifactId"); + + b.HasIndex("ItemId"); + + b.HasIndex("ReviewerId"); + + b.HasIndex("SuggestedById"); + + b.ToTable("GanjoorLinks"); + }); + + modelBuilder.Entity("RMuseum.Models.GanjoorIntegration.PinterestLink", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AltText") + .HasColumnType("nvarchar(max)"); + + b.Property("ArtifactId") + .HasColumnType("uniqueidentifier"); + + b.Property("GanjoorPostId") + .HasColumnType("int"); + + b.Property("GanjoorTitle") + .HasColumnType("nvarchar(max)"); + + b.Property("GanjoorUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("ItemId") + .HasColumnType("uniqueidentifier"); + + b.Property("LinkType") + .HasColumnType("int"); + + b.Property("PinterestImageUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("PinterestUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewDate") + .HasColumnType("datetime2"); + + b.Property("ReviewDesc") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewResult") + .HasColumnType("int"); + + b.Property("ReviewerId") + .HasColumnType("uniqueidentifier"); + + b.Property("SuggestedById") + .HasColumnType("uniqueidentifier"); + + b.Property("SuggestionDate") + .HasColumnType("datetime2"); + + b.Property("Synchronized") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("ArtifactId"); + + b.HasIndex("ItemId"); + + b.HasIndex("ReviewerId"); + + b.HasIndex("SuggestedById"); + + b.ToTable("PinterestLinks"); + }); + + modelBuilder.Entity("RMuseum.Models.ImportJob.ImportJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ArtifactId") + .HasColumnType("uniqueidentifier"); + + b.Property("EndTime") + .HasColumnType("datetime2"); + + b.Property("Exception") + .HasColumnType("nvarchar(max)"); + + b.Property("FriendlyUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("JobType") + .HasColumnType("int"); + + b.Property("ProgressPercent") + .HasColumnType("decimal(18,2)"); + + b.Property("QueueTime") + .HasColumnType("datetime2"); + + b.Property("ResourceNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("SrcContent") + .HasColumnType("nvarchar(max)"); + + b.Property("SrcUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("StartTime") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ArtifactId"); + + b.ToTable("ImportJobs"); + }); + + modelBuilder.Entity("RMuseum.Models.Note.RUserNote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("HtmlContent") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("Modified") + .HasColumnType("bit"); + + b.Property("NoteType") + .HasColumnType("int"); + + b.Property("RAppUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("RArtifactItemRecordId") + .HasColumnType("uniqueidentifier"); + + b.Property("RArtifactMasterRecordId") + .HasColumnType("uniqueidentifier"); + + b.Property("ReferenceNoteId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RAppUserId"); + + b.HasIndex("RArtifactItemRecordId"); + + b.HasIndex("RArtifactMasterRecordId"); + + b.HasIndex("ReferenceNoteId"); + + b.ToTable("UserNotes"); + }); + + modelBuilder.Entity("RMuseum.Models.Notification.RUserNotification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("HtmlText") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Subject") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Notifications"); + }); + + modelBuilder.Entity("RMuseum.Models.UploadSession.UploadSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ProcessEndTime") + .HasColumnType("datetime2"); + + b.Property("ProcessProgress") + .HasColumnType("int"); + + b.Property("ProcessStartTime") + .HasColumnType("datetime2"); + + b.Property("SessionType") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UploadEndTime") + .HasColumnType("datetime2"); + + b.Property("UploadStartTime") + .HasColumnType("datetime2"); + + b.Property("UseId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UploadSessions"); + }); + + modelBuilder.Entity("RMuseum.Models.UploadSession.UploadSessionFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContentDisposition") + .HasColumnType("nvarchar(max)"); + + b.Property("ContentType") + .HasColumnType("nvarchar(max)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("FilePath") + .HasColumnType("nvarchar(max)"); + + b.Property("Length") + .HasColumnType("bigint"); + + b.Property("MP3FileCheckSum") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessResult") + .HasColumnType("bit"); + + b.Property("ProcessResultMsg") + .HasColumnType("nvarchar(max)"); + + b.Property("UploadSessionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UploadSessionId"); + + b.ToTable("UploadedFiles"); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Audit.Db.REvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Duration") + .HasColumnType("int"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("EventType") + .HasColumnType("nvarchar(max)"); + + b.Property("IpAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("JsonData") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseStatusCode") + .HasColumnType("int"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("UserName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AuditLogs"); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RAppRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); + + b.Property("NormalizedName") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RAppUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("CreateDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); + + b.Property("NormalizedUserName") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("RImageId") + .HasColumnType("uniqueidentifier"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SureName") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("RImageId"); + + b.ToTable("AspNetUsers"); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RCaptchaImage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("RImageId") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RImageId"); + + b.ToTable("CaptchaImages"); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RPermission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("OperationShortName") + .HasColumnType("nvarchar(max)"); + + b.Property("RAppRoleId") + .HasColumnType("uniqueidentifier"); + + b.Property("SecurableItemShortName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RAppRoleId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RTemporaryUserSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ClientAppName") + .HasColumnType("nvarchar(max)"); + + b.Property("ClientIPAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Language") + .HasColumnType("nvarchar(max)"); + + b.Property("LastRenewal") + .HasColumnType("datetime2"); + + b.Property("LoginTime") + .HasColumnType("datetime2"); + + b.Property("RAppUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("Token") + .HasColumnType("nvarchar(max)"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("RAppUserId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RVerifyQueueItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ClientAppName") + .HasColumnType("nvarchar(max)"); + + b.Property("ClientIPAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("Language") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("QueueType") + .HasColumnType("int"); + + b.Property("Secret") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Secret") + .IsUnique() + .HasFilter("[Secret] IS NOT NULL"); + + b.ToTable("VerifyQueueItems"); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Image.RImage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContentType") + .HasColumnType("nvarchar(max)"); + + b.Property("DataTime") + .HasColumnType("datetime2"); + + b.Property("Discriminator") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileSizeInBytes") + .HasColumnType("bigint"); + + b.Property("FolderName") + .HasColumnType("nvarchar(max)"); + + b.Property("ImageHeight") + .HasColumnType("int"); + + b.Property("ImageWidth") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("OriginalFileName") + .HasColumnType("nvarchar(max)"); + + b.Property("StoredFileName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("GeneralImages"); + + b.HasDiscriminator("Discriminator").HasValue("RImage"); + }); + + modelBuilder.Entity("RMuseum.Models.Artifact.RPictureFile", b => + { + b.HasBaseType("RSecurityBackend.Models.Image.RImage"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DescriptionInEnglish") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModifiedMeta") + .HasColumnType("datetime2"); + + b.Property("NormalSizeImageHeight") + .HasColumnType("int"); + + b.Property("NormalSizeImageStoredFileName") + .HasColumnType("nvarchar(max)"); + + b.Property("NormalSizeImageWidth") + .HasColumnType("int"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("RArtifactItemRecordId") + .HasColumnType("uniqueidentifier"); + + b.Property("SrcUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("ThumbnailImageHeight") + .HasColumnType("int"); + + b.Property("ThumbnailImageStoredFileName") + .HasColumnType("nvarchar(max)"); + + b.Property("ThumbnailImageWidth") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("TitleInEnglish") + .HasColumnType("nvarchar(max)"); + + b.HasIndex("RArtifactItemRecordId"); + + b.HasDiscriminator().HasValue("RPictureFile"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.Artifact.RArtifactItemRecord", b => + { + b.HasOne("RMuseum.Models.Artifact.RArtifactMasterRecord", null) + .WithMany("Items") + .HasForeignKey("RArtifactMasterRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.Artifact.RArtifactMasterRecord", b => + { + b.HasOne("RMuseum.Models.Artifact.RPictureFile", "CoverImage") + .WithMany() + .HasForeignKey("CoverImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.Artifact.RTagValue", b => + { + b.HasOne("RMuseum.Models.Artifact.RArtifactItemRecord", null) + .WithMany("Tags") + .HasForeignKey("RArtifactItemRecordId"); + + b.HasOne("RMuseum.Models.Artifact.RArtifactMasterRecord", null) + .WithMany("Tags") + .HasForeignKey("RArtifactMasterRecordId"); + + b.HasOne("RMuseum.Models.Artifact.RTag", "RTag") + .WithMany() + .HasForeignKey("RTagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.Bookmark.RUserBookmark", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "RAppUser") + .WithMany() + .HasForeignKey("RAppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RMuseum.Models.Artifact.RArtifactItemRecord", "RArtifactItemRecord") + .WithMany() + .HasForeignKey("RArtifactItemRecordId"); + + b.HasOne("RMuseum.Models.Artifact.RArtifactMasterRecord", "RArtifactMasterRecord") + .WithMany() + .HasForeignKey("RArtifactMasterRecordId"); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCat", b => + { + b.HasOne("RMuseum.Models.Ganjoor.GanjoorCat", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoet", "Poet") + .WithMany() + .HasForeignKey("PoetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorPoem", b => + { + b.HasOne("RMuseum.Models.Ganjoor.GanjoorCat", "Cat") + .WithMany() + .HasForeignKey("CatId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorVerse", b => + { + b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoem", "Poem") + .WithMany() + .HasForeignKey("PoemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.GanjoorAudio.PoemNarration", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "Reviewer") + .WithMany() + .HasForeignKey("ReviewerId"); + }); + + modelBuilder.Entity("RMuseum.Models.GanjoorAudio.UserNarrationProfile", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.GanjoorIntegration.GanjoorLink", b => + { + b.HasOne("RMuseum.Models.Artifact.RArtifactMasterRecord", "Artifact") + .WithMany() + .HasForeignKey("ArtifactId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RMuseum.Models.Artifact.RArtifactItemRecord", "Item") + .WithMany() + .HasForeignKey("ItemId"); + + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "Reviewer") + .WithMany() + .HasForeignKey("ReviewerId"); + + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "SuggestedBy") + .WithMany() + .HasForeignKey("SuggestedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.GanjoorIntegration.PinterestLink", b => + { + b.HasOne("RMuseum.Models.Artifact.RArtifactMasterRecord", "Artifact") + .WithMany() + .HasForeignKey("ArtifactId"); + + b.HasOne("RMuseum.Models.Artifact.RArtifactItemRecord", "Item") + .WithMany() + .HasForeignKey("ItemId"); + + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "Reviewer") + .WithMany() + .HasForeignKey("ReviewerId"); + + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "SuggestedBy") + .WithMany() + .HasForeignKey("SuggestedById"); + }); + + modelBuilder.Entity("RMuseum.Models.ImportJob.ImportJob", b => + { + b.HasOne("RMuseum.Models.Artifact.RArtifactMasterRecord", "Artifact") + .WithMany() + .HasForeignKey("ArtifactId"); + }); + + modelBuilder.Entity("RMuseum.Models.Note.RUserNote", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "RAppUser") + .WithMany() + .HasForeignKey("RAppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RMuseum.Models.Artifact.RArtifactItemRecord", "RArtifactItemRecord") + .WithMany() + .HasForeignKey("RArtifactItemRecordId"); + + b.HasOne("RMuseum.Models.Artifact.RArtifactMasterRecord", "RArtifactMasterRecord") + .WithMany() + .HasForeignKey("RArtifactMasterRecordId"); + + b.HasOne("RMuseum.Models.Note.RUserNote", "ReferenceNote") + .WithMany() + .HasForeignKey("ReferenceNoteId"); + }); + + modelBuilder.Entity("RMuseum.Models.Notification.RUserNotification", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.UploadSession.UploadSession", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("RMuseum.Models.UploadSession.UploadSessionFile", b => + { + b.HasOne("RMuseum.Models.UploadSession.UploadSession", null) + .WithMany("UploadedFiles") + .HasForeignKey("UploadSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RAppUser", b => + { + b.HasOne("RSecurityBackend.Models.Image.RImage", "RImage") + .WithMany() + .HasForeignKey("RImageId"); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RCaptchaImage", b => + { + b.HasOne("RSecurityBackend.Models.Image.RImage", "RImage") + .WithMany() + .HasForeignKey("RImageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RPermission", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppRole", null) + .WithMany("Permissions") + .HasForeignKey("RAppRoleId"); + }); + + modelBuilder.Entity("RSecurityBackend.Models.Auth.Db.RTemporaryUserSession", b => + { + b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "RAppUser") + .WithMany() + .HasForeignKey("RAppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.Artifact.RPictureFile", b => + { + b.HasOne("RMuseum.Models.Artifact.RArtifactItemRecord", null) + .WithMany("Images") + .HasForeignKey("RArtifactItemRecordId"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/RMuseum/Migrations/20201022150541_GanjoorStructures.cs b/RMuseum/Migrations/20201022150541_GanjoorStructures.cs new file mode 100644 index 00000000..d1afb2e9 --- /dev/null +++ b/RMuseum/Migrations/20201022150541_GanjoorStructures.cs @@ -0,0 +1,128 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace RMuseum.Migrations +{ + public partial class GanjoorStructures : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "GanjoorPoets", + columns: table => new + { + Id = table.Column(nullable: false), + Name = table.Column(nullable: true), + Description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_GanjoorPoets", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "GanjoorCategories", + columns: table => new + { + Id = table.Column(nullable: false), + PoetId = table.Column(nullable: false), + Title = table.Column(nullable: true), + ParentId = table.Column(nullable: true), + UrlSlug = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_GanjoorCategories", x => x.Id); + table.ForeignKey( + name: "FK_GanjoorCategories_GanjoorCategories_ParentId", + column: x => x.ParentId, + principalTable: "GanjoorCategories", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_GanjoorCategories_GanjoorPoets_PoetId", + column: x => x.PoetId, + principalTable: "GanjoorPoets", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GanjoorPoems", + columns: table => new + { + Id = table.Column(nullable: false), + CatId = table.Column(nullable: false), + Title = table.Column(nullable: true), + FullTitle = table.Column(nullable: true), + UrlSlug = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_GanjoorPoems", x => x.Id); + table.ForeignKey( + name: "FK_GanjoorPoems_GanjoorCategories_CatId", + column: x => x.CatId, + principalTable: "GanjoorCategories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GanjoorVerses", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PoemId = table.Column(nullable: false), + VOrder = table.Column(nullable: false), + VersePosition = table.Column(nullable: false), + Text = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_GanjoorVerses", x => x.Id); + table.ForeignKey( + name: "FK_GanjoorVerses_GanjoorPoems_PoemId", + column: x => x.PoemId, + principalTable: "GanjoorPoems", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_GanjoorCategories_ParentId", + table: "GanjoorCategories", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_GanjoorCategories_PoetId", + table: "GanjoorCategories", + column: "PoetId"); + + migrationBuilder.CreateIndex( + name: "IX_GanjoorPoems_CatId", + table: "GanjoorPoems", + column: "CatId"); + + migrationBuilder.CreateIndex( + name: "IX_GanjoorVerses_PoemId", + table: "GanjoorVerses", + column: "PoemId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "GanjoorVerses"); + + migrationBuilder.DropTable( + name: "GanjoorPoems"); + + migrationBuilder.DropTable( + name: "GanjoorCategories"); + + migrationBuilder.DropTable( + name: "GanjoorPoets"); + } + } +} diff --git a/RMuseum/Migrations/RMuseumDbContextModelSnapshot.cs b/RMuseum/Migrations/RMuseumDbContextModelSnapshot.cs index 581bc6bf..dd583d46 100644 --- a/RMuseum/Migrations/RMuseumDbContextModelSnapshot.cs +++ b/RMuseum/Migrations/RMuseumDbContextModelSnapshot.cs @@ -336,6 +336,98 @@ namespace RMuseum.Migrations b.ToTable("UserBookmarks"); }); + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCat", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("ParentId") + .HasColumnType("int"); + + b.Property("PoetId") + .HasColumnType("int"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlSlug") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("PoetId"); + + b.ToTable("GanjoorCategories"); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorPoem", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("CatId") + .HasColumnType("int"); + + b.Property("FullTitle") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("UrlSlug") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CatId"); + + b.ToTable("GanjoorPoems"); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorPoet", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("GanjoorPoets"); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorVerse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("PoemId") + .HasColumnType("int"); + + b.Property("Text") + .HasColumnType("nvarchar(max)"); + + b.Property("VOrder") + .HasColumnType("int"); + + b.Property("VersePosition") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PoemId"); + + b.ToTable("GanjoorVerses"); + }); + modelBuilder.Entity("RMuseum.Models.GanjoorAudio.PoemNarration", b => { b.Property("Id") @@ -1255,6 +1347,37 @@ namespace RMuseum.Migrations .HasForeignKey("RArtifactMasterRecordId"); }); + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorCat", b => + { + b.HasOne("RMuseum.Models.Ganjoor.GanjoorCat", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoet", "Poet") + .WithMany() + .HasForeignKey("PoetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorPoem", b => + { + b.HasOne("RMuseum.Models.Ganjoor.GanjoorCat", "Cat") + .WithMany() + .HasForeignKey("CatId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("RMuseum.Models.Ganjoor.GanjoorVerse", b => + { + b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoem", "Poem") + .WithMany() + .HasForeignKey("PoemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + modelBuilder.Entity("RMuseum.Models.GanjoorAudio.PoemNarration", b => { b.HasOne("RSecurityBackend.Models.Auth.Db.RAppUser", "Owner") diff --git a/RMuseum/Models/Auth/Memory/RMuseumSecurableItem.cs b/RMuseum/Models/Auth/Memory/RMuseumSecurableItem.cs index 81127224..3a9f76cf 100644 --- a/RMuseum/Models/Auth/Memory/RMuseumSecurableItem.cs +++ b/RMuseum/Models/Auth/Memory/RMuseumSecurableItem.cs @@ -63,6 +63,11 @@ namespace RMuseum.Models.Auth.Memory /// public const string AudioNarrationEntityShortName = "narration"; + /// + /// ganjoor contents + /// + public const string GanjoorEntityShortName = "ganjoor"; + /// /// list of forms and their permissions /// @@ -121,6 +126,15 @@ namespace RMuseum.Models.Auth.Memory new SecurableItemOperation(ModerateOperationShortName, "بررسی", false) } }, + new SecurableItem() + { + ShortName = GanjoorEntityShortName, + Description = "محتوای گنجور", + Operations = new SecurableItemOperation[] + { + new SecurableItemOperation(ImportOperationShortName, "ورود اطلاعات", false), + } + }, }); return lst.ToArray(); diff --git a/RMuseum/Models/GanjoorAudio/PoemNarration.cs b/RMuseum/Models/GanjoorAudio/PoemNarration.cs index 4f29d9e3..b7182dfe 100644 --- a/RMuseum/Models/GanjoorAudio/PoemNarration.cs +++ b/RMuseum/Models/GanjoorAudio/PoemNarration.cs @@ -27,6 +27,10 @@ namespace RMuseum.Models.GanjoorAudio /// /// Final data is actually exported to a MySQL database which this auto increment field is its key /// + /// + /// Caution: this could become a relation with newly added table + /// but if we do this we lose the ability to drop and create without losing narration data + /// public int GanjoorAudioId { get; set; } /// diff --git a/RMuseum/RMuseum.csproj b/RMuseum/RMuseum.csproj index f88bd738..e3d3c0d6 100644 --- a/RMuseum/RMuseum.csproj +++ b/RMuseum/RMuseum.csproj @@ -13,6 +13,7 @@ + all diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index e90ae0d0..1de0d97d 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -738,6 +738,23 @@ + + + imports data from ganjoor SQLite database + + + + + + Ganjoor Service + + + + + constructor + + + returns image stream @@ -1536,6 +1553,11 @@ audio narrations + + + ganjoor contents + + list of forms and their permissions @@ -1735,6 +1757,10 @@ Final data is actually exported to a MySQL database which this auto increment field is its key + + Caution: this could become a relation with newly added table + but if we do this we lose the ability to drop and create without losing narration data + @@ -3855,7 +3881,7 @@ - imports data from ganjoor MySql database + imports narration data from ganjoor MySql database User Id which becomes owner of imported data @@ -3940,6 +3966,17 @@ retry publish unpublished narrations + + + Ganjoor Poems Content Privider Service + + + + + imports unimported poem data from a locally accessible ganjoor SqlLite database + + + IArtifactService implementation @@ -4785,6 +4822,34 @@ + + + IGanjoorService implementation + + + + + imports unimported poem data from a locally accessible ganjoor SqlLite database + + + + + + Database Contetxt + + + + + Configuration + + + + + constructor + + + + Persian specific text utility class diff --git a/RMuseum/Services/IAudioNarrationService.cs b/RMuseum/Services/IAudioNarrationService.cs index b6c82451..85800791 100644 --- a/RMuseum/Services/IAudioNarrationService.cs +++ b/RMuseum/Services/IAudioNarrationService.cs @@ -38,7 +38,7 @@ namespace RMuseum.Services Task> UpdatePoemNarration(Guid id, PoemNarrationUpdateViewModel metadata); /// - /// imports data from ganjoor MySql database + /// imports narration data from ganjoor MySql database /// /// User Id which becomes owner of imported data /// diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs new file mode 100644 index 00000000..0c53b137 --- /dev/null +++ b/RMuseum/Services/IGanjoorService.cs @@ -0,0 +1,17 @@ +using RSecurityBackend.Models.Generic; +using System.Threading.Tasks; + +namespace RMuseum.Services +{ + /// + /// Ganjoor Poems Content Privider Service + /// + public interface IGanjoorService + { + /// + /// imports unimported poem data from a locally accessible ganjoor SqlLite database + /// + /// + Task> ImportLocalSQLiteDb(); + } +} diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs new file mode 100644 index 00000000..2594f7f5 --- /dev/null +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -0,0 +1,174 @@ +using Microsoft.Data.Sqlite; +using RMuseum.DbContext; +using RSecurityBackend.Models.Generic; +using System.Threading.Tasks; +using System.Data; +using Dapper; +using System.Linq; +using Microsoft.EntityFrameworkCore; +using RMuseum.Models.Ganjoor; +using System; +using Microsoft.Extensions.Configuration; + +namespace RMuseum.Services.Implementation +{ + /// + /// IGanjoorService implementation + /// + public class GanjoorService : IGanjoorService + { + #region SQLite import + /// + /// imports unimported poem data from a locally accessible ganjoor SqlLite database + /// + /// + public async Task> ImportLocalSQLiteDb() + { + try + { + SqliteConnectionStringBuilder connectionStringBuilder = new SqliteConnectionStringBuilder(); + connectionStringBuilder.DataSource = @"C:\Users\moham\AppData\Local\ganjoor\ganjoor.s3db"; + using (SqliteConnection connection = new SqliteConnection(connectionStringBuilder.ToString())) + { + await connection.OpenAsync(); + + IDbConnection dapper = connection; + + foreach (var poet in await dapper.QueryAsync("SELECT * FROM poet ORDER BY id")) + { + int poetId = (int)poet.id; + using(RMuseumDbContext context = new RMuseumDbContext(Configuration)) + { + if ((await context.GanjoorPoets.Where(p => p.Id == poetId).FirstOrDefaultAsync()) != null) + { + continue; + } + + context.GanjoorPoets.Add + ( + new GanjoorPoet() + { + Id = poetId, + Name = poet.name, + Description = poet.description + } + ); + + await context.SaveChangesAsync(); + + + } + + await _ImportSQLiteCatChildren(dapper, poetId, 0, poet.name); + + + + } + + } + } + catch(Exception exp) + { + return new RServiceResult(false, exp.ToString()); + } + + return new RServiceResult(true); + } + + + + private async Task _ImportSQLiteCatChildren(IDbConnection dapper, int poetId, int catId, string itemFullTitle) + { + + foreach(var cat in await dapper.QueryAsync($"SELECT * FROM cat WHERE poet_id = {poetId} AND parent_id = {catId} ORDER BY id")) + { + using (RMuseumDbContext context = new RMuseumDbContext(Configuration)) + { + context.GanjoorCategories.Add + ( + new GanjoorCat() + { + Id = (int)cat.id, + PoetId = poetId, + Title = cat.text, + UrlSlug = _ExtractUrlSlug(cat.url) + } + ); + + foreach (var poem in await dapper.QueryAsync($"SELECT * FROM poem WHERE cat_id = {cat.id} ORDER BY id")) + { + context.GanjoorPoems.Add + ( + new GanjoorPoem() + { + Id = (int)poem.id, + CatId = (int)cat.id, + Title = poem.title, + UrlSlug = _ExtractUrlSlug(poem.url), + FullTitle = $"{itemFullTitle} » {cat.text} » {poem.title}" + } + ); + + foreach (var verse in await dapper.QueryAsync($"SELECT * FROM verse WHERE poem_id = {poem.id} ORDER BY vorder")) + { + context.GanjoorVerses.Add + ( + new GanjoorVerse() + { + PoemId = (int)poem.id, + VOrder = (int)verse.vorder, + VersePosition = (VersePosition)verse.position, + Text = verse.text + } + ); + } + + await context.SaveChangesAsync(); + } + + + await _ImportSQLiteCatChildren(dapper, poetId, (int)cat.id, $"{itemFullTitle} » {cat.text}"); + } + + + } + } + + #endregion + + private static string _ExtractUrlSlug(string slug) + { + if (!string.IsNullOrEmpty(slug)) + { + //sample: https://ganjoor.net/hafez + if (slug.LastIndexOf('/') != -1) + { + // => result = hafez + slug = slug.Substring(slug.LastIndexOf('/') + 1); + } + } + return slug; + } + + /// + /// Database Contetxt + /// + protected readonly RMuseumDbContext _context; + + /// + /// Configuration + /// + protected IConfiguration Configuration { get; } + + /// + /// constructor + /// + /// + /// + public GanjoorService(RMuseumDbContext context, IConfiguration configuration) + { + _context = context; + Configuration = configuration; + } + } +} diff --git a/RMuseum/Startup.cs b/RMuseum/Startup.cs index 6c469b0d..e44f3055 100644 --- a/RMuseum/Startup.cs +++ b/RMuseum/Startup.cs @@ -254,6 +254,9 @@ namespace RMuseum //audio service services.AddTransient(); + //ganjoor service + services.AddTransient(); + //upload limit for IIS services.Configure(options => {