From c9ee7a02fce36fc750dcf292304be334482c226a Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 29 May 2023 12:39:39 +0200 Subject: [PATCH 1/5] separati metodi per scrittura definitiva su db e preparazione --- WebDoorCreator.Core/Constants.cs | 1 + .../Controllers/WebDoorCreatorController.cs | 74 ++++++++++++++++--- .../Services/WebDoorCreatorService.cs | 38 +++++++++- 3 files changed, 100 insertions(+), 13 deletions(-) diff --git a/WebDoorCreator.Core/Constants.cs b/WebDoorCreator.Core/Constants.cs index 3635835..c7beb84 100644 --- a/WebDoorCreator.Core/Constants.cs +++ b/WebDoorCreator.Core/Constants.cs @@ -54,6 +54,7 @@ namespace WebDoorCreator.Core public const string rKeyUsersDataSearch = $"{redisBaseAddr}:Cache:UsersData:Search"; public const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView"; public const string rKeyVocLemma = $"{redisBaseAddr}:Cache:VocLemma"; + public const string rKeyVocLemmaTEMP = $"{redisBaseAddr}:Cache:VocLemmaTEMP"; public const string rKeyLanguage = $"{redisBaseAddr}:Cache:Languages"; } } diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index a87ddfd..ca63d49 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -1241,18 +1241,46 @@ namespace WebDoorCreator.Data.Controllers } return DTOResult; } + public Dictionary> VocLemmaTEMPGetAll() + { + Dictionary> DTOResult = new Dictionary>(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + List lingue = new List() + { + "IT", + "EN" + }; - /// - /// Aggiunta di un nuovo set di lemmi - /// - /// - /// - public async Task VocLemmaInsert(List listNewTerms) + // extracting entire set + var allVoc = localDbCtx + .DbSetVocabularyTemp + .AsNoTracking() + .ToList(); + + foreach (var lingua in lingue) + { + Dictionary dict = new Dictionary(); + foreach (var lemma in allVoc.Where(x => x.Lingua == lingua)) + { + dict.Add(lemma.Lemma, lemma.Traduzione); + } + DTOResult.Add(lingua, dict); + } + } + catch (Exception exc) + { + Log.Error($"Error in VocLemmaTEMPGetAll:{Environment.NewLine}{exc}"); + } + } + return DTOResult; + } + public async Task VocLemmaInsertPrepare(List listNewTerms) { bool fatto = false; - //var o = listNewTerms.Where(x => x.Traduzione.Length > 200).ToList(); - using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) { try @@ -1269,8 +1297,36 @@ namespace WebDoorCreator.Data.Controllers .AddRange(listNewTerms); await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante VocLemmaInsertPrepare: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Aggiunta di un nuovo set di lemmi + /// + /// + /// + public async Task VocLemmaInsert() + { + await Task.Delay(1); + bool fatto = false; + + //var o = listNewTerms.Where(x => x.Traduzione.Length > 200).ToList(); + + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + //bool isOk = await VocLemmaInsertPrepare(listNewTerms); + // stored di merge dati in vocabolario - storedRes = localDbCtx + var storedRes = localDbCtx .Database .ExecuteSqlRaw("exec dbo.stp_Voc_Import"); diff --git a/WebDoorCreator.Data/Services/WebDoorCreatorService.cs b/WebDoorCreator.Data/Services/WebDoorCreatorService.cs index 147ef49..dea0196 100644 --- a/WebDoorCreator.Data/Services/WebDoorCreatorService.cs +++ b/WebDoorCreator.Data/Services/WebDoorCreatorService.cs @@ -2231,11 +2231,24 @@ namespace WebDoorCreator.Data.Services Log.Debug($"VocLemmaGetAll | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } - - public async Task VocLemmaInsert(string rootPath) + public async Task>?> VocLemmaTEMPGetAll() { - bool fatto = false; + string source = "DB"; + Dictionary>? dbResult = new Dictionary>(); + // cerco da cache + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.VocLemmaTEMPGetAll(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"VocLemmaGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + public async Task> VocLemmaInsertPrepare(string rootPath) + { + //bool fatto = false; + await Task.Delay(1); List VocLemmas = new List(); Stopwatch stopWatch = new Stopwatch(); @@ -2271,7 +2284,24 @@ namespace WebDoorCreator.Data.Services } } } - fatto = await dbController.VocLemmaInsert(VocLemmas); + await dbController.VocLemmaInsertPrepare(VocLemmas); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"VocLemmaInsertPrepare in: {ts.TotalMilliseconds} ms"); + return VocLemmas; + } + + + + public async Task VocLemmaInsert() + { + bool fatto = false; + + List VocLemmas = new List(); + + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + fatto = await dbController.VocLemmaInsert(); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; Log.Debug($"VocLemmaInsert in: {ts.TotalMilliseconds} ms"); From acff028e5fc7386cd15c8d27a8e5c05c204028ff Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 29 May 2023 12:40:08 +0200 Subject: [PATCH 2/5] aggiunto componente per gestione files (Bozza x file dei messaggi) --- .../Components/FilesMan/FilesRefresh.razor | 45 ++++++++++++ .../Components/FilesMan/FilesRefresh.razor.cs | 71 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 WebDoorCreator.UI/Components/FilesMan/FilesRefresh.razor create mode 100644 WebDoorCreator.UI/Components/FilesMan/FilesRefresh.razor.cs diff --git a/WebDoorCreator.UI/Components/FilesMan/FilesRefresh.razor b/WebDoorCreator.UI/Components/FilesMan/FilesRefresh.razor new file mode 100644 index 0000000..2d6baf1 --- /dev/null +++ b/WebDoorCreator.UI/Components/FilesMan/FilesRefresh.razor @@ -0,0 +1,45 @@ + + + + + +@*@if (vocLemmas != null) +{ + @foreach (var item in vocLemmas) + { + @foreach (var k in item.Value) + { + @*
@($"{k.Key} --> {k.Value}")
+ @if(vocLemmasTEMP != null) + { + + } + } + } +}*@ + +@if (showList) +{ + + + @if (vocLemmas2Dict != null && vocLemmasTEMP2Dict != null) + { + @foreach (var item in vocLemmasTEMP2Dict) + { + @if (!vocLemmas2Dict.ContainsKey(item.Key)) + { +
+
@($"{item.Key} --> {vocLemmasTEMP2Dict[item.Key]}")
+
+ } + else if (item.Value != vocLemmas2Dict[item.Key]) + { +
+
@($"{item.Key} --> {vocLemmas2Dict[item.Key]}")
+
@($"{item.Key} --> {item.Value}")
+
+ } + } + } +} + diff --git a/WebDoorCreator.UI/Components/FilesMan/FilesRefresh.razor.cs b/WebDoorCreator.UI/Components/FilesMan/FilesRefresh.razor.cs new file mode 100644 index 0000000..98eee93 --- /dev/null +++ b/WebDoorCreator.UI/Components/FilesMan/FilesRefresh.razor.cs @@ -0,0 +1,71 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.CodeAnalysis.VisualBasic.Syntax; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.Data.Services; + +namespace WebDoorCreator.UI.Components.FilesMan +{ + public partial class FilesRefresh + { + [Inject] + protected WebDoorCreatorService WDCService { get; set; } = null!; + + [Parameter] + public string lang { get; set; } = ""; + + protected Dictionary>? vocLemmas { get; set; } = null; + protected Dictionary vocLemmas2Dict { get; set; } = new Dictionary(); + protected Dictionary>? vocLemmasTEMP { get; set; } = null; + protected Dictionary vocLemmasTEMP2Dict { get; set; } = new Dictionary(); + + protected bool showList { get; set; } = false; + + protected async override Task OnParametersSetAsync() + { + var rawVoc = await WDCService.VocLemmaGetAll(); + if (rawVoc != null) + { + vocLemmas = rawVoc.Where(x => x.Key == lang).ToDictionary(x => x.Key, x => x.Value); + if(vocLemmas != null) + { + foreach(var kvp in vocLemmas) + { + foreach(var item in kvp.Value) + { + vocLemmas2Dict.Add(item.Key, item.Value); + } + } + } + } + } + protected async Task refreshVoc() + { + vocLemmasTEMP = null; + await Task.Delay(1); + list2Mod = await WDCService.VocLemmaInsertPrepare(@$"{defaultPath}"); + if (list2Mod != null) + { + //bool ok = await WDCService.VocLemmaInsert(); + var k = await WDCService.VocLemmaTEMPGetAll(); + if (k != null) + { + vocLemmasTEMP = k.Where(x => x.Key == lang).ToDictionary(x => x.Key, x => x.Value); + if (vocLemmasTEMP != null) + { + foreach (var kvp in vocLemmasTEMP) + { + foreach (var item in kvp.Value) + { + vocLemmasTEMP2Dict.Add(item.Key, item.Value); + } + } + } + } + } + showList = true; + } + List list2Mod = new List(); + + protected string defaultPath { get; set; } = ""; + } +} \ No newline at end of file From 902b12267c7536c70b6bcc679db313f0303b3685 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 29 May 2023 12:40:27 +0200 Subject: [PATCH 3/5] fix grafico --- WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor index d05cb93..72bd844 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor @@ -73,7 +73,7 @@ { @if (compToShow != null) { - + } } } From aadb20a45b6d22c05c1df3e7c734c903034f45cc Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 29 May 2023 12:40:49 +0200 Subject: [PATCH 4/5] spostata gestione voc --- WebDoorCreator.UI/Pages/SuperAdmin.razor | 4 ++-- WebDoorCreator.UI/Pages/SuperAdmin.razor.cs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/WebDoorCreator.UI/Pages/SuperAdmin.razor b/WebDoorCreator.UI/Pages/SuperAdmin.razor index 71f015b..d8d739f 100644 --- a/WebDoorCreator.UI/Pages/SuperAdmin.razor +++ b/WebDoorCreator.UI/Pages/SuperAdmin.razor @@ -15,7 +15,7 @@
- + @**@
@@ -46,7 +46,7 @@ } else { - + } diff --git a/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs b/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs index 671c6d6..e4d2e1a 100644 --- a/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs +++ b/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs @@ -312,11 +312,13 @@ namespace WebDoorCreator.UI.Pages await Task.Delay(1); await WDService.CompoListSetAll(@$"{defaultPath}"); } +#if false protected async Task refreshVoc() { await Task.Delay(1); await WDService.VocLemmaInsert(@$"{defaultPath}"); - } + } +#endif protected async Task refreshFiles() { await Task.Delay(1); From 1d5b1084e43f7c57ec9369090771716b9e85a026 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 29 May 2023 12:40:59 +0200 Subject: [PATCH 5/5] refresh versioni --- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- WebDoorCreator.UI/WebDoorCreator.UI.csproj | 2 +- WebDoorCreator.UI/_Imports.razor | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 633f24f..38abe45 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ WebDoorCreator - Egalware -

Version: 0.9.2305.2908

+

Version: 0.9.2305.2912


Release note:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 6efddaa..6318d6d 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -0.9.2305.2908 +0.9.2305.2912 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index a720de5..3c444eb 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 0.9.2305.2908 + 0.9.2305.2912 http://nexus.steamware.net/repository/SWS/WDC/stable/WDC.UI.zip http://nexus.steamware.net/repository/SWS/WDC/stable/ChangeLog.html false diff --git a/WebDoorCreator.UI/WebDoorCreator.UI.csproj b/WebDoorCreator.UI/WebDoorCreator.UI.csproj index fa9af50..843cc26 100644 --- a/WebDoorCreator.UI/WebDoorCreator.UI.csproj +++ b/WebDoorCreator.UI/WebDoorCreator.UI.csproj @@ -3,7 +3,7 @@ net6.0 enable - 0.9.2305.2908 + 0.9.2305.2912 enable aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608 diff --git a/WebDoorCreator.UI/_Imports.razor b/WebDoorCreator.UI/_Imports.razor index 50fc7e5..3172152 100644 --- a/WebDoorCreator.UI/_Imports.razor +++ b/WebDoorCreator.UI/_Imports.razor @@ -22,6 +22,7 @@ @using WebDoorCreator.UI.Components.SvgComp @using WebDoorCreator.UI.Components.Filters @using WebDoorCreator.UI.Components.Report +@using WebDoorCreator.UI.Components.FilesMan @using WebDoorCreator.UI.Shared