cd90e6871f
- Completato modifiche x selezione ricetta - Controller x download ricetta
70 lines
2.2 KiB
C#
70 lines
2.2 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MP.Data.MgModels;
|
|
using MP.SPEC.Data;
|
|
using Newtonsoft.Json;
|
|
using NLog;
|
|
using System.Xml;
|
|
|
|
namespace MP.SPEC.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[AllowAnonymous]
|
|
public class RecipeArchiveController : ControllerBase
|
|
{
|
|
/// <summary>
|
|
/// Dataservice x accesso DB
|
|
/// </summary>
|
|
protected MpDataService DService { get; set; }
|
|
|
|
public RecipeArchiveController(IConfiguration configuration, MpDataService DataService)
|
|
{
|
|
Log.Info("Starting RecipeArchiveController");
|
|
_configuration = configuration;
|
|
DService = DataService;
|
|
Log.Info("Avviata classe RecipeArchiveController");
|
|
|
|
}
|
|
private static IConfiguration _configuration = null!;
|
|
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
[HttpGet("GetFile")]
|
|
public async Task<string> GetFile(string idxMacc, string fileName)
|
|
{
|
|
string answ = "";
|
|
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);
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
[HttpGet("GetByPODL")]
|
|
public async Task<string> GetByPODL(string idxMacc, int idxPODL)
|
|
{
|
|
string answ = "";
|
|
string archPath = await DService.MacchineRecipeArchive(idxMacc);
|
|
var podlData = await DService.POdlGetByKey(idxPODL);
|
|
if (podlData != null)
|
|
{
|
|
string fileName = podlData?.Recipe ?? "";
|
|
string fullPath = Path.Combine(archPath, fileName);
|
|
if (!string.IsNullOrEmpty(fullPath))
|
|
{
|
|
answ = System.IO.File.ReadAllText(fullPath);
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
}
|
|
}
|