52bdaec430
- Aggiunto reset shape nell'aggiunta sashGroup - Tolta chiamatareset dict nel cambiare shape split
497 lines
18 KiB
C#
497 lines
18 KiB
C#
using Egw.Window.Data;
|
|
using EgwCoreLib.Lux.Core;
|
|
using EgwCoreLib.Lux.Core.RestPayload;
|
|
using EgwCoreLib.Lux.Data.DbModel.Catalog;
|
|
using EgwCoreLib.Lux.Data.DbModel.Config;
|
|
using EgwCoreLib.Lux.Data.DbModel.Sales;
|
|
using EgwCoreLib.Lux.Data.DbModel.Utils;
|
|
using EgwCoreLib.Lux.Data.Domains;
|
|
using EgwCoreLib.Lux.Data.Services;
|
|
using EgwCoreLib.Lux.Data.Services.Config;
|
|
using EgwCoreLib.Lux.Data.Services.Items;
|
|
using EgwCoreLib.Lux.Data.Services.Sales;
|
|
using EgwCoreLib.Lux.Data.Services.Utils;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Newtonsoft.Json;
|
|
using WebWindowComplex;
|
|
using WebWindowComplex.DTO;
|
|
using static WebWindowComplex.LayoutConst;
|
|
|
|
namespace Test.UI.Components.Pages
|
|
{
|
|
public partial class EditJWD : IDisposable
|
|
{
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
DLService.PipeSvg.EA_NewMessage -= PipeSvg_EA_NewMessage;
|
|
DLService.PipeShape.EA_NewMessage -= PipeShape_EA_NewMessage;
|
|
DLService.PipeHwOpt.EA_NewMessage -= PipeHwOption_EA_NewMessage;
|
|
DLService.PipeProfElement.EA_NewMessage -= PipeProfElement_EA_NewMessage;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
/// <summary>
|
|
/// Configurazione selezionati
|
|
/// </summary>
|
|
protected SelectPayload SelectList = new SelectPayload();
|
|
|
|
/// <summary>
|
|
/// Configurazione elenchi anagrafiche
|
|
/// </summary>
|
|
protected BaseListPayload SetupList = new BaseListPayload();
|
|
|
|
/// <summary>
|
|
/// Livello di accesso
|
|
/// -- true: utente base (versione semplificata)
|
|
/// -- false: utente avanzato (versione completa)
|
|
/// </summary>
|
|
protected bool User = false;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected MarkupString JsonSer
|
|
{
|
|
get => (MarkupString)currJwd.Replace(Environment.NewLine, "<br/>").Replace(" ", " ");
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnAfterRender(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
// JS interop or data fetches go here
|
|
isInteractive = true;
|
|
}
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
ConfInit();
|
|
await ReloadBaseList();
|
|
User = false;
|
|
Random random = new Random();
|
|
CalcUid = Convert.ToString(random.Next(1000, 10000));
|
|
windowUid = CalcUid;
|
|
//initialJwd = File.ReadAllText("Data\\AntaDoppiaInglesine.jwd");
|
|
//initialJwd = File.ReadAllText("Data\\AntaDoppia.jwd");
|
|
currJwd = initialJwd;
|
|
// rileggo altri dati
|
|
//await ReloadData();
|
|
// converto i profili nel nuovo formato x payload...
|
|
var profList = AvailProfileList.Select(x => new ProfilePayload()
|
|
{
|
|
ProfileName = x.Code,
|
|
ThresholdList = x.ThresholdList,
|
|
ParameterDict = x.ProfileDataDict
|
|
}).ToList();
|
|
// preparo conf oggetti x controllo
|
|
SetupList = new BaseListPayload()
|
|
{
|
|
ColorMaterial = AvailColorMaterialList,
|
|
FamilyHardware = AvailFamilyHardwareList,
|
|
Glass = AvailGlassList,
|
|
Hardware = AvailHardwareList,
|
|
Material = AvailMaterialList,
|
|
ProfileList = profList
|
|
};
|
|
CurrData = new LivePayload()
|
|
{
|
|
CurrJwd = currJwd,
|
|
SvgPreview = currSvg,
|
|
DictShape = currGroupShape,
|
|
DictOptionsXml = currHwOption
|
|
};
|
|
DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage;
|
|
DLService.PipeShape.EA_NewMessage += PipeShape_EA_NewMessage;
|
|
DLService.PipeHwOpt.EA_NewMessage += PipeHwOption_EA_NewMessage;
|
|
DLService.PipeProfElement.EA_NewMessage += PipeProfElement_EA_NewMessage;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private ConfigDataService CDService { get; set; } = default!;
|
|
|
|
[Inject]
|
|
private IConfGlassService CGService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IConfProfileService CPService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IConfWoodService CWService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IGenValService GVService { get; set; } = default!;
|
|
|
|
[Inject]
|
|
private IConfiguration Config { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private DataLayerServices DLService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private ImageCacheService ICService { get; set; } = null!;
|
|
|
|
private string SelColorMaterial { get; set; } = "";
|
|
|
|
private string SelFamilyHardware { get; set; } = "";
|
|
|
|
private string SelGlass { get; set; } = "";
|
|
|
|
private string SelMaterial { get; set; } = "";
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Fields
|
|
|
|
private List<GlassModel> AllConfGlass = new();
|
|
private List<GenValueModel> AllColors = new();
|
|
private List<HardwareModel> AllConfHardware = new();
|
|
private List<WoodModel> AllConfWood = new();
|
|
private List<string> AvailColorMaterialList = new List<string>();
|
|
private List<string> AvailFamilyHardwareList = new List<string>();
|
|
private List<string> AvailGlassList = new List<string>();
|
|
private List<Hardware> AvailHardwareList = new();
|
|
private List<string> AvailMaterialList = new List<string>();
|
|
private List<ProfileModel> AvailProfileList = new();
|
|
|
|
private EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS cEnvir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW;
|
|
|
|
/// <summary>
|
|
/// Predisposizione valori live SVG/JWD
|
|
/// </summary>
|
|
private LivePayload CurrData = new LivePayload();
|
|
|
|
private List<AreaProfiles> currElement = new List<AreaProfiles>();
|
|
|
|
private Dictionary<int, string> currGroupShape = new Dictionary<int, string>();
|
|
|
|
private Dictionary<int, string> currHwOption = new Dictionary<int, string>();
|
|
|
|
private string currJwd = "...";
|
|
|
|
private Dictionary<string, string> m_CurrArgs = new Dictionary<string, string>();
|
|
|
|
private string prevJwd = "";
|
|
|
|
private string apiUrl = "";
|
|
|
|
///// <summary>
|
|
///// Lista profili da DB
|
|
///// </summary>
|
|
//private List<ProfilePayload> AvailProfileList = new List<ProfilePayload>();
|
|
|
|
private string calcTag = "";
|
|
|
|
private string CalcUid = "CurrWindow";
|
|
|
|
private string cFileHardware = "Hardware/Setup.json";
|
|
|
|
private string channelHwOpt = "";
|
|
|
|
private string channelProfElem = "";
|
|
|
|
private string channelProfList = "";
|
|
|
|
private string channelShape = "";
|
|
|
|
private string channelSvg = "";
|
|
|
|
private string currSvg = "";
|
|
|
|
private bool doEdit = false;
|
|
|
|
private string GenericBasePath = "";
|
|
|
|
private string imgBasePath = "";
|
|
|
|
/// <summary>
|
|
/// Semaforo x definire se sia già in modalità ionterattiva o di prerendering
|
|
/// </summary>
|
|
private bool isInteractive = false;
|
|
|
|
//private string colorMassUpdate;
|
|
//private string familyHWMassUpdate;
|
|
//private string glassMassUpdate;
|
|
//private Hardware hardwareMassUpdate;
|
|
//private string materialMassUpdate;
|
|
//private string profileMassUpdate;
|
|
|
|
private string outClose = "";
|
|
|
|
private string outSave = "";
|
|
|
|
private bool startEmpty = true;
|
|
|
|
private string windowUid = "CurrWindow";
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private string initialJwd
|
|
{
|
|
get
|
|
{
|
|
if (startEmpty)
|
|
{
|
|
return "{}";
|
|
}
|
|
else
|
|
{
|
|
return File.ReadAllText("Data\\AntaDoppiaInglesine.jwd");
|
|
//return File.ReadAllText("Data\\AntaDoppia.jwd");
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Init classi configurazione
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task ReloadBaseList()
|
|
{
|
|
// lettura config setup varie da DB/Cache Redis
|
|
AllConfGlass = await CGService.GetAllAsync();
|
|
AvailProfileList = await CPService.GetAllAsync();
|
|
|
|
// FixMe Todo: eliminare da REDIS e usare elenco DB solamente...
|
|
var rawProfiles = CDService.ProfileList(cEnvir, "Default");
|
|
// se fosse vuoto chiamo update...
|
|
if (rawProfiles == null || rawProfiles.Count == 0)
|
|
{
|
|
rawProfiles = CDService.ProfileList(cEnvir, "Default");
|
|
}
|
|
var rawHw = CDService.HwModelList(cEnvir, "HW.AGB");
|
|
// hw filtro solo validi...
|
|
AllConfHardware = rawHw
|
|
.Where(x => !x.FamilyName.Equals(x.Description, StringComparison.OrdinalIgnoreCase))
|
|
.ToList();
|
|
AllConfWood = await CWService.GetAllAsync();
|
|
AllColors = await GVService.GetFiltAsync("WoodCol");
|
|
// conversione tipi
|
|
AvailGlassList = AllConfGlass
|
|
.Select(x => x.Description)
|
|
.ToList();
|
|
AvailFamilyHardwareList = AllConfHardware
|
|
.DistinctBy(x => x.FamilyName)
|
|
.OrderBy(x => x.FamilyName)
|
|
.Select(x => x.FamilyName)
|
|
.ToList();
|
|
AvailHardwareList = AllConfHardware
|
|
.Select(x => new Egw.Window.Data.Hardware(x.Id, x.FamilyName, x.Description, x.OpeningType, x.Shape, x.SashQty, x.SashPosition))
|
|
.ToList();
|
|
AvailMaterialList = AllConfWood
|
|
.Select(x => x.Description)
|
|
.ToList();
|
|
AvailColorMaterialList = AllColors
|
|
.OrderBy(x => x.Index)
|
|
.Select(x => x.ValString)
|
|
.ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Effettua chiusura oggetto con eventuale save
|
|
/// </summary>
|
|
/// <param name="reqSave"></param>
|
|
private void CloseObj(DataSave reqSave)
|
|
{
|
|
currJwd = reqSave.ForceSave ? reqSave.currJwd : initialJwd;
|
|
outClose = !reqSave.ForceSave ? "Richiesto Close!" : "";
|
|
outSave = reqSave.ForceSave ? "Richiesto Close + Save!" : "";
|
|
doEdit = false;
|
|
}
|
|
|
|
private void ConfInit()
|
|
{
|
|
apiUrl = Config.GetValue<string>("ServerConf:Prog.ApiUrl") ?? "";
|
|
imgBasePath = Config.GetValue<string>("ServerConf:ImageBaseUrl") ?? "";
|
|
GenericBasePath = Config.GetValue<string>("ServerConf:GenericBaseUrl") ?? "";
|
|
calcTag = Config.GetValue<string>("ServerConf:CalcTag") ?? "";
|
|
channelSvg = Config.GetValue<string>("ServerConf:ChannelSvg") ?? "";
|
|
channelShape = Config.GetValue<string>("ServerConf:ChannelShape") ?? "";
|
|
channelHwOpt = Config.GetValue<string>("ServerConf:ChannelHwOpt") ?? "";
|
|
channelProfElem = Config.GetValue<string>("ServerConf:ChannelProfElem") ?? "";
|
|
channelProfList = Config.GetValue<string>("ServerConf:ChannelProfList") ?? "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Esecuzione azione richiesta
|
|
/// </summary>
|
|
/// <param name="actReq">Azione richiesta</param>
|
|
private void DoAction(DataAction actReq)
|
|
{
|
|
switch (actReq)
|
|
{
|
|
case DataAction.None:
|
|
break;
|
|
|
|
case DataAction.ResetDictShape:
|
|
CurrData.DictShape = new Dictionary<int, string>();
|
|
break;
|
|
|
|
case DataAction.ResetHwOpt:
|
|
CurrData.DictOptionsXml = new Dictionary<int, string>();
|
|
break;
|
|
|
|
case DataAction.ResetDimElem:
|
|
CurrData.ProfElementList = new List<AreaProfiles>();
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Esecuzione richiesta
|
|
/// </summary>
|
|
/// <param name="CurrArgs"></param>
|
|
/// <returns></returns>
|
|
private async Task ExecRequest(Dictionary<string, string> CurrArgs)
|
|
{
|
|
// Proseguo solo se sono in interattivo (NO prerender pagina)
|
|
if (isInteractive)
|
|
{
|
|
outClose = "";
|
|
outSave = "";
|
|
// verifico se contiene JWD, lo aggiorno
|
|
if (CurrArgs.ContainsKey("SerializedData"))
|
|
{
|
|
currJwd = CurrArgs["SerializedData"];
|
|
CurrData.CurrJwd = currJwd;
|
|
}
|
|
// se il SSE variato --> invio
|
|
if (!currJwd.Equals(prevJwd) || !EgwCoreLib.Utils.DictUtils.DictAreEqual(m_CurrArgs, CurrArgs))
|
|
{
|
|
m_CurrArgs = CurrArgs;
|
|
prevJwd = currJwd;
|
|
CalcRequestDTO calcRequestDTO = new CalcRequestDTO();
|
|
calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW;
|
|
calcRequestDTO.DictExec = m_CurrArgs;
|
|
// chiamo la chiamata POST alla API, che manda la richiesta via REDIS
|
|
await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO);
|
|
}
|
|
}
|
|
}
|
|
|
|
private async void PipeHwOption_EA_NewMessage(object? sender, EventArgs e)
|
|
{
|
|
// aggiorno visualizzazione
|
|
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
|
// conversione on-the-fly SVG da mostrare
|
|
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
|
{
|
|
if (currArgs.msgUid.StartsWith($"{channelHwOpt}:{windowUid}") && currArgs.newMessage.Length > 2)
|
|
{
|
|
// deserializzo il dizionario delle risposte...
|
|
Dictionary<int, string> rawDict = JsonConvert.DeserializeObject<Dictionary<int, string>>(currArgs.newMessage) ?? new Dictionary<int, string>();
|
|
if (rawDict.Count > 0)
|
|
currHwOption = rawDict;
|
|
}
|
|
else
|
|
{
|
|
currHwOption = new Dictionary<int, string>();
|
|
}
|
|
CurrData.DictOptionsXml = currHwOption;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private async void PipeProfElement_EA_NewMessage(object? sender, EventArgs e)
|
|
{
|
|
// aggiorno visualizzazione
|
|
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
|
// conversione on-the-fly SVG da mostrare
|
|
if (!string.IsNullOrEmpty(currArgs.newMessage) && currArgs.newMessage.Length > 2)
|
|
{
|
|
if (currArgs.msgUid.StartsWith($"{channelProfElem}:{windowUid}"))
|
|
{
|
|
// deserializzo il dizionario delle risposte...
|
|
var rawDict = JsonConvert.DeserializeObject<List<AreaProfiles>>(currArgs.newMessage);
|
|
currElement = rawDict ?? new List<AreaProfiles>();
|
|
CurrData.ProfElementList = currElement;
|
|
}
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private async void PipeShape_EA_NewMessage(object? sender, EventArgs e)
|
|
{
|
|
// aggiorno visualizzazione
|
|
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
|
// conversione on-the-fly SVG da mostrare
|
|
if (!string.IsNullOrEmpty(currArgs.newMessage) && currArgs.newMessage.Length > 2)
|
|
{
|
|
if (currArgs.msgUid.StartsWith($"{channelShape}:{windowUid}"))
|
|
{
|
|
// deserializzo il dizionario delle risposte...
|
|
var rawDict = JsonConvert.DeserializeObject<Dictionary<int, string>>(currArgs.newMessage);
|
|
currGroupShape = rawDict ?? new Dictionary<int, string>();
|
|
CurrData.DictShape = currGroupShape;
|
|
}
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private async void PipeSvg_EA_NewMessage(object? sender, EventArgs e)
|
|
{
|
|
// aggiorno visualizzazione
|
|
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
|
// conversione on-the-fly SVG da mostrare
|
|
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
|
{
|
|
if (currArgs.msgUid.Equals($"{channelSvg}:{windowUid}"))
|
|
{
|
|
currSvg = currArgs.newMessage;
|
|
CurrData.SvgPreview = currArgs.newMessage;
|
|
}
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private void SetEdit(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
|
|
{
|
|
doEdit = true;
|
|
}
|
|
|
|
private Task ToggleJwd()
|
|
{
|
|
startEmpty = !startEmpty;
|
|
currJwd = initialJwd;
|
|
currSvg = "";
|
|
CurrData.CurrJwd = currJwd;
|
|
CurrData.SvgPreview = currSvg;
|
|
return InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private void updateInfoJwd(string currSer, string? newFamilyHardware, Hardware? newHardware, string? newColorMaterial, string? newMaterial, string? newGlass, string? newProfile)
|
|
{
|
|
var newJwd = SerialMan.MassUpdate(currSer, newFamilyHardware, newHardware, newColorMaterial, newMaterial, newGlass, newProfile);
|
|
CurrData.CurrJwd = newJwd;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |