Fix log x IOC
This commit is contained in:
@@ -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<string> 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<string> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user