Update controllers
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
using EgwCoreLib.Lux.Core.RestPayload;
|
||||
using EgwCoreLib.Lux.Data.Services;
|
||||
using EgwMultiEngineManager;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NLog;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Lux.API.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class GenericController : ControllerBase
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public GenericController(IConfiguration config, IRedisService redisService, ImageCacheService imgServ)
|
||||
{
|
||||
_config = config;
|
||||
_redisService = redisService;
|
||||
_imgService = imgServ;
|
||||
pubChannel = _config.GetValue<string>("ServerConf:PubChannel") ?? "";
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata POST: specificando il tipo di richiesta + dizionario parametri esegue chiamata
|
||||
/// PUT: api/generic/calc/00000000-0000-0000-0000-000000000000
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("calc/{id}")]
|
||||
public async Task<ActionResult<string>> calc(string id, [FromBody] CalcRequestDTO currReq)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string svgContent = "";
|
||||
|
||||
// se contiene ".svg" lo levo...
|
||||
if (id.EndsWith(".svg"))
|
||||
{
|
||||
id = id.Replace(".svg", "");
|
||||
}
|
||||
|
||||
// ...se ricevo percorso --> leggo jwd/svg cablato
|
||||
if (currReq != null)
|
||||
{
|
||||
Dictionary<string, string> DictExec = currReq.DictExec;
|
||||
// controllo se mancassero parametri...
|
||||
if(!DictExec.ContainsKey("Mode"))
|
||||
{
|
||||
DictExec.Add("Mode", "1");
|
||||
}
|
||||
if (!DictExec.ContainsKey("UID"))
|
||||
{
|
||||
DictExec.Add("UID", id);
|
||||
}
|
||||
if (!DictExec.ContainsKey("Jwd"))
|
||||
{
|
||||
DictExec.Add("Jwd", demoJwd);
|
||||
}
|
||||
int nId = 1;
|
||||
// da modificare con tipo richiesta...
|
||||
ProcessArgs currArgs = new ProcessArgs(nId, DictExec);
|
||||
|
||||
await _redisService.PublishAsync(pubChannel, currArgs.sProcessArgs);
|
||||
svgContent = "DONE";
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Info($"calcSvg | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
return Ok(svgContent);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly IRedisService _redisService;
|
||||
private readonly string pubChannel = "";
|
||||
private IConfiguration _config;
|
||||
|
||||
/// <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}";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private ImageCacheService _imgService { get; set; }
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user