diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index 8550c92..6e8eb1d 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using MongoDB.Driver; +using Newtonsoft.Json; using Newtonsoft.Json.Converters; using NKC_SDK; using SteamWare; @@ -12,6 +13,148 @@ namespace AppData /// public class ComLib { + #region Gestione persistenza risposte via REST da NESTING + + /// + /// Database corrente MongoDB + /// + IMongoDatabase database; + /// + /// Init classe ComLib + /// + public ComLib() + { + database = memLayer.ML.getMongoDatabase("NKC"); + } + /// + /// Classe impiego sstatico ComLib... + /// + public static ComLib man = new ComLib(); + + /// + /// Salva una risposta ricevuta x STIMA + /// + /// Stringa della risposta JSON ricevuta dal nesting + /// + public bool saveEstAnsw(nestReplyBatchInitial nestAnsw) + { + bool answ = false; + try + { + // definisco filtro + var filtBuilder = Builders.Filter; + var filter = filtBuilder.Eq("BatchID", nestAnsw.BatchID); + var collRawData = database.GetCollection("EstimationArchive"); + // elimino old + collRawData.DeleteMany(filter); + // aggiungo + collRawData.InsertOne(nestAnsw); + + answ = true; + } + catch + { } + return answ; + } + /// + /// Salva una risposta ricevuta x NESTING + /// + /// Stringa della risposta JSON ricevuta dal nesting + /// + public bool saveNestAnsw(nestReplyBatchFinal nestAnsw) + { + bool answ = false; + try + { + // definisco filtro + var filtBuilder = Builders.Filter; + var filter = filtBuilder.Eq("BatchID", nestAnsw.BatchID); + var collRawData = database.GetCollection("NestingArchive"); + // elimino old + collRawData.DeleteMany(filter); + // aggiungo + collRawData.InsertOne(nestAnsw); + answ = true; + } + catch + { } + return answ; + } + /// + /// Recupero risposta stima salvata + /// + /// + /// + public nestReplyBatchInitial geEstAnsw(int BatchID) + { + nestReplyBatchInitial answ = null; + try + { + // definisco filtro + var filtBuilder = Builders.Filter; + var filter = filtBuilder.Eq("BatchID", BatchID); + var collRawData = database.GetCollection("EstimationArchive"); + // recupero + answ = collRawData.Find(filter).FirstOrDefault(); + } + catch + { } + return answ; + } + /// + /// Recupero risposta nesting salvata + /// + /// + /// + public nestReplyBatchFinal getNestAnsw(int BatchID) + { + nestReplyBatchFinal answ = null; + try + { + // definisco filtro + var filtBuilder = Builders.Filter; + var filter = filtBuilder.Eq("BatchID", BatchID); + var collRawData = database.GetCollection("NestingArchive"); + // recupero + answ = collRawData.Find(filter).FirstOrDefault(); + } + catch + { } + return answ; + } + + //public object getEstAnsw(int BatchId) + //{ + // List answ = null; + + // var collNAA = database.GetCollection("NestAnswArchive"); + // // oggetto filtraggio x nest answ + // var builderNAA = Builders.Filter; + // var filtBatchId = builderNAA.Eq(u => u.BatchID, BatchId); + + // var datiCorrenti = collNAA.Find(filtBatchId); + // foreach (var item in datiCorrenti) + // { + + // } + // return answ; + //} + + /// + /// restitusice ultima chiamata REST registrata su REDIS + /// + /// + public static string lastRestAnsw() + { + string answ = ""; + // recupero ultima call + string redKey = $"{ComLib.redNestAnsw}:LAST_CALL"; + answ = memLayer.ML.getRSV(redKey); + return answ; + } + + + #endregion /// /// Wrapper traduzione termini diff --git a/NKC_SDK/Objects.cs b/NKC_SDK/Objects.cs index 65891d7..dc14518 100644 --- a/NKC_SDK/Objects.cs +++ b/NKC_SDK/Objects.cs @@ -162,6 +162,31 @@ namespace NKC_SDK /// public double EstimatedWorktime { get; set; } = 0; /// + /// Superficie WORK (lavorata/tagliata) del foglio lavorato (= somma area dei pezzi disposti) + /// + public double SurfaceWork { get; set; } = 0; + /// + /// Superficie totale del foglio lavorato (= materiale) + /// + public double SurfaceTotal { get; set; } = 1; + /// + /// Resa (OEE) dell'impiego del materiale + /// + public double SurfaceOEE + { + get + { + double answ = 0; + try + { + answ = SurfaceWork / SurfaceTotal; + } + catch + { } + return answ; + } + } + /// /// Programma x printing /// public string PrintProgram { get; set; } = ""; diff --git a/NKC_WF/Controllers/BatchProcController.cs b/NKC_WF/Controllers/BatchProcController.cs index d77d04d..c08bf1b 100644 --- a/NKC_WF/Controllers/BatchProcController.cs +++ b/NKC_WF/Controllers/BatchProcController.cs @@ -133,6 +133,10 @@ namespace NKC_WF.Controllers int bStatus = 0; // deserializzo come BatchreqIniziale (stima) nestReplyBatchInitial rispStima = JsonConvert.DeserializeObject(content); + + // 2020.01.16 salvo su mongoDb la risposta... + ComLib.man.saveEstAnsw(rispStima); + // recupero info sul batch /KIT specifico x capire se sia di tipo "validation" bool isValidation = false; var tabOrd = DataLayer.man.taOL.getByBatch(rispStima.BatchID); @@ -222,6 +226,10 @@ namespace NKC_WF.Controllers { // deserializzo come BatchreqFinale nestReplyBatchFinal rispNest = JsonConvert.DeserializeObject(content); + + // 2020.01.16 salvo su mongoDb la risposta... + ComLib.man.saveNestAnsw(rispNest); + // calcolo status del batch... int bStatus = 2; switch (rispNest.ProcessStatus) diff --git a/NKC_WF/Web.config b/NKC_WF/Web.config index 2e173a8..47a909f 100644 --- a/NKC_WF/Web.config +++ b/NKC_WF/Web.config @@ -69,6 +69,8 @@ + + diff --git a/NKC_WF/WebUserControls/cmp_devUtils.ascx b/NKC_WF/WebUserControls/cmp_devUtils.ascx index 8ce0259..a68b48c 100644 --- a/NKC_WF/WebUserControls/cmp_devUtils.ascx +++ b/NKC_WF/WebUserControls/cmp_devUtils.ascx @@ -1,9 +1,14 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_devUtils.ascx.cs" Inherits="NKC_WF.WebUserControls.cmp_devUtils" %>
-
+
Reset
Stack building
- Reset
Nesting Calls
-
-
\ No newline at end of file +
+ Reset
Nesting Calls
+
+
+ SAVE
LAST Call
+
+
+ diff --git a/NKC_WF/WebUserControls/cmp_devUtils.ascx.cs b/NKC_WF/WebUserControls/cmp_devUtils.ascx.cs index 11c63b7..a5f0309 100644 --- a/NKC_WF/WebUserControls/cmp_devUtils.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_devUtils.ascx.cs @@ -1,4 +1,6 @@ using AppData; +using Newtonsoft.Json; +using NKC_SDK; using System; namespace NKC_WF.WebUserControls @@ -19,5 +21,35 @@ namespace NKC_WF.WebUserControls { DataLayer.man.taBL.resetNesting(-9999); } + + protected void lbtSaveLastAnsw_Click(object sender, EventArgs e) + { + string content = ComLib.lastRestAnsw(); + + // deserializzo. + baseNestAnsw batchProcAnsw = JsonConvert.DeserializeObject(content); + + // se non nullo... + if (batchProcAnsw != null) + { + if (batchProcAnsw.OrderType == oType.BatchRequest) + { + if (batchProcAnsw.ProcType == 1) + { + // deserializzo come BatchreqIniziale (stima) + nestReplyBatchInitial rispStima = JsonConvert.DeserializeObject(content); + // 2020.01.16 salvo su mongoDb la risposta... + ComLib.man.saveEstAnsw(rispStima); + } + else + { + // deserializzo come BatchreqFinale + nestReplyBatchFinal rispNest = JsonConvert.DeserializeObject(content); + // 2020.01.16 salvo su mongoDb la risposta... + ComLib.man.saveNestAnsw(rispNest); + } + } + } + } } } \ No newline at end of file diff --git a/NKC_WF/WebUserControls/cmp_devUtils.ascx.designer.cs b/NKC_WF/WebUserControls/cmp_devUtils.ascx.designer.cs index e1f2490..9e4cc58 100644 --- a/NKC_WF/WebUserControls/cmp_devUtils.ascx.designer.cs +++ b/NKC_WF/WebUserControls/cmp_devUtils.ascx.designer.cs @@ -31,5 +31,14 @@ namespace NKC_WF.WebUserControls /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.WebControls.LinkButton lbtResetNest; + + /// + /// Controllo lbtSaveLastAnsw. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.WebControls.LinkButton lbtSaveLastAnsw; } }