From cd90e6871fd12b90b96eb78b564d536bc1d735f4 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 4 Apr 2023 16:17:39 +0200 Subject: [PATCH] SPEC: - Completato modifiche x selezione ricetta - Controller x download ricetta --- MP.SPEC/Components/ListPODL.razor | 26 ++++--- MP.SPEC/Components/RecipeArchMan.razor | 20 ++---- MP.SPEC/Components/RecipeArchMan.razor.cs | 40 +++-------- .../Controllers/RecipeArchiveController.cs | 69 +++++++++++++++++++ MP.SPEC/Controllers/RecipeController.cs | 6 +- MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 9 files changed, 110 insertions(+), 59 deletions(-) create mode 100644 MP.SPEC/Controllers/RecipeArchiveController.cs diff --git a/MP.SPEC/Components/ListPODL.razor b/MP.SPEC/Components/ListPODL.razor index 5dde7f9a..71900f7d 100644 --- a/MP.SPEC/Components/ListPODL.razor +++ b/MP.SPEC/Components/ListPODL.razor @@ -19,7 +19,7 @@ else @if (currRecord != null) { - + } Cod @@ -131,13 +131,21 @@ else
T. Ciclo: @record.Tcassegnato.ToString("N3")
- @if (@record.Attivabile) +
+ @if (@record.Attivabile) + { + + } + else + { + + } +
+ @if (!string.IsNullOrEmpty(record.Recipe)) { - - } - else - { - +
+ @record.Recipe +
} @@ -160,10 +168,10 @@ else } - else if(showRecipeArch) + else if (showRecipeArch) {
- +
} } diff --git a/MP.SPEC/Components/RecipeArchMan.razor b/MP.SPEC/Components/RecipeArchMan.razor index be9f90a2..97fbfeab 100644 --- a/MP.SPEC/Components/RecipeArchMan.razor +++ b/MP.SPEC/Components/RecipeArchMan.razor @@ -10,7 +10,7 @@ else
-

Ricetta Assegnata

+

Assegnazione Ricetta

@if (string.IsNullOrEmpty(RecipeCode)) @@ -25,23 +25,23 @@ else
- + @(string.IsNullOrEmpty(RecipeCode) ? "-- SELEZIONARE --" : RecipeCode)
- +
@if (showSearch) { -
    +
    • - search + Ricette disponibili
      - +
    • @@ -72,14 +72,6 @@ else
    } - else if (showDetail) - { -
    -
    - @((MarkupString)rawRecipe) -
    -
    - }
} diff --git a/MP.SPEC/Components/RecipeArchMan.razor.cs b/MP.SPEC/Components/RecipeArchMan.razor.cs index 327c27cb..b86a4a49 100644 --- a/MP.SPEC/Components/RecipeArchMan.razor.cs +++ b/MP.SPEC/Components/RecipeArchMan.razor.cs @@ -1,5 +1,7 @@ using Microsoft.AspNetCore.Components; using MP.SPEC.Data; +using System.Text; +using System.Xml; namespace MP.SPEC.Components { @@ -15,6 +17,8 @@ namespace MP.SPEC.Components [Parameter] public string RecipeCode { get; set; } = ""; + [Parameter] + public string IdxMacc { get; set; } = ""; [Parameter] public EventCallback ReqCloseEvent { get; set; } @@ -24,12 +28,10 @@ namespace MP.SPEC.Components #region Protected Fields protected int _numShow = 10; - protected string _rawRecipe = ""; protected string _searchVal = ""; protected bool isLoading = false; protected int numFound = 0; protected int pHeight = 25; - protected bool showDetail = false; protected bool showSearch = false; #endregion Protected Fields @@ -53,14 +55,7 @@ namespace MP.SPEC.Components } } - protected string rawRecipe - { - get - { - return _rawRecipe.Replace(Environment.NewLine, sepDest).Replace("\n", sepDest).Replace("\r", sepDest); - } - set => _rawRecipe = value; - } + protected string searchVal { @@ -87,23 +82,13 @@ namespace MP.SPEC.Components protected override async Task OnParametersSetAsync() { - await ReloadData(); + if (!string.IsNullOrEmpty(RecipeArchPath) && !string.IsNullOrEmpty(RecipeCode) && !string.IsNullOrEmpty(IdxMacc)) + { + await ReloadData(); + } } - protected async Task showPreview() - { - showDetail = !showDetail; - if (showDetail) - { - if (!string.IsNullOrEmpty(RecipeCode)) - { - // leggo ricetta e carico... - string fullPath = Path.Combine(RecipeArchPath, RecipeCode); - rawRecipe = File.ReadAllText(fullPath); - } - } - await Task.Delay(1); - } + /// /// Salvataggio ricetta in PODL corrente @@ -117,10 +102,6 @@ namespace MP.SPEC.Components { RecipeCode = recipeName; showSearch = false; - showDetail = true; - // leggo ricetta e carico... - string fullPath = Path.Combine(RecipeArchPath, recipeName); - rawRecipe = File.ReadAllText(fullPath); } } @@ -130,7 +111,6 @@ namespace MP.SPEC.Components private List list2show = new List(); private List recipeList = new List(); - private string sepDest = "
"; #endregion Private Fields diff --git a/MP.SPEC/Controllers/RecipeArchiveController.cs b/MP.SPEC/Controllers/RecipeArchiveController.cs new file mode 100644 index 00000000..bacf8a06 --- /dev/null +++ b/MP.SPEC/Controllers/RecipeArchiveController.cs @@ -0,0 +1,69 @@ +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 + { + /// + /// Dataservice x accesso DB + /// + 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 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 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; + } + + } +} diff --git a/MP.SPEC/Controllers/RecipeController.cs b/MP.SPEC/Controllers/RecipeController.cs index 9e8554da..9d05d85d 100644 --- a/MP.SPEC/Controllers/RecipeController.cs +++ b/MP.SPEC/Controllers/RecipeController.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using MP.Data.MgModels; @@ -11,6 +12,7 @@ namespace MP.SPEC.Controllers { [Route("api/[controller]")] [ApiController] + [AllowAnonymous] public class RecipeController : ControllerBase { /// @@ -20,7 +22,7 @@ namespace MP.SPEC.Controllers public RecipeController(IConfiguration configuration, MpDataService DataService) { - Log.Info("Starting MpDataService INIT"); + Log.Info("Starting RecipeController"); _configuration = configuration; DService = DataService; Log.Info("Avviata classe Recipe"); diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index c43b4b15..14bcd293 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2304.411 + 6.16.2304.416 diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 01dfa59c..a46a43e9 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2304.411

+

Versione: 6.16.2304.416


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 93c4a2d8..bef5cf35 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2304.411 +6.16.2304.416 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 46ed7a02..3ccb7490 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2304.411 + 6.16.2304.416 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false