diff --git a/MP.Data/Controllers/MpIocController.cs b/MP.Data/Controllers/MpIocController.cs
new file mode 100644
index 00000000..9b52a93a
--- /dev/null
+++ b/MP.Data/Controllers/MpIocController.cs
@@ -0,0 +1,391 @@
+using Microsoft.Data.SqlClient;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
+using MP.Data.DatabaseModels;
+using NLog;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace MP.Data.Controllers
+{
+ public class MpIocController : IDisposable
+ {
+ #region Public Constructors
+
+ public MpIocController(IConfiguration configuration)
+ {
+ _configuration = configuration;
+ Log.Info("Avviata classe MpIocController");
+ }
+
+ #endregion Public Constructors
+
+ #region Public Methods
+
+
+ ///
+ /// Elenco da tabella Config
+ ///
+ ///
+ public List ConfigGetAll()
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = dbCtx
+ .DbSetConfig
+ .AsNoTracking()
+ .OrderBy(x => x.Chiave)
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Update record config
+ ///
+ ///
+ public bool ConfigUpdate(ConfigModel updRec)
+ {
+ bool fatto = false;
+ ConfigModel dbResult = new ConfigModel();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = dbCtx
+ .DbSetConfig
+ .Where(x => x.Chiave == updRec.Chiave)
+ .FirstOrDefault();
+ if (dbResult != null)
+ {
+ dbResult.Valore = updRec.Valore;
+ dbCtx.SaveChanges();
+ fatto = true;
+ }
+ }
+ return fatto;
+ }
+
+ ///
+ /// Intera tab dati macchina
+ ///
+ ///
+ public List DatiMacchineGetAll()
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = dbCtx
+ .DbSetDatiMacchine
+ .AsNoTracking()
+ .OrderBy(x => x.IdxMacchina)
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ public void Dispose()
+ {
+ _configuration = null;
+ }
+
+
+ ///
+ /// Aggiunta record EventList
+ ///
+ ///
+ ///
+ public async Task EvListInsert(EventListModel newRec)
+ {
+ bool fatto = false;
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ try
+ {
+ var currRec = dbCtx
+ .DbSetEvList
+ .Add(newRec);
+ await dbCtx.SaveChangesAsync();
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante EvListInsert{Environment.NewLine}{exc}");
+ }
+ }
+ await Task.Delay(1);
+ return fatto;
+ }
+
+ ///
+ /// Elenco ultimi n record flux log dato macchina e flusso (ordinato x data registrazione)
+ ///
+ /// Data massima x eventi
+ /// Data minima x eventi
+ /// * = tutte, altrimenti solo x una data macchina
+ /// *=tutti, altrimenti solo selezionato
+ /// numero massimo record da restituire
+ ///
+ public List FluxLogGetLastFilt(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec)
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = dbCtx
+ .DbSetFluxLog
+ .AsNoTracking()
+ .Where(x => (x.dtEvento >= DtMin && x.dtEvento <= DtMax) && (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodFlux == "*" || x.CodFlux == CodFlux))
+ .OrderByDescending(x => x.dtEvento)
+ .Take(MaxRec)
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ public bool KeepAliveUpsert(string IdxMacc, DateTime OraServer, DateTime OraMacc)
+ {
+ bool fatto = false;
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var currRec = dbCtx
+ .DbSetKeepAlive
+ .Where(x => x.IdxMacchina == IdxMacc)
+ .FirstOrDefault();
+ if (currRec != null)
+ {
+ currRec.DataOraServer = OraServer;
+ currRec.DataOraMacchina = OraMacc;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+ else
+ {
+ KeepAliveModel newRec = new KeepAliveModel()
+ {
+ IdxMacchina = IdxMacc,
+ DataOraMacchina = OraMacc,
+ DataOraServer = OraServer,
+ DataOraStart = DateTime.Now
+ };
+ dbCtx
+ .DbSetKeepAlive
+ .Add(newRec);
+ }
+ dbCtx.SaveChanges();
+ fatto = true;
+ }
+ return fatto;
+ }
+
+
+ public List ListLinkFilt(string tipoLink)
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = dbCtx
+ .DbSetLinkMenu
+ .Where(x => x.TipoLink == tipoLink)
+ .AsNoTracking()
+ .OrderBy(x => x.ordine)
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Intera tabella relazione master/slave in machine (gestione setup master --> slave)
+ ///
+ ///
+ public List Macchine2Slave()
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = dbCtx
+ .DbSetM2S
+ .AsNoTracking()
+ .OrderBy(x => x.IdxMacchina)
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Elenco da tabella Macchine
+ ///
+ ///
+ ///
+ public List MacchineGetFilt(string codGruppo)
+ {
+ List dbResult = new List();
+ try
+ {
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ if (codGruppo == "*")
+ {
+ dbResult = dbCtx
+ .DbSetMacchine
+ .AsNoTracking()
+ .OrderBy(x => x.IdxMacchina)
+ .ToList();
+ }
+ else
+ {
+ dbResult = dbCtx
+ .DbSetGrp2Macc
+ .Where(g => g.CodGruppo == codGruppo)
+ .Join(dbCtx.DbSetMacchine,
+ g => g.IdxMacchina,
+ m => m.IdxMacchina,
+ (g, m) => m
+ )
+ .AsNoTracking()
+ .OrderBy(x => x.IdxMacchina)
+ .ToList();
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in MacchineGetFilt{Environment.NewLine}{exc}");
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Elenco da tabella MappaStatoExpl
+ ///
+ ///
+ public List MseGetAll(int maxAge = 2000)
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
+
+ dbResult = dbCtx
+ .DbSetMSE
+ .FromSqlRaw("EXEC stp_MSE_getData @maxAgeSec", maxAgeSec)
+ .AsNoTracking()
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Annulla modifiche su una specifica entity (cancel update)
+ ///
+ ///
+ ///
+ public bool RollBackEntity(object item)
+ {
+ bool answ = false;
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ try
+ {
+ if (dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Deleted || dbCtx.Entry(item).State == Microsoft.EntityFrameworkCore.EntityState.Modified)
+ {
+ dbCtx.Entry(item).Reload();
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Intera tabella relazione master/slave in machine (gestione setup master --> slave)
+ ///
+ ///
+ public List StateMachineIngressi(int idxFam)
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var IdxFamIn = new SqlParameter("@IdxFamigliaIngresso", idxFam);
+ dbResult = dbCtx
+ .DbSetSMI
+ .FromSqlRaw("exec dbo.stp_TRI_getByIdxFamIng @IdxFamigliaIngresso", IdxFamIn)
+ .AsNoTracking()
+ .AsEnumerable()
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Stato prod macchina
+ ///
+ ///
+ ///
+ public StatoProdModel StatoProdMacchina(string idxMacchina)
+ {
+ StatoProdModel dbResult = new StatoProdModel();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
+ dbResult = dbCtx
+ .DbSetStatoProd
+ .FromSqlRaw("EXEC stp_PzProd_getByMacchina @IdxMacchina", IdxMacchina)
+ .AsNoTracking()
+ .FirstOrDefault();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Intera vista v_MSFD
+ ///
+ ///
+ public List VMSFDGetAll()
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = dbCtx
+ .DbSetMSFD
+ .AsNoTracking()
+ .OrderBy(x => x.IdxMacchina)
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Vista v_MSFD CALCOALTA x singola macchina (da stored) - singolo record
+ ///
+ ///
+ public List VMSFDGetByMacc(string idxMacc)
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
+
+ dbResult = dbCtx
+ .DbSetMSFD
+ .FromSqlRaw("exec dbo.stp_MSFD_getMacc @IdxMacchina", IdxMacchina)
+ .AsNoTracking()
+ .AsEnumerable()
+ .ToList();
+ }
+ return dbResult;
+ }
+
+ #endregion Public Methods
+
+ #region Private Fields
+
+ private static IConfiguration _configuration;
+
+ private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
+
+ #endregion Private Fields
+ }
+}
\ No newline at end of file
diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs
index c4c6a158..c73563aa 100644
--- a/MP.Data/Controllers/MpSpecController.cs
+++ b/MP.Data/Controllers/MpSpecController.cs
@@ -311,93 +311,6 @@ namespace MP.Data.Controllers
}
return dbResult;
}
- ///
- /// Intera vista v_MSFD
- ///
- ///
- public List VMSFDGetAll()
- {
- List dbResult = new List();
- using (var dbCtx = new MoonProContext(_configuration))
- {
- dbResult = dbCtx
- .DbSetMSFD
- .AsNoTracking()
- .OrderBy(x => x.IdxMacchina)
- .ToList();
- }
- return dbResult;
- }
-
- ///
- /// Vista v_MSFD CALCOALTA x singola macchina (da stored) - singolo record
- ///
- ///
- public List VMSFDGetByMacc(string idxMacc)
- {
- List dbResult = new List();
- using (var dbCtx = new MoonProContext(_configuration))
- {
- var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacc);
-
- dbResult = dbCtx
- .DbSetMSFD
- .FromSqlRaw("exec dbo.stp_MSFD_getMacc @IdxMacchina", IdxMacchina)
- .AsNoTracking()
- .AsEnumerable()
- .ToList();
- }
- return dbResult;
- }
-
- ///
- /// Intera tabella relazione master/slave in machine (gestione setup master --> slave)
- ///
- ///
- public List Macchine2Slave()
- {
- List dbResult = new List();
- using (var dbCtx = new MoonProContext(_configuration))
- {
- dbResult = dbCtx
- .DbSetM2S
- .AsNoTracking()
- .OrderBy(x => x.IdxMacchina)
- .ToList();
- }
- return dbResult;
- }
- ///
- /// Intera tabella relazione master/slave in machine (gestione setup master --> slave)
- ///
- ///
- public List StateMachineIngressi(int idxFam)
- {
- List dbResult = new List();
- 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()
{
@@ -933,32 +846,6 @@ namespace MP.Data.Controllers
return dbResult;
}
-#if false
-
- ///
- /// Elenco PODL non avviati filtrati x articolo, KeyRich (che contiene stato)
- ///
- /// Cod articolo
- /// KeyRich (parziale) da cercare (es cod stato x yacht)
- ///
- public List ListPODLFiltNOOdl(string codArt, string keyRichPart)
- {
- List dbResult = new List();
- using (var dbCtx = new MoonProContext(_configuration))
- {
- dbResult = dbCtx
- .DbSetPODL
- .Where(x => (x.IdxOdl != 0) && (x.KeyRichiesta.Contains(keyRichPart) || keyRichPart == "*") && (codArt == "*" || x.CodArticolo.Contains(codArt)))
- .AsNoTracking()
- .Include(m => m.MachineNav)
- .Include(a => a.ArticoloNav)
- .OrderByDescending(x => x.InsertDate)
- .ToList();
- }
- return dbResult;
- }
-#endif
-
///
/// Chiusura ODL con eventuale conferma pezzi
///
diff --git a/MP.Data/DatabaseModels/KeepAliveModel.cs b/MP.Data/DatabaseModels/KeepAliveModel.cs
new file mode 100644
index 00000000..a30ac535
--- /dev/null
+++ b/MP.Data/DatabaseModels/KeepAliveModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace MP.Data.DatabaseModels
+{
+ public partial class KeepAliveModel
+ {
+ public string IdxMacchina { get; set; }
+ public DateTime? DataOraServer { get; set; }
+ public DateTime? DataOraMacchina { get; set; }
+ public DateTime? DataOraStart { get; set; }
+ }
+}
diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs
index a95d8e80..d25b9ddf 100644
--- a/MP.Data/MoonProContext.cs
+++ b/MP.Data/MoonProContext.cs
@@ -60,6 +60,7 @@ namespace MP.Data
public virtual DbSet DbSetMSFD { get; set; }
public virtual DbSet DbSetM2S { get; set; }
public virtual DbSet DbSetSMI { get; set; }
+ public virtual DbSet DbSetKeepAlive { get; set; }
#endregion Public Properties
@@ -453,6 +454,19 @@ namespace MP.Data
entity.Property(e => e.NextIdxMicroStato).HasColumnName("next_IdxMicroStato");
});
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.IdxMacchina);
+
+ entity.ToTable("KeepAlive");
+
+ entity.Property(e => e.IdxMacchina).HasMaxLength(50);
+
+ entity.Property(e => e.DataOraMacchina).HasColumnType("datetime");
+
+ entity.Property(e => e.DataOraStart).HasColumnType("datetime");
+ });
+
OnModelCreatingPartial(modelBuilder);
}
diff --git a/MP.Data/Utils.cs b/MP.Data/Utils.cs
index ff70a27a..11a6940a 100644
--- a/MP.Data/Utils.cs
+++ b/MP.Data/Utils.cs
@@ -1,5 +1,5 @@
using MP.Data.DatabaseModels;
-using Newtonsoft.Json;
+using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -43,6 +43,16 @@ namespace MP.Data
return answ;
}
+ ///
+ /// Hash dati STATUS x la macchina specificata
+ ///
+ ///
+ ///
+ public static RedisKey dtMaccHash(string idxMacchina)
+ {
+ return (RedisKey)$"{redisBaseAddr}DtMac:{idxMacchina}";
+ }
+
public static string FormDurata(double durataMinuti)
{
string answ = "";
@@ -58,6 +68,16 @@ namespace MP.Data
return answ;
}
+ ///
+ /// RedisKey calcolata x tabella HSI
+ ///
+ ///
+ ///
+ public static RedisKey hSMI(int idxFamIn)
+ {
+ return (RedisKey)$"{redisBaseAddr}hSMI:{idxFamIn}";
+ }
+
///
/// Inizializzazione con periodo e arrotondamento
///
@@ -71,20 +91,40 @@ namespace MP.Data
return endRounded;
}
+ ///
+ /// Nome della variabile HASH da utilizzare (dato CodModulo / Server / DB impiegato
+ /// dafunzionalita' DbConfig) + keyName richiesto...
+ ///
+ ///
+ ///
+ public static RedisKey OptParHash(string keyName)
+ {
+ return (RedisKey)$"{redisBaseAddr}OpPar:{keyName}";
+ }
+
///
/// Nome della variabile HASH da utilizzare (dato CodModulo / Server / DB impiegato da
/// funzionalita' DbConfig) + keyName richiesto...
///
- public static string RedHash(string keyName)
+ public static RedisKey RedHash(string keyName)
{
- string answ = keyName;
- try
- {
- answ = $"MP:Data:{keyName}";
- }
- catch
- { }
- return answ;
+ return (RedisKey)$"MP:Data:{keyName}";
+ }
+
+ ///
+ /// Formato RedisKey delal chaive richeista (completa)
+ ///
+ public static RedisKey RedKeyHash(string keyName)
+ {
+ return (RedisKey)$"{redisBaseAddr}{keyName}";
+ }
+
+ ///
+ /// Formato RedisValue delal chaive richeista (completa)
+ ///
+ public static RedisValue RedValue(string keyName)
+ {
+ return (RedisValue)$"{redisBaseAddr}{keyName}";
}
///
@@ -179,5 +219,35 @@ namespace MP.Data
}
#endregion Public Classes
+
+ #region Private Fields
+
+ public const string redisActionReq = redisBaseAddr + "Action:Req";
+ public const string redisAnagGruppi = redisBaseAddr + "Cache:AnagGruppi";
+ public const string redisArtByDossier = redisBaseAddr + "Cache:ArtByDossier";
+ public const string redisArtList = redisBaseAddr + "Cache:ArtList";
+ public const string redisBaseAddr = "MP:";
+ public const string redisConfKey = redisBaseAddr + "Cache:Config";
+ public const string redisDossByMac = redisBaseAddr + "Cache:DossByMac";
+ public const string redisFluxByMac = redisBaseAddr + "Cache:FluxByMac";
+ public const string redisFluxLogFilt = redisBaseAddr + "Cache:FluxLogFilt";
+ public const string redisGiacenzaList = redisBaseAddr + "Cache:GiacenzaList";
+ public const string redisMacByFlux = redisBaseAddr + "Cache:MacByFlux";
+ public const string redisMacList = redisBaseAddr + "Cache:MacList";
+ public const string redisMacRecipe = redisBaseAddr + "Cache:Recipe";
+ public const string redisOdlByBatch = redisXdlData + "OdlByBatch";
+ public const string redisOdlCurrByMac = redisXdlData + "OdlByMac";
+ public const string redisOdlList = redisXdlData + "OdlList";
+ public const string redisParamPageExp = redisBaseAddr + "Cache:ParamPage";
+ public const string redisPOdlByOdl = redisXdlData + "POdlByOdl";
+ public const string redisPOdlByPOdl = redisXdlData + "POdlByPOdl";
+ public const string redisPOdlList = redisXdlData + "POdlList";
+ public const string redisRecipeConf = redisBaseAddr + "Cache:Recipe:Conf";
+ public const string redisStatoCom = redisBaseAddr + "Cache:StatoCom";
+ public const string redisTipoArt = redisBaseAddr + "Cache:TipoArt";
+ public const string redisVocabolario = redisBaseAddr + "Cache:Vocabolario";
+ public const string redisXdlData = redisBaseAddr + "Cache:XDL:";
+
+ #endregion Private Fields
}
}
\ No newline at end of file
diff --git a/MP.IOC/Controllers/BenchController.cs b/MP.IOC/Controllers/BenchController.cs
index 1cba0a0a..c0671a00 100644
--- a/MP.IOC/Controllers/BenchController.cs
+++ b/MP.IOC/Controllers/BenchController.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
+using MP.Data;
using MP.IOC.Data;
using NLog;
using System.Diagnostics;
@@ -13,10 +14,10 @@ namespace MP.IOC.Controllers
public BenchController(IConfiguration configuration, MpDataService DataService)
{
- Log.Info("Starting MpDataService INIT");
+ Log.Info("Starting BenchController");
_configuration = configuration;
DService = DataService;
- Log.Info("Avviata classe Recipe");
+ Log.Info("Avviata BenchController");
}
#endregion Public Constructors
@@ -116,9 +117,9 @@ namespace MP.IOC.Controllers
answ = "";
try
{
- string fiHASH = DService.hSMI(idxFamIn);
+ var fiHASH = Utils.hSMI(idxFamIn);
string outVal = "";
- bool trovato = DService.RedisHashPresentSz(fiHASH);
+ bool trovato = DService.RedisHashPresent(fiHASH);
if (!trovato)
{
// ricarico tabella!
diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs
new file mode 100644
index 00000000..8afa9aed
--- /dev/null
+++ b/MP.IOC/Controllers/IOBController.cs
@@ -0,0 +1,2216 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using MP.Data;
+using MP.IOC.Data;
+using NLog;
+using NLog.Fluent;
+using System.Data;
+using System.Globalization;
+using System.IO;
+
+namespace MP.IOC.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ public class IOBController : ControllerBase
+ {
+
+ public IOBController(IConfiguration configuration, MpDataService DataService)
+ {
+ Log.Info("Starting IOBController");
+ _configuration = configuration;
+ DService = DataService;
+ Log.Info("Avviato IOBController");
+ }
+
+
+ private static IConfiguration _configuration = null!;
+
+ private static Logger Log = LogManager.GetCurrentClassLogger();
+
+ ///
+ /// Dataservice x accesso DB
+ ///
+ protected MpDataService DService { get; set; }
+
+ #region Public Methods
+
+ /// SALVA x macchina KVP parametro/valore:
+ ///
+ /// GET: IOB/addOptPar/SIMUL_03?pName=PZREQ&pValue=1000
+ ///
+ ///
+ public string addOptPar(string id, string pName, string pValue)
+ {
+ string answ = "";
+ DService.ScriviKeepAlive(id, DateTime.Now);
+ try
+ {
+ //DataLayerObj.addOptPar4Machine(id, pName, pValue);
+ //answ = getOptPar(id);
+ }
+ catch
+ { }
+ return answ;
+ }
+
+ ///// AGGIUNGE TASK richiesto x macchina:
+ /////
+ ///// GET: IOB/addTask2Exe/3010?taskName=startSetup&taskVal=T190406101512
+ ///// GET: IOB/addTask2Exe/3010?taskName=stopSetup&taskVal=T190406101512
+ ///// GET: IOB/addTask2Exe/SIMUL_03?taskName=setProg&taskVal=P00000001
+ ///// GET: IOB/addTask2Exe/SIMUL_03?taskName=setComm&taskVal=ODL_0000123
+ ///// GET: IOB/addTask2Exe/SIMUL_03?taskName=setArt&taskVal=ART_0000321
+ /////
+ /////
+ //public string addTask2Exe(string id, string taskName, string taskVal)
+ //{
+ // string answ = "";
+ // // scrivo keep alive!!! (se necessario, altrimenti è in cache...)
+ // MapoDb.MapoDb connDb = new MapoDb.MapoDb();
+ // DataLayer DataLayerObj = new DataLayer();
+ // connDb.scriviKeepAlive(id, DateTime.Now);
+ // try
+ // {
+ // // converto stringa in tipo task...
+ // taskType tName = taskType.nihil;
+ // bool fatto = Enum.TryParse(taskName, out tName);
+ // if (fatto)
+ // {
+ // DataLayerObj.addTask4Machine(id, tName, taskVal);
+ // }
+ // else
+ // {
+ // logger.lg.scriviLog($"addTask2Exe: impossibile riconoscere il comando {taskName} come uno dei tipi ammessi, NON aggiunto", tipoLog.ERROR);
+ // }
+ // answ = getTask2Exe(id);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Richiesta chiusura manuale ODL x macchina (popup utente):
+ /////
+ ///// GET: IOB/askCloseODL/SIMUL_03?idxOdl=123
+ /////
+ ///// id macchina
+ ///// idx dell'ODL da chiudere
+ ///// bool esecuzione
+ //public bool askCloseODL(string id, int idxOdl)
+ //{
+ // bool answ = false;
+ // // init obj DataLayer
+ // DataLayer DataLayerObj = new DataLayer();
+ // try
+ // {
+ // // preparo una richiesta di chiusura...
+ // DisplayAction CurrAction = new DisplayAction()
+ // {
+ // Topic = "Chiusura ODL",
+ // Message = "Rilevato possibile fine operazioni, Vuoi chiudere la commessa?",
+ // ShowCancel = true,
+ // ShowClose = true,
+ // ShowConfirm = true,
+ // CancelAction = "DisableAction",
+ // ConfirmAction = "CloseODL",
+ // DtReq = DateTime.Now,
+ // IsActive = true,
+ // Parameter = $"{idxOdl}"
+ // };
+ // answ = DataLayerObj.ActionSetReq(CurrAction);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Chiude ODL x macchina:
+ /////
+ ///// GET: IOB/closeODL/SIMUL_03?idxOdl=123
+ /////
+ ///// id macchina
+ ///// idx dell'ODL da chiudere
+ ///// bool esecuzione
+ //public bool closeODL(string id, int idxOdl)
+ //{
+ // bool answ = false;
+
+ // // init obj DataLayer
+ // DataLayer DataLayerObj = new DataLayer();
+ // try
+ // {
+ // // chiamata diretta sul DB...
+ // DataLayerObj.taODL.forceClose(idxOdl, id);
+ // answ = true;
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ //// GET: IOB/enabled/SIMUL_03
+ //public string enabled(string id)
+ //{
+ // string answ = "ND";
+ // // se id nullo --> KO!
+ // if (id == null)
+ // {
+ // answ = "KO";
+ // }
+ // else
+ // {
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // // salvo risposta!
+ // answ = DataLayerObj.insEnab(id) ? "OK" : "NO";
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog(string.Format("Errore in enabled{0}{1}", Environment.NewLine, exc));
+ // answ = "NO";
+ // }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Processa una chiamata POST per l'invio di un array Json di oggetti input (EVENTI)
+ ///// POST: IOB/evListJson/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //[HttpPost]
+ //public string evListJson(string id)
+ //{
+ // int insDone = 0;
+ // string answ = "-";
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(
+ // Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // //Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // // se ho dati...
+ // if (content != "")
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // // procedo a deserializzare in blocco l'oggetto...
+ // evJsonPayload receivedData = new evJsonPayload();
+ // try
+ // {
+ // // deserializzo.
+ // receivedData = JsonConvert.DeserializeObject(content);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in fase deserializzazione inputJson{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // // se ho qualcosa da processare...
+ // if (receivedData != null)
+ // {
+ // // per ogni valore --> processo!
+ // try
+ // {
+ // foreach (var item in receivedData.eventList)
+ // {
+ // if (memLayer.ML.CRI("_logLevel") > 6)
+ // {
+ // logger.lg.scriviLog($"Valori letti: idxMacchina: {id} | valore: {item.valore}", tipoLog.INFO);
+ // }
+
+ // // formato datetime come yyyyMMddHHmmssfff -->es: 20181223180600000
+ // answ = DataLayerObj.processInput(id, item.valore, item.dtEve.ToString("yyyyMMddHHmmssfff"), item.dtCurr.ToString("yyyyMMddHHmmssfff"), item.cnt.ToString());
+ // insDone++;
+ // }
+ // // se vuoto --> OK!
+ // if (string.IsNullOrEmpty(answ))
+ // {
+ // answ = $"OK {insDone} processed";
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in fase invio valori inputJson{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Sistema Dossier/Snapshot giornalieri x impianto indicato, andando a generare 1 Dossier
+ ///// giornaliero x ogni giornata dall'ultimo registrato alla data corrente
+ ///// es: http://url_site/MP/IO/IOB/fixDailyDossier/SIMUL_03
+ /////
+ /////
+ /////
+ //public string fixDailyDossier(string id)
+ //{
+ // string answ = "";
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // // effettuo processing
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // // verifico se si possa processare, ovvero tab ConfFlux x macchina sia valorizzata...
+ // var confDataMach = DataLayerObj.confFluxMach(id);
+ // if (confDataMach.Count > 0)
+ // {
+ // // determino ultima data da processare (inizio oggi, a mezzanotte)
+ // DateTime dtTo = DateTime.Today;
+ // DateTime dtFrom = dtTo;
+ // // determino data di partenza, prima da dossier esistenti
+ // var listaDoss = DataLayerObj.dossierLastByMach(id);
+ // if (listaDoss.Count > 0)
+ // {
+ // // primo giorno DOPO ultima registrazione
+ // dtFrom = listaDoss.OrderByDescending(x => x).FirstOrDefault().AddDays(1);
+ // }
+ // else
+ // {
+ // // ...o da fluxLog acquisiti...
+ // var listaFL = DataLayerObj.fluxLogFirstByMach(id);
+ // if (listaFL.Count > 0)
+ // {
+ // // giorno successivo a prima registrazione
+ // dtFrom = listaFL.OrderBy(x => x).FirstOrDefault().AddDays(1);
+ // }
+ // }
+ // string caller = $"takeFlogSnapshot({id})";
+ // DateTime dtStart = dtFrom.Date;
+ // DateTime dtEnd = dtFrom;
+ // int maxAdd = 5;
+ // if (dtStart < dtTo)
+ // {
+ // // verifico di avere almeno 1 dossier da produrre ciclo fino ad esaurire le
+ // // date da processare
+ // while (dtStart < dtTo && maxAdd > 0)
+ // {
+ // // sistemo end
+ // dtEnd = dtStart.AddDays(1);
+ // // effettuo chiamata registrazione snapshot!
+ // answ = doSaveFLSnapshot(id, dtStart, dtEnd, caller);
+ // // incremento START...
+ // dtStart = dtEnd;
+ // // riduco il numero di chiamate ammesse x singolo task
+ // maxAdd--;
+ // }
+ // // reset cache dossier...
+ // DataLayerObj.dossierLastByMachReset(id);
+ // }
+ // else
+ // {
+ // answ = "NO more to add";
+ // }
+ // }
+ // else
+ // {
+ // answ = "NO ConfFluxData";
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Eccezione in recupero fixDailyDossier{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Sistema ODL giornalieri x impianto indicato, andando a generare 1 ODL giornaliero x ogni
+ ///// giornata dall'ultimo ODL aperto alla data corrente
+ ///// es: http://url_site/MP/IO/IOB/fixDailyOdl/SIMUL_03
+ /////
+ /////
+ /////
+ //public string fixDailyOdl(string id)
+ //{
+ // string answ = "";
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // // chiamo metodo redis/db...
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // // recupero ultimo ODL macchina...
+ // var lastOdlStarted = DataLayerObj.taODL.getLastByMacc(id);
+ // if (lastOdlStarted != null && lastOdlStarted.Count > 0)
+ // {
+ // // calcolo data ultimo avviato e chiedo dal giorno dopo...
+ // DateTime dtFrom = lastOdlStarted[0].DataInizio.AddDays(1);
+ // DateTime dtTo = DateTime.Today;
+ // if (dtTo >= dtFrom)
+ // {
+ // string codArt = lastOdlStarted[0].CodArticolo;
+ // // chiamo la stored x sistemare gli ODL
+ // DataLayerObj.taODL.AutoDayGener(id, dtFrom, dtTo, codArt);
+ // }
+ // answ = "OK";
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Eccezione in recupero fixDailyOdl{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
+ // }
+ // return answ;
+ //}
+
+ //// GET: IOB/flog/SIMUL_03?flux=PROG&valore=P0001&dtEve=20161223180600000&dtCurr=20161223180600000&cnt=999
+ //public string flog(string id, string flux, string valore, string dtEve, string dtCurr, string cnt)
+ //{
+ // string answ = "";
+ // // formato yyyymmddHHMMSSnnn ovvero da anno a millisecondi
+ // if (cnt == null)
+ // {
+ // cnt = "0";
+ // }
+
+ // DateTime dataOraEvento = DateTime.Now;
+ // if (memLayer.ML.CRI("_logLevel") > 6)
+ // {
+ // logger.lg.scriviLog($"Valori letti: idxMacchina: {id} | flux: {flux} valore: {valore}", tipoLog.INFO);
+ // }
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // int count = 0;
+ // Int32.TryParse(cnt, out count);
+ // answ = DataLayerObj.processFluxLog(id, flux, valore, dtEve, dtCurr, count);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in flog{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Processa una chiamata POST per l'invio di un array Json di oggetti fluxLog
+ ///// PUT: IOB/flogJson/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //[HttpPost]
+ //public string flogJson(string id)
+ //{
+ // int insDone = 0;
+ // string answ = "-";
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(
+ // Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // //Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // // se ho dati...
+ // if (content != "")
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // // procedo a deserializzare in blocco l'oggetto...
+ // flogJsonPayload receivedData = new flogJsonPayload();
+ // try
+ // {
+ // // deserializzo.
+ // receivedData = JsonConvert.DeserializeObject(content);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in fase deserializzazione flogJson{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // // se ho qualcosa da processare...
+ // if (receivedData != null)
+ // {
+ // // per ogni valore --> salvo!
+ // try
+ // {
+ // foreach (var item in receivedData.fluxData)
+ // {
+ // // formato datetime come yyyyMMddHHmmssfff -->es: 20181223180600000
+ // answ = DataLayerObj.processFluxLog(id, item.flux, item.valore, item.dtEve.ToString("yyyyMMddHHmmssfff"), item.dtCurr.ToString("yyyyMMddHHmmssfff"), item.cnt);
+ // }
+ // // se vuoto --> OK!
+ // if (string.IsNullOrEmpty(answ))
+ // {
+ // answ = $"OK {insDone} processed";
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in fase invio valori flogJson{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // // leggo parametri correnti...
+ // try
+ // {
+ // List currParams = DataLayerObj.getCurrObjItems(id);
+ // // ora per ogni valore RICEVUTO costruisco un oggetto in innovazioni da
+ // // inviare...x salvare in stato parametri...
+ // List innovazioni = new List();
+ // foreach (var item in receivedData.fluxData)
+ // {
+ // // flux = uuid del parametro
+ // objItem trovato = currParams.Find(obj => obj.uid == item.flux);
+ // // se lo trovo aggiorno...
+ // if (trovato != null)
+ // {
+ // // aggiorno valore e data
+ // trovato.value = item.valore;
+ // trovato.lastRead = DateTime.Now;
+ // // se fosse un valore WRITE e mi ha dato un valore vuoto --> mando
+ // // un fix x riscrittura
+ // if (trovato.writable && string.IsNullOrEmpty(item.valore))
+ // {
+ // logger.lg.scriviLog($"flogJson | verifica parametri | {trovato.uid} | reqVal: {trovato.reqValue}");
+ // taskType currTask = (taskType)Enum.Parse(typeof(taskType), trovato.uid);
+ // DataLayerObj.addCheckTask4Machine(id, currTask, item.valore);
+ // }
+ // }
+ // // altrimenti AGGIUNGO (READ ONLY)...
+ // else
+ // {
+ // trovato = new objItem
+ // {
+ // uid = item.flux,
+ // name = item.flux,
+ // value = item.valore,
+ // lastRead = DateTime.Now,
+ // writable = false
+ // };
+ // }
+ // // lo carico in innovation
+ // innovazioni.Add(trovato);
+ // }
+ // // faccio upsert innovations!
+ // DataLayerObj.upsertCurrObjItems(id, innovazioni);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in fase salvataggio innovazioni parametri correnti da flogJson{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Chiude ODL precedente ed avvia uno nuovo (duplicandolo e sitemando quantità RIMANENTE),
+ ///// e CONFERMA produzione...
+ /////
+ ///// GET: IOB/forceSplitOdl/SIMUL_03
+ /////
+ /////
+ ///// Esito chiamata (OK/vuoto)
+ //public string forceSplitOdl(string id)
+ //{
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // DataLayer DataLayerObj = new DataLayer();
+ // return DataLayerObj.AutoStartOdl(id, true, true, 100, "");
+ //}
+
+ ///// Chiude ODL precedente ed avvia uno nuovo (duplicandolo e sitemando quantità
+ ///// RIMANENTE), e CONFERMA produzione...
+ /////
+ ///// GET: IOB/forceSplitOdl/SIMUL_03?doConfirm=true&qtyFromLast=true&roundStep=150&extOrderCode=ABCDE1234
+ /////
+ ///// id impianto Cod esterno da legare all'ODL x tracciare lotti prod
+ ///// Esito chiamata (OK/vuoto)
+ //public string forceSplitOdlFull(string id, bool doConfirm, bool qtyFromLast, int? roundStep, string keyRichiesta = "")
+ //{
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // DataLayer DataLayerObj = new DataLayer();
+ // if (roundStep == null)
+ // {
+ // roundStep = 100;
+ // }
+ // return DataLayerObj.AutoStartOdl(id, doConfirm, qtyFromLast, (int)roundStep, keyRichiesta);
+ //}
+
+ /////
+ ///// Avvia PODL indicato
+ ///// - se esistesse un ODL da altro PODL --> chiude
+ ///// - se fosse già in essere ODL collegato --> lascia aperto
+ ///// - se fosse chiuso ODL collegato --> duplica PODL e poi avvia nuovo ODL.
+ /////
+ ///// GET: IOB/forceStartPOdl/SIMUL_03?idxPODL=123
+ /////
+ /////
+ ///// idx del PDL da avviare
+ ///// Esito chiamata (OK/vuoto)
+ //public string forceStartPOdl(string id, int idxPODL)
+ //{
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // DataLayer DataLayerObj = new DataLayer();
+ // return DataLayerObj.ForceStartPOdl(id, idxPODL, true);
+ //}
+
+ /////
+ ///// Recupera elenco articoli dei PODL correnti:
+ /////
+ ///// GET: IOB/getArtCurrPODL
+ /////
+ ///// Json contenente lista oggetti ARTICOLI serializzati
+ //public string getArtCurrPODL()
+ //{
+ // string answ = "";
+
+ // // init obj DataLayer
+ // DataLayer DataLayerObj = new DataLayer();
+ // try
+ // {
+ // // recupero dati macchina...
+ // var elencoArt = DataLayerObj.taAnagArt.getByCurrPODL();
+
+ // answ = JsonConvert.SerializeObject(elencoArt);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera elenco articoli USATI:
+ /////
+ ///// GET: IOB/getArtUsed
+ /////
+ ///// Json contenente lista oggetti ARTICOLI serializzati
+ //public string getArtUsed()
+ //{
+ // string answ = "";
+
+ // // init obj DataLayer
+ // DataLayer DataLayerObj = new DataLayer();
+ // try
+ // {
+ // // recupero dati macchina...
+ // var elencoArt = DataLayerObj.taAnagArt.getUsed();
+
+ // answ = JsonConvert.SerializeObject(elencoArt);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera COUNTER x macchina:
+ /////
+ ///// GET: IOB/getCounter/5
+ /////
+ /////
+ /////
+ //public string getCounter(string id)
+ //{
+ // string answ = "";
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // answ = DataLayerObj.pzCounter(id).ToString();
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog(string.Format("Errore in counter (get){0}{1}", Environment.NewLine, exc));
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera COUNTER x macchina dal CONTEGGIO dei TCRecorded:
+ /////
+ ///// GET: IOB/getCounterTCRec/5
+ /////
+ /////
+ /////
+ //public string getCounterTCRec(string id)
+ //{
+ // string answ = "";
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // answ = DataLayerObj.pzCounterTC(id).ToString();
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog(string.Format("Errore in counter TC (get){0}{1}", Environment.NewLine, exc));
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera DATI correnti x macchina:
+ /////
+ ///// GET: IOB/getCurrData/SIMUL_03
+ /////
+ /////
+ ///// Json contenente la riga di stato macchina
+ //public string getCurrData(string id)
+ //{
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // string answ = "";
+ // // scrivo keep alive!!! (se necessario, altrimenti è in cache...)
+ // MapoDb.MapoDb connDb = new MapoDb.MapoDb();
+ // DataLayer DataLayerObj = new DataLayer();
+ // connDb.scriviKeepAlive(id, DateTime.Now);
+ // try
+ // {
+ // // recupero dati macchina...
+ // Dictionary valori = DataLayerObj.mDatiMacchine(id);
+ // answ = JsonConvert.SerializeObject(valori);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera ODL corrente x macchina:
+ /////
+ ///// GET: IOB/getCurrODL/SIMUL_03
+ /////
+ /////
+ /////
+ //public string getCurrODL(string id)
+ //{
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // string answ = "";
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // answ = $"{DataLayerObj.currODL(id)}";
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog(string.Format("Errore in currODL (get){0}{1}", Environment.NewLine, exc));
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Restituisce intera riga dell'odl correntemente in lavorazione sulla macchina...
+ ///// GET: IOB/getCurrOdlRow/SIMUL_01
+ /////
+ /////
+ /////
+ //public string getCurrOdlRow(string id)
+ //{
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // string answ = "";
+ // DS_ProdTempi.ODLDataTable currData = null;
+ // // chiamo metodo redis/db...
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // currData = DataLayerObj.currODLRowTab(id);
+ // answ = JsonConvert.SerializeObject(currData);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Eccezione in recupero getCurrOdlRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Restituisce data-ora inizio dell'odl correntemente in lavorazione sulla macchina...
+ ///// es: http://url_site/MP/IO/IOB/getCurrOdlStart/SIMUL_03
+ /////
+ /////
+ /////
+ //public string getCurrOdlStart(string id)
+ //{
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // DateTime answ = new DateTime(DateTime.Now.Year - 1, 12, 31);
+ // // chiamo metodo redis/db...
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // DS_ProdTempi.ODLDataTable currTab = DataLayerObj.currODLRowTab(id);
+ // if (currTab.Count > 0)
+ // {
+ // DS_ProdTempi.ODLRow odlRow = currTab[0];
+ // answ = odlRow.DataInizio;
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Eccezione in recupero getCurrOdlStart{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
+ // }
+ // return answ.ToString("yyyy-MM-dd HH:mm:ss");
+ //}
+
+ /////
+ ///// Recupera DATI PODL correnti x macchina:
+ /////
+ ///// GET: IOB/getCurrPODL/SIMUL_03
+ /////
+ ///// id macchina, se "" mostra tutto
+ ///// Json contenente lista oggetti PODL serializzati
+ //public string getCurrPODL(string id)
+ //{
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // if (!string.IsNullOrEmpty(id))
+ // {
+ // id = id.Replace("|", "#");
+ // }
+ // string answ = "";
+
+ // // init obj DataLayer
+ // DataLayer DataLayerObj = new DataLayer();
+ // try
+ // {
+ // // recupero dati macchina...
+ // var elencoOdl = DataLayerObj.taPODL.getByMaccArt(id, "", "", true);
+ // answ = JsonConvert.SerializeObject(elencoOdl);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Restituisce intera riga dello stato di macchina...
+ ///// GET: IOB/getCurrStatoRow/SIMUL_01
+ /////
+ /////
+ /////
+ //public string getCurrStatoRow(string id)
+ //{
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // string answ = "";
+ // DS_applicazione.StatoMacchineDataTable currData = null;
+ // // chiamo metodo redis/db...
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // currData = DataLayerObj.currSMTab(id);
+ // answ = JsonConvert.SerializeObject(currData);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Eccezione in recupero getCurrStatoRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Restituisce un array JSon di files di una IOB
+ ///// PUT: IOB/getFiles/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ ///// Oggetto Json in formato MapoSDK.fileEmbed
+ //public string getFiles(string id)
+ //{
+ // string answ = "";
+ // // procedo a deserializzare in blocco l'oggetto...
+ // try
+ // {
+ // // recupero TUTTI i files della folder dell'IOB richiesta
+ // string basePath = Server.MapPath(memLayer.ML.CRS("uploadFileDir"));
+ // string dirPath = $"{basePath}\\{id}";
+ // var fileList = fileMover.obj.elencoFilesDir(dirPath);
+ // fileEmbed objFiles = new fileEmbed();
+ // MapoSDK.smallFile currFile = null;
+ // string fileContent = "";
+ // foreach (var item in fileList)
+ // {
+ // fileContent = System.IO.File.ReadAllText($"{dirPath}\\{item.Nome}");
+ // currFile = new MapoSDK.smallFile()
+ // {
+ // fileName = item.Nome,
+ // content = fileContent.Replace("\r\n", Environment.NewLine)
+ // };
+ // objFiles.fileList.Add(currFile);
+ // }
+ // // serializzo
+ // answ = JsonConvert.SerializeObject(objFiles);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in uploadFile{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Restituisce il valore dello stato di IDLE della macchina, quindi SOLO SE NON é in lavoro
+ ///// e già convertito in minuti...
+ ///// GET: IOB/getIdlePeriod/SIMUL_01
+ /////
+ /////
+ /////
+ //public int getIdlePeriod(string id)
+ //{
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // int answ = 0;
+ // DataLayer DataLayerObj = new DataLayer();
+ // DS_applicazione.StatoMacchineDataTable currData = null;
+ // // chiamo metodo redis/db...
+ // try
+ // {
+ // currData = DataLayerObj.currSMTab(id);
+ // if (currData.Count > 0)
+ // {
+ // // recupero da redis elenco stati
+ // DS_applicazione.AnagraficaStatiDataTable anagStati = DataLayerObj.AnagraficaStati();
+ // DS_applicazione.AnagraficaStatiRow currStato = anagStati.FindByIdxStato(currData[0].IdxStato);
+ // // calcolo SE sia idle... OVVERO SEMAFORO NON VERDE!!!
+ // if (currStato.Semaforo != "sVe")
+ // {
+ // // calcolo durata...
+ // answ = (int)DateTime.Now.Subtract(currData[0].InizioStato).TotalMinutes;
+ // }
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Eccezione in recupero getIdlePeriod{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Restituisce il (primo) codice IOB da dover gestire (se un IOBMAN chiede di gestirne uno
+ ///// in +...)
+ /////
+ ///// IP del Gateway
+ /////
+ //public string getIob2call(string GWIP)
+ //{
+ // string answ = "";
+
+ // // !!!FARE!!! temporanemanete genera a caso vuoto o 3000 x permettere test... altrimenti
+ // // gestisce VERA coda... secondi pari...
+ // int resto = 0;
+ // Math.DivRem(DateTime.Now.Second, 2, out resto);
+ // if (resto == 0)
+ // {
+ // answ = "3000";
+ // }
+
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera elenco articoli USATI per ultimi:
+ ///// - quelli dei PODL correnti
+ ///// - quelli degli ultimi n (DOSS_LastArt in config) ODL lavorati
+ /////
+ ///// GET: IOB/getArtByMacc
+ /////
+ ///// Json contenente lista oggetti ARTICOLI serializzati
+ //public string getLastArtByMacc(string id)
+ //{
+ // string answ = "";
+
+ // // init obj DataLayer
+ // DataLayer DataLayerObj = new DataLayer();
+ // try
+ // {
+ // // recupero dati macchina...
+ // var elencoArt = DataLayerObj.taAnagArt.getLastByMacc(id);
+
+ // answ = JsonConvert.SerializeObject(elencoArt);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera DATI dell'ultimo dossier dato articolo:
+ /////
+ ///// GET: IOB/getLastDossArt/cod_articolo
+ /////
+ ///// codice articolo, se vuoto --> non fa nulla
+ ///// Json contenente lista oggetti DOSSIER serializzati
+ //public string getLastDossArt(string id)
+ //{
+ // string answ = "";
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // if (string.IsNullOrEmpty(id))
+ // {
+ // answ = "N.A.";
+ // }
+ // else
+ // {
+ // id = id.Replace("|", "#");
+
+ // // init obj DataLayer
+ // DataLayer DataLayerObj = new DataLayer();
+ // try
+ // {
+ // // recupero dati macchina...
+ // var elencoDoss = DataLayerObj.taDOSS.getLastByArt(id);
+
+ // answ = JsonConvert.SerializeObject(elencoDoss);
+ // }
+ // catch
+ // { }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera DATI dell'ultimo dossier dato articolo:
+ /////
+ ///// GET: IOB/getLastDossArt/cod_articolo
+ /////
+ ///// codice articolo, se vuoto --> non fa nulla
+ ///// Json contenente lista oggetti DOSSIER serializzati
+ //public string getLastDossByMacc(string id)
+ //{
+ // string answ = "";
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // if (string.IsNullOrEmpty(id))
+ // {
+ // answ = "N.A.";
+ // }
+ // else
+ // {
+ // id = id.Replace("|", "#");
+
+ // // init obj DataLayer
+ // DataLayer DataLayerObj = new DataLayer();
+ // try
+ // {
+ // // recupero dati macchina...
+ // var elencoDoss = DataLayerObj.taDOSS.getLastByMacc(id);
+
+ // answ = JsonConvert.SerializeObject(elencoDoss);
+ // }
+ // catch
+ // { }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera DATI dell'ultimo dossier dato PODL correnti:
+ /////
+ ///// GET: IOB/getLastDossPODL
+ /////
+ ///// Json contenente lista oggetti DOSSIER serializzati
+ //public string getLastDossPODL()
+ //{
+ // string answ = "";
+
+ // // init obj DataLayer
+ // DataLayer DataLayerObj = new DataLayer();
+ // try
+ // {
+ // // recupero dati macchina...
+ // var elencoDoss = DataLayerObj.taDOSS.getLastByPODL();
+
+ // answ = JsonConvert.SerializeObject(elencoDoss);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera elenco ListValues data tabella:
+ /////
+ ///// GET: IOB/getListValByTable
+ /////
+ ///// nome tabella x cui filtrare risultati, se "" mostra tutto
+ ///// Json contenente lista oggetti ListValue serializzati
+ //public string getListValByTable(string id)
+ //{
+ // string answ = "";
+
+ // // init obj DataLayer
+ // DataLayer DataLayerObj = new DataLayer();
+ // try
+ // {
+ // // recupero dati macchina...
+ // var elencoOdl = DataLayerObj.taListVal.getByTableField(id, "*");
+ // answ = JsonConvert.SerializeObject(elencoOdl);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Restituisce dati di associazione tra macchina, device IOB chiamante e sue info
+ /////
+ ///// Id della macchina
+ /////
+ //public string getM2IOB(string id)
+ //{
+ // string answ = "";
+ // try
+ // {
+ // // recupero da redis...
+ // string hM2IOB = DataLayer.hM2IOB(id);
+ // string dataSer = memLayer.ML.getRSV(hM2IOB);
+ // if (dataSer != "" && dataSer != null)
+ // {
+ // // restituisco Json
+ // answ = dataSer;
+ // }
+ // else
+ // {
+ // answ = "NO";
+ // }
+ // }
+ // catch
+ // {
+ // answ = "KO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// restituisce elenco parametri correnti come una List Json di oggetti objItem
+ ///// GET: IOB/getObjItems/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //public string getObjItems(string id)
+ //{
+ // string answ = "";
+ // if (string.IsNullOrWhiteSpace(id))
+ // {
+ // answ = "Missing IOB";
+ // }
+ // else
+ // {
+ // // procedo a recuperare l'oggetto...
+ // List currParams = new List();
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // // deserializzo
+ // currParams = DataLayerObj.getCurrObjItems(id);
+ // // se != null --> salvo!
+ // if (currParams != null)
+ // {
+ // answ = JsonConvert.SerializeObject(currParams);
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in getObjItems{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// restituisce elenco parametri CHE RICHIEDONO scrittura su PLC come una List Json di
+ ///// oggetti objItem
+ ///// GET: IOB/getObjItems2Write/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //public string getObjItems2Write(string id)
+ //{
+ // string answ = "";
+ // if (string.IsNullOrWhiteSpace(id))
+ // {
+ // answ = "Missing IOB";
+ // }
+ // else
+ // {
+ // // procedo a recuperare l'oggetto...
+ // List currParams = new List();
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // // deserializzo
+ // currParams = DataLayerObj.getCurrObjItemsPendigWrite(id);
+ // // se != null --> salvo!
+ // if (currParams != null)
+ // {
+ // answ = JsonConvert.SerializeObject(currParams);
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in getCurrParams{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera ODL x macchina e data, se + di 1 quello di durata maggiore:
+ /////
+ ///// GET: IOB/getOdlAtDate/SIMUL_03
+ /////
+ ///// IdxMacchina
+ ///// DataRiferimento, formato yyyyMMdd (8 cifre)
+ /////
+ //public string getOdlAtDate(string id, string dateRif)
+ //{
+ // string answ = "";
+ // // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // // carattere "|" che poi trasformiamo ora in "#"
+ // id = id.Replace("|", "#");
+ // // converto la data in formato dateTime... e ottengo intervallo data indicata da
+ // // mezzanotte a 23:59:59...
+ // CultureInfo provider = CultureInfo.InvariantCulture;
+ // DateTime dtFrom = DateTime.Today;
+ // bool fatto = DateTime.TryParseExact(dateRif, "yyyyMMdd", provider, DateTimeStyles.None, out dtFrom);
+ // if (fatto)
+ // {
+ // // data fine giorno dopo
+ // DateTime dtTo = dtFrom.AddDays(1);
+ // // cerco ODL alla data (validi)
+ // DataLayer DataLayerObj = new DataLayer();
+ // DS_ProdTempi.ODLDataTable odlList = DataLayerObj.taODL.getByMacchinaPeriodoNoNull(id, dtFrom, dtTo);
+ // // se non trovo aumento ricerca all'indietro...
+ // int maxTry = 14;
+ // while (odlList.Count == 0 && maxTry > 0)
+ // {
+ // dtFrom = dtFrom.AddDays(-1);
+ // odlList = DataLayerObj.taODL.getByMacchinaPeriodoNoNull(id, dtFrom, dtTo);
+ // maxTry++;
+ // }
+ // int idxOdl = 0;
+ // // se > 1 --> prendo il + durevole
+ // if (odlList.Count > 1)
+ // {
+ // double maxPeriod = 0;
+ // foreach (var item in odlList)
+ // {
+ // DateTime dtStart = item.DataInizio > dtFrom ? item.DataInizio : dtFrom;
+ // DateTime dtEnd = item.DataFine < dtTo ? item.DataFine : dtTo;
+ // double currPeriod = dtEnd.Subtract(dtStart).TotalMinutes;
+ // if (currPeriod > maxPeriod)
+ // {
+ // maxPeriod = currPeriod;
+ // idxOdl = item.IdxODL;
+ // }
+ // }
+ // }
+ // else if (odlList.Count == 1)
+ // {
+ // idxOdl = odlList[0].IdxODL;
+ // }
+ // else
+ // {
+ // // cerco ODL prendendo qualche gg prima...
+ // }
+ // // conversione!
+ // answ = $"{idxOdl}";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera TASK richiesto x macchina:
+ /////
+ ///// GET: IOB/getOptPar/SIMUL_03
+ /////
+ /////
+ ///// Json contenente 1..n task da eseguire
+ //public string getOptPar(string id)
+ //{
+ // string answ = "";
+ // // scrivo keep alive!!! (se necessario, altrimenti è in cache...)
+ // MapoDb.MapoDb connDb = new MapoDb.MapoDb();
+ // connDb.scriviKeepAlive(id, DateTime.Now);
+ // try
+ // {
+ // // leggo da REDIS eventuale elenco task x macchina...
+ // DataLayer DataLayerObj = new DataLayer();
+ // Dictionary valori = DataLayerObj.mOptParMacchina(id);
+ // answ = JsonConvert.SerializeObject(valori);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Recupera TASK richiesto x macchina:
+ /////
+ ///// GET: IOB/getTask2Exe/SIMUL_03
+ /////
+ /////
+ ///// Json contenente 1..n task da eseguire
+ //public string getTask2Exe(string id)
+ //{
+ // string answ = "";
+ // // scrivo keep alive!!! (se necessario, altrimenti è in cache...)
+ // MapoDb.MapoDb connDb = new MapoDb.MapoDb();
+ // DataLayer DataLayerObj = new DataLayer();
+ // connDb.scriviKeepAlive(id, DateTime.Now);
+ // try
+ // {
+ // // leggo da REDIS eventuale elenco task x macchina...
+ // Dictionary valori = DataLayerObj.mTaskMacchina(id);
+ // answ = JsonConvert.SerializeObject(valori);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ //// GET: IOB (è un check alive del server)
+ //public string Index()
+ //{
+ // if (memLayer.ML.CRB("IOB_RedEnab"))
+ // {
+ // // conto la richiesta nel contatore REDIS
+ // long nCall = memLayer.ML.setRCntI(DataLayer.mHash("COUNT:pCall:IOB_INDEX"));
+ // //... se == nCall2Log scrivo su log e resetto
+ // long nCall2Log = memLayer.ML.cdvi("nCall2Log");
+ // if (nCall >= nCall2Log)
+ // {
+ // // loggo
+ // logger.lg.scriviLog(string.Format("IOB_INDEX: effettuate {0} call", nCall), tipoLog.INFO);
+ // // resetto!
+ // memLayer.ML.resetRCnt(DataLayer.mHash("COUNT:pCall:IOB_INDEX"));
+ // }
+ // }
+ // return "OK";
+ //}
+
+ //// GET: IOB/input/SIMUL_03?valore=3&dtEve=20181206180600000&dtCurr=20181206180600000&cnt=999
+ //public string input(string id, string valore, string dtEve, string dtCurr, string cnt)
+ //{
+ // string answ = "";
+ // // formato yyyymmddHHMMSSnnn ovvero da anno a millisecondi
+ // if (cnt == null)
+ // {
+ // cnt = "0";
+ // }
+
+ // DateTime dataOraEvento = DateTime.Now;
+ // if (memLayer.ML.CRI("_logLevel") > 6)
+ // {
+ // logger.lg.scriviLog($"Valori letti: idxMacchina: {id} | valore: {valore}", tipoLog.INFO);
+ // }
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // answ = DataLayerObj.processInput(id, valore, dtEve, dtCurr, cnt);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog(string.Format("Errore in processInput{0}{1}", Environment.NewLine, exc));
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Processa una chiamata POST per l'invio di un array Json di oggetti LIVE REC
+ ///// PUT: IOB/liveJson/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //[HttpPost]
+ //public string liveJson(string id)
+ //{
+ // string answ = "-";
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(
+ // Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // //Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // // procedo a deserializzare in blocco l'oggetto...
+ // try
+ // {
+ // // deserializzo.
+ // liveIOB receivedData = JsonConvert.DeserializeObject(content);
+ // DataLayer DataLayerObj = new DataLayer();
+ // answ = DataLayerObj.processLiveJson(id, receivedData);
+ // // se vuoto --> OK!
+ // if (string.IsNullOrEmpty(answ))
+ // {
+ // answ = "OK 1 done";
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in liveJson{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ //// GET: IOB/liveRec/SIMUL_03?&liveData=chiave1|valore1#chiave2|valore#|chiave3|valore3
+ //public string liveRec(string id, string liveData)
+ //{
+ // string answ = "";
+ // DateTime dataOraEvento = DateTime.Now;
+ // if (memLayer.ML.CRI("_logLevel") > 6)
+ // {
+ // logger.lg.scriviLog($"Valori Live:{Environment.NewLine}idxMacchina: {id}{Environment.NewLine}liveData: {liveData}", tipoLog.INFO);
+ // }
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // answ = DataLayerObj.processLiveRec(id, liveData);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in liveRec{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Processa una chiamata POST per l'invio di un array Json di oggetti rawTransfer
+ ///// (generiche info da deserializzare)
+ ///// POST: IOB/rawTransfJson/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //[HttpPost]
+ //public string rawTransfJson(string id)
+ //{
+ // int insDone = 0;
+ // string answ = "";
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(
+ // Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // //Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // // se ho dati...
+ // if (content != "")
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // MagDataLayer DataLayerMagObj = new MagDataLayer();
+ // // deserializzo come un dictionary generico di oggetti rawDataType/string
+ // List receivedData = new List();
+ // // procedo a deserializzare in blocco l'oggetto...
+ // try
+ // {
+ // // deserializzo.
+ // receivedData = JsonConvert.DeserializeObject>(content);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in fase deserializzazione rawTransfJson{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // // se ho qualcosa da processare...
+ // if (receivedData != null)
+ // {
+ // try
+ // {
+ // foreach (var item in receivedData)
+ // {
+ // // per ora salvo su REDIS ultimo x tipo
+ // DataLayerObj.lastRawTrasfData = JsonConvert.SerializeObject(item.mesContent);
+
+ // // !!! FixMe ToDo fare deserializzazione e salvataggio su MongoDB
+ // // salvataggio su tab RawTrasf su DB IS
+
+ // // in base al tipo processo...
+ // switch (item.mesType)
+ // {
+ // case rawTransfType.IcoelBatch:
+ // break;
+
+ // case rawTransfType.IcoelVarInfo:
+ // break;
+
+ // case rawTransfType.RegGiacenze:
+ // // elenco ODL da svuotare preventivamente x insert...
+ // List listOdl = new List();
+ // // processo scrittura giacenze... processo 1:1 record di RegGiacenze
+ // List recData = new List();
+ // foreach (var singleRow in item.mesContent)
+ // {
+ // var listGiac = JsonConvert.DeserializeObject(singleRow.Value.ToString());
+ // recData.Add(listGiac);
+ // if (!listOdl.Contains(listGiac.IdxODL))
+ // {
+ // listOdl.Add(listGiac.IdxODL);
+ // }
+ // }
+ // // svuoto le giacenze degli ODL oggetto di import...
+ // bool fatto = DataLayerMagObj.resetRegGiacByOdl(listOdl);
+ // if (fatto)
+ // {
+ // // invio x salvare
+ // fatto = DataLayerMagObj.salvaRegGiac(recData);
+ // }
+ // break;
+
+ // case rawTransfType.ND:
+ // default:
+ // break;
+ // }
+ // insDone++;
+ // }
+ // // se vuoto --> OK!
+ // if (string.IsNullOrEmpty(answ))
+ // {
+ // answ = $"OK {insDone} processed";
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in fase invio valori rawTransfJson{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// ELIMINA TASK richiesto x macchina:
+ /////
+ ///// GET: IOB/remOptPar/SIMUL_03?pName=PZREQ
+ /////
+ /////
+ /////
+ //public string remOptPar(string id, string pName)
+ //{
+ // string answ = "";
+ // // scrivo keep alive!!! (se necessario, altrimenti è in cache...)
+ // MapoDb.MapoDb connDb = new MapoDb.MapoDb();
+ // DataLayer DataLayerObj = new DataLayer();
+ // connDb.scriviKeepAlive(id, DateTime.Now);
+ // try
+ // {
+ // DataLayerObj.remOptPar4Machine(id, pName);
+ // answ = getOptPar(id);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// ELIMINA TASK richiesto x macchina:
+ /////
+ ///// GET: IOB/remTask2Exe/SIMUL_03?taskName=T180326160502
+ /////
+ /////
+ /////
+ //public string remTask2Exe(string id, string taskName)
+ //{
+ // string answ = "";
+ // // scrivo keep alive!!! (se necessario, altrimenti è in cache...)
+ // MapoDb.MapoDb connDb = new MapoDb.MapoDb();
+ // DataLayer DataLayerObj = new DataLayer();
+ // connDb.scriviKeepAlive(id, DateTime.Now);
+ // try
+ // {
+ // // converto stringa in tipo task...
+ // taskType tName = taskType.nihil;
+ // bool fatto = Enum.TryParse(taskName, out tName);
+ // if (fatto)
+ // {
+ // DataLayerObj.remTask4Machine(id, tName);
+ // }
+ // else
+ // {
+ // logger.lg.scriviLog($"remTask2Exe: impossibile riconoscere il comando {taskName} come uno dei tipi ammessi, NON rimosso", tipoLog.ERROR);
+ // }
+ // answ = getTask2Exe(id);
+ // }
+ // catch
+ // { }
+ // return answ;
+ //}
+
+ /////
+ ///// Effettua RESET dell'ODL corrente x macchina:
+ /////
+ ///// GET: IOB/resetCurrODL/5
+ /////
+ /////
+ /////
+ //public string resetCurrODL(string id)
+ //{
+ // DataLayer DataLayerObj = new DataLayer();
+ // return DataLayerObj.emptyCurrODL(id);
+ //}
+
+ /////
+ ///// Processa una chiamata POST per l'invio di un array Json di oggetti plcMemConf
+ ///// PUT: IOB/saveConf/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //[HttpPost]
+ //public string saveConf(string id)
+ //{
+ // string answ = "";
+ // if (string.IsNullOrWhiteSpace(id))
+ // {
+ // answ = "Missing IOB";
+ // }
+ // else
+ // {
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in
+ // // altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // //Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // // procedo a deserializzare in blocco l'oggetto...
+ // plcMemMap currMemMap = null;
+ // try
+ // {
+ // // deserializzo.
+ // currMemMap = JsonConvert.DeserializeObject(content);
+ // // se != null --> salvo!
+ // if (currMemMap != null)
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // DataLayerObj.setIobMemMap(id, currMemMap);
+ // answ = "OK";
+ // }
+ // }
+ // catch
+ // { }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Processa una chiamata POST per l'invio di un array Json di oggetti di conf DataItems (es
+ ///// per MTC)
+ ///// PUT: IOB/saveDataItems/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //[HttpPost]
+ //public string saveDataItems(string id)
+ //{
+ // string answ = "";
+ // logger.lg.scriviLog($"Richiesta saveDataItems per id {id}");
+ // if (string.IsNullOrWhiteSpace(id))
+ // {
+ // answ = "Missing IOB";
+ // }
+ // else
+ // {
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in
+ // // altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // // Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+
+ // // procedo a deserializzare in blocco l'oggetto...
+ // List dataItems = null;
+ // try
+ // {
+ // logger.lg.scriviLog($"Ricevuto payload di {content.Length} chars");
+ // // deserializzo.
+ // dataItems = JsonConvert.DeserializeObject>(content);
+ // // se != null --> salvo!
+ // if (dataItems != null)
+ // {
+ // // chiamo metodo update direttamente!
+ // MtcDataModelArchive.man.saveMachineDataItems(id, dataItems);
+ // answ = "OK";
+ // logger.lg.scriviLog($"Effettuato salvataggio saveDataItems per id {id}:{Environment.NewLine}{content}");
+ // }
+ // }
+ // catch
+ // { }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// SALVA in blocco un incremento pezzi x macchina restituendo il valore appena inviato o,
+ ///// se mancasse chaive redis, del valore da DB
+ /////
+ ///// GET: IOB/savePzCountInc/5?qty=10
+ /////
+ ///// codice macchina
+ ///// num peziz da salvare in blocco
+ /////
+ //public string savePzCountInc(string id, string qty)
+ //{
+ // string answ = "";
+ // DateTime dataOraEvento = DateTime.Now;
+ // // salvo SEMPRE log x questo tipo di dati!
+ // logger.lg.scriviLog($"Salvataggio incremento contapezzi | idxMacchina: {id} | pezzi: {qty}", tipoLog.INFO);
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // answ = DataLayerObj.saveCaricoPezzi(id, qty);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in savePzCountInc{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Registrazione variazione allarmi
+ /////
+ ///// GET: IOB/sendAlarmBankUpdate/SIMUL_03
+ /////
+ /////
+ /////
+ //[HttpPost]
+ //public string sendAlarmBankUpdate(string id, string memAddr, int index, int currStatus)
+ //{
+ // DataLayer DataLayerObj = new DataLayer();
+ // // esempio valido x MAPO
+ // string answ = "";
+ // logger.lg.scriviLog($"Richiesta sendAlarmBankUpdate per id {id}");
+ // if (string.IsNullOrWhiteSpace(id))
+ // {
+ // answ = "Missing IOB";
+ // }
+ // else
+ // {
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in
+ // // altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // // Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+
+ // // procedo a deserializzare in blocco l'oggetto...
+ // List ActiveAlarms = null;
+ // try
+ // {
+ // logger.lg.scriviLog($"Ricevuto payload di {content.Length} chars");
+ // // deserializzo.
+ // ActiveAlarms = JsonConvert.DeserializeObject>(content);
+ // // se != null --> salvo!
+ // if (ActiveAlarms != null)
+ // {
+ // string alarmDecoded = "-";
+ // if (ActiveAlarms != null && ActiveAlarms.Count > 0)
+ // {
+ // alarmDecoded = String.Join(" | ", ActiveAlarms);
+ // }
+ // DataLayerObj.taAlarmLog.insertQuery(DateTime.Now, id, memAddr, index, currStatus, alarmDecoded);
+ // answ = "OK";
+ // }
+ // }
+ // catch
+ // { }
+ // }
+ // return answ;
+
+ // // esempio GWMS
+ //}
+
+ ///// Salva MAC adress + IP dopo il reboot
+ ///// GET: IOB/sendReboot?idxMacchina=5&mac=18:C0:4D:37:3C:8C IP
+ ///// del Gateway
+ //public string sendReboot(string idxMacchina, string mac)
+ //{
+ // string answ = "NO";
+ // string IPv4 = "";
+ // string agent = "";
+ // try
+ // {
+ // // recupero IP del client remoto
+ // IPv4 = Request.UserHostName;
+ // agent = Request.UserAgent;
+ // }
+ // catch
+ // { }
+ // try
+ // {
+ // // ora salvo che la macchina è stata (ri)avviata...
+ // MapoDb.MapoDb MapoDbObj = new MapoDb.MapoDb();
+ // MapoDbObj.registraStartup(idxMacchina, IPv4, agent, mac);
+ // answ = "OK";
+ // }
+ // catch (Exception exc)
+ // {
+ // if (memLayer.ML.CRI("_logLevel") > 5)
+ // {
+ // string errore = string.Format("Errore: {0}{1}", Environment.NewLine, exc);
+ // logger.lg.scriviLog(errore, tipoLog.EXCEPTION);
+ // }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Salva IP del gateway dopo il reboot
+ /////
+ ///// IP del Gateway
+ /////
+ //public string sendRebootGateway(string GWIP)
+ //{
+ // string answ = "OK";
+
+ // // !!!FARE!!! deve salvare il riavvio dell'applicazione GATEWAY multiclient
+
+ // return answ;
+ //}
+
+ /////
+ ///// SALVA Counter x macchina restituendo il valore appena inviato o, se mancasse chiave
+ ///// redis, del valore da DB
+ /////
+ ///// GET: IOB/setCounter/5?counter=10
+ /////
+ ///// cod macchina
+ ///// contapezzi da salvare
+ /////
+ //public string setCounter(string id, string counter)
+ //{
+ // string answ = "-1";
+ // DateTime dataOraEvento = DateTime.Now;
+ // if (memLayer.ML.CRI("_logLevel") > 6)
+ // {
+ // logger.lg.scriviLog($"Salvataggio counter | idxMacchina: {id}", tipoLog.INFO);
+ // }
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // answ = DataLayerObj.saveCounter(id, counter);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog(string.Format("Errore in counter (set){0}{1}", Environment.NewLine, exc));
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Salva associazione tra macchina, device IOB chiamante e sue info
+ /////
+ ///// Id della macchina
+ ///// Nome dell'IOB di acquisizione della macchina
+ /////
+ //public string setM2IOB(string id, string IOB_name)
+ //{
+ // string answ = "";
+ // try
+ // {
+ // // recupero IP del client remoto
+ // string IPv4 = Request.UserHostName;
+ // string agent = Request.UserAgent;
+ // // creo oggetto IOB_data...
+ // IOB_data m2IOB = new IOB_data
+ // {
+ // name = IOB_name,
+ // IP = IPv4,
+ // iType = IobType.ND,
+ // typeCss = "fa fa-question-circle-o",
+ // CNC_Counter = false
+ // };
+ // // imposto tipo ed icona come windows/linux secondo UserAgent...
+ // if (agent.IndexOf("WIN") >= 0)
+ // {
+ // m2IOB.iType = IobType.WIN;
+ // m2IOB.typeCss = "fa fa-windows";
+ // m2IOB.CNC_Counter = true;
+ // }
+ // else if (agent.IndexOf("Python") >= 0)
+ // {
+ // m2IOB.iType = IobType.rPi;
+ // m2IOB.typeCss = "fa fa-linux";
+ // }
+ // // serializzo...
+ // string dataSer = JsonConvert.SerializeObject(m2IOB);
+ // // salvo in redis...
+ // string hM2IOB = DataLayer.hM2IOB(id);
+ // memLayer.ML.setRSV(hM2IOB, dataSer);
+ // // salvo tutto OK
+ // answ = "OK";
+ // }
+ // catch
+ // {
+ // answ = "KO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Processa una chiamata POST per l'invio di una List Json di oggetti objItem
+ ///// POST: IOB/setObjItems/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //[HttpPost]
+ //public string setObjItems(string id)
+ //{
+ // string answ = "";
+ // if (string.IsNullOrWhiteSpace(id))
+ // {
+ // answ = "Missing IOB";
+ // }
+ // else
+ // {
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in
+ // // altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // //Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // // procedo a deserializzare in blocco l'oggetto...
+ // List currParams = new List();
+ // try
+ // {
+ // // deserializzo.
+ // currParams = JsonConvert.DeserializeObject>(content);
+ // // se != null --> salvo!
+ // if (currParams != null)
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // bool fatto = DataLayerObj.setCurrObjItems(id, currParams);
+ // answ = fatto ? "OK" : "KO";
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in setCurrParams{Environment.NewLine}{exc}");
+ // answ = "EXC";
+ // }
+ // }
+ // return answ;
+ //}
+
+ //// GET: IOB/slog/SIMUL_03
+ //public string slog(string id)
+ //{
+ // string answ = "ND";
+ // // se id nullo --> KO!
+ // if (id == null)
+ // {
+ // answ = "KO";
+ // }
+ // else
+ // {
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // // salvo risposta
+ // answ = DataLayerObj.sLogEnab(id) ? "OK" : "NO";
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog(string.Format("Errore in sLog{0}{1}", Environment.NewLine, exc));
+ // answ = "NO";
+ // }
+ // }
+ // return answ;
+ //}
+
+ //// GET: IOB/takeFlogSnapshot/SIMUL_03
+ //public string takeFlogSnapshot(string id)
+ //{
+ // string answ = "";
+ // string caller = $"takeFlogSnapshot({id})";
+
+ // DateTime adesso = DateTime.Now;
+ // DateTime dtEnd = adesso;
+ // DateTime dtStart = adesso.AddDays(-1);
+ // //effettuo chiamata!
+ // answ = doSaveFLSnapshot(id, dtStart, dtEnd, caller);
+ // return answ;
+ //}
+
+ //// GET: IOB/ulog/SIMUL_03?flux=PROG&valore=P0001&dtEve=20161223180600000&dtCurr=20161223180600000&cnt=999&matrOpr=0=0&label=&valNum
+ //public string ulog(string id, string flux, string valore, string dtEve, string dtCurr, string cnt, string matrOpr, string label, string valNum)
+ //{
+ // string answ = "";
+ // // formato yyyymmddHHMMSSnnn ovvero da anno a millisecondi
+ // if (cnt == null)
+ // {
+ // cnt = "0";
+ // }
+
+ // DateTime dataOraEvento = DateTime.Now;
+ // if (memLayer.ML.CRI("_logLevel") > 6)
+ // {
+ // logger.lg.scriviLog($"ulog | Valori letti: idxMacchina: {id} | flux: {flux} valore: {valore} | matrOpr: {matrOpr} | label: {label} | valNum: {valNum}", tipoLog.INFO);
+ // }
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // int count = 0;
+ // int nMatrOpr = 0;
+ // int nValNum = 0;
+ // Int32.TryParse(cnt, out count);
+ // Int32.TryParse(matrOpr, out nMatrOpr);
+ // Int32.TryParse(valNum, out nValNum);
+ // answ = DataLayerObj.processUserLog(id, flux, valore, dtEve, dtCurr, count, nMatrOpr, label, nValNum);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in ulog{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Processa una chiamata POST per l'invio di una List Json 1+ UserAction (contiene
+ ///// controlli, scarti, dichiarazioni)
+ ///// POST: IOB/ulogJson/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //[HttpPost]
+ //public string ulogJson(string id)
+ //{
+ // int insDone = 0;
+ // string answ = "-";
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(
+ // Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // //Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // // se ho dati...
+ // if (content != "")
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // // procedo a deserializzare in blocco l'oggetto...
+ // ulogJsonPayload receivedData = new ulogJsonPayload();
+ // try
+ // {
+ // // deserializzo.
+ // receivedData = JsonConvert.DeserializeObject(content);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in fase deserializzazione ulogJson{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // // se ho qualcosa da processare...
+ // if (receivedData != null)
+ // {
+ // // per ogni valore --> salvo!
+ // try
+ // {
+ // foreach (var item in receivedData.fluxData)
+ // {
+ // // formato datetime come yyyyMMddHHmmssfff -->es: 20181223180600000
+ // answ = DataLayerObj.processUserLog(id, item.flux, item.valore, item.dtEve.ToString("yyyyMMddHHmmssfff"), item.dtCurr.ToString("yyyyMMddHHmmssfff"), item.cnt, item.matrOpr, item.label, item.valNum);
+ // }
+ // // se vuoto --> OK!
+ // if (string.IsNullOrEmpty(answ))
+ // {
+ // answ = $"OK {insDone} processed";
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in fase invio valori ulogJson{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // }
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Processa una chiamata POST per l'invio di un SET di file "a nome" di un IOB, formato MapoSDK.fileEmbed
+ ///// PUT: IOB/uploadFile/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //[HttpPost]
+ //public string uploadFile(string id)
+ //{
+ // string answ = "";
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // //Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // // procedo a deserializzare in blocco l'oggetto...
+ // try
+ // {
+ // // deserializzo.
+ // fileEmbed receivedData = JsonConvert.DeserializeObject(content);
+ // // salvo nella cartella di Upload...
+ // string basePath = Server.MapPath(memLayer.ML.CRS("uploadFileDir"));
+ // string dirPath = $"{basePath}\\{id}";
+ // // fix directory...
+ // Directory.CreateDirectory(dirPath);
+ // foreach (var item in receivedData.fileList)
+ // {
+ // // scrivo!
+ // System.IO.File.WriteAllText($"{dirPath}\\{item.fileName}", item.content);
+ // }
+ // answ = "OK";
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in uploadFile{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // return answ;
+ //}
+
+ /////
+ ///// Processa una chiamata POST per l'invio di una List Json di UNO O PIU' oggetti objItem
+ ///// POST: IOB/upsertObjItems/SIMUL_03
+ /////
+ ///// ID dell'IOB
+ /////
+ //[HttpPost]
+ //public string upsertObjItems(string id)
+ //{
+ // string answ = "";
+ // if (string.IsNullOrWhiteSpace(id))
+ // {
+ // answ = "Missing IOB";
+ // }
+ // else
+ // {
+ // // questa classe è derivata da Controller.Response... x cui recupero lo stream in
+ // // altro modo...
+ // string content = "";
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
+ // {
+ // content = reader.ReadToEnd();
+ // }
+ // //Rest
+ // System.Web.HttpContext.Current.Request.InputStream.Position = 0;
+ // // procedo a deserializzare in blocco l'oggetto...
+ // List innovazioni = new List();
+ // try
+ // {
+ // // deserializzo.
+ // innovazioni = JsonConvert.DeserializeObject>(content);
+ // // se != null --> salvo!
+ // if (innovazioni != null)
+ // {
+ // // salvo
+ // DataLayer DataLayerObj = new DataLayer();
+ // DataLayerObj.upsertCurrObjItems(id, innovazioni);
+ // answ = "OK";
+ // }
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in upsertObjItems{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+ // }
+ // return answ;
+ //}
+
+ #endregion Public Methods
+
+ #region Private Methods
+
+ /////
+ ///// Effettua vera chiamata x salvataggio snapshot dati FluxLog
+ /////
+ /////
+ /////
+ /////
+ /////
+ //private static string doSaveFLSnapshot(string id, DateTime dtStart, DateTime dtEnd, string caller)
+ //{
+ // string answ;
+ // DateTime dataOraEvento = DateTime.Now;
+ // if (memLayer.ML.CRI("_logLevel") > 6)
+ // {
+ // logger.lg.scriviLog($"{caller} | Richiesta snapshot dati FluxLog macchina: idxMacchina: {id} | periodo: {dtStart} - {dtEnd}", tipoLog.INFO);
+ // }
+ // try
+ // {
+ // DataLayer DataLayerObj = new DataLayer();
+ // answ = DataLayerObj.takeFlogSnapshotLast(id, dtStart, dtEnd);
+ // }
+ // catch (Exception exc)
+ // {
+ // logger.lg.scriviLog($"Errore in {caller}{Environment.NewLine}{exc}");
+ // answ = "NO";
+ // }
+
+ // return answ;
+ //}
+
+ #endregion Private Methods
+ }
+}
diff --git a/MP.IOC/Controllers/RecipeController.cs b/MP.IOC/Controllers/RecipeController.cs
index 882930a7..e245c688 100644
--- a/MP.IOC/Controllers/RecipeController.cs
+++ b/MP.IOC/Controllers/RecipeController.cs
@@ -14,10 +14,10 @@ namespace MP.IOC.Controllers
public RecipeController(IConfiguration configuration, MpDataService DataService)
{
- Log.Info("Starting MpDataService INIT");
+ Log.Info("Starting RecipeController");
_configuration = configuration;
DService = DataService;
- Log.Info("Avviata classe Recipe");
+ Log.Info("Avviata RecipeController");
}
#endregion Public Constructors
diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs
index e549da18..f6dd806f 100644
--- a/MP.IOC/Data/MpDataService.cs
+++ b/MP.IOC/Data/MpDataService.cs
@@ -1,4 +1,5 @@
-using MP.Data;
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
+using MP.Data;
using MP.Data.Conf;
using MP.Data.DatabaseModels;
using MP.Data.DTO;
@@ -6,6 +7,7 @@ using MP.Data.MgModels;
using Newtonsoft.Json;
using NLog;
using StackExchange.Redis;
+using System.Data;
using System.Diagnostics;
namespace MP.IOC.Data
@@ -38,8 +40,9 @@ namespace MP.IOC.Data
}
else
{
- dbController = new MP.Data.Controllers.MpSpecController(configuration);
- _logger.LogInformation("DbController OK");
+ SpecDbController = new MP.Data.Controllers.MpSpecController(configuration);
+ IocDbController = new MP.Data.Controllers.MpIocController(configuration);
+ _logger.LogInformation("DbControllers INIT OK");
}
// conf mongo...
@@ -51,7 +54,7 @@ namespace MP.IOC.Data
else
{
mongoController = new MP.Data.Controllers.MpMongoController(configuration);
- _logger.LogInformation("MongoController OK");
+ _logger.LogInformation("MongoController INIT OK");
}
}
@@ -59,7 +62,8 @@ namespace MP.IOC.Data
#region Public Properties
- public static MP.Data.Controllers.MpSpecController dbController { get; set; } = null!;
+ public static MP.Data.Controllers.MpIocController IocDbController { get; set; } = null!;
+ public static MP.Data.Controllers.MpSpecController SpecDbController { get; set; } = null!;
public static MP.Data.Controllers.MpMongoController mongoController { get; set; } = null!;
public MessagePipe BroadastMsgPipe { get; set; } = null!;
@@ -73,15 +77,7 @@ namespace MP.IOC.Data
#region Public Methods
- ///
- /// Hash dati STATUS x la macchina specificata
- ///
- ///
- ///
- public static string dtMaccHash(string idxMacchina)
- {
- return $"{redisBaseAddrIOC}DtMac:{idxMacchina}";
- }
+
///
/// Recupera eventuali azioni richieste
@@ -93,7 +89,7 @@ namespace MP.IOC.Data
stopWatch.Start();
DisplayAction? result = null;
// cerco in redis...
- RedisValue rawData = await redisDb.StringGetAsync(redisActionReq);
+ RedisValue rawData = await redisDb.StringGetAsync(Utils.redisActionReq);
if (!string.IsNullOrEmpty($"{rawData}"))
{
result = JsonConvert.DeserializeObject($"{rawData}");
@@ -121,8 +117,7 @@ namespace MP.IOC.Data
// cerco in redis...
string rawData = JsonConvert.SerializeObject(act2save);
// invio broadcast + salvo in redis
- BroadastMsgPipe.saveAndSendMessage(redisActionReq, rawData);
- //await redisDb.StringSetAsync(redisActionReq, rawData);
+ BroadastMsgPipe.saveAndSendMessage(Utils.redisActionReq, rawData);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ActionSetReq REDIS send to broadcast + Write cache: {ts.TotalMilliseconds}ms");
@@ -135,7 +130,7 @@ namespace MP.IOC.Data
stopWatch.Start();
List? result = new List();
// cerco in redis...
- RedisValue rawData = await redisDb.StringGetAsync(redisStatoCom);
+ RedisValue rawData = await redisDb.StringGetAsync(Utils.redisStatoCom);
if (!string.IsNullOrEmpty($"{rawData}"))
{
result = JsonConvert.DeserializeObject>($"{rawData}");
@@ -145,10 +140,10 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.AnagStatiComm());
+ result = await Task.FromResult(SpecDbController.AnagStatiComm());
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(redisStatoCom, rawData, getRandTOut(redisLongTimeCache));
+ await redisDb.StringSetAsync(Utils.redisStatoCom, rawData, getRandTOut(redisLongTimeCache));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AnagStatiComm Read from DB: {ts.TotalMilliseconds}ms");
@@ -167,7 +162,7 @@ namespace MP.IOC.Data
string source = "DB";
List? result = new List();
// cerco in redis...
- RedisValue rawData = await redisDb.StringGetAsync(redisTipoArt);
+ RedisValue rawData = await redisDb.StringGetAsync(Utils.redisTipoArt);
if (!string.IsNullOrEmpty($"{rawData}"))
{
result = JsonConvert.DeserializeObject>($"{rawData}");
@@ -175,10 +170,10 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.AnagTipoArtLV());
+ result = await Task.FromResult(SpecDbController.AnagTipoArtLV());
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(redisTipoArt, rawData, getRandTOut(redisLongTimeCache));
+ await redisDb.StringSetAsync(Utils.redisTipoArt, rawData, getRandTOut(redisLongTimeCache));
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
@@ -200,7 +195,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = redisArtByDossier;
+ string currKey = Utils.redisArtByDossier;
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -210,7 +205,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.ArticleWithDossier());
+ result = await Task.FromResult(SpecDbController.ArticleWithDossier());
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
@@ -232,7 +227,7 @@ namespace MP.IOC.Data
///
public async Task ArticoliDeleteRecord(AnagArticoli currRec)
{
- bool fatto = await dbController.ArticoliDeleteRecord(currRec);
+ bool fatto = await SpecDbController.ArticoliDeleteRecord(currRec);
await resetCacheArticoli();
return fatto;
}
@@ -250,7 +245,7 @@ namespace MP.IOC.Data
stopWatch.Start();
string readType = "DB";
string sKey = string.IsNullOrEmpty(searchVal) ? "***" : searchVal;
- string currKey = $"{redisArtList}:{azienda}:{sKey}";
+ string currKey = $"{Utils.redisArtList}:{azienda}:{sKey}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -260,7 +255,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal));
+ result = await Task.FromResult(SpecDbController.ArticoliGetSearch(numRecord, azienda, searchVal));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache / 5));
@@ -282,7 +277,7 @@ namespace MP.IOC.Data
///
public async Task ArticoliUpdateRecord(AnagArticoli currRec)
{
- bool fatto = await dbController.ArticoliUpdateRecord(currRec);
+ bool fatto = await SpecDbController.ArticoliUpdateRecord(currRec);
await resetCacheArticoli();
return fatto;
}
@@ -324,7 +319,7 @@ namespace MP.IOC.Data
if (artList == null || artList.Count == 0)
{
artList = new List();
- var tabArticoli = dbController.ArticoliGetUsed();
+ var tabArticoli = SpecDbController.ArticoliGetUsed();
var codList = tabArticoli.Select(x => x.CodArticolo);
foreach (string cod in codList)
{
@@ -365,7 +360,7 @@ namespace MP.IOC.Data
stopWatch.Start();
List? result = new List();
// cerco in redis...
- RedisValue rawData = await redisDb.StringGetAsync(redisConfKey);
+ RedisValue rawData = await redisDb.StringGetAsync(Utils.redisConfKey);
if (!string.IsNullOrEmpty($"{rawData}"))
{
result = JsonConvert.DeserializeObject>($"{rawData}");
@@ -375,10 +370,10 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.ConfigGetAll());
+ result = await Task.FromResult(SpecDbController.ConfigGetAll());
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(redisConfKey, rawData, getRandTOut(redisLongTimeCache));
+ await redisDb.StringSetAsync(Utils.redisConfKey, rawData, getRandTOut(redisLongTimeCache));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ConfigGetAll Read from DB: {ts.TotalMilliseconds}ms");
@@ -396,7 +391,7 @@ namespace MP.IOC.Data
///
public async Task ConfigResetCache()
{
- await redisDb.StringSetAsync(redisConfKey, "");
+ await redisDb.StringSetAsync(Utils.redisConfKey, "");
}
///
@@ -405,7 +400,7 @@ namespace MP.IOC.Data
///
public async Task ConfigUpdate(ConfigModel updRec)
{
- return await Task.FromResult(dbController.ConfigUpdate(updRec));
+ return await Task.FromResult(SpecDbController.ConfigUpdate(updRec));
}
///
@@ -418,7 +413,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisBaseAddrIOC}:TabDatiMacchine:ALL";
+ string currKey = $"{Utils.redisBaseAddr}:TabDatiMacchine:ALL";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -428,7 +423,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.DatiMacchineGetAll());
+ result = await Task.FromResult(SpecDbController.DatiMacchineGetAll());
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
@@ -449,7 +444,7 @@ namespace MP.IOC.Data
public void Dispose()
{
// Clear database controller
- dbController.Dispose();
+ SpecDbController.Dispose();
mongoController.Dispose();
redisConn.Dispose();
}
@@ -464,9 +459,9 @@ namespace MP.IOC.Data
bool result = false;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
- result = await dbController.DossiersDeleteRecord(selRecord);
+ result = await SpecDbController.DossiersDeleteRecord(selRecord);
// elimino cache redis...
- RedisValue pattern = new RedisValue($"{redisDossByMac}:*");
+ RedisValue pattern = new RedisValue($"{Utils.redisDossByMac}:*");
bool answ = await RedisFlushPatternAsync(pattern);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
@@ -488,7 +483,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisDossByMac}:{IdxMacchina}:{CodArticolo}:{DtStart:yyyyMMddHHmm}:{DtEnd:yyyyMMddHHmm}";
+ string currKey = $"{Utils.redisDossByMac}:{IdxMacchina}:{CodArticolo}:{DtStart:yyyyMMddHHmm}:{DtEnd:yyyyMMddHHmm}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -498,7 +493,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.DossiersGetLastFilt(IdxMacchina, CodArticolo, DtStart, DtEnd));
+ result = await Task.FromResult(SpecDbController.DossiersGetLastFilt(IdxMacchina, CodArticolo, DtStart, DtEnd));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache / 5));
@@ -521,7 +516,7 @@ namespace MP.IOC.Data
public async Task DossiersInsert(DossierModel currDoss)
{
// aggiorno record sul DB
- bool answ = await dbController.DossiersInsert(currDoss);
+ bool answ = await SpecDbController.DossiersInsert(currDoss);
return answ;
}
@@ -539,9 +534,9 @@ namespace MP.IOC.Data
await Task.Delay(1);
Log.Info($"Richiesta snapshot per macchina {IdxMacchina} | periodo {dtMin} --> {dtMax}");
// chiamo stored x salvare parametri
- dbController.DossiersTakeParamsSnapshotLast(IdxMacchina, dtMin, dtMax);
+ SpecDbController.DossiersTakeParamsSnapshotLast(IdxMacchina, dtMin, dtMax);
// elimino cache redis...
- RedisValue pattern = new RedisValue($"{redisDossByMac}:*");
+ RedisValue pattern = new RedisValue($"{Utils.redisDossByMac}:*");
answ = await RedisFlushPatternAsync(pattern);
Log.Info($"Svuotata cache dossier | {pattern}");
return answ;
@@ -555,7 +550,7 @@ namespace MP.IOC.Data
public async Task DossiersUpdateValore(DossierModel currDoss)
{
// aggiorno record sul DB
- bool answ = await dbController.DossiersUpdateValore(currDoss);
+ bool answ = await SpecDbController.DossiersUpdateValore(currDoss);
return answ;
}
@@ -566,7 +561,7 @@ namespace MP.IOC.Data
///
public Task> ElencoAziende()
{
- return Task.FromResult(dbController.AnagGruppiAziende());
+ return Task.FromResult(SpecDbController.AnagGruppiAziende());
}
///
@@ -579,7 +574,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisAnagGruppi}";
+ string currKey = $"{Utils.redisAnagGruppi}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -593,7 +588,7 @@ namespace MP.IOC.Data
}
else
{
- result = dbController.AnagGruppiFase();
+ result = SpecDbController.AnagGruppiFase();
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache / 5));
@@ -610,7 +605,7 @@ namespace MP.IOC.Data
public Task> ElencoLink()
{
- return Task.FromResult(dbController.ElencoLink());
+ return Task.FromResult(SpecDbController.ElencoLink());
}
///
@@ -620,7 +615,7 @@ namespace MP.IOC.Data
///
public async Task EvListInsert(EventListModel newRec)
{
- return await dbController.EvListInsert(newRec);
+ return await SpecDbController.EvListInsert(newRec);
}
///
@@ -631,7 +626,7 @@ namespace MP.IOC.Data
public DateTime ExpiryReloadParamGet()
{
DateTime dtRif = DateTime.Now;
- string currKey = $"{redisParamPageExp}";
+ string currKey = $"{Utils.redisParamPageExp}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
@@ -648,7 +643,7 @@ namespace MP.IOC.Data
public bool ExpiryReloadParamSet(DateTime expTime)
{
bool fatto = false;
- string currKey = $"{redisParamPageExp}";
+ string currKey = $"{Utils.redisParamPageExp}";
string rawData = JsonConvert.SerializeObject(expTime);
fatto = redisDb.StringSet(currKey, rawData);
return fatto;
@@ -657,7 +652,7 @@ namespace MP.IOC.Data
public async Task FlushRedisCache()
{
await Task.Delay(1);
- RedisValue pattern = new RedisValue($"{redisBaseAddrIOC}*");
+ RedisValue pattern = Utils.RedValue("*");
bool answ = await RedisFlushPatternAsync(pattern);
// rileggo vocabolario.,..
ObjVocabolario = VocabolarioGetAll();
@@ -667,7 +662,7 @@ namespace MP.IOC.Data
public async Task FlushRedisKey(string redKey)
{
await Task.Delay(1);
- RedisValue pattern = new RedisValue($"{redisBaseAddrIOC}{redKey}");
+ RedisValue pattern = Utils.RedValue(redKey);
bool answ = await RedisFlushPatternAsync(pattern);
return answ;
}
@@ -709,7 +704,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisFluxLogFilt}:{IdxMacchina}:{CodFlux}:{MaxRec}:{DtMax:yyyyMMddHHmm}:{DtMin:yyyyMMddHHmm}";
+ string currKey = $"{Utils.redisFluxLogFilt}:{IdxMacchina}:{CodFlux}:{MaxRec}:{DtMax:yyyyMMddHHmm}:{DtMin:yyyyMMddHHmm}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -719,7 +714,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.FluxLogGetLastFilt(DtMax, DtMin, IdxMacchina, CodFlux, MaxRec));
+ result = await Task.FromResult(SpecDbController.FluxLogGetLastFilt(DtMax, DtMin, IdxMacchina, CodFlux, MaxRec));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
if (string.IsNullOrEmpty(canCacheParametri))
@@ -741,11 +736,8 @@ namespace MP.IOC.Data
return result;
}
- public string hSMI(int idxFamIn)
- {
- return $"{redisBaseAddrIOC}hSMI:{idxFamIn}";
- }
+
///
/// Init ricetta
///
@@ -779,7 +771,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisGiacenzaList}:{IdxOdl}";
+ string currKey = $"{Utils.redisGiacenzaList}:{IdxOdl}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -789,7 +781,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.ListGiacenze(IdxOdl));
+ result = await Task.FromResult(SpecDbController.ListGiacenze(IdxOdl));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache));
@@ -815,27 +807,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
-#if false
- string currKey = $"{redisGiacenzaList}:{IdxOdl}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache));
- }
- if (result == null)
- {
- result = new List();
- }
-#endif
- result = dbController.ListOdlAll();
+ result = SpecDbController.ListOdlAll();
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ListOdlAll | Read from {readType}: {ts.TotalMilliseconds}ms");
@@ -859,7 +831,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisOdlList}:{inCorso}:{codArt}:{keyRichPart}:{Reparto}:{IdxMacchina}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}";
+ string currKey = $"{Utils.redisOdlList}:{inCorso}:{codArt}:{keyRichPart}:{Reparto}:{IdxMacchina}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -869,7 +841,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.ListODLFilt(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
+ result = await Task.FromResult(SpecDbController.ListODLFilt(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache));
@@ -883,7 +855,7 @@ namespace MP.IOC.Data
Log.Debug($"ListODLFilt | Read from {readType}: {ts.TotalMilliseconds}ms");
return result;
- //return await Task.FromResult(dbController.ListODLFilt(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
+ //return await Task.FromResult(SpecDbController.ListODLFilt(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
}
///
@@ -902,7 +874,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisPOdlList}:{codGruppo}:{idxMacchina}:{keyRichPart}:{lanciato}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}";
+ string currKey = $"{Utils.redisPOdlList}:{codGruppo}:{idxMacchina}:{keyRichPart}:{lanciato}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -912,7 +884,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.ListPODLFilt(lanciato, keyRichPart, idxMacchina, codGruppo, startDate, endDate));
+ result = await Task.FromResult(SpecDbController.ListPODLFilt(lanciato, keyRichPart, idxMacchina, codGruppo, startDate, endDate));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache));
@@ -937,7 +909,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisBaseAddrIOC}:M2STab";
+ string currKey = $"{Utils.redisBaseAddr}:M2STab";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -947,7 +919,7 @@ namespace MP.IOC.Data
}
else
{
- result = dbController.Macchine2Slave();
+ result = IocDbController.Macchine2Slave();
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
@@ -974,7 +946,7 @@ namespace MP.IOC.Data
stopWatch.Start();
string readType = "DB";
string keyGrp = codGruppo != "*" ? codGruppo : "ALL";
- string currKey = $"{redisMacList}:{keyGrp}";
+ string currKey = $"{Utils.redisMacList}:{keyGrp}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -984,7 +956,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.MacchineGetFilt(codGruppo));
+ result = await Task.FromResult(SpecDbController.MacchineGetFilt(codGruppo));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
@@ -1010,7 +982,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisMacRecipe}:{idxMacchina}";
+ string currKey = $"{Utils.redisMacRecipe}:{idxMacchina}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -1046,7 +1018,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisMacByFlux}:{dtStart:yyyyMMddHHmm}:{dtEnd:yyyyMMddHHmm}";
+ string currKey = $"{Utils.redisMacByFlux}:{dtStart:yyyyMMddHHmm}:{dtEnd:yyyyMMddHHmm}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -1056,7 +1028,7 @@ namespace MP.IOC.Data
}
else
{
- result = await dbController.MacchineWithFlux(dtStart, dtEnd);
+ result = await SpecDbController.MacchineWithFlux(dtStart, dtEnd);
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
@@ -1100,8 +1072,8 @@ namespace MP.IOC.Data
// ORA recupero da memoria redis...
try
{
- string currHash = dtMaccHash(idxMacchina);
- answ = RedisGetHashDict(currHash);
+ var currHash = Utils.dtMaccHash(idxMacchina);
+ answ = RedisGetHashDict($"{currHash}");
// se è vuoto... leggo da DB e popolo!
if (answ.Count == 0)
{
@@ -1126,7 +1098,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = redisOdlByBatch;
+ string currKey = Utils.redisOdlByBatch;
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -1136,7 +1108,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.OdlByBatch(BatchSel));
+ result = await Task.FromResult(SpecDbController.OdlByBatch(BatchSel));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
@@ -1162,27 +1134,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
-#if false
- string currKey = $"{redisGiacenzaList}:{IdxOdl}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache));
- }
- if (result == null)
- {
- result = new List();
- }
-#endif
- result = dbController.OdlByKey(IdxOdl);
+ result = SpecDbController.OdlByKey(IdxOdl);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"OdlByKey | Read from {readType}: {ts.TotalMilliseconds}ms");
@@ -1217,7 +1169,7 @@ namespace MP.IOC.Data
int.TryParse(currRec.Valore, out modoConfProd);
}
// chiamo metodo conferma!
- fatto = await dbController.ODLClose(idxOdl, idxMacchina, matrOpr, confPezzi, confRett, modoConfProd);
+ fatto = await SpecDbController.ODLClose(idxOdl, idxMacchina, matrOpr, confPezzi, confRett, modoConfProd);
}
return fatto;
@@ -1230,7 +1182,7 @@ namespace MP.IOC.Data
public async Task OdlGetByKey(int IdxOdl)
{
await Task.Delay(1);
- var dbResult = dbController.OdlGetByKey(IdxOdl);
+ var dbResult = SpecDbController.OdlGetByKey(IdxOdl);
return dbResult;
}
@@ -1245,7 +1197,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisOdlCurrByMac}";
+ string currKey = $"{Utils.redisOdlCurrByMac}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -1260,7 +1212,7 @@ namespace MP.IOC.Data
}
else
{
- dbResult = dbController.OdlGetCurrent().Select(x => x.IdxMacchina).Distinct().ToList();
+ dbResult = SpecDbController.OdlGetCurrent().Select(x => x.IdxMacchina).Distinct().ToList();
rawData = JsonConvert.SerializeObject(dbResult);
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(3));
}
@@ -1286,7 +1238,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisFluxByMac}:{IdxMacchina}";
+ string currKey = $"{Utils.redisFluxByMac}:{IdxMacchina}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -1296,7 +1248,7 @@ namespace MP.IOC.Data
}
else
{
- result = await Task.FromResult(dbController.ParametriGetFilt(IdxMacchina));
+ result = await Task.FromResult(SpecDbController.ParametriGetFilt(IdxMacchina));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
@@ -1324,7 +1276,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisPOdlByPOdl}:{idxPODL}";
+ string currKey = $"{Utils.redisPOdlByPOdl}:{idxPODL}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -1338,7 +1290,7 @@ namespace MP.IOC.Data
}
else
{
- result = await dbController.PODL_getByKey(idxPODL);
+ result = await SpecDbController.PODL_getByKey(idxPODL);
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
@@ -1371,7 +1323,7 @@ namespace MP.IOC.Data
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- string currKey = $"{redisPOdlByOdl}:{idxODL}";
+ string currKey = $"{Utils.redisPOdlByOdl}:{idxODL}";
// cerco in redis dato valore sel macchina...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -1385,7 +1337,7 @@ namespace MP.IOC.Data
}
else
{
- result = dbController.PODL_getByOdl(idxODL);
+ result = SpecDbController.PODL_getByOdl(idxODL);
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
@@ -1412,9 +1364,9 @@ namespace MP.IOC.Data
///
public async Task PODLDeleteRecord(PODLExpModel currRec)
{
- var dbResult = await dbController.PODLDeleteRecord(currRec);
+ var dbResult = await SpecDbController.PODLDeleteRecord(currRec);
// elimino cache redis...
- RedisValue pattern = new RedisValue($"{redisXdlData}:*");
+ RedisValue pattern = new RedisValue($"{Utils.redisXdlData}:*");
bool answ = await RedisFlushPatternAsync(pattern);
await Task.Delay(1);
return dbResult;
@@ -1427,9 +1379,9 @@ namespace MP.IOC.Data
///
public async Task POdlDoSetup(PODLExpModel currRec)
{
- var dbResult = await dbController.PODL_startSetup(currRec, 0, 1, 1, "");
+ var dbResult = await SpecDbController.PODL_startSetup(currRec, 0, 1, 1, "");
// elimino cache redis...
- RedisValue pattern = new RedisValue($"{redisXdlData}:*");
+ RedisValue pattern = new RedisValue($"{Utils.redisXdlData}:*");
bool answ = await RedisFlushPatternAsync(pattern);
await Task.Delay(1);
return dbResult;
@@ -1442,9 +1394,9 @@ namespace MP.IOC.Data
///
public async Task POdlUpdateRecord(PODLModel currRec)
{
- var dbResult = await dbController.PODLUpdateRecord(currRec);
+ var dbResult = await SpecDbController.PODLUpdateRecord(currRec);
// elimino cache redis...
- RedisValue pattern = new RedisValue($"{redisXdlData}:*");
+ RedisValue pattern = new RedisValue($"{Utils.redisXdlData}:*");
bool answ = await RedisFlushPatternAsync(pattern);
await Task.Delay(1);
return dbResult;
@@ -1535,7 +1487,7 @@ namespace MP.IOC.Data
///
///
///
- public bool RedisFlushPattern(RedisValue pattern)
+ public bool RedisFlushPattern(string pattern)
{
bool answ = false;
var listEndpoints = redisConnAdmin.GetEndPoints();
@@ -1550,8 +1502,6 @@ namespace MP.IOC.Data
{
redisDb.KeyDelete(item);
}
- // brutalmente rimuovo intero contenuto DB... DANGER
- //await server.FlushDatabaseAsync();
answ = true;
}
}
@@ -1584,7 +1534,7 @@ namespace MP.IOC.Data
return answ;
}
- public KeyValuePair[] RedisGetHash(string redKey)
+ public KeyValuePair[] RedisGetHash(RedisKey redKey)
{
HashEntry[] rawData = redisDb.HashGetAll(redKey);
var result = rawData.Where(x => !x.Name.IsNull).Select(x => new KeyValuePair(x.Name, x.Value)).ToArray();
@@ -1603,31 +1553,13 @@ namespace MP.IOC.Data
HashEntry[] rawData = redisDb.HashGetAll(hashKey);
var result = rawData.Where(x => !x.Name.IsNull).ToDictionary(x => x.Name.ToString(), x => x.Value.ToString());
return result;
-
- //Dictionary dictionary = new Dictionary();
- //try
- //{
- // RedisKey key = hashKey;
- // HashEntry[] array = redisDb.HashGetAll(key);
- // HashEntry[] array2 = array;
- // for (int i = 0; i < array2.Length; i++)
- // {
- // HashEntry hashEntry = array2[i];
- // dictionary.Add(hashEntry.Name, hashEntry.Value);
- // }
- //}
- //catch
- //{ }
-
- //return dictionary;
}
- public string RedisGetHashField(string hashKey, string hashField)
+ public string RedisGetHashField(RedisKey key, string hashField)
{
string result = "";
try
{
- RedisKey key = hashKey;
RedisValue hashField2 = hashField;
result = redisDb.HashGet(key, hashField2).ToString();
}
@@ -1656,17 +1588,7 @@ namespace MP.IOC.Data
public bool RedisHashPresentSz(string key)
{
- bool result = false;
- try
- {
- RedisKey key2 = key;
- result = RedisHashPresent(key2);
- }
- catch
- {
- }
-
- return result;
+ return RedisHashPresent((RedisKey)key);
}
public bool RedisKeyPresent(RedisKey key)
@@ -1684,7 +1606,22 @@ namespace MP.IOC.Data
return result;
}
- public bool RedisSetHash(string redKey, KeyValuePair[] valori, double expireSeconds = -1.0)
+ public bool RedisKeyPresentSz(string key)
+ {
+ bool result = false;
+ try
+ {
+ RedisKey key2 = key;
+ result = RedisKeyPresent(key2);
+ }
+ catch
+ {
+ }
+
+ return result;
+ }
+
+ public bool RedisSetHash(RedisKey redKey, KeyValuePair[] valori, double expireSeconds = -1.0)
{
bool answ = false;
answ = RedisSetHash(redKey, valori);
@@ -1695,7 +1632,7 @@ namespace MP.IOC.Data
return answ;
}
- public bool RedisSetHash(string redKey, KeyValuePair[] valori)
+ public bool RedisSetHash(RedisKey redKey, KeyValuePair[] valori)
{
bool answ = false;
HashEntry[] redHash = valori.Select(x => new HashEntry(x.Key, x.Value)).ToArray();
@@ -1704,7 +1641,7 @@ namespace MP.IOC.Data
return answ;
}
- public bool RedisSetHashDict(string redKey, Dictionary valori, double expireSeconds = -1.0)
+ public bool RedisSetHashDict(RedisKey redKey, Dictionary valori, double expireSeconds = -1.0)
{
bool answ = false;
answ = RedisSetHashDict(redKey, valori);
@@ -1715,7 +1652,7 @@ namespace MP.IOC.Data
return answ;
}
- public bool RedisSetHashDict(string redKey, Dictionary valori)
+ public bool RedisSetHashDict(RedisKey redKey, Dictionary valori)
{
bool answ = false;
HashEntry[] redHash = valori.Select(x => new HashEntry(x.Key, x.Value)).ToArray();
@@ -1724,11 +1661,14 @@ namespace MP.IOC.Data
return answ;
}
- public async Task RedisSetKey(string redKey, string redVal)
+ public bool RedisSetKey(string valKey, string redVal)
{
- await Task.Delay(1);
- RedisValue pattern = new RedisValue($"{redisBaseAddrIOC}{redKey}");
- bool answ = redisDb.StringSet(redKey, redVal);
+ bool answ = redisDb.StringSet(Utils.RedKeyHash(valKey), redVal);
+ return answ;
+ }
+ public bool RedisSetKey(RedisKey valKey, string redVal, int TTL_sec)
+ {
+ bool answ = redisDb.StringSet(Utils.RedKeyHash(valKey), redVal, TimeSpan.FromSeconds(TTL_sec));
return answ;
}
@@ -1739,14 +1679,14 @@ namespace MP.IOC.Data
///
public Dictionary ResetDatiMacchina(string idxMacc)
{
- string currHash = dtMaccHash(idxMacc);
+ var currHash = Utils.dtMaccHash(idxMacc);
// inizio con un bel reset...
- RedisFlushPattern(currHash);
+ RedisFlushPattern($"{currHash}");
Dictionary? result = new Dictionary();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
- var dbResults = dbController.VMSFDGetByMacc(idxMacc);
+ var dbResults = IocDbController.VMSFDGetByMacc(idxMacc);
// converto in formato dizionario...
if (dbResults != null && dbResults.Count > 0)
{
@@ -1810,9 +1750,9 @@ namespace MP.IOC.Data
///
public KeyValuePair[] resetSMI(int idxFamIn)
{
- string currHash = hSMI(idxFamIn);
+ var currHash = Utils.hSMI(idxFamIn);
// leggo da DB...
- var tabSMI = dbController.StateMachineIngressi(idxFamIn);
+ var tabSMI = IocDbController.StateMachineIngressi(idxFamIn);
KeyValuePair[] answ = new KeyValuePair[tabSMI.Count];
// salvo tutti i valori StateMachineIngressi...
@@ -1854,7 +1794,7 @@ namespace MP.IOC.Data
// ORA recupero da memoria redis...
try
{
- string currHash = hSMI(idxFamIn);
+ var currHash = Utils.hSMI(idxFamIn);
answ = RedisGetHash(currHash);
// se è vuoto... leggo da DB e popolo!
if (answ.Length == 0)
@@ -1869,13 +1809,49 @@ namespace MP.IOC.Data
return answ;
}
+ ///
+ /// scrive un evento di keepalive sulla tabella
+ ///
+ ///
+ ///
+ ///
+ public void ScriviKeepAlive(string IdxMacchina, DateTime oraMacchina)
+ {
+ string nomeVar = string.Format("KeepAlive:{0}", IdxMacchina);
+ // cerco se ho keep alive in redis,
+ bool keyPresent = false;
+ DateTime adesso = DateTime.Now;
+ var currKey = Utils.RedKeyHash(nomeVar);
+ try
+ {
+ keyPresent = RedisKeyPresent(currKey);
+ }
+ catch
+ { }
+ // se NON presente salvo in REDIS con TTL 10 sec e sul DB...
+ if (!keyPresent)
+ {
+ RedisSetKey(currKey, adesso.ToString("s"), 10);
+ try
+ {
+ Log.Trace($"Scrittura keep alive! IdxMacchina: {IdxMacchina}");
+ // effettuo scrittura sul DB
+ IocDbController.KeepAliveUpsert(IdxMacchina, DateTime.Now, oraMacchina);
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Errore in scrittura keep alive!{Environment.NewLine}oraMacchina: {oraMacchina} - IdxMacchina: {IdxMacchina}{Environment.NewLine}{exc}");
+ }
+ }
+ }
+
///
/// Statistiche ODL calcolate (da stored stp_STAT_ODL)
///
///
public Task> StatOdl(int IdxOdl)
{
- return dbController.OdlStart(IdxOdl);
+ return SpecDbController.OdlStart(IdxOdl);
}
///
@@ -1980,7 +1956,7 @@ namespace MP.IOC.Data
string rawVal = JsonConvert.SerializeObject(updatedResult);
currDoss.Valore = rawVal;
// aggiorno record sul DB
- await dbController.DossiersUpdateValore(currDoss);
+ await SpecDbController.DossiersUpdateValore(currDoss);
}
return answ;
@@ -1996,7 +1972,7 @@ namespace MP.IOC.Data
///
public string ValoreSMI(int idxFamIn, int idxMicroStato, int valoreIn)
{
- string currHash = hSMI(idxFamIn);
+ var currHash = Utils.hSMI(idxFamIn);
string field = $"{idxMicroStato}_{valoreIn}";
return RedisGetHashField(currHash, field);
}
@@ -2012,17 +1988,17 @@ namespace MP.IOC.Data
List? result = new List();
string source = "REDIS";
// cerco in redis...
- RedisValue rawData = redisDb.StringGet(redisVocabolario);
+ RedisValue rawData = redisDb.StringGet(Utils.redisVocabolario);
if (!string.IsNullOrEmpty($"{rawData}"))
{
result = JsonConvert.DeserializeObject>($"{rawData}");
}
else
{
- result = dbController.VocabolarioGetAll();
+ result = SpecDbController.VocabolarioGetAll();
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(redisVocabolario, rawData, getRandTOut(redisLongTimeCache / 5));
+ redisDb.StringSet(Utils.redisVocabolario, rawData, getRandTOut(redisLongTimeCache / 5));
source = "DB";
}
stopWatch.Stop();
@@ -2066,42 +2042,7 @@ namespace MP.IOC.Data
#region Private Fields
- private const string redisActionReq = redisBaseAddrIOC + "Action:Req";
- private const string redisAnagGruppi = redisBaseAddrIOC + "Cache:AnagGruppi";
- private const string redisArtByDossier = redisBaseAddrIOC + "Cache:ArtByDossier";
-
- private const string redisArtList = redisBaseAddrIOC + "Cache:ArtList";
-
- private const string redisBaseAddr = "MP:";
- private const string redisBaseAddrIOC = redisBaseAddr + "IOC:";
-
- private const string redisConfKey = redisBaseAddrIOC + "Cache:Config";
-
- private const string redisDossByMac = redisBaseAddrIOC + "Cache:DossByMac";
-
- private const string redisFluxByMac = redisBaseAddrIOC + "Cache:FluxByMac";
-
- private const string redisFluxLogFilt = redisBaseAddrIOC + "Cache:FluxLogFilt";
-
- private const string redisGiacenzaList = redisBaseAddrIOC + "Cache:GiacenzaList";
- private const string redisMacByFlux = redisBaseAddrIOC + "Cache:MacByFlux";
-
- private const string redisMacList = redisBaseAddrIOC + "Cache:MacList";
- private const string redisMacRecipe = redisBaseAddrIOC + "Cache:Recipe";
-
- private const string redisOdlByBatch = redisXdlData + "OdlByBatch";
- private const string redisOdlCurrByMac = redisXdlData + "OdlByMac";
- private const string redisOdlList = redisXdlData + "OdlList";
- private const string redisParamPageExp = redisBaseAddrIOC + "Cache:ParamPage";
- private const string redisPOdlByOdl = redisXdlData + "POdlByOdl";
- private const string redisPOdlByPOdl = redisXdlData + "POdlByPOdl";
- private const string redisPOdlList = redisXdlData + "POdlList";
- private const string redisRecipeConf = redisBaseAddrIOC + "Cache:Recipe:Conf";
- private const string redisStatoCom = redisBaseAddrIOC + "Cache:StatoCom";
- private const string redisTipoArt = redisBaseAddrIOC + "Cache:TipoArt";
- private const string redisVocabolario = redisBaseAddrIOC + "Cache:Vocabolario";
- private const string redisXdlData = redisBaseAddrIOC + "Cache:XDL:";
private static IConfiguration _configuration = null!;
private static ILogger _logger = null!;
@@ -2136,9 +2077,9 @@ namespace MP.IOC.Data
private async Task resetCacheArticoli()
{
- RedisValue pattern = new RedisValue($"{redisArtByDossier}:*");
+ RedisValue pattern = new RedisValue($"{Utils.redisArtByDossier}:*");
await RedisFlushPatternAsync(pattern);
- pattern = new RedisValue($"{redisArtList}:*");
+ pattern = new RedisValue($"{Utils.redisArtList}:*");
await RedisFlushPatternAsync(pattern);
}
diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html
index 915f447b..5e55ea29 100644
--- a/MP.IOC/Resources/ChangeLog.html
+++ b/MP.IOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-IOC
- Versione: 6.16.2302.1516
+ Versione: 6.16.2302.1519
Note di rilascio:
-
diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt
index 984cd353..c97e0676 100644
--- a/MP.IOC/Resources/VersNum.txt
+++ b/MP.IOC/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2302.1516
+6.16.2302.1519
diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml
index 9dc7ea48..d1c87922 100644
--- a/MP.IOC/Resources/manifest.xml
+++ b/MP.IOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2302.1516
+ 6.16.2302.1519
https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip
https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html
false