From ef2fd78269abe6992b020161396008a41e329ced Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 5 Apr 2023 09:32:09 +0200 Subject: [PATCH] Fix log x IOC --- MP.IOC/Controllers/RecipeArchiveController.cs | 61 +++++++++++++++++-- MP.IOC/NLog.config | 46 ++++++++++++++ MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- 5 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 MP.IOC/NLog.config diff --git a/MP.IOC/Controllers/RecipeArchiveController.cs b/MP.IOC/Controllers/RecipeArchiveController.cs index 405040f9..9e4059b1 100644 --- a/MP.IOC/Controllers/RecipeArchiveController.cs +++ b/MP.IOC/Controllers/RecipeArchiveController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using MP.IOC.Data; using NLog; +using NLog.Fluent; namespace MP.IOC.Controllers { @@ -26,7 +27,7 @@ namespace MP.IOC.Controllers [HttpGet("GetByPODL")] public async Task GetByPODL(string idxMacc, int idxPODL) { - string answ = ""; + string answ = "NO DATA"; string archPath = await DService.MacchineRecipeArchive(idxMacc); var podlData = await DService.POdlGetByKey(idxPODL); if (podlData != null) @@ -35,8 +36,34 @@ namespace MP.IOC.Controllers string fullPath = Path.Combine(archPath, fileName); if (!string.IsNullOrEmpty(fullPath)) { - answ = System.IO.File.ReadAllText(fullPath); + try + { + if (System.IO.File.Exists(fullPath)) + { + answ = System.IO.File.ReadAllText(fullPath); + if (string.IsNullOrEmpty(answ)) + { + Log.Error($"Errore in GetByPODL: contenuto file vuoto | idxMacc: {idxMacc} | idxPODL: {idxPODL}"); + } + } + else + { + Log.Error($"Errore in GetByPODL: il file non esiste | fullPath {fullPath}"); + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in GetByPODL:{Environment.NewLine}{exc}"); + } } + else + { + Log.Error($"Errore in GetByPODL: fullPath null "); + } + } + else + { + Log.Error($"Errore in GetByPODL: podlData null | idxPODL: {idxPODL}"); } return answ; } @@ -44,15 +71,41 @@ namespace MP.IOC.Controllers [HttpGet("GetFile")] public async Task GetFile(string idxMacc, string fileName) { - string answ = ""; + string answ = "NO DATA"; string archPath = await DService.MacchineRecipeArchive(idxMacc); if (!string.IsNullOrEmpty(archPath)) { string fullPath = Path.Combine(archPath, fileName); if (!string.IsNullOrEmpty(fullPath)) { - answ = System.IO.File.ReadAllText(fullPath); + try + { + if (System.IO.File.Exists(fullPath)) + { + answ = System.IO.File.ReadAllText(fullPath); + if (string.IsNullOrEmpty(answ)) + { + Log.Error($"Errore in GetFile: contenuto file vuoto | idxMacc: {idxMacc} | fileName: {fileName}"); + } + } + else + { + Log.Error($"Errore in GetFile: il file non esiste | fullPath {fullPath}"); + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in GetFile:{Environment.NewLine}{exc}"); + } } + else + { + Log.Error($"Errore in GetFile: fullPath null "); + } + } + else + { + Log.Error($"Errore in GetFile: archPath null "); } return answ; } diff --git a/MP.IOC/NLog.config b/MP.IOC/NLog.config new file mode 100644 index 00000000..3e4185f4 --- /dev/null +++ b/MP.IOC/NLog.config @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 05e7e91a..bf127384 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 6.16.2304.419

+

Versione: 6.16.2304.509


Note di rilascio:
  • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 176b40f4..ee4e3914 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2304.419 +6.16.2304.509 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 871a034a..7a310848 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2304.419 + 6.16.2304.509 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false