From e1342d08c2afdffc928f3414bd6e46d050d3d2c2 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 4 Sep 2024 18:38:33 +0200 Subject: [PATCH] Porting API a Blazor 8 --- GPW.CORE.Api/GPW.CORE.Api.csproj | 2 +- GPW.CORE.Api/Program.cs | 27 +++++------ GPW.CORE.Api/appsettings.json | 45 ++++++++++++++++++- GPW.CORE.WRKLOG/Components/App.razor | 18 ++++++++ .../PublishProfiles/IIS-PROD.pubxml | 6 +-- .../PublishProfiles/IIS-PROD.pubxml.user | 2 +- 6 files changed, 77 insertions(+), 23 deletions(-) diff --git a/GPW.CORE.Api/GPW.CORE.Api.csproj b/GPW.CORE.Api/GPW.CORE.Api.csproj index 94e2069..4569e5b 100644 --- a/GPW.CORE.Api/GPW.CORE.Api.csproj +++ b/GPW.CORE.Api/GPW.CORE.Api.csproj @@ -15,9 +15,9 @@ - + diff --git a/GPW.CORE.Api/Program.cs b/GPW.CORE.Api/Program.cs index 6698073..87b27b6 100644 --- a/GPW.CORE.Api/Program.cs +++ b/GPW.CORE.Api/Program.cs @@ -2,6 +2,8 @@ using GPW.CORE.Api.Data; using GPW.CORE.Data; using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.AspNetCore.Localization; +using NLog; +using NLog.Web; using StackExchange.Redis; using StackExchange.Redis.Extensions.Core.Configuration; using StackExchange.Redis.Extensions.Newtonsoft; @@ -10,6 +12,11 @@ using System.Text.Json.Serialization; var builder = WebApplication.CreateBuilder(args); +var logger = LogManager.Setup() + .LoadConfigurationFromAppSettings() + .GetCurrentClassLogger(); +logger.Info("Program.cs: startup"); + // configuration setup ConfigurationManager configuration = builder.Configuration; // Redis @@ -18,6 +25,7 @@ string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":")) // avvio oggetto shared x redis... var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis); +logger.Info("Conf Redis completata"); // Add services to the container. @@ -39,27 +47,11 @@ builder.Services.Configure(options => options.Sender_Name = configuration["ExternalProviders:MailKit:SMTP:SenderName"] ?? ""; }); -builder.Services.AddStackExchangeRedisCache(options => -{ - configuration.GetSection("Redis").Get(); - //options.Configuration = configuration.GetSection("Redis").GetConnectionString("Redis"); -}); +logger.Info("Conf Email completata"); builder.Services.AddControllers() .AddJsonOptions(c => c.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve); -builder.Services.AddStackExchangeRedisExtensions((options) => -{ - List newConf = new List(); - var currConf = configuration.GetSection("Redis").Get(); - if (currConf != null) - { - newConf.Add(currConf); - } - return newConf; - //return configuration.GetSection("Redis").Get(); -}); - builder.Services.AddSingleton(); builder.Services.AddSingleton(redisMultiplexer); @@ -93,4 +85,5 @@ app.UseAuthorization(); app.MapControllers(); +logger.Info("App run!"); app.Run(); diff --git a/GPW.CORE.Api/appsettings.json b/GPW.CORE.Api/appsettings.json index 6e2e462..6b1e911 100644 --- a/GPW.CORE.Api/appsettings.json +++ b/GPW.CORE.Api/appsettings.json @@ -5,9 +5,52 @@ "Microsoft.AspNetCore": "Warning" } }, + "NLog": { + "variables": { + "baseFileDir": "${basedir}/logs/", + "layout": "${longdate} | ${uppercase:${level}} | ${logger:shortName=false} | ${message}" + }, + // "internalLogLevel": "Info", + // "internalLogFile": "c:\\temp\\internal-nlog.txt", + "extensions": [ + { "assembly": "NLog.Extensions.Logging" }, + { "assembly": "NLog.Web.AspNetCore" } + ], + "throwConfigExceptions": true, + "targets": { + "async": true, + "logfile": { + "type": "File", + "fileName": "${basedir}/logs/${shortdate}.log", + "archiveEvery": "Day", + "archiveFileName": "${basedir}/logs/old/${shortdate}_{#}.log", + "archiveNumbering": "DateAndSequence", + "archiveAboveSize": "1024000", + "archiveDateFormat": "HH", + "maxArchiveFiles": "60", + "maxArchiveDays": "30" + }, + "logconsole": { + "type": "ColoredConsole", + "layout": "${longdate} | ${uppercase:${level}} | ${logger:shortName=true} | ${message}" + } + }, + "rules": [ + { + "logger": "*", + "minLevel": "Trace", + "writeTo": "logconsole" + }, + { + "logger": "*", + "minLevel": "Info", + "writeTo": "logfile" + } + ] + }, "AllowedHosts": "*", "ConnectionStrings": { - "GPW.DB": "Server=W2019-SQL-STEAM;Database=GPW;User ID=UserGPW; Password=Us3rGpw!75x93$77;integrated security=False;MultipleActiveResultSets=True;App=LiMan.API;", + "GPW.DB": "Server=W2019-SQL-STEAM; Database=GPW; User ID=UserGPW; Password=Us3rGpw!75x93$77; integrated security=False; MultipleActiveResultSets=True;App=LiMan.API; TrustServerCertificate=True;", "Redis": "localhost:26379,serviceName=prod,DefaultDatabase=15,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,password=BtN9Py1wtLfLRvmzWnOPJ7RytDM+CLiVsJ/16zduNTlV8IOPGNrtzJSXPUnImA5PqmUMhKaUqo9NdHIG" }, "ExternalProviders": { diff --git a/GPW.CORE.WRKLOG/Components/App.razor b/GPW.CORE.WRKLOG/Components/App.razor index 1ba2c48..ac4731d 100644 --- a/GPW.CORE.WRKLOG/Components/App.razor +++ b/GPW.CORE.WRKLOG/Components/App.razor @@ -26,6 +26,24 @@ + @* Gestione Blazor 6 x autoreconnect, da valutare *@ + @* + *@ + @* *@ diff --git a/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml b/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml index 7bafc40..9bc6278 100644 --- a/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml +++ b/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml @@ -9,12 +9,12 @@ by editing this MSBuild file. In order to learn more about this please visit htt true Release Any CPU - https://office.egalware.com/GPW/CORE.WRKLOG + https://office.egalware.com/GPW/CORE.WRKLOG8 false e4229ee4-ed4f-4507-8058-b01dc3ca1b28 false https://office.egalware.com:8172/MsDeploy.axd - office.egalware.com/GPW/CORE.WRKLOG + office.egalware.com/GPW/CORE.WRKLOG8 true WMSVC @@ -22,6 +22,6 @@ by editing this MSBuild file. In order to learn more about this please visit htt true jenkins <_SavePWD>true - net6.0 + net8.0 \ No newline at end of file diff --git a/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml.user b/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml.user index 31cacb9..2fc0dd7 100644 --- a/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml.user +++ b/GPW.CORE.WRKLOG/Properties/PublishProfiles/IIS-PROD.pubxml.user @@ -7,7 +7,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAw3dMMgC4FUywyOTV2xvCRgAAAAACAAAAAAADZgAAwAAAABAAAADrbAogtj/xpZqylbgs9Hb3AAAAAASAAACgAAAAEAAAAFm1lcdH7oj+NFy4QgZ7q18YAAAAROPsyRR12dhPTKfMEQ5yNCAZJ5K7C4pvFAAAAEFBVTwItjyYP2BlOTsuK1g9myQ8 - True|2023-04-11T08:12:15.0154900Z;False|2023-04-11T10:11:47.1977827+02:00;True|2023-04-11T09:18:55.4555319+02:00;True|2023-04-11T09:16:05.8827677+02:00;True|2022-06-06T12:56:03.5790550+02:00;False|2022-06-06T12:54:19.4739620+02:00;False|2022-06-06T12:53:46.4246554+02:00; + True|2024-09-04T16:21:49.9717603Z||;True|2023-04-11T10:12:15.0154900+02:00||;False|2023-04-11T10:11:47.1977827+02:00||;True|2023-04-11T09:18:55.4555319+02:00||;True|2023-04-11T09:16:05.8827677+02:00||;True|2022-06-06T12:56:03.5790550+02:00||;False|2022-06-06T12:54:19.4739620+02:00||;False|2022-06-06T12:53:46.4246554+02:00||; \ No newline at end of file