Files
lux/Lux.UI/Components/Pages/Scratch.razor.cs
T

66 lines
3.2 KiB
C#

using EgwCoreLib.Lux.Data;
using EgwCoreLib.Lux.Data.Services;
using Microsoft.AspNetCore.Components;
namespace Lux.UI.Components.Pages
{
public partial class Scratch
{
private string windowUid = "TestWindow";
/// <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}";
[Inject]
protected ImageCacheService ICService { get; set; } = null!;
[Inject]
protected IRedisService RedServ { get; set; } = null!;
[Inject]
protected IConfiguration Config { get; set; } = null!;
private string apiUrl = "";
private string calcTag = "";
private string subChannel = "";
private string currChannel = "";
protected override Task OnInitializedAsync()
{
apiUrl = Config.GetValue<string>("ServerConf:Prog.ApiUrl") ?? "";
calcTag = Config.GetValue<string>("ServerConf:ImageCalcTag") ?? "";
subChannel = Config.GetValue<string>("ServerConf:SvgChannel") ?? "";
RedServ.Subscribe($"{subChannel}:*", (ch, msg) =>
{
saveSvg($"{ch}", $"{msg}");
});
return Task.CompletedTask;
}
private void saveSvg(string channel, string newSvg)
{
// se è la mia immagine
if (channel.EndsWith(windowUid) || true)
{
currSvg = newSvg;
}
}
protected async Task SendCalc()
{
await ICService.CallRestPost(apiUrl, $"{calcTag}/{windowUid}", demoJwd);
}
protected MarkupString outSvg { get; set; } = (MarkupString)"";
private string currSvg = "";
}
}