From c020e5fff3e372aeadc4849bcc8b7404e50e7726 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 23 Apr 2024 09:23:59 +0200 Subject: [PATCH] Aggiunta gestione file statici esterni x PDF (ccon folders!) --- WebDoorCreator.UI/Data/WDCRefreshService.cs | 58 ++++++++++++------- WebDoorCreator.UI/Program.cs | 17 ++++++ WebDoorCreator.UI/WebDoorCreator.UI.csproj | 2 +- WebDoorCreator.UI/appsettings.Production.json | 3 + WebDoorCreator.UI/appsettings.json | 3 + WebDoorCreator.UI/compilerconfig.json | 4 ++ 6 files changed, 66 insertions(+), 21 deletions(-) diff --git a/WebDoorCreator.UI/Data/WDCRefreshService.cs b/WebDoorCreator.UI/Data/WDCRefreshService.cs index 96fac4d..2df4cfd 100644 --- a/WebDoorCreator.UI/Data/WDCRefreshService.cs +++ b/WebDoorCreator.UI/Data/WDCRefreshService.cs @@ -1,5 +1,8 @@ using Microsoft.AspNetCore.Components; using WebDoorCreator.Data; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.Data.Services; +using static Org.BouncyCastle.Math.EC.ECCurve; namespace WebDoorCreator.UI.Data { @@ -7,35 +10,28 @@ namespace WebDoorCreator.UI.Data { #region Public Events - public event Action EA_UpdDoorOp = null!; public event EventHandler EA_ConfDoorOp = delegate { }; + public event Action EA_UpdDoorOp = null!; + #endregion Public Events #region Public Properties - public bool isDoorOpUpd { get => _isDoorOpUpd; set { - _isDoorOpUpd = value; - reportDoorOpUpd(); + _isDoorOpUpd = value; + reportDoorOpUpd(); } } #endregion Public Properties - #region Protected Methods + #region Public Methods - protected void reportDoorOpUpd() - { - if (EA_UpdDoorOp != null) - { - EA_UpdDoorOp?.Invoke(); - } - } public void ReportDoorOpConf(int doorId, int doorOpId, string objId) { DOPEventArgs currOpr = new DOPEventArgs() @@ -50,19 +46,41 @@ namespace WebDoorCreator.UI.Data EA_ConfDoorOp(this, currOpr); } } + + #endregion Public Methods + + #region Public Classes + + public class DOPEventArgs : EventArgs + { + #region Public Properties + + public int DoorId { get; set; } = 0; + public int DoorOpId { get; set; } = 0; + public string ObjectId { get; set; } = ""; + + #endregion Public Properties + } + + #endregion Public Classes + + #region Protected Methods + + protected void reportDoorOpUpd() + { + if (EA_UpdDoorOp != null) + { + EA_UpdDoorOp?.Invoke(); + } + } + #endregion Protected Methods #region Private Properties - private bool _isDoorOpUpd { get; set; } = false; private bool _isDoorOpConf { get; set; } = false; - #endregion Private Properties + private bool _isDoorOpUpd { get; set; } = false; - public class DOPEventArgs : EventArgs - { - public int DoorId { get; set; } = 0; - public int DoorOpId { get; set; } = 0; - public string ObjectId { get; set; } = ""; - } + #endregion Private Properties } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Program.cs b/WebDoorCreator.UI/Program.cs index b5e87c6..c0d8ab9 100644 --- a/WebDoorCreator.UI/Program.cs +++ b/WebDoorCreator.UI/Program.cs @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Identity.UI; using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.AspNetCore.Localization; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.FileProviders; using StackExchange.Redis; using System.Globalization; using System.Text.Json.Serialization; @@ -102,6 +103,22 @@ app.UseHttpsRedirection(); app.UseStaticFiles(); +// gestione static files: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0 +string BasePathPdf = configuration.GetValue("ServerConf:BasePathPdf") ?? configuration.GetValue("OptConf:BasePathPdf") ?? ""; +if (!string.IsNullOrEmpty(BasePathPdf)) +{ + // verifico esista folder disegni + if (Directory.Exists(BasePathPdf)) + { + // gestione cartella x PDF + app.UseStaticFiles(new StaticFileOptions + { + FileProvider = new PhysicalFileProvider(BasePathPdf), + RequestPath = "/docs", + }); + } +} + app.UseRouting(); app.UseAuthentication(); diff --git a/WebDoorCreator.UI/WebDoorCreator.UI.csproj b/WebDoorCreator.UI/WebDoorCreator.UI.csproj index 7a18a3f..59eeead 100644 --- a/WebDoorCreator.UI/WebDoorCreator.UI.csproj +++ b/WebDoorCreator.UI/WebDoorCreator.UI.csproj @@ -3,7 +3,7 @@ net6.0 enable - 0.9.2404.1909 + 0.9.2404.2309 enable aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608 diff --git a/WebDoorCreator.UI/appsettings.Production.json b/WebDoorCreator.UI/appsettings.Production.json index 6d5ef22..ec3041a 100644 --- a/WebDoorCreator.UI/appsettings.Production.json +++ b/WebDoorCreator.UI/appsettings.Production.json @@ -15,6 +15,9 @@ "MaxDayCalcCache": 28, "BaseUrl": "/UI" }, + "ServerConf": { + "BasePathPdf": "U:\\WebDoorSync\\WdcPdf" + }, "CompoBaseDirs": { "CurrCompoDir": "U:\\WebDoorSync\\CurrentComp\\Compo", "NewCompoDir": "U:\\WebDoorSync\\NewComp\\Compo" diff --git a/WebDoorCreator.UI/appsettings.json b/WebDoorCreator.UI/appsettings.json index dd2fa14..3ddd733 100644 --- a/WebDoorCreator.UI/appsettings.json +++ b/WebDoorCreator.UI/appsettings.json @@ -28,6 +28,9 @@ "DisableIdentMigrate": true, "DisableWDCMigrate": true }, + "ServerConf": { + "BasePathPdf": "\\\\IIS04\\WebDoorSync\\WdcPdf" + }, "RuntimeOpt": { "WaitReloadSvg": 100, "VetoRemoveProcessing": 5, diff --git a/WebDoorCreator.UI/compilerconfig.json b/WebDoorCreator.UI/compilerconfig.json index 4447134..142cd84 100644 --- a/WebDoorCreator.UI/compilerconfig.json +++ b/WebDoorCreator.UI/compilerconfig.json @@ -130,5 +130,9 @@ { "outputFile": "Components/FilesMan/CompoCompare.razor.css", "inputFile": "Components/FilesMan/CompoCompare.razor.less" + }, + { + "outputFile": "Components/DoorDef/DoorDefSizingSI.razor.css", + "inputFile": "Components/DoorDef/DoorDefSizingSI.razor.less" } ] \ No newline at end of file