139 lines
5.4 KiB
C#
139 lines
5.4 KiB
C#
using EgwCoreLib.Lux.Core;
|
|
using EgwCoreLib.Lux.Data.Services;
|
|
using EgwCoreLib.Lux.Data.Services.General;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace Lux.UI.Components.Pages
|
|
{
|
|
public partial class Scratch : IDisposable
|
|
{
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
DLService.PipeSvg.EA_NewMessage -= PipeSvg_EA_NewMessage;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
private ControlMode CurrMode = ControlMode.HistStats;
|
|
|
|
protected enum ControlMode
|
|
{
|
|
None,
|
|
HistStats,
|
|
RealtimeStats,
|
|
TestSvg
|
|
}
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IConfiguration Config { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IDataLayerServices DLService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected ImageCacheService ICService { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Generazione componente SVG da mostrare
|
|
/// </summary>
|
|
protected MarkupString outSvg
|
|
{
|
|
get
|
|
{
|
|
// aggiunta gestione classe svg per posizionamento con costraints
|
|
var newSvg = currSvg.Replace("<svg", "<svg class=\"responsive-svg\"");
|
|
return (MarkupString)newSvg;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnAfterRender(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
// This only runs once the interactive circuit is established
|
|
Console.WriteLine("Now interactive!");
|
|
// JS interop or data fetches go here
|
|
isInteractive = true;
|
|
}
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
apiUrl = Config.GetValue<string>("ServerConf:Prog.ApiUrl") ?? "";
|
|
imgBasePath = Config.GetValue<string>("ServerConf:ImageBaseUrl") ?? "";
|
|
calcTag = Config.GetValue<string>("ServerConf:ImageCalcTag") ?? "";
|
|
chSub = Config.GetValue<string>("ServerConf:ChannelSvg") ?? "";
|
|
DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage;
|
|
}
|
|
|
|
protected void Reset()
|
|
{
|
|
currSvg = "";
|
|
}
|
|
|
|
protected async Task SendCalc()
|
|
{
|
|
// Proseguo solo se sono in interattivo (NO prerender pagina)
|
|
if (isInteractive)
|
|
{
|
|
// chiamo la chiamata POST alla API, che manda la richiesta via REDIS
|
|
await ICService.CallRestPost($"{apiUrl}/{imgBasePath}", $"{calcTag}/{windowUid}", demoJwd);
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private string apiUrl = "";
|
|
|
|
private string calcTag = "";
|
|
|
|
private string currSvg = "";
|
|
|
|
/// <summary>
|
|
/// Demorichiesta jwd x fare test richiesta calcolo
|
|
/// </summary>
|
|
private string demoJwd = "{\r\n\"ProfilePath\":\"Profilo78\",\r\n\"AreaList\":[\r\n{\r\n\"Shape\":\"RECTANGLE\",\r\n\"DimensionList\":[\r\n{\r\n\"nIndex\":1,\r\n\"sName\":\"Width\",\r\n\"dValue\":1200.0\r\n},\r\n{\r\n\"nIndex\":2,\r\n\"sName\":\"Height\",\r\n\"dValue\":1500.0\r\n}\r\n],\r\n\"JointList\":[\r\n{\r\n\"nIndex\":1,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":2,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":3,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":4,\r\n\"JointType\":\"FULL_V\"\r\n}\r\n],\r\n\"BottomRail\":false,\r\n\"BottomRailQty\":0,\r\n\"AreaList\":[\r\n{\r\n\"bIsSashVertical\":true,\r\n\"SashList\":[\r\n{\r\n\"OpeningType\":\"TURNONLY_LEFT\",\r\n\"bHasHandle\":false,\r\n\"dDimension\":50.0\r\n},\r\n{\r\n\"OpeningType\":\"TILTTURN_RIGHT\",\r\n\"bHasHandle\":true,\r\n\"dDimension\":50.0\r\n}\r\n],\r\n\"SashType\":\"NULL\",\r\n\"JointList\":[\r\n{\r\n\"nIndex\":1,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":2,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":3,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":4,\r\n\"JointType\":\"FULL_V\"\r\n}\r\n],\r\n\"Hardware\":\"000000\",\r\n\"AreaList\":[\r\n{\r\n\"AreaList\":[\r\n{\r\n\"FillType\":\"GLASS\",\r\n\"AreaList\":[],\r\n\"AreaType\":\"FILL\"\r\n}\r\n],\r\n\"AreaType\":\"SPLITTED\"\r\n},\r\n{\r\n\"AreaList\":[\r\n{\r\n\"FillType\":\"GLASS\",\r\n\"AreaList\":[],\r\n\"AreaType\":\"FILL\"\r\n}\r\n],\r\n\"AreaType\":\"SPLITTED\"\r\n}\r\n],\r\n\"AreaType\":\"SASH\"\r\n}\r\n],\r\n\"AreaType\":\"FRAME\"\r\n}\r\n]\r\n}";
|
|
|
|
private string imgBasePath = "";
|
|
|
|
/// <summary>
|
|
/// Semaforo x definire se sia gi� in modalit� ionterattiva o di prerendering
|
|
/// </summary>
|
|
private bool isInteractive = false;
|
|
|
|
private string chSub = "";
|
|
private string windowUid = "TestWindow";
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
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($"{chSub}:{windowUid}"))
|
|
{
|
|
currSvg = currArgs.newMessage;
|
|
}
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |