From a93ece75be5b4756d5207e5e2ae4367c1a2a601e Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 16 Jan 2020 20:51:27 +0100 Subject: [PATCH 1/3] Aggiunta salvataggio in mongoDB delle risposte nesting (TESTARE!!!) --- AppData/ComLib.cs | 72 ++++++++++++++++++++++- NKC_WF/Controllers/BatchProcController.cs | 8 +++ NKC_WF/Web.config | 2 + 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index 8550c92..11a7cb0 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,75 @@ namespace AppData /// public class ComLib { + /// + /// 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 + { + var collRawData = database.GetCollection("EstimationArchive"); + 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 + { + var collRawData = database.GetCollection("NestingArchive"); + collRawData.InsertOne(nestAnsw); + answ = true; + } + 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; + //} /// /// Wrapper traduzione termini 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 @@ + + From f8a870e324d501513eb0bccb3727d5798a7c5f3a Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 17 Jan 2020 09:57:34 +0100 Subject: [PATCH 2/3] Aggiunta nuova gestioen salvataggio (con delete vecchio) e recupero dati nesting archiviati --- AppData/ComLib.cs | 73 ++++++++++++++++++++++++++++++++++++++++++++++ NKC_SDK/Objects.cs | 25 ++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index 11a7cb0..6e8eb1d 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -13,6 +13,8 @@ namespace AppData /// public class ComLib { + #region Gestione persistenza risposte via REST da NESTING + /// /// Database corrente MongoDB /// @@ -39,8 +41,15 @@ namespace AppData 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 @@ -57,7 +66,13 @@ namespace AppData 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; } @@ -65,6 +80,48 @@ namespace AppData { } 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) //{ @@ -83,6 +140,22 @@ namespace AppData // 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; } = ""; From c6efdd9e42c00b19290b73a77690a61e4e3c842c Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 17 Jan 2020 09:57:50 +0100 Subject: [PATCH 3/3] Aggiunta button x salvare last answ --- NKC_WF/WebUserControls/cmp_devUtils.ascx | 13 +++++--- NKC_WF/WebUserControls/cmp_devUtils.ascx.cs | 32 +++++++++++++++++++ .../cmp_devUtils.ascx.designer.cs | 9 ++++++ 3 files changed, 50 insertions(+), 4 deletions(-) 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; } }