Continuo gestione vocabolari

This commit is contained in:
zaccaria.majid
2023-06-06 17:12:26 +02:00
parent ac115ac7ee
commit a56818a2c8
15 changed files with 1331 additions and 76 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>WebDoorCreator - Egalware</i>
<h4>Version: 0.9.2306.0611</h4>
<h4>Version: 0.9.2306.0617</h4>
<br /> Release note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2306.0611
0.9.2306.0617
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2306.0611</version>
<version>0.9.2306.0617</version>
<url>http://nexus.steamware.net/repository/SWS/WDC/stable/WDC.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/WDC/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>
@@ -540,7 +540,7 @@ namespace WebDoorCreator.Data.Controllers
.OrderBy(x => x.DoorOpTypId)
.ToList();
}
else if(hwCode != "*" && parentId == -1)
else if (hwCode != "*" && parentId == -1)
{
dbResult = localDbCtx
.DbSetDoorOpType
@@ -548,7 +548,7 @@ namespace WebDoorCreator.Data.Controllers
.OrderBy(x => x.DoorOpTypId)
.ToList();
}
else if(hwCode == "*" && parentId >= 0)
else if (hwCode == "*" && parentId >= 0)
{
dbResult = localDbCtx
.DbSetDoorOpType
@@ -556,7 +556,7 @@ namespace WebDoorCreator.Data.Controllers
.OrderBy(x => x.DoorOpTypId)
.ToList();
}
else if(hwCode != "*" && parentId >= 0)
else if (hwCode != "*" && parentId >= 0)
{
dbResult = localDbCtx
.DbSetDoorOpType
@@ -744,7 +744,8 @@ namespace WebDoorCreator.Data.Controllers
.DbSetDoor
.Where(x => x.DoorId == addEditRec.DoorId)
.FirstOrDefault();
if (currRec != null) //if is not null edit the record found
//if is not null edit the record found
if (currRec != null)
{
currRec.Quantity = addEditRec.Quantity;
currRec.DoorExtCode = addEditRec.DoorExtCode;
@@ -752,7 +753,8 @@ namespace WebDoorCreator.Data.Controllers
currRec.ParentId = addEditRec.ParentId;
localDbCtx.Entry(currRec).State = EntityState.Modified;
}
else //if is null add the record as new in the table
//if is null add the record as new in the table
else
{
localDbCtx
.DbSetDoor
@@ -1517,6 +1519,66 @@ namespace WebDoorCreator.Data.Controllers
}
return fatto;
}
public async Task<bool> VocLemmaSetConf(string lingua, string lemma, bool isConf)
{
await Task.Delay(1);
bool fatto = false;
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
// import massivo dati in tab temp
var termSearch = localDbCtx
.DbSetVocabularyTemp
.Where(x => x.Lingua == lingua && x.Lemma == lemma)
.FirstOrDefault();
if (termSearch != null)
{
termSearch.IsConfSave = isConf;
localDbCtx.Entry(termSearch).State = EntityState.Modified;
await localDbCtx.SaveChangesAsync();
fatto = true;
}
}
catch (Exception exc)
{
Log.Error($"Eccezione durante VocLemmaSetConf: {Environment.NewLine}{exc}");
}
}
return fatto;
}
public async Task<VocabularyTempModel> VocLemmaFindByKeys(string lingua, string lemma)
{
await Task.Delay(1);
VocabularyTempModel dbResult = new VocabularyTempModel();
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
// import massivo dati in tab temp
var termSearch = localDbCtx
.DbSetVocabularyTemp
.Where(x => x.Lingua == lingua && x.Lemma == lemma)
.FirstOrDefault();
if (termSearch != null)
{
dbResult = termSearch;
}
}
catch (Exception exc)
{
Log.Error($"Eccezione durante VocLemmaCheckConf: {Environment.NewLine}{exc}");
}
}
return dbResult;
}
public Dictionary<string, Dictionary<string, string>> VocLemmaTEMPGetAll()
{
@@ -35,5 +35,9 @@ namespace WebDoorCreator.Data.DbModels
/// </summary>
[MaxLength(500)]
public string Traduzione { get; set; } = "";
/// <summary>
/// Indica se è da salvare su db o no
/// </summary>
public bool IsConfSave { get; set; } = false;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WebDoorCreator.Data.Migrations.WDCData
{
public partial class modVocTempModel : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsConfSave",
table: "VocabularyTemp",
type: "bit",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsConfSave",
table: "VocabularyTemp");
}
}
}
@@ -986,6 +986,9 @@ namespace WebDoorCreator.Data.Migrations.WDCData
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("IsConfSave")
.HasColumnType("bit");
b.Property<string>("Traduzione")
.IsRequired()
.HasMaxLength(500)
@@ -479,7 +479,6 @@ namespace WebDoorCreator.Data.Services
int numHead = 1;
// scansione della directory...
string[] files = Directory.GetFiles(dir, "Config.ini");
compoName = "";
//iterazione per cercare tutti numPar file "Config.ini" nelle sotto directory
foreach (string file in files)
@@ -2533,6 +2532,43 @@ namespace WebDoorCreator.Data.Services
Log.Debug($"VocLemmaGetAll | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
public async Task<VocabularyTempModel?> VocLemmaFindByKeys(string lingua, string lemma)
{
string source = "DB";
VocabularyTempModel? dbResult = new VocabularyTempModel();
// cerco da cache
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string currKey = $"{Constants.rKeyVocLemma}:{lingua}:{lemma}";
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<VocabularyTempModel>(rawData);
if (tempResult == null)
{
dbResult = new VocabularyTempModel();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = await dbController.VocLemmaFindByKeys(lingua, lemma);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new VocabularyTempModel();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"VocLemmaFindByKeys | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
public async Task<bool> VocLemmaInsert()
{
@@ -2548,6 +2584,17 @@ namespace WebDoorCreator.Data.Services
Log.Debug($"VocLemmaInsert in: {ts.TotalMilliseconds} ms");
return fatto;
}
public async Task<bool> VocLemmaSetConf(string lingua, string lemma, bool isConf)
{
bool fatto = false;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
fatto = await dbController.VocLemmaSetConf(lingua, lemma, isConf);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"VocLemmaSetConf in: {ts.TotalMilliseconds} ms");
return fatto;
}
public async Task<List<VocabularyTempModel>> VocLemmaInsertPrepare(string rootPath)
{
@@ -2595,6 +2642,8 @@ namespace WebDoorCreator.Data.Services
return VocLemmas;
}
public async Task<Dictionary<string, Dictionary<string, string>>?> VocLemmaTEMPGetAll()
{
string source = "DB";
@@ -1,14 +1,12 @@
@page
@model LoginModel
@inject WebDoorCreator.UI.Data.WDCVocabularyService WDCVService
@inject WebDoorCreator.UI.Data.WDCUserService WDCUService
@*@{
@{
ViewData["Title"] = "Log in";
}*@
}
<div class="d-flex justify-content-center">
<h1>@WDCVService.Traduci(WDCUService.currLanguage ?? "EN" , "UI_200")</h1>
<h1>@ViewData["Title"]</h1>
</div>
<div style="
display: flex;
@@ -31,7 +29,7 @@
<div class="row">
<div class="py-3 d-flex justify-content-center align-content-center flex-wrap">
<form id="account" method="post">
<h2 class="text-dark">@WDCVService.Traduci(WDCUService.currLanguage ?? "EN" , "UI_207")</h2>
<h2 class="text-dark">Login to your account</h2>
<hr />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-floating mb-1">
@@ -48,8 +46,7 @@
<div class="checkbox text-dark text-start">
<label asp-for="Input.RememberMe" class="form-label">
<input class="form-check-input" asp-for="Input.RememberMe" />
@*@Html.DisplayNameFor(m => m.Input.RememberMe)*@
@WDCVService.Traduci(WDCUService.currLanguage ?? "EN" , "UI_203")
@Html.DisplayNameFor(m => m.Input.RememberMe)
</label>
</div>
</div>
@@ -58,13 +55,13 @@
</div>
<div>
<p>
<a id="forgot-password" asp-page="./ForgotPassword" class="text-decoration-none text-dark">@WDCVService.Traduci(WDCUService.currLanguage ?? "EN" , "UI_204")</a>
<a id="forgot-password" asp-page="./ForgotPassword" class="text-decoration-none text-dark">Forgot your password?</a>
</p>
<p>
<a asp-page="./Register" asp-route-returnUrl="@Model.ReturnUrl" class="text-decoration-none text-dark">@WDCVService.Traduci(WDCUService.currLanguage ?? "EN" , "UI_205")</a>
<a asp-page="./Register" asp-route-returnUrl="@Model.ReturnUrl" class="text-decoration-none text-dark">Register as a new user</a>
</p>
<p>
<a id="resend-confirmation" asp-page="./ResendEmailConfirmation" class="text-decoration-none text-dark">@WDCVService.Traduci(WDCUService.currLanguage ?? "EN" , "UI_206")</a>
<a id="resend-confirmation" asp-page="./ResendEmailConfirmation" class="text-decoration-none text-dark">Resend email confirmation</a>
</p>
</div>
</form>
@@ -76,4 +73,4 @@
@section Scripts {
<partial name="_ValidationScriptsPartial" />
}
}
@@ -3,45 +3,67 @@
<input @bind-value="@defaultPath" />
@*@if (vocLemmas != null)
{
@foreach (var item in vocLemmas)
{
@foreach (var k in item.Value)
{
@*<div>@($"{k.Key} --> {k.Value}")</div>
@if(vocLemmasTEMP != null)
{
}
}
}
}*@
<button class="btn btn-sm btn-success" @onclick="()=>saveVoc()">SAVE</button>
@result
@if (showList)
{
@if (vocLemmas2Dict != null && vocLemmasTEMP2Dict != null)
{
@foreach (var item in vocLemmasTEMP2Dict)
{
@if (!vocLemmas2Dict.ContainsKey(item.Key))
{
<div class="row">
<div class="col-12 text-success">@($"{item.Key} --> {vocLemmasTEMP2Dict[item.Key]}")</div>
</div>
}
else if (item.Value != vocLemmas2Dict[item.Key])
{
<div class="row">
<div class="col-6 text-danger text-decoration-line-through">@($"{item.Key} --> {vocLemmas2Dict[item.Key]}")</div>
<div class="col-6 text-success">@($"{item.Key} --> {item.Value}")</div>
</div>
}
}
<button class="btn btn-sm btn-success" @onclick="()=>saveVoc()">SAVE</button>
@result
<table class="table table-striped table-bordered border-dark">
<thead>
<tr>
<th class="text-end">Old text</th>
<th>New text</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in vocLemmasTEMP2Dict)
{
<tr>
@if (!vocLemmas2Dict.ContainsKey(item.Key))
{
<td>
</td>
<td class="text-start text-success">
@($"{item.Key} --> {vocLemmasTEMP2Dict[item.Key]}")
</td>
<td>
</td>
}
else if (item.Value != vocLemmas2Dict[item.Key])
{
<td class="col-5 text-end text-danger text-decoration-line-through">
@($"{item.Key} --> {vocLemmas2Dict[item.Key]}")
</td>
<td class="col-5 text-start text-success">
@($"{item.Key} --> {item.Value}")
</td>
<td class="col-1 text-center">
<div class="form-check">
@if (isReady2Save(item.Key))
{
<input class="form-check-input" type="checkbox" value="" id="flexCheckChecked" checked @onclick="()=>setConf(item.Key, false)">
}
else
{
<input class="form-check-input" type="checkbox" value="" id="flexCheckChecked" @onclick="()=>setConf(item.Key, true)">
}
</div>
</td>
}
</tr>
}
</tbody>
</table>
}
}
@@ -16,21 +16,20 @@ namespace WebDoorCreator.UI.Components.FilesMan
protected Dictionary<string, Dictionary<string, string>>? vocLemmas { get; set; } = null;
protected Dictionary<string, string> vocLemmas2Dict { get; set; } = new Dictionary<string, string>();
protected Dictionary<string, Dictionary<string, string>>? vocLemmasTEMP { get; set; } = null;
protected Dictionary<string, string> vocLemmasTEMP2Dict { get; set; } = new Dictionary<string, string>();
protected Dictionary<string, string> vocLemmasTEMP2Dict { get; set; } = new Dictionary<string, string>();
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)
if (vocLemmas != null)
{
foreach(var kvp in vocLemmas)
foreach (var kvp in vocLemmas)
{
foreach(var item in kvp.Value)
foreach (var item in kvp.Value)
{
vocLemmas2Dict.Add(item.Key, item.Value);
}
@@ -38,6 +37,20 @@ namespace WebDoorCreator.UI.Components.FilesMan
}
}
}
#if false
var s = dmp.diff_main(vocLemmas2Dict["11"], newText.Value);
dmp.diff_cleanupSemantic(s);
foreach (var diffes in s)
{
if (diffes.operation == Operation.DELETE)
{
diff.Add(diffes);
}
}
#endif
Dictionary<string, Dictionary<string, string>> listVocLemmaTemp = new Dictionary<string, Dictionary<string, string>>();
protected async Task refreshVoc()
{
vocLemmasTEMP = null;
@@ -46,19 +59,19 @@ namespace WebDoorCreator.UI.Components.FilesMan
if (list2Mod != null)
{
//bool ok = await WDCService.VocLemmaInsert();
var k = await WDCService.VocLemmaTEMPGetAll();
if (k != null)
listVocLemmaTemp = await WDCService.VocLemmaTEMPGetAll();
if (listVocLemmaTemp != null)
{
vocLemmasTEMP = k.Where(x => x.Key == lang).ToDictionary(x => x.Key, x => x.Value);
vocLemmasTEMP = listVocLemmaTemp.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);
}
}
}
}
}
}
@@ -74,6 +87,29 @@ namespace WebDoorCreator.UI.Components.FilesMan
if (done)
{
result = "Done";
vocLemmas2Dict.Clear();
vocLemmasTEMP2Dict.Clear();
}
}
protected bool isReady2Save(string lemma)
{
bool isConf = false;
var tempModTerm = Task.Run(async () => await WDCService.VocLemmaFindByKeys(lang, lemma)).Result;
if (tempModTerm != null)
{
isConf = tempModTerm.IsConfSave;
}
return isConf;
}
protected async Task setConf(string lemma, bool isConf)
{
var tempModTerm = await WDCService.VocLemmaFindByKeys(lang, lemma);
if (tempModTerm != null)
{
var done = await WDCService.VocLemmaSetConf(tempModTerm.Lingua, tempModTerm.Lemma, isConf);
}
}
protected string defaultPath { get; set; } = "";
+1 -1
View File
@@ -9,7 +9,7 @@
<div class="row mb-3">
<div class="fw-bold fs-2 text-start col-4 text-nowrap">
ORDER LIST
@(translate("OHP_OrderList"))
@(translate("Order List"))
</div>
<div class="d-flex justify-content-end col-8">
<div style="width: 17rem; height: 5rem">
+7 -10
View File
@@ -10,17 +10,17 @@
Company management
</div>
<div class="fs-5 @selectedUser" @onclick="()=>doShowUser()">
Users Management
Files management
</div>
</div>
<div>
<button class="btn btn-warning" @onclick="()=>refreshHw()">HARDWARE REFRESH</button>
@*<button class="btn btn-info" @onclick="()=>refreshVoc()">VOCABULARY REFRESH</button>*@
<button class="btn btn-info" @onclick="()=>refreshFiles()">FILES REFRESH</button>
@*<div>
<button class="btn btn-warning" @onclick="()=>refreshHw()">HARDWARE REFRESH</button>
@*<button class="btn btn-info" @onclick="()=>refreshVoc()">VOCABULARY REFRESH</button>
<button class="btn btn-info" @onclick="()=>refreshFiles()">FILES REFRESH</button>
</div>
<!--NON USO TYPE FILE PERCHE' NON PRENDE IL PATH DEL FILE MA RESTITUISCE C:\\fakepath-->
<input @bind-value="@defaultPath" />
<input @bind-value="@defaultPath" />*@
</div>
<div class="listContainer">
<!-- Button trigger modal -->
@@ -34,10 +34,7 @@
}
else
{
<h5 class="">General Application user list</h5>
<button type="button" class="btn btn-sm btn-success" data-bs-toggle="modal" data-bs-target="#newUserModal">
<i class="fa-solid fa-plus"></i> Add new user
</button>
<h5 class="">General Application files management</h5>
}
</div>
@if (isCompShow)
+2 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>0.9.2306.0611</Version>
<Version>0.9.2306.0617</Version>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608</UserSecretsId>
</PropertyGroup>
@@ -37,6 +37,7 @@
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Blazored.SessionStorage" Version="2.3.0" />
<PackageReference Include="DiffMatchPatch" Version="1.0.3" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2305.3021" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2305.3021" />
<PackageReference Include="EntityFrameworkCore.SqlServer.HierarchyId" Version="3.0.1" />