bozza sel macchine
This commit is contained in:
@@ -360,6 +360,7 @@ namespace MP.Data.Controllers
|
||||
/// <summary>
|
||||
/// Vista v_MSFD CALCOALTA x singola macchina (da stored) - singolo record
|
||||
/// </summary>
|
||||
/// <param name="idxMacc"></param>
|
||||
/// <returns></returns>
|
||||
public List<VMSFDModel> VMSFDGetByMacc(string idxMacc)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,9 @@ using System.Collections.Generic;
|
||||
|
||||
namespace MP.Data.DatabaseModels
|
||||
{
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
public partial class VMSFDModel
|
||||
{
|
||||
public string IdxMacchina { get; set; }
|
||||
|
||||
@@ -25,6 +25,17 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
public Dictionary<string, string> DictMacchine { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario macchine con info multi(bool)
|
||||
/// </summary>
|
||||
public Dictionary<string, int> DictMacchMulti { get; set; } = new Dictionary<string, int>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// List configurazione attiva da tab DB
|
||||
/// </summary>
|
||||
public List<VMSFDModel> ListMSFD { get; set; } = new List<VMSFDModel>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario Menu
|
||||
/// </summary>
|
||||
@@ -85,6 +96,14 @@ namespace MP.Data.Services
|
||||
Log.Info("SharedMemService | SetConfig executed!");
|
||||
}
|
||||
|
||||
public void SetMsfd(List<VMSFDModel> newList)
|
||||
{
|
||||
ListMSFD = newList ?? new List<VMSFDModel>();
|
||||
// salvo dizionario
|
||||
DictMacchMulti = ListMSFD.ToDictionary(x => x.IdxMacchina, x => x.Multi);
|
||||
Log.Info("SharedMemService | SetMsfd executed!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua setup memorie menu recuperando dati dal DB + popolando dizionario x livelli
|
||||
/// </summary>
|
||||
|
||||
@@ -31,9 +31,11 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new Controllers.MpTabController(configuration);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
dbTabController = new Controllers.MpTabController(configuration);
|
||||
sb.AppendLine($"TabDataService | MpTabController OK");
|
||||
dbIocController = new Controllers.MpIocController(configuration);
|
||||
sb.AppendLine($"TabDataService | MpIocController OK");
|
||||
Log.Info(sb.ToString());
|
||||
}
|
||||
}
|
||||
@@ -42,7 +44,8 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static Controllers.MpTabController dbController { get; set; } = null!;
|
||||
public static Controllers.MpIocController dbIocController { get; set; } = null!;
|
||||
public static Controllers.MpTabController dbTabController { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -67,7 +70,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.AnagEventiGetAll();
|
||||
result = dbTabController.AnagEventiGetAll();
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -95,7 +98,7 @@ namespace MP.Data.Services
|
||||
public bool ConfermaProdMacchina(string idxMacchina, int modoConfProd, int numPzConfermati, int numPzScarto, DateTime DataOraApp, int MatrOpr)
|
||||
{
|
||||
bool answ = false;
|
||||
answ = dbController.ConfermaProdMacchina(idxMacchina, modoConfProd, numPzConfermati, numPzScarto, DataOraApp, MatrOpr);
|
||||
answ = dbTabController.ConfermaProdMacchina(idxMacchina, modoConfProd, numPzConfermati, numPzScarto, DataOraApp, MatrOpr);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -116,7 +119,7 @@ namespace MP.Data.Services
|
||||
public bool ConfermaProdMacchinaFull(string idxMacchina, int modoConfProd, int numPzConfermati, int numPzLasciati, int numPzScarto, DateTime DataOraApp, int MatrOpr)
|
||||
{
|
||||
bool answ = false;
|
||||
answ = dbController.ConfermaProdMacchinaFull(idxMacchina, modoConfProd, numPzConfermati, numPzLasciati, numPzScarto, DataOraApp, MatrOpr);
|
||||
answ = dbTabController.ConfermaProdMacchinaFull(idxMacchina, modoConfProd, numPzConfermati, numPzLasciati, numPzScarto, DataOraApp, MatrOpr);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -140,7 +143,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ConfigGetAll());
|
||||
result = await Task.FromResult(dbTabController.ConfigGetAll());
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -157,7 +160,7 @@ namespace MP.Data.Services
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
dbTabController.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -169,7 +172,7 @@ namespace MP.Data.Services
|
||||
public bool RicalcMse(string idxMacchina, int maxAgeSec)
|
||||
{
|
||||
bool answ = false;
|
||||
answ = dbController.RicalcMse(idxMacchina, maxAgeSec);
|
||||
answ = dbTabController.RicalcMse(idxMacchina, maxAgeSec);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -196,7 +199,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.STAR_byGrpOdl(codGruppo, idxODL);
|
||||
result = dbTabController.STAR_byGrpOdl(codGruppo, idxODL);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -234,7 +237,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.STAR_byGrpOdlLbl(codGruppo, label, idxODL);
|
||||
result = dbTabController.STAR_byGrpOdlLbl(codGruppo, label, idxODL);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -271,7 +274,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.StatoProdMacchina(idxMacchina, dtReq);
|
||||
result = dbTabController.StatoProdMacchina(idxMacchina, dtReq);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraFastCache);
|
||||
@@ -285,6 +288,77 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intera vista v_MSFD
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<VMSFDModel>> VMSFDGetAll()
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<VMSFDModel> result = new List<VMSFDModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:MSFD:ALL";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<VMSFDModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbIocController.VMSFDGetAll();
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<VMSFDModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"VMSFDGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vista v_MSFD CALCOALTA x singola macchina (da stored) - singolo record
|
||||
/// </summary>
|
||||
/// <param name="idxMacc"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<VMSFDModel>> VMSFDGetByMacc(string idxMacc)
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<VMSFDModel>? result = new List<VMSFDModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:MSFD:MACCH:{idxMacc}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<VMSFDModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbIocController.VMSFDGetByMacc(idxMacc);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraFastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<VMSFDModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"VMSFDGetByMacc | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
Reference in New Issue
Block a user