diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs
index a3e62c7d..51027aea 100644
--- a/MP.Data/Controllers/MpTabController.cs
+++ b/MP.Data/Controllers/MpTabController.cs
@@ -2281,6 +2281,98 @@ namespace MP.Data.Controllers
return dbResult;
}
+ ///
+ /// Elenco template da ricerca
+ ///
+ ///
+ ///
+ public List TemplateKitFilt(string searchVal)
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = dbCtx
+ .DbSetTempKit
+ .Where(x => x.CodArtParent.Contains(searchVal) || x.CodArtChild.Contains(searchVal))
+ .AsNoTracking()
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Elimina record
+ ///
+ ///
+ public bool TemplateKitDelete(TemplateKitModel currRecord)
+ {
+ bool fatto = false;
+#if false
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var actRec = dbCtx
+ .DbSetInsManuali
+ .Where(x => currRecord.IdxInsMan > 0 && x.IdxInsMan == currRecord.IdxInsMan)
+ .FirstOrDefault();
+ // se ci fosse aggiorno...
+ if (actRec != null)
+ {
+ dbCtx
+ .DbSetInsManuali
+ .Remove(actRec);
+ }
+ var res = dbCtx.SaveChanges();
+ fatto = res != 0;
+ }
+#endif
+ return fatto;
+ }
+
+
+ ///
+ /// Esegue upsert record
+ ///
+ ///
+ public bool TemplateKitUpsert(TemplateKitModel currRecord)
+ {
+ bool fatto = false;
+#if false
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var actRec = dbCtx
+ .DbSetInsManuali
+ .Where(x => currRecord.IdxInsMan > 0 && x.IdxInsMan == currRecord.IdxInsMan)
+ .FirstOrDefault();
+ // se ci fosse aggiorno...
+ if (actRec == null)
+ {
+ dbCtx
+ .DbSetInsManuali
+ .Add(currRecord);
+ }
+ else
+ {
+ actRec.CodArticolo = currRecord.CodArticolo;
+ actRec.FineStato = currRecord.FineStato;
+ actRec.IdxMacchina = currRecord.IdxMacchina;
+ actRec.IdxTipoEv = currRecord.IdxTipoEv;
+ actRec.Imported = currRecord.Imported;
+ actRec.InizioStato = currRecord.InizioStato;
+ actRec.KeyRichiesta = currRecord.KeyRichiesta;
+ actRec.MatrOpr = currRecord.MatrOpr;
+ actRec.MinProd = currRecord.MinProd;
+ actRec.PzBuoni = currRecord.PzBuoni;
+ actRec.TCiclo = currRecord.TCiclo;
+ dbCtx.Entry(actRec).State = EntityState.Modified;
+ }
+ var res = dbCtx.SaveChanges();
+ fatto = res != 0;
+ }
+#endif
+ return fatto;
+ }
+
+
///
/// Elenco turni macchina (all)
///
diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs
index 92c6b5cb..e32af9bb 100644
--- a/MP.Data/Services/TabDataService.cs
+++ b/MP.Data/Services/TabDataService.cs
@@ -259,41 +259,6 @@ namespace MP.Data.Services
return result;
}
-
- ///
- /// Elenco parametri validi tab/campo
- ///
- ///
- public List ListValuesFilt(string tabName, string fieldName)
- {
- string source = "DB";
- Stopwatch sw = new Stopwatch();
- sw.Start();
- List? result = new List();
- // cerco in redis...
- string currKey = $"{redisBaseKey}:ListVal:{tabName}:{fieldName}";
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- source = "REDIS";
- }
- else
- {
- result = dbTabController.ListValuesFilt(tabName, fieldName);
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, UltraLongCache);
- }
- if (result == null)
- {
- result = new List();
- }
- sw.Stop();
- Log.Debug($"ListValuesFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms");
- return result;
- }
-
///
/// Elenco EVENTI validi x macchina
///
@@ -1079,6 +1044,28 @@ namespace MP.Data.Services
return result;
}
+ ///
+ /// Chiama stored x congelare i dati giornalieri
+ ///
+ ///
+ ///
+ ///
+ public async Task InsManFreezeDay(string idxMacchina, DateTime dtCurr)
+ {
+ bool fatto = false;
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+ Log.Info($"Inizio InsManFreezeDay | idxMacchina: {idxMacchina}");
+ // salvo
+ fatto = await dbTabController.InsManFreezeDay(idxMacchina, dtCurr);
+ // svuoto cache
+ RedisValue pattern = $"{redisBaseKey}:InsMan:*";
+ await ExecFlushRedisPatternAsync(pattern);
+ sw.Stop();
+ Log.Info($"Fine InsManFreezeDay | idxMacchina: {idxMacchina} | elapsed: {sw.Elapsed.TotalMilliseconds:N2} ms");
+ return fatto;
+ }
+
///
/// Elenco DTO x plotting seq stati giornaliero
///
@@ -1179,36 +1166,12 @@ namespace MP.Data.Services
ValueMax = 1440
};
result.Add(currRec);
-
}
}
}
return result;
}
- ///
- /// Chiama stored x congelare i dati giornalieri
- ///
- ///
- ///
- ///
- public async Task InsManFreezeDay(string idxMacchina, DateTime dtCurr)
- {
- bool fatto = false;
- Stopwatch sw = new Stopwatch();
- sw.Start();
- Log.Info($"Inizio InsManFreezeDay | idxMacchina: {idxMacchina}");
- // salvo
- fatto = await dbTabController.InsManFreezeDay(idxMacchina, dtCurr);
- // svuoto cache
- RedisValue pattern = $"{redisBaseKey}:InsMan:*";
- await ExecFlushRedisPatternAsync(pattern);
- sw.Stop();
- Log.Info($"Fine InsManFreezeDay | idxMacchina: {idxMacchina} | elapsed: {sw.Elapsed.TotalMilliseconds:N2} ms");
- return fatto;
- }
-
-
///
/// Esegue salvataggio record + svuotamento cache
///
@@ -1308,6 +1271,40 @@ namespace MP.Data.Services
return result;
}
+ ///
+ /// Elenco parametri validi tab/campo
+ ///
+ ///
+ public List ListValuesFilt(string tabName, string fieldName)
+ {
+ string source = "DB";
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+ List? result = new List();
+ // cerco in redis...
+ string currKey = $"{redisBaseKey}:ListVal:{tabName}:{fieldName}";
+ RedisValue rawData = redisDb.StringGet(currKey);
+ if (rawData.HasValue)
+ {
+ result = JsonConvert.DeserializeObject>($"{rawData}");
+ source = "REDIS";
+ }
+ else
+ {
+ result = dbTabController.ListValuesFilt(tabName, fieldName);
+ // serializzo e salvo...
+ rawData = JsonConvert.SerializeObject(result);
+ redisDb.StringSet(currKey, rawData, UltraLongCache);
+ }
+ if (result == null)
+ {
+ result = new List();
+ }
+ sw.Stop();
+ Log.Debug($"ListValuesFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms");
+ return result;
+ }
+
///
/// Elenco lotti esterni presenti sul db di ARCA
///
@@ -3444,6 +3441,71 @@ namespace MP.Data.Services
return result;
}
+ ///
+ /// Elimina record + svuotamento cache
+ ///
+ ///
+ public async Task TemplateKitDelete(TemplateKitModel currRecord)
+ {
+ bool fatto = false;
+ // salvo
+ fatto = dbTabController.TemplateKitDelete(currRecord);
+ // svuoto cache
+ RedisValue pattern = $"{redisBaseKey}:KitTemplate:*";
+ await ExecFlushRedisPatternAsync(pattern);
+ return fatto;
+ }
+
+ ///
+ /// Elenco template da ricerca
+ ///
+ ///
+ ///
+ public List TemplateKitFilt(string searchVal)
+ {
+ string source = "DB";
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+ List? result = new List();
+ // cerco in redis...
+ string currKey = $"{redisBaseKey}:KitTemplate:{searchVal}";
+ RedisValue rawData = redisDb.StringGet(currKey);
+ if (rawData.HasValue)
+ {
+ result = JsonConvert.DeserializeObject>($"{rawData}");
+ source = "REDIS";
+ }
+ else
+ {
+ result = dbTabController.TemplateKitFilt(searchVal);
+ // serializzo e salvo...
+ rawData = JsonConvert.SerializeObject(result);
+ redisDb.StringSet(currKey, rawData, FastCache);
+ }
+ if (result == null)
+ {
+ result = new List();
+ }
+ sw.Stop();
+ Log.Debug($"TemplateKitFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms");
+ return result;
+ }
+
+ ///
+ /// Esegue salvataggio record + svuotamento cache
+ ///
+ ///
+ public async Task TemplateKitUpsert(TemplateKitModel currRecord)
+ {
+ bool fatto = false;
+ // salvo
+ fatto = dbTabController.TemplateKitUpsert(currRecord);
+ // svuoto cache
+ RedisValue pattern = $"{redisBaseKey}:KitTemplate:*";
+ await ExecFlushRedisPatternAsync(pattern);
+ return fatto;
+ }
+
///
/// Turno macchina
///
@@ -4119,7 +4181,6 @@ namespace MP.Data.Services
return redHashMpIO($"SavedTask:{idxMacchina}");
}
-
#endregion Private Methods
}
}
\ No newline at end of file