Ancora update metodi bench
This commit is contained in:
@@ -367,6 +367,36 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// Intera tabella relazione master/slave in machine (gestione setup master --> slave)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<TransizioneIngressiModel> StateMachineIngressi(int idxFam)
|
||||
{
|
||||
List<TransizioneIngressiModel> dbResult = new List<TransizioneIngressiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
//dbResult = dbCtx
|
||||
// .DbSetSMI
|
||||
// .Where(x => x.IdxFamigliaIngresso == idxFam)
|
||||
// .AsNoTracking()
|
||||
// .OrderBy(x => x.IdxMicroStato)
|
||||
// .ThenBy(x => x.ValoreIngresso)
|
||||
// .ToList();
|
||||
|
||||
var IdxFamIng = new SqlParameter("@IdxFamigliaIngresso", idxFam);
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetSMI
|
||||
.FromSqlRaw("exec dbo.stp_TRI_getByIdxFamIng @IdxFamigliaIngresso", IdxFamIng)
|
||||
.AsNoTracking()
|
||||
.AsEnumerable()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MP.Data.DatabaseModels
|
||||
{
|
||||
public partial class TransizioneIngressiModel
|
||||
{
|
||||
public int IdxFamigliaIngresso { get; set; }
|
||||
public int IdxMicroStato { get; set; }
|
||||
public int ValoreIngresso { get; set; }
|
||||
public int? IdxTipoEvento { get; set; }
|
||||
public int NextIdxMicroStato { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,7 @@ namespace MP.Data
|
||||
public virtual DbSet<DatiMacchineModel> DbSetDatiMacchine { get; set; }
|
||||
public virtual DbSet<VMSFDModel> DbSetMSFD { get; set; }
|
||||
public virtual DbSet<Macchine2SlaveModel> DbSetM2S { get; set; }
|
||||
public virtual DbSet<TransizioneIngressiModel> DbSetSMI { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -443,6 +444,14 @@ namespace MP.Data
|
||||
entity.Property(e => e.IdxMacchinaSlave).HasMaxLength(50);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TransizioneIngressiModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.IdxFamigliaIngresso, e.IdxMicroStato, e.ValoreIngresso });
|
||||
|
||||
entity.ToTable("TransizioneIngressi");
|
||||
|
||||
entity.Property(e => e.NextIdxMicroStato).HasColumnName("next_IdxMicroStato");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace MP.IOC.Controllers
|
||||
// Get the elapsed time as a TimeSpan value.
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
// accodo tempo!
|
||||
answ += $"Elapsed: {ts.TotalMilliseconds}ms";
|
||||
answ += $"{Environment.NewLine}Elapsed: {ts.TotalMilliseconds}ms";
|
||||
// ritorno
|
||||
return answ;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ namespace MP.IOC.Controllers
|
||||
// Get the elapsed time as a TimeSpan value.
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
// accodo tempo!
|
||||
answ += $"Elapsed: {ts.TotalMilliseconds}ms";
|
||||
answ += $"{Environment.NewLine}Elapsed: {ts.TotalMilliseconds}ms";
|
||||
// ritorno
|
||||
return answ;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ namespace MP.IOC.Controllers
|
||||
// Get the elapsed time as a TimeSpan value.
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
// accodo tempo!
|
||||
answ += $"Elapsed: {ts.TotalMilliseconds}ms";
|
||||
answ += $"{Environment.NewLine}Elapsed: {ts.TotalMilliseconds}ms";
|
||||
// ritorno
|
||||
return answ;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ namespace MP.IOC.Controllers
|
||||
answ = "";
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> valori = DService.GetCurrMSFDMacc(id);
|
||||
Dictionary<string, string> valori = DService.MSFDMaccGetCurr(id);
|
||||
foreach (var item in valori)
|
||||
{
|
||||
answ += $"{item.Key}|{item.Value}{Environment.NewLine}";
|
||||
@@ -199,69 +199,80 @@ namespace MP.IOC.Controllers
|
||||
// Get the elapsed time as a TimeSpan value.
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
// accodo tempo!
|
||||
answ += $"Elapsed: {ts.TotalMilliseconds}ms";
|
||||
answ += $"{Environment.NewLine}Elapsed: {ts.TotalMilliseconds}ms";
|
||||
// ritorno
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Conteggio chiavi REDIS dato pattern
|
||||
/// api/Bench/CountKeys
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("CountKeys")]
|
||||
public string CNTKEY(string? id)
|
||||
{
|
||||
string answ = "ND";
|
||||
if (id == null) id = "";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
// conto quanti oggetti ho in memoria REDIS...
|
||||
string groupHash = ""; // DataLayer.mHash("");
|
||||
if (id.Length > 0)
|
||||
{
|
||||
groupHash += id + ":";
|
||||
}
|
||||
groupHash += "*";
|
||||
answ = $"Trovate {DService.RedisCountKey(groupHash)} Hash per {groupHash}";
|
||||
stopWatch.Stop();
|
||||
// Get the elapsed time as a TimeSpan value.
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
// accodo tempo!
|
||||
answ += $"{Environment.NewLine}Elapsed: {ts.TotalMilliseconds}ms";
|
||||
// ritorno
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Lettura tab StateMachineIngressi
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("StateMachineIn")]
|
||||
public string tSMI(int? id)
|
||||
{
|
||||
string answ = "ND";
|
||||
long splitTime = 0;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
// se id nullo --> KO!
|
||||
if (id == null)
|
||||
{
|
||||
answ = "KO";
|
||||
}
|
||||
else
|
||||
{
|
||||
int idxFamIn = Convert.ToInt32(id);
|
||||
answ = "";
|
||||
try
|
||||
{
|
||||
KeyValuePair<string, string>[] valori = DService.StateMachInByKey(idxFamIn);
|
||||
splitTime = stopWatch.ElapsedMilliseconds;
|
||||
foreach (var item in valori)
|
||||
{
|
||||
answ += $"{item.Key}|{item.Value}{Environment.NewLine}";
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
stopWatch.Stop();
|
||||
// Get the elapsed time as a TimeSpan value.
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
// accodo tempo!
|
||||
answ += $"{Environment.NewLine}ReadTime: {splitTime}ms<br>Total Time Elapsed: {ts.TotalMilliseconds}ms";
|
||||
// ritorno
|
||||
return answ;
|
||||
}
|
||||
//// GET BENCH/CNTKEY/KEY_NAME
|
||||
//public string CNTKEY(string id)
|
||||
//{
|
||||
// string answ = "ND";
|
||||
// if (id == null) id = "";
|
||||
// Stopwatch stopWatch = new Stopwatch();
|
||||
// stopWatch.Start();
|
||||
// // conto quanti oggetti DTMac ho in memoria...
|
||||
// string groupHash = DataLayer.mHash("");
|
||||
// if (id.Length > 0)
|
||||
// {
|
||||
// groupHash += id + ":";
|
||||
// }
|
||||
// groupHash += "*";
|
||||
// answ = string.Format("Trovate {0} Hash per {1}", memLayer.ML.redCountKey(groupHash), groupHash);
|
||||
// stopWatch.Stop();
|
||||
// // Get the elapsed time as a TimeSpan value.
|
||||
// TimeSpan ts = stopWatch.Elapsed;
|
||||
// // accodo tempo!
|
||||
// answ += $"Elapsed: {ts.TotalMilliseconds}ms";
|
||||
// // ritorno
|
||||
// return answ;
|
||||
//}
|
||||
//// GET BENCH/tSMI/1
|
||||
//public string tSMI(int? id)
|
||||
//{
|
||||
// string answ = "ND";
|
||||
// long splitTime = 0;
|
||||
// Stopwatch stopWatch = new Stopwatch();
|
||||
// stopWatch.Start();
|
||||
// // se id nullo --> KO!
|
||||
// if (id == null)
|
||||
// {
|
||||
// answ = "KO";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// int idxFamIn = Convert.ToInt32(id);
|
||||
// answ = "";
|
||||
// try
|
||||
// {
|
||||
// KeyValuePair<string, string>[] valori = DataLayerObj.mTabSMI(idxFamIn);
|
||||
// splitTime = stopWatch.ElapsedMilliseconds;
|
||||
// foreach (var item in valori)
|
||||
// {
|
||||
// answ += string.Format("{0}|{1}<br/>", item.Key, item.Value);
|
||||
// }
|
||||
// }
|
||||
// catch
|
||||
// { }
|
||||
// }
|
||||
// stopWatch.Stop();
|
||||
// // Get the elapsed time as a TimeSpan value.
|
||||
// TimeSpan ts = stopWatch.Elapsed;
|
||||
// // accodo tempo!
|
||||
// answ += string.Format("<hr/>ReadTime: {0}ms<br>Total Time Elapsed: {1}ms", splitTime, ts.TotalMilliseconds);
|
||||
// // ritorno
|
||||
// return answ;
|
||||
//}
|
||||
//// GET BENCH/fSMI/18?idxMS=1&valore=1
|
||||
//public string fSMI(int? id, int? idxMS, int? valore)
|
||||
//{
|
||||
|
||||
+237
-129
@@ -662,6 +662,28 @@ namespace MP.IOC.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
public List<FluxLogDTO> FluxLogGetByFlux(string Valore)
|
||||
{
|
||||
List<FluxLogDTO> answ = new List<FluxLogDTO>();
|
||||
DossierFluxLogDTO? result = JsonConvert.DeserializeObject<DossierFluxLogDTO>(Valore);
|
||||
if (result != null)
|
||||
{
|
||||
if (result.ODL != null)
|
||||
{
|
||||
answ = result
|
||||
.ODL
|
||||
.OrderBy(x => x.CodFlux)
|
||||
.ToList();
|
||||
// inizializzo SE necessario
|
||||
foreach (var item in answ)
|
||||
{
|
||||
item.ValoreEdit = String.IsNullOrEmpty(item.ValoreEdit) ? item.Valore : item.ValoreEdit;
|
||||
}
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ultimi n record flux log dato macchina e flusso (ordinato x data registrazione)
|
||||
/// </summary>
|
||||
@@ -709,132 +731,6 @@ namespace MP.IOC.Data
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco setup dei tag conf correnti
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<Dictionary<string, List<TagData>>> getAllTags()
|
||||
{
|
||||
return Task.FromResult(currTagConf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato
|
||||
/// </summary>
|
||||
/// <param name="idxMacc"></param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> GetCurrMSFDMacc(string idxMacc)
|
||||
{
|
||||
Dictionary<string, string>? result = new Dictionary<string, string>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string readType = "DB";
|
||||
string currKey = $"{redisBaseAddr}:DSMacc:{idxMacc}";
|
||||
// cerco in redis dato valore sel macchina...
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<Dictionary<string, string>>($"{rawData}");
|
||||
readType = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
var dbResults = dbController.VMSFDGetByMacc(idxMacc);
|
||||
// converto in formato dizionario...
|
||||
if (dbResults != null && dbResults.Count > 0)
|
||||
{
|
||||
var rowResult = dbResults[0];
|
||||
// salvo 1:1 i valori... STATO
|
||||
result.Add("IdxMicroStato", $"{rowResult.IdxMicroStato}");
|
||||
result.Add("IdxStato", $"{rowResult.IdxStato}");
|
||||
result.Add("CodArticolo", $"{rowResult.CodArticolo}");
|
||||
result.Add("insEnabled", $"{rowResult.InsEnabled}");
|
||||
result.Add("sLogEnabled", $"{rowResult.SLogEnabled}");
|
||||
result.Add("pallet", $"{rowResult.Pallet}");
|
||||
result.Add("CodArticolo_A", $"{rowResult.CodArticoloA}");
|
||||
result.Add("CodArticolo_B", $"{rowResult.CodArticoloB}");
|
||||
result.Add("TempoCicloBase", $"{rowResult.TempoCicloBase}");
|
||||
result.Add("PzPalletProd", $"{rowResult.PzPalletProd}");
|
||||
result.Add("MatrOpr", $"{rowResult.MatrOpr}");
|
||||
result.Add("lastVal", $"{rowResult.LastVal}");
|
||||
result.Add("TCBase", $"{rowResult.TempoCicloBase}");
|
||||
|
||||
//...e SETUP
|
||||
result.Add("CodMacc", $"{rowResult.Codmacchina}");
|
||||
result.Add("IdxFamIn", $"{rowResult.IdxFamigliaIngresso}");
|
||||
result.Add("Multi", $"{rowResult.Multi}");
|
||||
result.Add("BitFilt", $"{rowResult.BitFilt}");
|
||||
result.Add("MaxVal", $"{rowResult.MaxVal}");
|
||||
result.Add("BSR", $"{rowResult.Bsr}");
|
||||
result.Add("ExplodeBit", $"{rowResult.ExplodeBit}");
|
||||
result.Add("NumBit", $"{rowResult.NumBit}");
|
||||
result.Add("IdxFamMacc", $"{rowResult.IdxFamiglia}");
|
||||
result.Add("simplePallet", $"{rowResult.SimplePallet}");
|
||||
result.Add("palletChange", $"{rowResult.PalletChange}");
|
||||
}
|
||||
// cerco info Master/slave...
|
||||
var m2sTab = Macchine2SlaveGetAll();
|
||||
string isMaster = m2sTab.Where(x => x.IdxMacchina == idxMacc).Count() > 0 ? "1" : "0";
|
||||
string isSlave = m2sTab.Where(x => x.IdxMacchinaSlave == idxMacc).Count() > 0 ? "1" : "0";
|
||||
result.Add("Master", isMaster);
|
||||
result.Add("Slave", isSlave);
|
||||
|
||||
// serializzo
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
// durata cache secondo valore insEnabled...
|
||||
double numMinCache = (result["insEnabled"].ToLower() == "true") ? redisShortTimeCache / 4 : redisShortTimeCache;
|
||||
// ...e salvo...
|
||||
redisDb.StringSet(currKey, rawData, getRandTOut(numMinCache));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new Dictionary<string, string>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"GetCurrMSFDMacc | Read from {readType}: {ts.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<FluxLogDTO> getFluxLog(string Valore)
|
||||
{
|
||||
List<FluxLogDTO> answ = new List<FluxLogDTO>();
|
||||
DossierFluxLogDTO? result = JsonConvert.DeserializeObject<DossierFluxLogDTO>(Valore);
|
||||
if (result != null)
|
||||
{
|
||||
if (result.ODL != null)
|
||||
{
|
||||
answ = result
|
||||
.ODL
|
||||
.OrderBy(x => x.CodFlux)
|
||||
.ToList();
|
||||
// inizializzo SE necessario
|
||||
foreach (var item in answ)
|
||||
{
|
||||
item.ValoreEdit = String.IsNullOrEmpty(item.ValoreEdit) ? item.Valore : item.ValoreEdit;
|
||||
}
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// restituisce il valore da REDIS associato al tag richeisto
|
||||
/// </summary>
|
||||
/// <param name="redKey">Chiave in cui cercare il valore</param>
|
||||
/// <returns></returns>
|
||||
public string getTagConf(string redKey)
|
||||
{
|
||||
string outVal = "";
|
||||
// cerco in REDIS la conf x l'IOB
|
||||
var rawData = redisDb.StringGet(redKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
outVal = $"{rawData}";
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init ricetta
|
||||
/// </summary>
|
||||
@@ -1149,6 +1045,84 @@ namespace MP.IOC.Data
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato
|
||||
/// </summary>
|
||||
/// <param name="idxMacc"></param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> MSFDMaccGetCurr(string idxMacc)
|
||||
{
|
||||
Dictionary<string, string>? result = new Dictionary<string, string>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string readType = "DB";
|
||||
string currKey = $"{redisBaseAddr}:DSMacc:{idxMacc}";
|
||||
// cerco in redis dato valore sel macchina...
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<Dictionary<string, string>>($"{rawData}");
|
||||
readType = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
var dbResults = dbController.VMSFDGetByMacc(idxMacc);
|
||||
// converto in formato dizionario...
|
||||
if (dbResults != null && dbResults.Count > 0)
|
||||
{
|
||||
var rowResult = dbResults[0];
|
||||
// salvo 1:1 i valori... STATO
|
||||
result.Add("IdxMicroStato", $"{rowResult.IdxMicroStato}");
|
||||
result.Add("IdxStato", $"{rowResult.IdxStato}");
|
||||
result.Add("CodArticolo", $"{rowResult.CodArticolo}");
|
||||
result.Add("insEnabled", $"{rowResult.InsEnabled}");
|
||||
result.Add("sLogEnabled", $"{rowResult.SLogEnabled}");
|
||||
result.Add("pallet", $"{rowResult.Pallet}");
|
||||
result.Add("CodArticolo_A", $"{rowResult.CodArticoloA}");
|
||||
result.Add("CodArticolo_B", $"{rowResult.CodArticoloB}");
|
||||
result.Add("TempoCicloBase", $"{rowResult.TempoCicloBase}");
|
||||
result.Add("PzPalletProd", $"{rowResult.PzPalletProd}");
|
||||
result.Add("MatrOpr", $"{rowResult.MatrOpr}");
|
||||
result.Add("lastVal", $"{rowResult.LastVal}");
|
||||
result.Add("TCBase", $"{rowResult.TempoCicloBase}");
|
||||
|
||||
//...e SETUP
|
||||
result.Add("CodMacc", $"{rowResult.Codmacchina}");
|
||||
result.Add("IdxFamIn", $"{rowResult.IdxFamigliaIngresso}");
|
||||
result.Add("Multi", $"{rowResult.Multi}");
|
||||
result.Add("BitFilt", $"{rowResult.BitFilt}");
|
||||
result.Add("MaxVal", $"{rowResult.MaxVal}");
|
||||
result.Add("BSR", $"{rowResult.Bsr}");
|
||||
result.Add("ExplodeBit", $"{rowResult.ExplodeBit}");
|
||||
result.Add("NumBit", $"{rowResult.NumBit}");
|
||||
result.Add("IdxFamMacc", $"{rowResult.IdxFamiglia}");
|
||||
result.Add("simplePallet", $"{rowResult.SimplePallet}");
|
||||
result.Add("palletChange", $"{rowResult.PalletChange}");
|
||||
}
|
||||
// cerco info Master/slave...
|
||||
var m2sTab = Macchine2SlaveGetAll();
|
||||
string isMaster = m2sTab.Where(x => x.IdxMacchina == idxMacc).Count() > 0 ? "1" : "0";
|
||||
string isSlave = m2sTab.Where(x => x.IdxMacchinaSlave == idxMacc).Count() > 0 ? "1" : "0";
|
||||
result.Add("Master", isMaster);
|
||||
result.Add("Slave", isSlave);
|
||||
|
||||
// serializzo
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
// durata cache secondo valore insEnabled...
|
||||
double numMinCache = (result["insEnabled"].ToLower() == "true") ? redisShortTimeCache / 4 : redisShortTimeCache;
|
||||
// ...e salvo...
|
||||
redisDb.StringSet(currKey, rawData, getRandTOut(numMinCache));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new Dictionary<string, string>();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"GetCurrMSFDMacc | Read from {readType}: {ts.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ODL dato batch selezionato
|
||||
/// </summary>
|
||||
@@ -1514,6 +1488,35 @@ namespace MP.IOC.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua conteggio chaivi REDIS dato pattern ricerca
|
||||
/// </summary>
|
||||
/// <param name="keyPattern"></param>
|
||||
/// <returns></returns>
|
||||
public int RedisCountKey(string keyPattern)
|
||||
{
|
||||
int num = 0;
|
||||
keyPattern = (string.IsNullOrEmpty(keyPattern) ? "**" : keyPattern);
|
||||
try
|
||||
{
|
||||
var listEndpoints = redisConnAdmin.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
var server = redisConnAdmin.GetServer(endPoint);
|
||||
foreach (RedisKey item in server.Keys(pattern: keyPattern, database: redisDb.Database, pageSize: 250, cursor: 0L))
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception arg)
|
||||
{
|
||||
Log.Error($"Eccezione in RedisCountKey{Environment.NewLine}{arg}");
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue eliminazione memoria redis keyVal
|
||||
/// </summary>
|
||||
@@ -1525,7 +1528,6 @@ namespace MP.IOC.Data
|
||||
var listEndpoints = redisConnAdmin.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
|
||||
var server = redisConnAdmin.GetServer(endPoint);
|
||||
if (server != null)
|
||||
{
|
||||
@@ -1604,6 +1606,18 @@ namespace MP.IOC.Data
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool RedisSetHash(string redKey, KeyValuePair<string, string>[] valori, double expireSeconds = -1.0)
|
||||
{
|
||||
bool answ = false;
|
||||
string rKey = $"{redisBaseAddrSpec}:{redKey}";
|
||||
answ = RedisSetHash(redKey, valori);
|
||||
if (expireSeconds > 0.0)
|
||||
{
|
||||
redisDb.KeyExpire(rKey, DateTime.Now.AddSeconds(expireSeconds));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public bool RedisSetHash(string redKey, KeyValuePair<string, string>[] valori)
|
||||
{
|
||||
bool answ = false;
|
||||
@@ -1614,7 +1628,7 @@ namespace MP.IOC.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<bool> SetRedisKey(string redKey, string redVal)
|
||||
public async Task<bool> RedisSetKey(string redKey, string redVal)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
RedisValue pattern = new RedisValue($"{redisBaseAddrSpec}:{redKey}");
|
||||
@@ -1622,6 +1636,74 @@ namespace MP.IOC.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resetta (rileggendo) i dati della State Machine ingressi nel formato
|
||||
/// key: cState_nVal (current MICRO-STATE + "_" + new Value)
|
||||
/// value: iTipoEv_nState (IdxTipoEv da trasmettere + New MICRO-STATE)
|
||||
/// </summary>
|
||||
/// <param name="idxFamIn"></param>
|
||||
/// <returns></returns>
|
||||
public KeyValuePair<string, string>[] resetSMI(int idxFamIn)
|
||||
{
|
||||
string currHash = $"{redisBaseAddrSpec}:hSMI:{idxFamIn}";
|
||||
// leggo da DB...
|
||||
var tabSMI = dbController.StateMachineIngressi(idxFamIn);
|
||||
|
||||
KeyValuePair<string, string>[] answ = new KeyValuePair<string, string>[tabSMI.Count];
|
||||
// salvo tutti i valori StateMachineIngressi...
|
||||
int i = 0;
|
||||
string key = "";
|
||||
string val = "";
|
||||
foreach (var item in tabSMI)
|
||||
{
|
||||
key = string.Format("{0}_{1}", item.IdxMicroStato, item.ValoreIngresso);
|
||||
val = string.Format("{0}_{1}", item.IdxTipoEvento, item.NextIdxMicroStato);
|
||||
answ[i] = new KeyValuePair<string, string>(key, val);
|
||||
i++;
|
||||
}
|
||||
// verifico il timeout (default 60 sec...)
|
||||
var sTOutSmi = tryGetConfig("TmOut.SMI").Result;
|
||||
int tOut = 60;
|
||||
if (!string.IsNullOrEmpty(sTOutSmi))
|
||||
{
|
||||
int.TryParse(sTOutSmi, out tOut);
|
||||
}
|
||||
// salvo in redis!
|
||||
RedisSetHash(currHash, answ, tOut);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei campi della State Machine ingressi nel formato
|
||||
/// key: cState_nVal (current MICRO-STATE + "_" + new Value)
|
||||
/// value: iTipoEv_nState (IdxTipoEv da trasmettere + New MICRO-STATE
|
||||
/// </summary>
|
||||
/// <param name="idxFamIn"></param>
|
||||
/// <returns></returns>
|
||||
public KeyValuePair<string, string>[] StateMachInByKey(int idxFamIn)
|
||||
{
|
||||
// hard coded dimensione vettore DatiMacchine
|
||||
KeyValuePair<string, string>[] answ = new KeyValuePair<string, string>[1];
|
||||
// iniziualizzo con un valore... 0/0
|
||||
answ[0] = new KeyValuePair<string, string>("0", "0");
|
||||
// ORA recupero da memoria redis...
|
||||
try
|
||||
{
|
||||
string currHash = $"{redisBaseAddrSpec}:hSMI:{idxFamIn}";
|
||||
answ = RedisGetHash(currHash);
|
||||
// se è vuoto... leggo da DB e popolo!
|
||||
if (answ.Length == 0)
|
||||
{
|
||||
answ = resetSMI(idxFamIn);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in compilazione State Machine Ingressi x Redis:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Statistiche ODL calcolate (da stored stp_STAT_ODL)
|
||||
/// </summary>
|
||||
@@ -1631,6 +1713,32 @@ namespace MP.IOC.Data
|
||||
return dbController.OdlStart(IdxOdl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// restituisce il valore da REDIS associato al tag richeisto
|
||||
/// </summary>
|
||||
/// <param name="redKey">Chiave in cui cercare il valore</param>
|
||||
/// <returns></returns>
|
||||
public string TagConfGetKey(string redKey)
|
||||
{
|
||||
string outVal = "";
|
||||
// cerco in REDIS la conf x l'IOB
|
||||
var rawData = redisDb.StringGet(redKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
outVal = $"{rawData}";
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco setup dei tag conf correnti
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<Dictionary<string, List<TagData>>> TagsGetAll()
|
||||
{
|
||||
return Task.FromResult(currTagConf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue traduzione dato vocabolario da Lingua + Lemma
|
||||
/// </summary>
|
||||
@@ -1677,7 +1785,7 @@ namespace MP.IOC.Data
|
||||
{
|
||||
bool answ = false;
|
||||
// recupero intero set valori dossier deserializzando...
|
||||
var fluxLogList = getFluxLog(currDoss.Valore);
|
||||
var fluxLogList = FluxLogGetByFlux(currDoss.Valore);
|
||||
await Task.Delay(1);
|
||||
|
||||
// se tutto ok
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<div>
|
||||
<b>IOB-PI</b> I/O
|
||||
</div>
|
||||
<div class="text-warning">
|
||||
<div class="text-danger">
|
||||
<i class="fa-solid fa-circle-check"></i>
|
||||
</div>
|
||||
</li>
|
||||
@@ -47,7 +47,7 @@
|
||||
<div>
|
||||
<b>IOB-WIN</b> I/O
|
||||
</div>
|
||||
<div class="text-warning">
|
||||
<div class="text-danger">
|
||||
<i class="fa-solid fa-circle-check"></i>
|
||||
</div>
|
||||
</li>
|
||||
@@ -55,7 +55,7 @@
|
||||
<div>
|
||||
<b>File</b> upload
|
||||
</div>
|
||||
<div class="text-warning">
|
||||
<div class="text-danger">
|
||||
<i class="fa-solid fa-circle-check"></i>
|
||||
</div>
|
||||
</li>
|
||||
@@ -63,7 +63,7 @@
|
||||
</div>
|
||||
<div class="col-6 text-center">
|
||||
<h1>MAPO IO</h1>
|
||||
<h4>.net Core Landing Page</h4>
|
||||
<h4>.net Core-6</h4>
|
||||
</div>
|
||||
<div class="col-3 text-end">
|
||||
<ul class="list-group">
|
||||
@@ -79,7 +79,7 @@
|
||||
<div>
|
||||
<b>Parameters</b> management
|
||||
</div>
|
||||
<div class="text-warning">
|
||||
<div class="text-danger">
|
||||
<i class="fa-solid fa-circle-check"></i>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user