diff --git a/Lux.API/Controllers/JwdController.cs b/Lux.API/Controllers/JwdController.cs new file mode 100644 index 00000000..f13578a0 --- /dev/null +++ b/Lux.API/Controllers/JwdController.cs @@ -0,0 +1,99 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; + +namespace Lux.API.Controllers +{ + [ApiController] + [Route("api/[controller]")] + public class JwdController : ControllerBase + { + #region Public Constructors + + public JwdController(ILogger logger) + { + _logger = logger; + } + + #endregion Public Constructors + + #region Public Methods + + /// + /// Chiamata POST: riceve Json in formato JwdDto, restituisce jpeg file + /// PUT: api/Jwd/svg/00000000-0000-0000-0000-000000000000 + /// + /// token comunicazione + /// + [HttpPost("jpegfile/{id}")] + public async Task jpegFile(string id, [FromBody] Lux.Core.RestPayload.JwdDTO currJwd) + { + // finta attesa/elaborazione + await Task.Delay(waitDelay); + // path immagine finto... + string fakeImagePath = "DemoImg/Window01.jpg"; + var imageBytes = await System.IO.File.ReadAllBytesAsync(fakeImagePath); + return File(imageBytes, "image/jpeg"); + } + + /// + /// Chiamata POST: riceve Json in formato JwdDto, restituisce png file + /// PUT: api/Jwd/svg/00000000-0000-0000-0000-000000000000 + /// + /// token comunicazione + /// + [HttpPost("pngfile/{id}")] + public async Task pngFile(string id, [FromBody] Core.RestPayload.JwdDTO currJwd) + { + // finta attesa/elaborazione + await Task.Delay(waitDelay); + // path immagine finto... + string fakeImagePath = "DemoImg/Window01.png"; + var imageBytes = await System.IO.File.ReadAllBytesAsync(fakeImagePath); + return File(imageBytes, "image/png"); + } + /// + /// Chiamata POST: riceve Json in formato JwdDto, restituisce svg file + /// PUT: api/Jwd/svg/00000000-0000-0000-0000-000000000000 + /// + /// token comunicazione + /// + [HttpPost("svgfile/{id}")] + public async Task svgFile(string id, [FromBody] Core.RestPayload.JwdDTO currJwd) + { + // finta attesa/elaborazione + await Task.Delay(waitDelay); + // path immagine finto... + string fakeImagePath = "DemoImg/Window01.svg"; + var svgContent = await System.IO.File.ReadAllTextAsync(fakeImagePath); + var bytes = System.Text.Encoding.UTF8.GetBytes(svgContent); + return File(bytes, "image/svg+xml"); + } + + /// + /// Chiamata POST: riceve Json in formato JwdDto, restituisce svg come string + /// PUT: api/Jwd/svg/00000000-0000-0000-0000-000000000000 + /// + /// token comunicazione + /// + [HttpPost("svg/{id}")] + public async Task> svgString(string id, [FromBody] Core.RestPayload.JwdDTO currJwd) + { + // finta attesa/elaborazione + await Task.Delay(waitDelay); + // path immagine finto... + string fakeImagePath = "DemoImg/Window01.svg"; + var svgContent = await System.IO.File.ReadAllTextAsync(fakeImagePath); + return Ok(svgContent); + } + + #endregion Public Methods + + #region Private Fields + + private readonly ILogger _logger; + private int waitDelay = 250; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/Lux.API/DemoImg/Window01.jpg b/Lux.API/DemoImg/Window01.jpg new file mode 100644 index 00000000..96f7ee6c Binary files /dev/null and b/Lux.API/DemoImg/Window01.jpg differ diff --git a/Lux.API/DemoImg/Window01.png b/Lux.API/DemoImg/Window01.png new file mode 100644 index 00000000..318effec Binary files /dev/null and b/Lux.API/DemoImg/Window01.png differ diff --git a/Lux.API/DemoImg/Window01.svg b/Lux.API/DemoImg/Window01.svg new file mode 100644 index 00000000..baff5ad6 --- /dev/null +++ b/Lux.API/DemoImg/Window01.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj new file mode 100644 index 00000000..2adcb589 --- /dev/null +++ b/Lux.API/Lux.API.csproj @@ -0,0 +1,18 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + diff --git a/Lux.API/Lux.API.http b/Lux.API/Lux.API.http new file mode 100644 index 00000000..a467d7b7 --- /dev/null +++ b/Lux.API/Lux.API.http @@ -0,0 +1,6 @@ +@Lux.API_HostAddress = http://localhost:5109 + +GET {{Lux.API_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/Lux.API/Program.cs b/Lux.API/Program.cs new file mode 100644 index 00000000..48863a6d --- /dev/null +++ b/Lux.API/Program.cs @@ -0,0 +1,25 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Lux.API/Properties/launchSettings.json b/Lux.API/Properties/launchSettings.json new file mode 100644 index 00000000..12a5a9e8 --- /dev/null +++ b/Lux.API/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:44205", + "sslPort": 44342 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5109", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7135;http://localhost:5109", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Lux.API/appsettings.Development.json b/Lux.API/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/Lux.API/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Lux.API/appsettings.json b/Lux.API/appsettings.json new file mode 100644 index 00000000..10f68b8c --- /dev/null +++ b/Lux.API/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Lux.All.sln b/Lux.All.sln index b120c896..9f7937b3 100644 --- a/Lux.All.sln +++ b/Lux.All.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lux.UI", "Lux.UI\Lux.UI\Lux EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lux.UI.Client", "Lux.UI\Lux.UI.Client\Lux.UI.Client.csproj", "{ECA4B6A4-692B-41EB-8238-C33C5FB71942}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lux.API", "Lux.API\Lux.API.csproj", "{803F1751-6183-45DE-A914-56EF91AF8637}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,6 +41,10 @@ Global {ECA4B6A4-692B-41EB-8238-C33C5FB71942}.Debug|Any CPU.Build.0 = Debug|Any CPU {ECA4B6A4-692B-41EB-8238-C33C5FB71942}.Release|Any CPU.ActiveCfg = Release|Any CPU {ECA4B6A4-692B-41EB-8238-C33C5FB71942}.Release|Any CPU.Build.0 = Release|Any CPU + {803F1751-6183-45DE-A914-56EF91AF8637}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {803F1751-6183-45DE-A914-56EF91AF8637}.Debug|Any CPU.Build.0 = Debug|Any CPU + {803F1751-6183-45DE-A914-56EF91AF8637}.Release|Any CPU.ActiveCfg = Release|Any CPU + {803F1751-6183-45DE-A914-56EF91AF8637}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Lux.Core/RestPayload/JwdDTO.cs b/Lux.Core/RestPayload/JwdDTO.cs new file mode 100644 index 00000000..72f7bfa9 --- /dev/null +++ b/Lux.Core/RestPayload/JwdDTO.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Lux.Core.RestPayload +{ + public class JwdDTO + { + + public double Width { get; set; } = 800; + public double Height { get; set; } = 800; + + public string ImagePath { get; set; } = @"c:\local\path.jpg"; + } +}