88 lines
3.0 KiB
C#
88 lines
3.0 KiB
C#
using EgwCoreLib.Lux.Core;
|
|
using EgwCoreLib.Lux.Core.RestPayload;
|
|
using EgwCoreLib.Lux.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Test.UI.Components.Pages
|
|
{
|
|
public partial class Aedifica : IDisposable
|
|
{
|
|
|
|
private string channelSub = "";
|
|
private string CalcUid = "TestBeam";
|
|
private string currSvg = "";
|
|
private string apiUrl = "";
|
|
private string calcTag = "";
|
|
private string GenericBasePath = "";
|
|
|
|
[Inject]
|
|
protected IConfiguration Config { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected DataLayerServices DLService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected ImageCacheService ICService { get; set; } = null!;
|
|
|
|
public void Dispose()
|
|
{
|
|
DLService.PipeSvg.EA_NewMessage -= PipeSvg_EA_NewMessage;
|
|
}
|
|
|
|
protected MarkupString JsonSer
|
|
{
|
|
get => (MarkupString)currSvg.Replace(Environment.NewLine, "<br/>").Replace(" ", " ");
|
|
}
|
|
|
|
protected Dictionary<string, string> m_CurrArgs = new Dictionary<string, string>();
|
|
|
|
protected override Task OnInitializedAsync()
|
|
{
|
|
ConfInit();
|
|
DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage;
|
|
//await ReloadData();
|
|
return Task.Delay(1);
|
|
}
|
|
|
|
private void ConfInit()
|
|
{
|
|
apiUrl = Config.GetValue<string>("ServerConf:Prog.ApiUrl") ?? "";
|
|
GenericBasePath = Config.GetValue<string>("ServerConf:GenericBaseUrl") ?? "";
|
|
//imgTag = Config.GetValue<string>("ServerConf:ImageFileTag") ?? "";
|
|
calcTag = Config.GetValue<string>("ServerConf:CalcTag") ?? "";
|
|
channelSub = Config.GetValue<string>("ServerConf:ChannelSvg") ?? "";
|
|
}
|
|
|
|
private async Task SendBtlRequest(Dictionary<string, string> CurrArgs)
|
|
{
|
|
m_CurrArgs = CurrArgs;
|
|
// chiamo la chiamata POST alla API, che manda la richiesta via REDIS
|
|
if (m_CurrArgs != null)
|
|
{
|
|
CalcRequestDTO calcRequestDTO = new CalcRequestDTO();
|
|
calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM;
|
|
calcRequestDTO.DictExec = m_CurrArgs;
|
|
await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO);
|
|
}
|
|
}
|
|
|
|
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($"{channelSub}:{CalcUid}"))
|
|
{
|
|
currSvg = currArgs.newMessage;
|
|
}
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
}
|
|
}
|