diff --git a/MP-IO/Controllers/IOBController.cs b/MP-IO/Controllers/IOBController.cs index 1127d645..acded05e 100644 --- a/MP-IO/Controllers/IOBController.cs +++ b/MP-IO/Controllers/IOBController.cs @@ -2,6 +2,7 @@ using MapoDb; using MapoSDK; using Newtonsoft.Json; +using StackExchange.Redis; using SteamWare; using System; using System.Collections.Generic; @@ -134,7 +135,7 @@ namespace MP_IO.Controllers catch { } return answ; - } + } #endif /// @@ -426,7 +427,8 @@ namespace MP_IO.Controllers /// /// Sistema ODL giornalieri x impianto indicato, andando a generare 1 ODL giornaliero x ogni - /// giornata dall'ultimo ODL aperto alla data corrente + conferma pezzi (es TFT x ODL giornalieri energia) + /// giornata dall'ultimo ODL aperto alla data corrente + conferma pezzi (es TFT x ODL + /// giornalieri energia) /// es: http://url_site/MP/IO/IOB/fixDailyOdlConfPzCount/SIMUL_03 /// /// @@ -607,6 +609,21 @@ namespace MP_IO.Controllers return answ; } + /// Creazione nuovo ODL dato CodArt + numPz + /// GET: IOB/forceCreatePOdl/SIMUL_03?CodArt=ABCD_1234&numPz=5 IdxODL creato + public int forceCreatePOdl(string id, string CodArt, string CodGruppo, int numPz) + { + int answ = 0; + // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il + // carattere "|" che poi trasformiamo ora in "#" + id = id.Replace("|", "#"); + DataLayer DataLayerObj = new DataLayer(); + answ = DataLayerObj.ForceCreatePOdl(id, CodArt, numPz, CodGruppo); + return answ; + } + /// /// Chiude ODL precedente ed avvia uno nuovo (duplicandolo e sitemando quantità RIMANENTE), /// e CONFERMA produzione... @@ -630,9 +647,12 @@ namespace MP_IO.Controllers /// /// 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 + /// + /// 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 = "") { @@ -670,26 +690,6 @@ namespace MP_IO.Controllers return answ; } - /// - /// Creazione nuovo ODL dato CodArt + numPz - /// GET: IOB/forceCreatePOdl/SIMUL_03?CodArt=ABCD_1234&numPz=5 - /// - /// - /// - /// - /// - /// IdxODL creato - public int forceCreatePOdl(string id, string CodArt, string CodGruppo, int numPz) - { - int answ = 0; - // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il - // carattere "|" che poi trasformiamo ora in "#" - id = id.Replace("|", "#"); - DataLayer DataLayerObj = new DataLayer(); - answ = DataLayerObj.ForceCreatePOdl(id, CodArt, numPz, CodGruppo); - return answ; - } - /// /// Recupera elenco articoli dei PODL correnti: /// @@ -837,32 +837,6 @@ namespace MP_IO.Controllers 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 getCurrOdlRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - return answ; - } /// /// Restituisce la quantità pezzi dell'odl correntemente in lavorazione sulla macchina... /// GET: IOB/getCurrOdlQtaReq/SIMUL_01 @@ -893,6 +867,33 @@ namespace MP_IO.Controllers 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 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 @@ -1147,7 +1148,7 @@ namespace MP_IO.Controllers /// /// GET: IOB/getLastDossArt/cod_articolo /// - /// codice articolo, se vuoto --> non fa nulla + /// codice articolo, se vuoto --> non fa nulla /// Json contenente lista oggetti DOSSIER serializzati public string getLastDossByMacc(string id) { @@ -1862,6 +1863,55 @@ namespace MP_IO.Controllers return answ; } + /// + /// Processa una chiamata POST per l'invio di una Dictionary HashList da salvare in redis + /// POST: IOB/saveMachineIobConf/SIMUL_03 + /// + /// ID dell'IOB + /// + [HttpPost] + public string saveMachineIobConf(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 dictionary... + Dictionary currDict = new Dictionary(); + try + { + // deserializzo. + currDict = JsonConvert.DeserializeObject>(content); + string keyHashDict = DataLayer.hMachineIobConf(id); + // se != null --> salvo! + if (currDict != null) + { + bool fatto = memLayer.ML.redSaveHashDict(keyHashDict, currDict); + answ = fatto ? "OK" : "KO"; + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Errore in saveMachineIobConf{Environment.NewLine}{exc}"); + answ = "EXC"; + } + } + return answ; + } + /// /// SALVA in blocco un incremento pezzi x macchina restituendo il valore appena inviato o, /// se mancasse chaive redis, del valore da DB @@ -2164,7 +2214,7 @@ namespace MP_IO.Controllers /// /// Processa una chiamata POST per l'invio di una Dictionary HashList da salvare in redis - /// POST: IOB/setObjItems/SIMUL_03 + /// POST: IOB/setRedisHashDict/SIMUL_03 /// /// ID dell'IOB /// diff --git a/MapoDb/DataLayer.cs b/MapoDb/DataLayer.cs index d28e7c29..8f4badfd 100644 --- a/MapoDb/DataLayer.cs +++ b/MapoDb/DataLayer.cs @@ -379,15 +379,31 @@ namespace MapoDb return mHash($"PODLRow:{idxPODL}"); } - /// Hash dati relativi all'associazione macchina <--> IOB Macchina PRINCIPALE + /// + /// Hash dati relativi all'associazione macchina <--> IOB + /// + /// Macchina + /// public static string hIobDict(string IdxMacchina) { return mHash($"IOB:{IdxMacchina}:CurrInfo"); } - /// Hash dati relativi all'associazione macchina <--> IOB Macchina PRINCIPALE + /// + /// Hash dati relativi a macchina + IOB + conf speciali + /// + /// Macchina + /// + public static string hMachineIobConf(string IdxMacchina) + { + return mHash($"IOB:{IdxMacchina}:MachIobConf"); + } + + /// + /// Hash dati relativi all'associazione macchina <--> IOB + /// + /// Macchina PRINCIPALE + /// public static string hM2IOB(string IdxMacchina) { return mHash(string.Format("hM2IOB:{0}", IdxMacchina)); diff --git a/MapoDb/MtcDataModelArchive.cs b/MapoDb/MtcDataModelArchive.cs index 4d539ef9..c2a5f78c 100644 --- a/MapoDb/MtcDataModelArchive.cs +++ b/MapoDb/MtcDataModelArchive.cs @@ -6,14 +6,14 @@ using System.Collections.Generic; namespace MapoDb { /// - /// Classe gestione archivio modelli MTC dei vari IOB + /// Classe gestione archivio modelli MTC in MongoDB /// public class MtcDataModelArchive { #region Public Fields /// - /// Singleton gestione istanza AlarmsManager + /// Singleton gestione istanza condivisa /// public static MtcDataModelArchive man = new MtcDataModelArchive(); @@ -27,7 +27,7 @@ namespace MapoDb #region Public Constructors /// - /// Classe gestione archivio allarmi + /// init classe x connessione MongoDB /// public MtcDataModelArchive() {