diff --git a/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs b/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs index da37c9b0..0b836c52 100644 --- a/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs +++ b/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs @@ -102,6 +102,8 @@ namespace EgwCoreLib.Lux.Data // aggiunta servizi finali Singleton... services.TryAddSingleton(); services.TryAddSingleton(); + services.TryAddSingleton(); + services.TryAddSingleton(); //services.TryAddSingleton(); diff --git a/EgwCoreLib.Lux.Data/Services/CalcRequestService.cs b/EgwCoreLib.Lux.Data/Services/General/CalcRequestService.cs similarity index 96% rename from EgwCoreLib.Lux.Data/Services/CalcRequestService.cs rename to EgwCoreLib.Lux.Data/Services/General/CalcRequestService.cs index 6a0c069c..54415f83 100644 --- a/EgwCoreLib.Lux.Data/Services/CalcRequestService.cs +++ b/EgwCoreLib.Lux.Data/Services/General/CalcRequestService.cs @@ -2,9 +2,9 @@ using NLog; using RestSharp; -namespace EgwCoreLib.Lux.Data.Services +namespace EgwCoreLib.Lux.Data.Services.General { - public class CalcRequestService + public class CalcRequestService : ICalcRequestService { #region Public Constructors diff --git a/EgwCoreLib.Lux.Data/Services/FileService.cs b/EgwCoreLib.Lux.Data/Services/General/FileService.cs similarity index 98% rename from EgwCoreLib.Lux.Data/Services/FileService.cs rename to EgwCoreLib.Lux.Data/Services/General/FileService.cs index 2ed5a9ae..50464b81 100644 --- a/EgwCoreLib.Lux.Data/Services/FileService.cs +++ b/EgwCoreLib.Lux.Data/Services/General/FileService.cs @@ -1,12 +1,12 @@ using Microsoft.Extensions.Configuration; using NLog; -namespace EgwCoreLib.Lux.Data.Services +namespace EgwCoreLib.Lux.Data.Services.General { /// /// Gestione IO File-based /// - public class FileService + public class FileService : IFileService { #region Public Constructors @@ -98,6 +98,7 @@ namespace EgwCoreLib.Lux.Data.Services } return answ; } + /// /// Esegue salvataggio del file ricevuto path, securename e content /// @@ -127,6 +128,7 @@ namespace EgwCoreLib.Lux.Data.Services } return answ; } + /// /// Effettua salvataggio di un ContentStream generico (non semplice string) /// @@ -161,7 +163,6 @@ namespace EgwCoreLib.Lux.Data.Services return answ; } - #endregion Public Methods #region Private Fields diff --git a/EgwCoreLib.Lux.Data/Services/General/ICalcRequestService.cs b/EgwCoreLib.Lux.Data/Services/General/ICalcRequestService.cs new file mode 100644 index 00000000..e877c66b --- /dev/null +++ b/EgwCoreLib.Lux.Data/Services/General/ICalcRequestService.cs @@ -0,0 +1,24 @@ +using Microsoft.Extensions.Configuration; +using RestSharp; + +namespace EgwCoreLib.Lux.Data.Services.General +{ + /// + /// Interfaccia servizio richiesta calcolo + /// + public interface ICalcRequestService + { + #region Public Methods + + /// + /// Effettua una generica chiamata ApiRest POST + /// + /// URL Api di base + /// Endpoint richiesta + /// Corpo Json trasmesso con richiesta + /// Risposta dalla chiamata REST + Task CallRestPost(string ApiUrl, string ApiRequest, object rawBody); + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/EgwCoreLib.Lux.Data/Services/General/IFileService.cs b/EgwCoreLib.Lux.Data/Services/General/IFileService.cs new file mode 100644 index 00000000..fb4c6a00 --- /dev/null +++ b/EgwCoreLib.Lux.Data/Services/General/IFileService.cs @@ -0,0 +1,57 @@ +using System.IO; + +namespace EgwCoreLib.Lux.Data.Services.General +{ + /// + /// Interfaccia servizio gestione IO File-based + /// + public interface IFileService + { + #region Public Methods + + /// + /// Eliminazione file + /// + /// Cartella del file + /// Nome secure del file + /// True se eliminato con successo + bool DeleteOldFile(string folderPath, string secureName); + + /// + /// Restituisce il contenuto del file salvato + /// + /// Cartella del file + /// Nome secure del file + /// Contenuto del file come stringa + string LoadFileContent(string folderPath, string secureName); + + /// + /// Salva contenuto file (sincrono) + /// + /// Cartella del file + /// Nome secure del file + /// Contenuto file + /// True se salvato con successo + bool SaveFileContent(string folderPath, string secureName, string content); + + /// + /// Salva contenuto file asincrono + /// + /// Cartella del file + /// Nome secure del file + /// Contenuto file + /// True se salvato con successo + Task SaveFileContentAsync(string folderPath, string secureName, string content); + + /// + /// Salva stream file generico + /// + /// Cartella del file + /// Nome secure del file + /// Stream contenitore dati + /// True se salvato con successo + Task SaveFileStreamAsync(string folderPath, string secureName, Stream contentStream); + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/EgwCoreLib.Lux.Data/Services/General/ImageCacheService.cs b/EgwCoreLib.Lux.Data/Services/General/ImageCacheService.cs index 85001230..028826b0 100644 --- a/EgwCoreLib.Lux.Data/Services/General/ImageCacheService.cs +++ b/EgwCoreLib.Lux.Data/Services/General/ImageCacheService.cs @@ -34,7 +34,7 @@ namespace EgwCoreLib.Lux.Data.Services.General // conf tag x cache liveTag = _config.GetValue("ServerConf:ImageLiveTag") ?? "svg"; cacheTag = _config.GetValue("ServerConf:ImageFileTag") ?? "svgfile"; - calcTag = _config.GetValue("ServerConf:ImageCalcTag") ?? "svg-preview"; + imgCalcTag = _config.GetValue("ServerConf:ImageCalcTag") ?? "live"; // verifico la url base apiUrl = _config.GetValue("ServerConf:Prog.ApiUrl") ?? "https://iis01.egalware.com/lux/srv/api"; imgBasePath = _config.GetValue("ServerConf:ImageBaseUrl") ?? "window"; @@ -548,7 +548,7 @@ namespace EgwCoreLib.Lux.Data.Services.General private readonly string cacheTag = "svgfile"; - private readonly string calcTag = "svgpreview"; + private readonly string imgCalcTag = "live"; private readonly string chBom = "lux:bom"; @@ -572,7 +572,7 @@ namespace EgwCoreLib.Lux.Data.Services.General private readonly string chSvg = "lux:svg:img"; - private readonly string chUpdate = "lux::update"; + private readonly string chUpdate = "lux:update"; private readonly string imgBasePath = ""; diff --git a/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs b/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs index bc0a5419..99c652b8 100644 --- a/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs +++ b/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs @@ -86,7 +86,7 @@ namespace Lux.UI.Components.Compo.Config private ICalcRuidService CRService { get; set; } = null!; [Inject] - private CalcRequestService CService { get; set; } = null!; + private ICalcRequestService CService { get; set; } = null!; [Inject] private DataLayerServices DLService { get; set; } = null!; diff --git a/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs b/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs index ef0891c9..0b6785f1 100644 --- a/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs +++ b/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs @@ -97,7 +97,7 @@ namespace Lux.UI.Components.Compo.Config private ICalcRuidService CRService { get; set; } = null!; [Inject] - private CalcRequestService CService { get; set; } = null!; + private ICalcRequestService CService { get; set; } = null!; private string cssBtnThresh { diff --git a/Lux.UI/Components/Compo/Item/SellingItemEdit.razor.cs b/Lux.UI/Components/Compo/Item/SellingItemEdit.razor.cs index a4c18429..33ca2b27 100644 --- a/Lux.UI/Components/Compo/Item/SellingItemEdit.razor.cs +++ b/Lux.UI/Components/Compo/Item/SellingItemEdit.razor.cs @@ -1,6 +1,7 @@ using EgwCoreLib.Lux.Data.DbModel.Items; using EgwCoreLib.Lux.Data.DbModel.Job; using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.General; using EgwCoreLib.Lux.Data.Services.Items; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; @@ -28,16 +29,19 @@ namespace Lux.UI.Components.Compo.Item #endregion Public Properties + #region Private Fields + + private string folderPath = "static"; + + #endregion Private Fields + #region Private Properties [Inject] private DataLayerServices DLService { get; set; } = null!; [Inject] - private ISellingItemService SIService { get; set; } = null!; - - [Inject] - private FileService FService { get; set; } = null!; + private IFileService FService { get; set; } = null!; /// /// Wrapper per valore margine in modalità decimal @@ -54,6 +58,9 @@ namespace Lux.UI.Components.Compo.Item } } + [Inject] + private ISellingItemService SIService { get; set; } = null!; + #endregion Private Properties #region Private Methods @@ -75,9 +82,6 @@ namespace Lux.UI.Components.Compo.Item return EC_Updated.InvokeAsync(CurrRecord); } - - private string folderPath = "static"; - private List ListEnvir() { var tmpList = Enum.GetValues(typeof(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS)) diff --git a/Lux.UI/Components/Compo/OfferCommonPar.razor.cs b/Lux.UI/Components/Compo/OfferCommonPar.razor.cs index 0ccc837c..3e665ecc 100644 --- a/Lux.UI/Components/Compo/OfferCommonPar.razor.cs +++ b/Lux.UI/Components/Compo/OfferCommonPar.razor.cs @@ -105,7 +105,7 @@ namespace Lux.UI.Components.Compo private ICalcRuidService CRService { get; set; } = null!; [Inject] - private CalcRequestService CService { get; set; } = null!; + private ICalcRequestService CService { get; set; } = null!; [Inject] private DataLayerServices DLService { get; set; } = null!; diff --git a/Lux.UI/Components/Compo/OfferRowMan.razor.cs b/Lux.UI/Components/Compo/OfferRowMan.razor.cs index 1791ad04..32063070 100644 --- a/Lux.UI/Components/Compo/OfferRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OfferRowMan.razor.cs @@ -301,7 +301,7 @@ namespace Lux.UI.Components.Compo private ICalcRuidService CRService { get; set; } = default!; [Inject] - private CalcRequestService CService { get; set; } = default!; + private ICalcRequestService CService { get; set; } = default!; [Inject] private IWebHostEnvironment CurrEnv { get; set; } = default!; @@ -316,7 +316,7 @@ namespace Lux.UI.Components.Compo private IEnvirParamService EPService { get; set; } = null!; [Inject] - private FileService FService { get; set; } = default!; + private IFileService FService { get; set; } = default!; /// /// Costo totale calcolato x offerta diff --git a/Lux.UI/Components/Compo/OrderRowMan.razor.cs b/Lux.UI/Components/Compo/OrderRowMan.razor.cs index 75f4f964..6910fdc6 100644 --- a/Lux.UI/Components/Compo/OrderRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OrderRowMan.razor.cs @@ -359,7 +359,7 @@ namespace Lux.UI.Components.Compo private ICalcRuidService CRService { get; set; } = null!; [Inject] - private CalcRequestService CService { get; set; } = null!; + private ICalcRequestService CService { get; set; } = null!; [Inject] private IConfWoodService CWService { get; set; } = null!; diff --git a/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs b/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs index 6a045c9d..a53d8ca9 100644 --- a/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs +++ b/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs @@ -269,7 +269,7 @@ namespace Lux.UI.Components.Compo.Templates private ICalcRuidService CRService { get; set; } = null!; [Inject] - private CalcRequestService CService { get; set; } = null!; + private ICalcRequestService CService { get; set; } = null!; [Inject] private IConfGlassService CGService { get; set; } = null!; diff --git a/Lux.UI/Components/Compo/Templates/TemplateRowMan.razor.cs b/Lux.UI/Components/Compo/Templates/TemplateRowMan.razor.cs index c75bc1e2..0e17b4e0 100644 --- a/Lux.UI/Components/Compo/Templates/TemplateRowMan.razor.cs +++ b/Lux.UI/Components/Compo/Templates/TemplateRowMan.razor.cs @@ -1,7 +1,8 @@ using EgwCoreLib.Lux.Data.DbModel.Catalog; using EgwCoreLib.Lux.Data.DbModel.Items; -using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.General; using Microsoft.AspNetCore.Components; + using Microsoft.AspNetCore.Components.Forms; namespace Lux.UI.Components.Compo.Templates @@ -35,25 +36,6 @@ namespace Lux.UI.Components.Compo.Templates #region Private Fields - /// - /// Check visibilità upload dato il selling item ID corrente - /// - /// - /// - private bool ShowImgUpload(int sellItemId) - { - bool answ = false; - if (sellItemId > 0) - { - var selRec = ListSellinglItems.FirstOrDefault(x => x.SellingItemID == sellItemId); - if (selRec != null) - { - answ = selRec.ImgType != EgwCoreLib.Lux.Core.Enums.ImageType.Calculated; - } - } - return answ; - } - /// /// Path da parent record /// @@ -66,7 +48,7 @@ namespace Lux.UI.Components.Compo.Templates #region Private Properties [Inject] - private FileService FService { get; set; } = null!; + private IFileService FService { get; set; } = null!; #endregion Private Properties @@ -91,6 +73,25 @@ namespace Lux.UI.Components.Compo.Templates return EC_Updated.InvokeAsync(CurrRecord); } + /// + /// Check visibilità upload dato il selling item ID corrente + /// + /// + /// + private bool ShowImgUpload(int sellItemId) + { + bool answ = false; + if (sellItemId > 0) + { + var selRec = ListSellinglItems.FirstOrDefault(x => x.SellingItemID == sellItemId); + if (selRec != null) + { + answ = selRec.ImgType != EgwCoreLib.Lux.Core.Enums.ImageType.Calculated; + } + } + return answ; + } + private async Task UploadFile(InputFileChangeEventArgs e) { IBrowserFile file = e.File; diff --git a/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs b/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs index b0cceed6..8cfaf328 100644 --- a/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs +++ b/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs @@ -75,7 +75,7 @@ namespace Lux.UI.Components.Pages private ICalcRuidService CRService { get; set; } = null!; [Inject] - private CalcRequestService CService { get; set; } = null!; + private ICalcRequestService CService { get; set; } = null!; [Inject] private DataLayerServices DLService { get; set; } = null!; diff --git a/Lux.UI/Program.cs b/Lux.UI/Program.cs index ce01fed2..7622c30b 100644 --- a/Lux.UI/Program.cs +++ b/Lux.UI/Program.cs @@ -185,8 +185,6 @@ builder.Services.AddIdentityCore(options => options.SignIn.Requ builder.Services.AddSingleton, IdentityNoOpEmailSender>(); // Aggiunta servizi specifici -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); builder.Services.AddSingleton(); // aggiunta componenti Radzen