Bozza modifica img unificata SVG/PNG
This commit is contained in:
@@ -44,10 +44,10 @@ namespace EgwCoreLib.Lux.Data
|
||||
|
||||
// init dati x invio serializzazioni da environment
|
||||
modelBuilder.Entity<EnvirParamModel>().HasData(
|
||||
new EnvirParamModel { EnvirID = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, SerStrucKey = "Jwd" },
|
||||
new EnvirParamModel { EnvirID = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM, SerStrucKey = "Btl" },
|
||||
new EnvirParamModel { EnvirID = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.CABINET, SerStrucKey = "Btl" },
|
||||
new EnvirParamModel { EnvirID = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WALL, SerStrucKey = "Btl" }
|
||||
new EnvirParamModel { EnvirID = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, SerStrucKey = "SerializedData" },
|
||||
new EnvirParamModel { EnvirID = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM, SerStrucKey = "SerializedData" },
|
||||
new EnvirParamModel { EnvirID = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.CABINET, SerStrucKey = "SerializedData" },
|
||||
new EnvirParamModel { EnvirID = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WALL, SerStrucKey = "SerializedData" }
|
||||
);
|
||||
|
||||
modelBuilder.Entity<GenValueModel>().HasData(
|
||||
|
||||
@@ -123,12 +123,19 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
public string ImageUrl(string baseUrl, bool isLive, string imgUID, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW)
|
||||
{
|
||||
string tag = isLive ? liveTag : cacheTag;
|
||||
string fType = "undef";
|
||||
if (imgUID.EndsWith(".svg"))
|
||||
{
|
||||
fType = "svg";
|
||||
imgUID.Replace(".svg", "");
|
||||
}
|
||||
else if (imgUID.EndsWith(".png"))
|
||||
{
|
||||
fType = "png";
|
||||
imgUID.Replace(".png", "");
|
||||
}
|
||||
string rndImg = $"{DateTime.Now:HHmmssfff}";
|
||||
string fullUrl = $"{baseUrl}/{tag}/{imgUID}-{rndImg}.svg?envir={envir}".Replace("////", "//");
|
||||
string fullUrl = $"{baseUrl}/{tag}/{imgUID}-{rndImg}.{fType}?envir={envir}".Replace("////", "//");
|
||||
return fullUrl;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Lux.API.Controllers
|
||||
DictExec.Add("Mode", $"{(int)Enums.QuestionModes.BOM}");
|
||||
// UID cablato x ora...
|
||||
DictExec.Add("UID", id);
|
||||
DictExec.Add("Jwd", currSer);
|
||||
DictExec.Add("SerializedData", currSer);
|
||||
int nId = 1;
|
||||
// da modificare con tipo richiesta...
|
||||
QuestionDTO currArgs = new QuestionDTO(nId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, DictExec);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using EgwCoreLib.Lux.Data.Services;
|
||||
using EgwMultiEngineManager.Data;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
@@ -11,11 +13,45 @@ namespace Lux.API.Controllers
|
||||
[ApiController]
|
||||
public class ImageController : ControllerBase
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public ImageController(ImageCacheService imgServ, ILogger<ImageController> logger)
|
||||
{
|
||||
_imgService = imgServ;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata GET: restituisce file PNG (da file o da cache)
|
||||
/// PUT: api/image/png/00000000-0000-0000-0000-000000000000
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("png/{id}")]
|
||||
public async Task<IActionResult> png(string id)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string base64Encoded = "";
|
||||
byte[] decodedBytes = new byte[0];
|
||||
// ...se ricevo percorso --> leggo jwd/svg cablato
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
// bonifica nome svg da
|
||||
base64Encoded = _imgService.LoadPng(id, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM);
|
||||
// converto base64
|
||||
decodedBytes = Convert.FromBase64String(base64Encoded);
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Info($"pngString | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
//return Ok(decodedString);
|
||||
return File(decodedBytes, "image/png");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata GET: riceve Json in formato JwdDto, restituisce svg file
|
||||
/// GET: api/Jwd/svg/00000000-0000-0000-0000-000000000000
|
||||
@@ -35,37 +71,98 @@ namespace Lux.API.Controllers
|
||||
return File(bytes, "image/svg+xml");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata GET: restituisce file PNG (da file o da cache)
|
||||
/// PUT: api/image/png/00000000-0000-0000-0000-000000000000
|
||||
/// Chiamata GET: restituisce file SVG/PNG (da file o cache REDIS), eliminando nome rand (x force refresh)
|
||||
/// GET: api/image/file/OFF0000001.001.svg?env=WINDOW
|
||||
/// GET: api/image/cache/OFF0000001.001.svg?env=WINDOW
|
||||
/// GET: api/image/file/OFF0000002.001.png?env=WINDOW
|
||||
/// GET: api/image/cache/OFF0000002.001.png?env=WINDOW
|
||||
/// GET: api/image/file/OFF0000002.002-123456.png?env=WINDOW
|
||||
/// GET: api/image/cache/OFF0000002.002-123456.png?env=WINDOW
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <param name="id">uid oggetto</param>
|
||||
/// <param name="env">environment oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("png/{id}")]
|
||||
public async Task<IActionResult> png(string id)
|
||||
[HttpGet("{id}")]
|
||||
//[HttpGet("file/{id}")]
|
||||
//[HttpGet("cache/{id}")]
|
||||
public async Task<IActionResult> cacheFile(string id, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string base64Encoded = "";
|
||||
byte[] decodedBytes = new byte[0];
|
||||
|
||||
if (string.IsNullOrEmpty(id))
|
||||
return NotFound();
|
||||
|
||||
string mimeType = "txt";
|
||||
byte[] bytes = new byte[0];
|
||||
// ...se ricevo percorso --> leggo jwd/svg cablato
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
// bonifica nome svg da
|
||||
base64Encoded = _imgService.LoadPng(id, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM);
|
||||
// converto base64
|
||||
decodedBytes = Convert.FromBase64String(base64Encoded);
|
||||
// se contiene ".svg" lo levo...
|
||||
if (id.EndsWith(".svg"))
|
||||
{
|
||||
mimeType = "image/svg+xml";
|
||||
//id = id.Replace(".svg", "");
|
||||
}
|
||||
else if (id.EndsWith(".png"))
|
||||
{
|
||||
mimeType = "image/png";
|
||||
//id.Replace(".png", "");
|
||||
}
|
||||
|
||||
// se contiene i caratteri casuali x forzare reload --> li levo
|
||||
if (id.Contains("-"))
|
||||
{
|
||||
id = id.Substring(0, id.IndexOf("-"));
|
||||
}
|
||||
|
||||
// secondo del tipo + envr decodifico valore corretto
|
||||
switch (env)
|
||||
{
|
||||
case Constants.EXECENVIRONMENTS.NULL:
|
||||
break;
|
||||
case Constants.EXECENVIRONMENTS.WINDOW:
|
||||
mimeType = "image/svg+xml";
|
||||
string svgContent = await _imgService.LoadSvgAsync(id, env);
|
||||
// se vuoto --> leggo img logo...
|
||||
if (string.IsNullOrEmpty(svgContent))
|
||||
{
|
||||
string filePath = Path.Combine("DemoImg", "LogoEgalware.svg");
|
||||
svgContent = await System.IO.File.ReadAllTextAsync(filePath);
|
||||
}
|
||||
bytes = Encoding.UTF8.GetBytes(svgContent);
|
||||
break;
|
||||
case Constants.EXECENVIRONMENTS.BEAM:
|
||||
case Constants.EXECENVIRONMENTS.WALL:
|
||||
case Constants.EXECENVIRONMENTS.CABINET:
|
||||
default:
|
||||
mimeType = "image/png";
|
||||
string base64Encoded = _imgService.LoadPng(id, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM);
|
||||
// converto base64
|
||||
bytes = Convert.FromBase64String(base64Encoded);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Info($"pngString | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
//return Ok(decodedString);
|
||||
return File(decodedBytes, "image/png");
|
||||
Log.Info($"{mimeType} | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
return File(bytes, mimeType);
|
||||
}
|
||||
|
||||
private ImageCacheService _imgService { get; set; }
|
||||
private readonly ILogger<ImageController> _logger;
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly ILogger<ImageController> _logger;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private ImageCacheService _imgService { get; set; }
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace Lux.API.Controllers
|
||||
DictExec.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.BOM}");
|
||||
// UID cablato x ora...
|
||||
DictExec.Add("UID", id);
|
||||
DictExec.Add("Jwd", currJwd);
|
||||
DictExec.Add("SerializedData", currJwd);
|
||||
int nId = 1;
|
||||
// da modificare con tipo richiesta...
|
||||
QuestionDTO currArgs = new QuestionDTO(nId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, DictExec);
|
||||
@@ -242,7 +242,7 @@ namespace Lux.API.Controllers
|
||||
DictExec.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.PREVIEW}");
|
||||
// UID cablato x ora...
|
||||
DictExec.Add("UID", id);
|
||||
DictExec.Add("Jwd", currJwd);
|
||||
DictExec.Add("SerializedData", currJwd);
|
||||
int nId = 1;
|
||||
// da modificare con tipo richiesta...
|
||||
QuestionDTO currArgs = new QuestionDTO(nId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, DictExec);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>0.9.2511.0318</Version>
|
||||
<Version>0.9.2511.0417</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -88,7 +88,6 @@ else
|
||||
<tr class="@RowClass(item)">
|
||||
<td class="text-nowrap">
|
||||
<span class="px-1">
|
||||
@* @item.RowNum *@
|
||||
<button class="btn btn-sm btn-primary" @onclick="() => DoSelect(item)"><i class="fa-solid fa-magnifying-glass"></i></button>
|
||||
</span>
|
||||
@if (DisplayMode == EgwCoreLib.Lux.Core.Enums.DisplayMode.Edit)
|
||||
|
||||
@@ -711,9 +711,9 @@ namespace Lux.UI.Components.Compo
|
||||
await reqBomUpdate(EditRecord);
|
||||
}
|
||||
// aggiorno nel dizionari
|
||||
if (reqDict.ContainsKey("Jwd"))
|
||||
if (reqDict.ContainsKey("SerializedData"))
|
||||
{
|
||||
reqDict["Jwd"] = prevJwd;
|
||||
reqDict["SerializedData"] = prevJwd;
|
||||
}
|
||||
|
||||
if (reqDict != null && reqDict.Count > 0)
|
||||
@@ -1058,7 +1058,7 @@ namespace Lux.UI.Components.Compo
|
||||
Dictionary<string, string> DictExec = new Dictionary<string, string>();
|
||||
// verifico parametri da conf envir...
|
||||
var envRec = AllConfEnvir.FirstOrDefault(x => x.EnvirID == currRec.Envir);
|
||||
string serKey = envRec != null ? envRec.SerStrucKey : "Jwd";
|
||||
string serKey = envRec != null ? envRec.SerStrucKey : "SerializedData";
|
||||
// cablata la BOM
|
||||
DictExec.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.BOM}");
|
||||
// UID cablato x ora...
|
||||
@@ -1108,9 +1108,9 @@ namespace Lux.UI.Components.Compo
|
||||
if (EditRecord != null)
|
||||
{
|
||||
// SE contiene il mio Jwd...
|
||||
if (args.ContainsKey("Jwd"))
|
||||
if (args.ContainsKey("SerializedData"))
|
||||
{
|
||||
string serStruct = args["Jwd"];
|
||||
string serStruct = args["SerializedData"];
|
||||
// controllo SE variato...
|
||||
if (!prevJwd.Equals(serStruct) || !EgwCoreLib.Utils.DictUtils.DictAreEqual(reqDict, args))
|
||||
{
|
||||
@@ -1231,13 +1231,20 @@ namespace Lux.UI.Components.Compo
|
||||
|
||||
// parametri richiesta
|
||||
fileArgs.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.PREVIEW}");
|
||||
fileArgs.Add("Btl", rawContent);
|
||||
fileArgs.Add("SubMode", "2");
|
||||
fileArgs.Add("FileName", $"{file.Name}");
|
||||
fileArgs.Add("Height", "1200");
|
||||
fileArgs.Add("Width", "1800");
|
||||
//fileArgs.Add("Btl", rawContent);
|
||||
fileArgs.Add("SerializedData", rawContent);
|
||||
// invio!
|
||||
CalcRequestDTO calcRequestDTO = new CalcRequestDTO();
|
||||
calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM;
|
||||
calcRequestDTO.DictExec = fileArgs;
|
||||
await ICService.CallRestPost($"{apiUrl}/{genericBasePath}", $"{calcTag}/{EditRecord.OfferRowUID}", calcRequestDTO);
|
||||
|
||||
// ora chiedo anche la BOM!
|
||||
|
||||
#if false
|
||||
// salvo in locale il file: SISTEMARE PERMESSI
|
||||
saveFileContent(EditFileRecord.OfferRowUID, trustedFileName, rawContent);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
|
||||
<Version>0.9.2511.0318</Version>
|
||||
<Version>0.9.2511.0417</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>LUX - Web Windows MES</i>
|
||||
<h4>Versione: 0.9.2511.0318</h4>
|
||||
<h4>Versione: 0.9.2511.0417</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
0.9.2511.0318
|
||||
0.9.2511.0417
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>0.9.2511.0318</version>
|
||||
<version>0.9.2511.0417</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user