From d031504128c666aaf4a96986e9f1268addbcbf14 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Fri, 12 Feb 2021 09:08:48 +0330 Subject: [PATCH] using DNTPersianUtils.Core for persian text replacements --- RMuseum/RMuseum.csproj | 1 + RMuseum/RMuseum.xml | 12 ------- .../Services/Implementation/GanjoorService.cs | 6 ++-- .../GPersianTextSync.cs | 36 ------------------- .../Implementation/RecitationService.cs | 3 +- 5 files changed, 6 insertions(+), 52 deletions(-) diff --git a/RMuseum/RMuseum.csproj b/RMuseum/RMuseum.csproj index e3d3c0d6..301725a6 100644 --- a/RMuseum/RMuseum.csproj +++ b/RMuseum/RMuseum.csproj @@ -12,6 +12,7 @@ + diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 7e54fc17..f64adac7 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -6934,18 +6934,6 @@ Persian specific text utility class - - - convert arabic characters to persian equivalents - - - - - - - list of persian letters - - convert persian text to simple pinglish diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index c1122e92..89d88022 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -14,10 +14,10 @@ using System.Data; using System.Globalization; using System.Linq; using System.Threading.Tasks; -using RMuseum.Services.Implementation.ImportedFromDesktopGanjoor; using RMuseum.Models.Artifact; using System.Text.RegularExpressions; using RSecurityBackend.Services.Implementation; +using DNTPersianUtils.Core; namespace RMuseum.Services.Implementation { @@ -962,9 +962,9 @@ namespace RMuseum.Services.Implementation song.ArtistName = ""; song.ArtistUrl = ""; - song.AlbumName = $"{golhaTrack.GolhaProgram.GolhaCollection.Name} » شمارهٔ {GPersianTextSync.Sync(golhaTrack.GolhaProgram.Title)}"; + song.AlbumName = $"{golhaTrack.GolhaProgram.GolhaCollection.Name} » شمارهٔ {golhaTrack.GolhaProgram.Title.ToPersianNumbers().ApplyCorrectYeKe()}"; song.AlbumUrl = ""; - song.TrackName = $"{GPersianTextSync.Sync(golhaTrack.Timing)} {golhaTrack.Title}"; + song.TrackName = $"{golhaTrack.Timing.ToPersianNumbers().ApplyCorrectYeKe()} {golhaTrack.Title}"; song.TrackUrl = golhaTrack.GolhaProgram.Url; } else diff --git a/RMuseum/Services/Implementation/ImportedFromDesktopGanjoor/GPersianTextSync.cs b/RMuseum/Services/Implementation/ImportedFromDesktopGanjoor/GPersianTextSync.cs index af8f9d1f..748f9aea 100644 --- a/RMuseum/Services/Implementation/ImportedFromDesktopGanjoor/GPersianTextSync.cs +++ b/RMuseum/Services/Implementation/ImportedFromDesktopGanjoor/GPersianTextSync.cs @@ -7,42 +7,6 @@ namespace RMuseum.Services.Implementation.ImportedFromDesktopGanjoor /// public class GPersianTextSync { - /// - /// convert arabic characters to persian equivalents - /// - /// - /// - public static string Sync(string inputStr) - { - return - inputStr - .Replace('ك', 'ک') - .Replace('ي', 'ی') - .Replace("ۀ", "هٔ") - .Replace("ه‌ی", "هٔ") - .Replace("0", "۰") - .Replace("1", "۱") - .Replace("2", "۲") - .Replace("3", "۳") - .Replace("4", "۴") - .Replace("5", "۵") - .Replace("6", "۶") - .Replace("7", "۷") - .Replace("8", "۸") - .Replace("9", "۹"); - } - - /// - /// list of persian letters - /// - public static string PersianLetters - { - get - { - return "اآئأإءبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی"; - } - } - /// /// convert persian text to simple pinglish /// diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index 20ab7117..6eaa82fc 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -1,4 +1,5 @@ using Dapper; +using DNTPersianUtils.Core; using ganjoor; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; @@ -659,7 +660,7 @@ namespace RMuseum.Services.Implementationa while((await _context.UserRecitationProfiles.Where(p => p.UserId == ownerRAppUserId && p.Name == profile.Name).SingleOrDefaultAsync())!=null) { pIndex++; - profile.Name = $"{profile.ArtistName} {GPersianTextSync.Sync(pIndex.ToString())}"; + profile.Name = $"{profile.ArtistName} {pIndex.ToPersianNumbers()}"; } _context.UserRecitationProfiles.Add(profile); await _context.SaveChangesAsync(); //this logically should be outside this loop,