- update NLog
- update nuget vari
This commit is contained in:
Samuele Locatelli
2024-09-04 09:06:23 +02:00
parent b982ed20e3
commit 0d1e9f0773
10 changed files with 210 additions and 199 deletions
+7 -8
View File
@@ -6,20 +6,19 @@
<ItemGroup>
<PackageReference Include="DiffMatchPatch" Version="1.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.13">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.13">
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.33" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="6.0.13" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NLog" Version="5.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.3.3" />
</ItemGroup>
<ItemGroup>
+117 -109
View File
@@ -14,46 +14,12 @@ using System.Threading.Tasks;
using System.Diagnostics;
using MP.FileData.Controllers;
using MP.FileData.DTO;
using StackExchange.Redis;
namespace MP.Prog.Data
{
public class FileArchDataService : IDisposable
{
#region Private Fields
private static IConfiguration _configuration;
private static ILogger<FileArchDataService> _logger;
private static List<FileData.DatabaseModels.MacchinaModel> ElencoMacchine = new List<FileData.DatabaseModels.MacchinaModel>();
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private readonly IDistributedCache distributedCache;
private readonly IMemoryCache memoryCache;
/// <summary>
/// Durata assoluta massima della cache
/// </summary>
private int chAbsExp = 15;
/// <summary>
/// Durata della cache in modalità inattiva (non acceduta) prima di venire rimossa
/// NON estende oltre il tempo massimo di validità della cache (chAbsExp)
/// </summary>
private int chSliExp = 5;
#endregion Private Fields
#region Protected Fields
protected static string connStringBBM = "";
protected static string connStringFatt = "";
#endregion Protected Fields
#region Public Fields
public static FileData.Controllers.FileController dbController;
@@ -62,13 +28,15 @@ namespace MP.Prog.Data
#region Public Constructors
public FileArchDataService(IConfiguration configuration, ILogger<FileArchDataService> logger, IMemoryCache memoryCache, IDistributedCache distributedCache)
public FileArchDataService(IConfiguration configuration, ILogger<FileArchDataService> logger, IConnectionMultiplexer redisConnMult)
{
_logger = logger;
_configuration = configuration;
// conf cache
this.memoryCache = memoryCache;
this.distributedCache = distributedCache;
// Conf cache
redisConn = redisConnMult;
redisDb = this.redisConn.GetDatabase();
// conf DB
string connStr = _configuration.GetConnectionString("MP.Prog");
if (string.IsNullOrEmpty(connStr))
@@ -84,60 +52,6 @@ namespace MP.Prog.Data
#endregion Public Constructors
#region Private Properties
private DistributedCacheEntryOptions cacheOpt
{
get
{
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp));
}
}
private DistributedCacheEntryOptions cacheOptLong
{
get
{
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp * 10)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp));
}
}
#endregion Private Properties
#region Internal Methods
internal Task FileApprove(FileData.DatabaseModels.FileModel currItem)
{
return Task.FromResult(dbController.FileModApprove(currItem));
}
internal Task FileDelete(FileData.DatabaseModels.FileModel currItem)
{
return Task.FromResult(dbController.FileDelete(currItem));
}
internal Task FileExport(FileData.DatabaseModels.FileModel currItem)
{
return Task.FromResult(dbController.FileExport(currItem));
}
internal Task FileReject(FileData.DatabaseModels.FileModel currItem)
{
return Task.FromResult(dbController.FileModReject(currItem));
}
internal Task FileUpdate(FileData.DatabaseModels.FileModel updItem)
{
return Task.FromResult(dbController.FileUpdate(updItem));
}
internal void ResetController()
{
dbController.ResetController();
}
#endregion Internal Methods
#region Public Methods
public void Dispose()
@@ -227,24 +141,12 @@ namespace MP.Prog.Data
return Task.FromResult(answ);
}
#if false
protected string getCacheKey(string TableName, SelectData CurrFilter)
{
string answ = $"{TableName}:M_{CurrFilter.IdxMacchina}:A_{CurrFilter.CodArticolo}:K_{CurrFilter.KeyRichiesta}:O_{CurrFilter.IdxOdl}:D_{CurrFilter.DateStart:yyyyMMddHHmm}_{CurrFilter.DateEnd:yyyyMMddHHmm}";
return answ;
}
protected string getCacheKeyPaged(string TableName, SelectData CurrFilter)
{
string answ = $"{TableName}:M_{CurrFilter.IdxMacchina}:A_{CurrFilter.CodArticolo}:K_{CurrFilter.KeyRichiesta}:O_{CurrFilter.IdxOdl}:D_{CurrFilter.DateStart:yyMMddHHmm}_{CurrFilter.DateEnd:yyMMddHHmm}:R_{CurrFilter.FirstRecord}_{CurrFilter.FirstRecord + CurrFilter.NumRecord}";
return answ;
}
#endif
/// <summary>
/// Aggiorna intero archivio scansionando dati x tutte le macchine che hanno un path valido
/// </summary>
/// <param name="numDayPre">Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite</param>
/// <param name="numDayPre">
/// Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite
/// </param>
/// <returns></returns>
public async Task<int> updateAllArchive(int numDayPre, bool forceTag)
{
@@ -262,7 +164,9 @@ namespace MP.Prog.Data
/// Aggiorna archivio di una amcchina scansionando path relativo
/// </summary>
/// <param name="idxMacchina">Codice macchina</param>
/// <param name="numDayPre">Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite</param>
/// <param name="numDayPre">
/// Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite
/// </param>
/// <param name="forceTag">Forza la riverifica dei tags (x update da setup)</param>
/// <param name="fullLog">Scrittura log verboso macchina</param>
/// <returns></returns>
@@ -342,5 +246,109 @@ namespace MP.Prog.Data
}
#endregion Public Methods
#region Internal Methods
internal Task FileApprove(FileData.DatabaseModels.FileModel currItem)
{
return Task.FromResult(dbController.FileModApprove(currItem));
}
internal Task FileDelete(FileData.DatabaseModels.FileModel currItem)
{
return Task.FromResult(dbController.FileDelete(currItem));
}
internal Task FileExport(FileData.DatabaseModels.FileModel currItem)
{
return Task.FromResult(dbController.FileExport(currItem));
}
internal Task FileReject(FileData.DatabaseModels.FileModel currItem)
{
return Task.FromResult(dbController.FileModReject(currItem));
}
internal Task FileUpdate(FileData.DatabaseModels.FileModel updItem)
{
return Task.FromResult(dbController.FileUpdate(updItem));
}
internal void ResetController()
{
dbController.ResetController();
}
#endregion Internal Methods
#region Protected Fields
protected static string connStringBBM = "";
protected static string connStringFatt = "";
#endregion Protected Fields
#region Private Fields
private static IConfiguration _configuration;
private static ILogger<FileArchDataService> _logger;
private static List<FileData.DatabaseModels.MacchinaModel> ElencoMacchine = new List<FileData.DatabaseModels.MacchinaModel>();
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// Durata cache lunga IN SECONDI
/// </summary>
private int cacheTtlLong = 60 * 5;
/// <summary>
/// Durata cache breve IN SECONDI
/// </summary>
private int cacheTtlShort = 60 * 1;
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
private IConnectionMultiplexer redisConn;
//ISubscriber sub = redis.GetSubscriber();
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// </summary>
private IDatabase redisDb = null!;
private Random rnd = new Random();
#endregion Private Fields
#region Private Properties
/// <summary>
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
/// </summary>
private TimeSpan FastCache
{
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
}
/// <summary>
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
/// </summary>
private TimeSpan LongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
}
/// <summary>
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
/// </summary>
private TimeSpan UltraLongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
}
#endregion Private Properties
}
}
+6 -10
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Prog</RootNamespace>
<Version>6.16.2402.1919</Version>
<Version>6.16.2409.0409</Version>
</PropertyGroup>
<ItemGroup>
@@ -18,15 +18,11 @@
<ItemGroup>
<PackageReference Include="DiffMatchPatch" Version="1.0.3" />
<PackageReference Include="Majorsoft.Blazor.Components.Debounce" Version="1.5.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="6.0.13" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.11" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NLog" Version="5.1.1" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.2.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.17" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.3.3" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.12" />
<PackageReference Include="StackExchange.Redis" Version="2.8.12" />
</ItemGroup>
<ItemGroup>
-46
View File
@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue" />
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<!--
Write events to a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
<target xsi:type="File" name="fileTarget" fileName="${basedir}/logs/${shortdate}.log" layout="${longdate} | ${uppercase:${level}} | ${logger:shortName=false} | ${message}" />
<target xsi:type="ColoredConsole" name="consoleTarget" layout="${longdate} | ${uppercase:${level}} | ${logger:shortName=true} | ${message}" />
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
<logger name="*" minlevel="Trace" writeTo="consoleTarget" />
<!--<logger name="Microsoft.*" maxlevel="Info" final="true" />-->
<logger name="*" minlevel="Info" writeTo="fileTarget" />
</rules>
</nlog>
+4 -3
View File
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog;
using NLog.Web;
using System;
using System.Collections.Generic;
@@ -30,9 +31,9 @@ namespace MP.Prog
public static void Main(string[] args)
{
// inclusione NLog:
// https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-5
// https://codewithmukesh.com/blog/logging-with-nlog-in-aspnet-core/
var logger = NLog.Web.NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();
var logger = LogManager.Setup()
.LoadConfigurationFromAppSettings()
.GetCurrentClassLogger();
try
{
logger.Info("MP.Prog Application Starting Up");
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo gestione Programmi MAPO</i>
<h4>Versione: 6.16.2402.1919</h4>
<h4>Versione: 6.16.2409.0409</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.16.2402.1919
6.16.2409.0409
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2402.1919</version>
<version>6.16.2409.0409</version>
<url>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+15 -5
View File
@@ -8,6 +8,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MP.Prog.Data;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -116,12 +117,20 @@ namespace MP.Prog
// options.ConnectionString = elmaConn;
//});
#if false
services.AddStackExchangeRedisCache(options =>
{
//options.Configuration = "localhost:6379";
options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 5, EndPoints = { { "localhost", 6379 } } };
options.InstanceName = "MP:Prog";
});
{
//options.Configuration = "localhost:6379";
options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 5, EndPoints = { { "localhost", 6379 } } };
options.InstanceName = "MP:Prog";
});
#endif
// REDIS setup
string connStringRedis = Configuration.GetConnectionString("Redis");
string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
// avvio oggetto shared x redis...
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
services.AddLocalization();
@@ -134,6 +143,7 @@ namespace MP.Prog
//services.AddSingleton<FileArchDataService>();
services.AddScoped<FileArchDataService>();
services.AddScoped<MessageService>();
services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
}
#endregion Public Methods
+58 -15
View File
@@ -1,18 +1,61 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Tags": {
"DefaultSearch": "##"
},
"ConnectionStrings": {
"DefaultConnection": "Server=SQL2016DEV;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Prog;",
"MP.Prog": "Server=SQL2016DEV;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Prog;",
"Redis": "localhost:26379,serviceName=devel,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false"
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"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": "*",
"Tags": {
"DefaultSearch": "##"
},
"ConnectionStrings": {
"DefaultConnection": "Server=SQL2016DEV;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Prog;",
"MP.Prog": "Server=SQL2016DEV;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Prog;",
"Redis": "localhost:26379,serviceName=devel,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false"
}
}