From 7a8907b2405ac5441f76b1ab90b1242b227001a3 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Thu, 1 Apr 2021 11:08:06 +0430 Subject: [PATCH] #103 a fix for import from MySql --- .../GanjoorService-MySqlImports.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/RMuseum/Services/Implementation/GanjoorService-Imports/GanjoorService-MySqlImports.cs b/RMuseum/Services/Implementation/GanjoorService-Imports/GanjoorService-MySqlImports.cs index 8332f1b0..dd1bf9da 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Imports/GanjoorService-MySqlImports.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Imports/GanjoorService-MySqlImports.cs @@ -189,6 +189,13 @@ namespace RMuseum.Services.Implementation int? poetId = row["post_author"].ToString() == "1" ? (int?)null : int.Parse(row["post_author"].ToString()); + string htmlText = row["post_content"].ToString(); + + //this changes fixes some issues with ganjoor audio player + htmlText = htmlText.Replace("\r", "").Replace("\n", ""); + htmlText = htmlText.Replace("", "\r\n"); + htmlText = htmlText.Replace("
", "
\r\n
"); + GanjoorPage page = new GanjoorPage() { @@ -198,7 +205,7 @@ namespace RMuseum.Services.Implementation PageOrder = -1, Title = row["post_title"].ToString(), UrlSlug = row["post_name"].ToString(), - HtmlText = row["post_content"].ToString(), + HtmlText = htmlText, ParentId = row["post_parent"].ToString() == "0" ? (int?)null : int.Parse(row["post_parent"].ToString()), PoetId = poetId, SecondPoetId = row["other_poet_id"] == DBNull.Value ? (int?)null : int.Parse(row["other_poet_id"].ToString()), @@ -1097,6 +1104,13 @@ namespace RMuseum.Services.Implementation } } + string htmlText = row["post_content"].ToString(); + + //this changes fixes some issues with ganjoor audio player + htmlText = htmlText.Replace("\r", "").Replace("\n", ""); + htmlText = htmlText.Replace("
", "\r\n"); + htmlText = htmlText.Replace("
", "
\r\n
"); + GanjoorPoem poem = new GanjoorPoem() { Id = int.Parse(row["ID"].ToString()), @@ -1105,7 +1119,7 @@ namespace RMuseum.Services.Implementation UrlSlug = row["post_name"].ToString(), FullTitle = $"{catFullTitle} ยป {row["post_title"]}", FullUrl = $"{poemCat.FullUrl}/{row["post_name"]}", - HtmlText = row["post_content"].ToString(), + HtmlText = htmlText, }; List verses = _extractVersesFromPoemHtmlText(poem.Id, poem.HtmlText);