Lettura BTL e rappresentazione svg per Aedifica
This commit is contained in:
@@ -1,12 +1,87 @@
|
||||
namespace Test.UI.Components.Pages
|
||||
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
|
||||
public partial class Aedifica : IDisposable
|
||||
{
|
||||
protected string currText = "...";
|
||||
private async Task SaveText(string newText)
|
||||
|
||||
private string subChannel = "";
|
||||
private string CalcUid = "Pizza";
|
||||
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()
|
||||
{
|
||||
currText = newText;
|
||||
await Task.Delay(100);
|
||||
DLService.CalcDonePipe.EA_NewMessage -= CalcDonePipe_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 async Task OnInitializedAsync()
|
||||
{
|
||||
ConfInit();
|
||||
DLService.CalcDonePipe.EA_NewMessage += CalcDonePipe_EA_NewMessage;
|
||||
//await ReloadData();
|
||||
await 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") ?? "";
|
||||
subChannel = Config.GetValue<string>("ServerConf:SvgChannel") ?? "";
|
||||
}
|
||||
|
||||
private async Task SaveText(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 CalcDonePipe_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($"{subChannel}:{CalcUid}"))
|
||||
{
|
||||
currSvg = currArgs.newMessage;
|
||||
}
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user