From bf856bcf05fa8e82f3c336238f10efd25367342b Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 26 Nov 2020 18:07:58 +0100 Subject: [PATCH] fix gestione errori --- AppData/ComLib.cs | 12 +++++--- NKC_WF/Controllers/BatchProcController.cs | 2 +- NKC_WF/site/DxfValidation.aspx.cs | 37 ++++++++++++++++++----- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index 73f906c..1462aae 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -1860,10 +1860,14 @@ namespace AppData var tabBatchRunning = DLMan.taBL.getByStatus(1, "", 0); if (tabBatchRunning.Count == 0) { - // ora verifico, se ci sono batch in stato 8 (da validare) --> metto in coda! - var tabBatch = DLMan.taBL.getByStatus(8, "", 1); - bool hasValReq = tabBatch.Count > 0; - if (hasValReq) + // ora verifico, se ci sono batch per FILE (dxf) VALIDATION in stato 8 (da validare) --> metto in coda! + DS_App.BatchListDataTable tabBatch = DLMan.taBL.getByStatus(8, "", 2); + // se non ne ho cerco nei PartValidation + if (tabBatch.Count == 0) + { + tabBatch = DLMan.taBL.getByStatus(8, "", 1); + } + if (tabBatch.Count > 0) { // invia a redis una richiesta... sendMaterials(); diff --git a/NKC_WF/Controllers/BatchProcController.cs b/NKC_WF/Controllers/BatchProcController.cs index c4cab44..d04f8cc 100644 --- a/NKC_WF/Controllers/BatchProcController.cs +++ b/NKC_WF/Controllers/BatchProcController.cs @@ -249,7 +249,7 @@ namespace NKC_WF.Controllers // recupero ordine da batch if (tabOrd.Count > 0) { - DLMan.taFV.upsertQuery(tabOrd[0].OrdCodOrig, rispStima.BatchID, bStatus, rispStima.EstimatedWorktime); + DLMan.taFV.upsertQuery(tabOrd[0].OrderExtCode, rispStima.BatchID, bStatus, rispStima.EstimatedWorktime); } } } diff --git a/NKC_WF/site/DxfValidation.aspx.cs b/NKC_WF/site/DxfValidation.aspx.cs index 959cf7e..5f8e3a4 100644 --- a/NKC_WF/site/DxfValidation.aspx.cs +++ b/NKC_WF/site/DxfValidation.aspx.cs @@ -16,12 +16,12 @@ namespace NKC_WF.site /// /// Path base x nesting, area TEMP /// - protected string cadBasePath = $"{memLayer.ML.CRS("nestBasePath")}{memLayer.ML.CRS("fileTestFolder")}\\"; + protected string cadBasePath = $"{memLayer.ML.CRS("nestBasePath")}{memLayer.ML.CRS("fileTestFolder")}/"; /// /// Path base x server, area TEMP /// - protected string srvCadBasePath = $"{memLayer.ML.CRS("servBasePath")}{memLayer.ML.CRS("fileTestFolder")}\\"; + protected string srvCadBasePath = $"{memLayer.ML.CRS("servBasePath")}{memLayer.ML.CRS("fileTestFolder")}/"; #endregion Protected Fields @@ -40,6 +40,8 @@ namespace NKC_WF.site bool dataValidated = true; DateTime adesso = DateTime.Now; string dirFrom = e.LocalPath; + int batchID = 0; + string TaktCode = $"T{e.FileName.ToLower().Replace(".dxf", "")}"; // copio su area testing try { @@ -64,12 +66,33 @@ namespace NKC_WF.site DLMan.taEL.insertQuery(DateTime.Now, "Import KIT TEST", $"{e.BatchName}", $"{e.BatchName}.{e.FileName}", $"Exception: {exc}"); dataValidated = false; } - // FIX eventuali cadFilePath... - DLMan.taIL.updateCadPath(cadBasePath, 0, false); - if (dataValidated) + try { - // avvio validazione! - bool newValidSent = ComLib.sendFirstValidationBatch(); + var tabBatch = DLMan.taBL.getLastByTakt(TaktCode); + if (tabBatch != null) + { + if (tabBatch.Count > 0) + { + batchID = tabBatch[0].BatchID; + } + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"{traduci("ErrOrderCsvImp03")}:{Environment.NewLine}{exc}"); + dataValidated = false; + } + if (batchID > 0) + { + // FIX eventuali cadFilePath... + DLMan.taIL.updateCadPath(cadBasePath, 0, false); + // chiamo procedura x inserire come NON validato in FileValidation + DLMan.taFV.upsertQuery(TaktCode, batchID, 8, 0); + if (dataValidated) + { + // avvio validazione! + bool newValidSent = ComLib.sendFirstValidationBatch(); + } } Response.Redirect(Request.RawUrl); }