From 0cfbbe069abb6f1528c7dd2e7adebb97978404f8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 8 Jun 2020 21:22:14 +0200 Subject: [PATCH] Fix Filesystem IO 4 recipe --- .../Thermo.Active.Config.csproj | 2 +- .../Controllers/WebApi/RecipeController.cs | 29 +++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/Thermo.Active.Config/Thermo.Active.Config.csproj b/Thermo.Active.Config/Thermo.Active.Config.csproj index aab7c136..bfee6bae 100644 --- a/Thermo.Active.Config/Thermo.Active.Config.csproj +++ b/Thermo.Active.Config/Thermo.Active.Config.csproj @@ -185,7 +185,7 @@ - PreserveNewest + Always diff --git a/Thermo.Active/Controllers/WebApi/RecipeController.cs b/Thermo.Active/Controllers/WebApi/RecipeController.cs index 9da46752..29f895ce 100644 --- a/Thermo.Active/Controllers/WebApi/RecipeController.cs +++ b/Thermo.Active/Controllers/WebApi/RecipeController.cs @@ -211,11 +211,6 @@ namespace Thermo.Active.Controllers.WebApi { using (NcFileAdapter ncAdapter = new NcFileAdapter()) { - // Try connection - CmsError libraryError = ncAdapter.Connect(); - if (libraryError.errorCode != 0) - return NotFound(); - // chiamo metodo di lettura... bool fatto = ServerConfigController.LoadTemplate(); @@ -226,9 +221,9 @@ namespace Thermo.Active.Controllers.WebApi if (cmsError.IsError()) return BadRequest(cmsError.localizationKey); - // ritorno solo fatto! - return Ok(); } + // ritorno solo fatto! + return Ok(); } /// @@ -240,10 +235,6 @@ namespace Thermo.Active.Controllers.WebApi { using (NcFileAdapter ncAdapter = new NcFileAdapter()) { - // Try connection - CmsError libraryError = ncAdapter.Connect(); - if (libraryError.errorCode != 0) - return NotFound(); // recupero i dati LIVE dei parametri HMI della ricetta... CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); @@ -272,11 +263,6 @@ namespace Thermo.Active.Controllers.WebApi { using (NcFileAdapter ncAdapter = new NcFileAdapter()) { - // Try connection - CmsError libraryError = ncAdapter.Connect(); - if (libraryError.errorCode != 0) - return NotFound(); - // recupero i dati LIVE dei parametri HMI della ricetta... CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); if (cmsError.IsError()) @@ -306,11 +292,6 @@ namespace Thermo.Active.Controllers.WebApi { using (NcFileAdapter ncAdapter = new NcFileAdapter()) { - // Try connection - CmsError libraryError = ncAdapter.Connect(); - if (libraryError.errorCode != 0) - return NotFound(); - // recupero i dati LIVE dei parametri HMI della ricetta... CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); if (cmsError.IsError()) @@ -368,6 +349,12 @@ namespace Thermo.Active.Controllers.WebApi using (NcAdapter ncAdapter = new NcAdapter()) { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.errorCode != 0) + return libraryError; + + // copy data to PLC checkError = ncAdapter.ReadFullRecipe(out Dictionary prevRecipe); if (checkError.IsError())