191 lines
6.2 KiB
C#
191 lines
6.2 KiB
C#
using EgwCoreLib.Lux.Core;
|
|
using EgwCoreLib.Lux.Core.RestPayload;
|
|
using EgwCoreLib.Lux.Data.DbModel.Sales;
|
|
using EgwCoreLib.Lux.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace Lux.UI.Components.Compo
|
|
{
|
|
public partial class OfferCommonPar
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public OfferModel CurrRecord { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_Close { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<OfferModel> EC_Updated { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected ConfigDataService CDService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected IConfiguration Config { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected CalcRuidService CRService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected CalcRequestService CService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected DataLayerServices DLService { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Gestione selezione Colore
|
|
/// </summary>
|
|
protected string SelColor
|
|
{
|
|
get => CurrSel.GetVal("Color");
|
|
set => CurrSel.SetVal("Color", value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gestione selezione Glass
|
|
/// </summary>
|
|
protected string SelGlass
|
|
{
|
|
get => CurrSel.GetVal("Glass");
|
|
set => CurrSel.SetVal("Glass", value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gestione selezione Profile
|
|
/// </summary>
|
|
protected string SelProfile
|
|
{
|
|
get => CurrSel.GetVal("Profile");
|
|
set => CurrSel.SetVal("Profile", value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gestione selezione Wood
|
|
/// </summary>
|
|
protected string SelWood
|
|
{
|
|
get => CurrSel.GetVal("Wood");
|
|
set => CurrSel.SetVal("Wood", value);
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
ConfInit();
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
isLoading = true;
|
|
// deserializzo se possibile dal record...
|
|
CurrSel = new ParamDict(CurrRecord.DictPresel);
|
|
// leggo dati di base
|
|
var AllColors = await DLService.GenValGetFiltAsync("WoodCol");
|
|
var AllConfGlass = await DLService.ConfGlassGetAllAsync();
|
|
var AllConfProfile = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default");
|
|
// se fosse vuoto chiamo update...
|
|
if (AllConfProfile == null || AllConfProfile.Count == 0)
|
|
{
|
|
await callRefreshProfList();
|
|
// aspetto 200ms... e richiedo!
|
|
await Task.Delay(200);
|
|
AllConfProfile = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default");
|
|
}
|
|
var AllConfWood = await DLService.ConfWoodGetAllAsync();
|
|
// conversione tipi
|
|
ListColors = AllColors
|
|
.Select(x => x.ValString)
|
|
.ToList();
|
|
ListGlass = AllConfGlass
|
|
.Select(x => x.Description)
|
|
.ToList();
|
|
ListProfiles = AllConfProfile;
|
|
ListWood = AllConfWood
|
|
.Select(x => x.Description)
|
|
.ToList();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private string apiUrl = "";
|
|
private string calcTag = "calc";
|
|
private EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS cEnvir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW;
|
|
private ParamDict CurrSel = new ParamDict("");
|
|
|
|
private string genericBasePath = "";
|
|
private bool isLoading = false;
|
|
|
|
private List<string> ListColors = new List<string>();
|
|
|
|
private List<string> ListGlass = new List<string>();
|
|
|
|
private List<string> ListProfiles = new List<string>();
|
|
|
|
private List<string> ListWood = new List<string>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Effettua vera richiesta della BOM
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task callRefreshProfList()
|
|
{
|
|
Dictionary<string, string> DictExec = new Dictionary<string, string>();
|
|
var cMode = Egw.Window.Data.Enums.QuestionModes.CONFIG;
|
|
var cSubMode = Egw.Window.Data.Enums.QuestionConfSubModes.PROFILELIST;
|
|
// compongo righiesta
|
|
string reqUid = "Default";
|
|
DictExec.Add("Mode", $"{(int)cMode}");
|
|
DictExec.Add("UID", reqUid);
|
|
// creo registrazione richiesta...
|
|
var ruid = await CRService.AddRequestAsync($"{cEnvir}", $"{cMode}-{cSubMode}", reqUid);
|
|
// aggiungo RUID effettivo
|
|
DictExec.Add("RUID", ruid);
|
|
DictExec.Add("SubMode", $"{(int)cSubMode}");
|
|
CalcRequestDTO req = new CalcRequestDTO()
|
|
{
|
|
EnvType = cEnvir,
|
|
DictExec = DictExec
|
|
};
|
|
// chiamo la chiamata POST alla API, che manda la richiesta via REDIS
|
|
await CService.CallRestPost($"{apiUrl}/{genericBasePath}", $"{calcTag}/{reqUid}", req);
|
|
}
|
|
|
|
private void ConfInit()
|
|
{
|
|
apiUrl = Config.GetValue<string>("ServerConf:Prog.ApiUrl") ?? "";
|
|
genericBasePath = Config.GetValue<string>("ServerConf:GenericBaseUrl") ?? "";
|
|
calcTag = Config.GetValue<string>("ServerConf:CalcTag") ?? "calc";
|
|
}
|
|
|
|
private async Task DoCancel()
|
|
{
|
|
await EC_Close.InvokeAsync(true);
|
|
}
|
|
|
|
private async Task DoSave()
|
|
{
|
|
// aggiorno valore serializzato...
|
|
CurrRecord.DictPresel = CurrSel.Serialized;
|
|
// richiesta update con salvataggio record
|
|
await EC_Updated.InvokeAsync(CurrRecord);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |