Fix traduzione scheda tecnica

This commit is contained in:
Samuele Locatelli
2023-10-26 15:27:32 +02:00
parent b8b506ca4e
commit 20b92a2c71
10 changed files with 192 additions and 89 deletions
+51 -33
View File
@@ -746,39 +746,6 @@ namespace MP.Data.Controllers
return dbResult;
}
/// <summary>
/// Restituisce elenco gruppi Scheda tecnica
/// </summary>
/// <returns></returns>
public List<ST_AnagGruppi> ST_AnagGruppiList()
{
List<ST_AnagGruppi> dbResult = new List<ST_AnagGruppi>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetStAnagGruppi
.OrderBy(x => x.OrdVisual)
.AsNoTracking()
.ToList();
}
return dbResult;
}
public bool ST_CheckCleanByOdl(int idxOdl)
{
bool fatto = false;
using (var dbCtx = new MoonProContext(_configuration))
{
var IdxOdl = new SqlParameter("@IdxOdl", idxOdl);
var result = dbCtx
.Database
.ExecuteSqlRaw("EXEC stp_ST_CHK_cleanByOdl @IdxOdl", IdxOdl);
fatto = result != 0;
}
return fatto;
}
/// <summary>
/// Registra controllo
/// </summary>
@@ -1053,6 +1020,39 @@ namespace MP.Data.Controllers
return dbResult;
}
/// <summary>
/// Restituisce elenco gruppi Scheda tecnica
/// </summary>
/// <returns></returns>
public List<ST_AnagGruppi> ST_AnagGruppiList()
{
List<ST_AnagGruppi> dbResult = new List<ST_AnagGruppi>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetStAnagGruppi
.OrderBy(x => x.OrdVisual)
.AsNoTracking()
.ToList();
}
return dbResult;
}
public bool ST_CheckCleanByOdl(int idxOdl)
{
bool fatto = false;
using (var dbCtx = new MoonProContext(_configuration))
{
var IdxOdl = new SqlParameter("@IdxOdl", idxOdl);
var result = dbCtx
.Database
.ExecuteSqlRaw("EXEC stp_ST_CHK_cleanByOdl @IdxOdl", IdxOdl);
fatto = result != 0;
}
return fatto;
}
/// <summary>
/// Recupero Righe (Actual) della scheda tecnica da GRUPPO + ODL
/// </summary>
@@ -1230,6 +1230,24 @@ namespace MP.Data.Controllers
return answ;
}
/// <summary>
/// Elenco Vocabolario (completo)
/// </summary>
/// <returns></returns>
public List<VocabolarioModel> VocabolarioGetAll()
{
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetVocabolario
.AsNoTracking()
.OrderBy(x => x.Lemma)
.ToList();
}
return dbResult;
}
/// <summary>
/// Elenco causali scarto
/// </summary>
+48
View File
@@ -45,6 +45,11 @@ namespace MP.Data.Services
/// </summary>
public Dictionary<int, AnagStatiModel> DictStati { get; set; } = new Dictionary<int, AnagStatiModel>();
/// <summary>
/// Dizionario globale (key: lingua_lemma, lowercase)
/// </summary>
public Dictionary<string, string> DictVocab { get; set; } = new Dictionary<string, string>();
/// <summary>
/// Lista completa eventi
/// </summary>
@@ -60,6 +65,11 @@ namespace MP.Data.Services
/// </summary>
public List<AnagStatiModel> ListStati { get; set; } = new List<AnagStatiModel>();
/// <summary>
/// Lista completa stati
/// </summary>
public List<VocabolarioModel> ListVocab { get; set; } = new List<VocabolarioModel>();
public bool MenuOk
{
get => AllMenuData.Count > 0;
@@ -81,6 +91,7 @@ namespace MP.Data.Services
DictConfig = new Dictionary<string, string>();
DictEventi = new Dictionary<int, AnagEventiModel>();
DictStati = new Dictionary<int, AnagStatiModel>();
DictVocab = new Dictionary<string, string>();
Log.Info("SharedMemService | Cache resetted!");
}
@@ -224,12 +235,49 @@ namespace MP.Data.Services
Log.Info("SharedMemService | SetupMenu executed!");
}
/// <summary>
/// Effettua setup vocabolario
/// </summary>
/// <param name="allVoc"></param>
public void SetVocab(List<VocabolarioModel> allVoc)
{
ListVocab = allVoc ?? new List<VocabolarioModel>();
// salvo dizionario
DictVocab = ListVocab.ToDictionary(x => $"{x.Lingua}_{x.Lemma.ToUpper()}", x => x.Traduzione);
Log.Info("SharedMemService | SetVocab executed!");
}
public string Traduci(string lingua, string lemma)
{
return Traduci($"{lingua}_{lemma}".ToUpper());
}
/// <summary>
/// Traduzione diretta vocabolario
/// </summary>
/// <param name="lingua_lemma">Formato {lingua}_{lemma}, lowercase</param>
/// <returns></returns>
public string Traduci(string lingua_lemma)
{
string answ = $"[{lingua_lemma}]";
if (DictVocab.ContainsKey(lingua_lemma))
{
answ = DictVocab[lingua_lemma];
}
return answ;
}
#endregion Public Methods
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// Oggetto vocabolario x uso continuo traduzione
/// </summary>
private List<VocabolarioModel> ObjVocabolario = new List<VocabolarioModel>();
#endregion Private Fields
#region Private Properties
+30
View File
@@ -1078,6 +1078,36 @@ namespace MP.Data.Services
return result;
}
public List<VocabolarioModel> VocabolarioGetAll()
{
// setup parametri costanti
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<VocabolarioModel>? result = new List<VocabolarioModel>();
// cerco in redis...
string currKey = $"{redisBaseKey}:Vocab";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<List<VocabolarioModel>>($"{rawData}");
source = "REDIS";
}
else
{
result = dbTabController.VocabolarioGetAll();
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, UltraLongCache);
}
if (result == null)
{
result = new List<VocabolarioModel>();
}
sw.Stop();
Log.Debug($"VocabolarioGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
/// <summary>
/// Aggiunta record RegistroScarti