Update API x metodo mode 2 (BOM)
This commit is contained in:
@@ -24,14 +24,117 @@ namespace Lux.API.Controllers
|
||||
|
||||
#region Public Methods
|
||||
|
||||
[Obsolete("Please use svg-preview")]
|
||||
[HttpPost("calc/{id}")]
|
||||
public async Task<ActionResult<string>> calc(string id, [FromBody] string currJwd)
|
||||
{
|
||||
return await svgPreview(id, currJwd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata POST: riceve Json in formato JWD serializzato, lo ripete come risposta
|
||||
/// PUT: api/calc/svg/00000000-0000-0000-0000-000000000000
|
||||
/// Chiamata POST: riceve Json in formato JWD serializzato, invia richeista calcolo modo 2 (BOM)
|
||||
/// PUT: api/svgPreview/svg/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] string currJwd)
|
||||
[HttpPost("bom/{id}")]
|
||||
public async Task<ActionResult<string>> getBom(string id, [FromBody] string currJwd)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string svgContent = "";
|
||||
|
||||
// se contiene ".svg" lo levo...
|
||||
if (id.EndsWith(".svg"))
|
||||
{
|
||||
id = id.Replace(".svg", "");
|
||||
}
|
||||
|
||||
// se messaggio vuoto --> uso default!
|
||||
currJwd = string.IsNullOrEmpty(currJwd) ? demoJwd : currJwd;
|
||||
|
||||
// ...se ricevo percorso --> leggo jwd/svg cablato
|
||||
if (!string.IsNullOrEmpty(currJwd))
|
||||
{
|
||||
if (true)
|
||||
{
|
||||
Dictionary<string, string> DictExec = new Dictionary<string, string>();
|
||||
DictExec.Add("Mode", "2");
|
||||
// UID cablato x ora...
|
||||
DictExec.Add("UID", id);
|
||||
DictExec.Add("Jwd", currJwd);
|
||||
int nId = 1;
|
||||
ProcessArgs currArgs = new ProcessArgs(nId, DictExec);
|
||||
|
||||
await _redisService.PublishAsync(pubChannel, currArgs.sProcessArgs);
|
||||
svgContent = "DONE";
|
||||
}
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Info($"getBom | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
return Ok(svgContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata POST: riceve Json in formato JWD serializzato, lo ripete come risposta
|
||||
/// PUT: api/svgPreview/svg/00000000-0000-0000-0000-000000000000
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("svg/{id}")]
|
||||
public async Task<ActionResult<string>> svg(string id)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string svgContent = "";
|
||||
// ...se ricevo percorso --> leggo jwd/svg cablato
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
svgContent = _imgService.LoadSvg(id);
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Info($"svgString | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
return Ok(svgContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata POST: riceve Json in formato JWD serializzato, lo ripete come risposta
|
||||
/// PUT: api/svgPreview/svg/00000000-0000-0000-0000-000000000000
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("svgFile/{id}")]
|
||||
public async Task<ActionResult<string>> svgFile(string id)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
if (string.IsNullOrEmpty(id))
|
||||
return NotFound();
|
||||
|
||||
// se contiene ".svg" lo levo...
|
||||
if (id.EndsWith(".svg"))
|
||||
{
|
||||
id = id.Replace(".svg", "");
|
||||
}
|
||||
|
||||
string svgContent = await _imgService.LoadSvgAsync(id);
|
||||
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(svgContent);
|
||||
|
||||
sw.Stop();
|
||||
Log.Info($"svgString | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
|
||||
return File(bytes, "image/svg+xml");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata POST: riceve Json in formato JWD serializzato, lo ripete come risposta
|
||||
/// PUT: api/svg-preview/svg/00000000-0000-0000-0000-000000000000
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("svg-preview/{id}")]
|
||||
public async Task<ActionResult<string>> svgPreview(string id, [FromBody] string currJwd)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
@@ -64,62 +167,10 @@ namespace Lux.API.Controllers
|
||||
}
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Info($"svgString | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
Log.Info($"calcSvg | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
return Ok(svgContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata POST: riceve Json in formato JWD serializzato, lo ripete come risposta
|
||||
/// PUT: api/calc/svg/00000000-0000-0000-0000-000000000000
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("svg/{id}")]
|
||||
public async Task<ActionResult<string>> svg(string id)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string svgContent = "";
|
||||
// ...se ricevo percorso --> leggo jwd/svg cablato
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
svgContent = _imgService.LoadSvg(id);
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Info($"svgString | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
return Ok(svgContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata POST: riceve Json in formato JWD serializzato, lo ripete come risposta
|
||||
/// PUT: api/calc/svg/00000000-0000-0000-0000-000000000000
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("svgFile/{id}")]
|
||||
public async Task<ActionResult<string>> svgFile(string id)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
if (string.IsNullOrEmpty(id))
|
||||
return NotFound();
|
||||
|
||||
// se contiene ".svg" lo levo...
|
||||
if (id.EndsWith(".svg"))
|
||||
{
|
||||
id = id.Replace(".svg", "");
|
||||
}
|
||||
|
||||
string svgContent = await _imgService.LoadSvgAsync(id);
|
||||
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(svgContent);
|
||||
|
||||
sw.Stop();
|
||||
Log.Info($"svgString | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
|
||||
return File(bytes, "image/svg+xml");
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
Reference in New Issue
Block a user