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!; /// /// Generazione componente SVG da mostrare /// protected MarkupString outSvg { get { // aggiunta gestione classe svg per posizionamento con costraints var newSvg = currSvg.Replace("("ServerConf:Prog.ApiUrl") ?? ""; imgBasePath = Config.GetValue("ServerConf:ImageBaseUrl") ?? ""; calcTag = Config.GetValue("ServerConf:ImageCalcTag") ?? ""; chSub = Config.GetValue("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 = ""; /// /// Demorichiesta jwd x fare test richiesta calcolo /// 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 = ""; /// /// Semaforo x definire se sia gi� in modalit� ionterattiva o di prerendering /// 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 } }