cd90e6871f
- Completato modifiche x selezione ricetta - Controller x download ricetta
150 lines
3.9 KiB
C#
150 lines
3.9 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.SPEC.Data;
|
|
using System.Text;
|
|
using System.Xml;
|
|
|
|
namespace MP.SPEC.Components
|
|
{
|
|
public partial class RecipeArchMan
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public int IdxPODL { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public string RecipeArchPath { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public string RecipeCode { get; set; } = "";
|
|
[Parameter]
|
|
public string IdxMacc { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> ReqCloseEvent { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected int _numShow = 10;
|
|
protected string _searchVal = "";
|
|
protected bool isLoading = false;
|
|
protected int numFound = 0;
|
|
protected int pHeight = 25;
|
|
protected bool showSearch = false;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; } = null!;
|
|
|
|
protected int numShow
|
|
{
|
|
get => _numShow;
|
|
set
|
|
{
|
|
if (_numShow != value)
|
|
{
|
|
_numShow = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected string searchVal
|
|
{
|
|
get => _searchVal;
|
|
set
|
|
{
|
|
if (_searchVal != value)
|
|
{
|
|
_searchVal = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task doClose()
|
|
{
|
|
await ReqCloseEvent.InvokeAsync(true);
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (!string.IsNullOrEmpty(RecipeArchPath) && !string.IsNullOrEmpty(RecipeCode) && !string.IsNullOrEmpty(IdxMacc))
|
|
{
|
|
await ReloadData();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Salvataggio ricetta in PODL corrente
|
|
/// </summary>
|
|
/// <param name="recipeName"></param>
|
|
/// <returns></returns>
|
|
protected async Task saveRecipe(string recipeName)
|
|
{
|
|
bool fatto = await MDService.POdlUpdateRecipe(IdxPODL, recipeName);
|
|
if (fatto)
|
|
{
|
|
RecipeCode = recipeName;
|
|
showSearch = false;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<string> list2show = new List<string>();
|
|
private List<string> recipeList = new List<string>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
await Task.Delay(1);
|
|
isLoading = true;
|
|
if (IdxPODL != 0 && !string.IsNullOrEmpty(RecipeArchPath))
|
|
{
|
|
recipeList = Directory
|
|
.GetFiles(RecipeArchPath)
|
|
.Select(x => Path.GetFileName(x))
|
|
.Where(x => x.Contains(searchVal) || string.IsNullOrEmpty(searchVal))
|
|
.ToList();
|
|
numFound = recipeList.Count;
|
|
list2show = recipeList.Take(numShow).ToList();
|
|
}
|
|
await Task.Delay(1);
|
|
isLoading = false;
|
|
}
|
|
|
|
private async Task showSelect()
|
|
{
|
|
isLoading = true;
|
|
// carico dati x ricerca...
|
|
await ReloadData();
|
|
// mostro!
|
|
showSearch = true;
|
|
isLoading = false;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |