- update NLog
- update nuget
This commit is contained in:
Samuele Locatelli
2024-09-04 09:36:18 +02:00
parent 9819f88532
commit b351d5f521
8 changed files with 159 additions and 118 deletions
+3 -3
View File
@@ -7,9 +7,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NLog" Version="5.1.1" />
<PackageReference Include="YamlDotNet" Version="13.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.3.3" />
<PackageReference Include="YamlDotNet" Version="16.1.0" />
</ItemGroup>
</Project>
+41 -32
View File
@@ -11,48 +11,57 @@
</div>
</div>
<div class="row">
<div class="col-4">
<div class="card">
<div class="card-header d-flex justify-content-between">
<div class="px-1">
<h2>INI</h2>
@if (!fileOk)
{
<div class="alert alert-warning">
No file found
</div>
}
else
{
<div class="col-4">
<div class="card">
<div class="card-header d-flex justify-content-between">
<div class="px-1">
<h2>INI</h2>
</div>
<div class="px-1">
</div>
</div>
<div class="px-1">
<div class="card-body small textConsensed">
<p>@confINI</p>
</div>
</div>
<div class="card-body small textConsensed">
<p>@confINI</p>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-header d-flex justify-content-between">
<div class="px-1">
<h2>JSON</h2>
<div class="col-4">
<div class="card">
<div class="card-header d-flex justify-content-between">
<div class="px-1">
<h2>JSON</h2>
</div>
<div class="px-1">
<button class="btn btn-sm btn-primary" @onclick="() => SaveJson()">Save Json</button>
</div>
</div>
<div class="px-1">
<button class="btn btn-sm btn-primary" @onclick="() => SaveJson()">Save Json</button>
<div class="card-body small textConsensed">
<p>@confJson</p>
</div>
</div>
<div class="card-body small textConsensed">
<p>@confJson</p>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-header d-flex justify-content-between">
<div class="px-1">
<h2>YAML</h2>
<div class="col-4">
<div class="card">
<div class="card-header d-flex justify-content-between">
<div class="px-1">
<h2>YAML</h2>
</div>
<div class="px-1">
<button class="btn btn-sm btn-primary" @onclick="() => SaveYaml()">Save Yaml</button>
</div>
</div>
<div class="px-1">
<button class="btn btn-sm btn-primary" @onclick="() => SaveYaml()">Save Yaml</button>
<div class="card-body small textConsensed">
<p>@confYaml</p>
</div>
</div>
<div class="card-body small textConsensed">
<p>@confYaml</p>
</div>
</div>
</div>
}
</div>
+59 -38
View File
@@ -7,15 +7,23 @@ namespace IobConf.UI.Components
{
#region Public Methods
public async Task LoadINI()
public void LoadINI()
{
checkOutDir();
await Task.Delay(1);
rawFileContent = File.ReadAllText(iniPath);
confINI=getMarkup(rawFileContent);
CurrentConf = IobConfTree.LoadFromINI(iniPath);
updateConf();
if (File.Exists(iniPath))
{
fileOk = true;
rawFileContent = File.ReadAllText(iniPath);
confINI = getMarkup(rawFileContent);
CurrentConf = IobConfTree.LoadFromINI(iniPath);
updateConf();
}
else
{
fileOk = false;
}
}
public async Task SaveJson()
{
checkOutDir();
@@ -32,13 +40,33 @@ namespace IobConf.UI.Components
CurrentConf.SaveYaml(fileName);
}
private void updateConf()
#endregion Public Methods
#region Protected Properties
protected MarkupString confINI { get; set; }
protected MarkupString confJson { get; set; }
protected MarkupString confYaml { get; set; }
protected IobConfTree CurrentConf { get; set; } = new IobConfTree();
protected bool fileOk { get; set; } = false;
protected string iniPath
{
// aggiorno conf JSON/YAML
confJson = getMarkup(CurrentConf.GetJson());
confYaml = getMarkup(CurrentConf.GetYaml());
get => _iniPath;
set
{
if (!iniPath.Equals(value))
{
_iniPath = value;
LoadINI();
}
}
}
#endregion Protected Properties
#region Protected Methods
/// <summary>
/// Converte la stringa in formato markup valido
/// </summary>
@@ -49,40 +77,26 @@ namespace IobConf.UI.Components
return new MarkupString(rawData.Replace("\n", "<br/>").Replace(" ", "&nbsp;&nbsp;"));
}
protected string iniPath = @"C:\temp\DATA\CONF\SIMUL_01.ini";
#endregion Public Methods
#region Protected Fields
protected string baseDir = @"c:\temp\IobConf";
protected string CodIOB = "NewIOB_00";
#endregion Protected Fields
#region Protected Properties
protected MarkupString confINI { get; set; }
protected MarkupString confJson { get; set; }
protected MarkupString confYaml { get; set; }
protected string rawFileContent = "";
protected IobConfTree CurrentConf { get; set; } = new IobConfTree();
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await LoadINI();
LoadINI();
await Task.Delay(1);
}
#endregion Protected Methods
#region Private Fields
private string _iniPath = @"C:\temp\DATA\CONF\SIMUL_01.ini";
private string baseDir = @"c:\temp\IobConf";
private string CodIOB = "NewIOB_00";
private string rawFileContent = "";
#endregion Private Fields
#region Private Methods
private void checkOutDir()
@@ -93,6 +107,13 @@ namespace IobConf.UI.Components
}
}
private void updateConf()
{
// aggiorno conf JSON/YAML
confJson = getMarkup(CurrentConf.GetJson());
confYaml = getMarkup(CurrentConf.GetYaml());
}
#endregion Private Methods
}
}
+4
View File
@@ -12,6 +12,10 @@
<_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS04.pubxml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.12" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IobConf.Core\IobConf.Core.csproj" />
</ItemGroup>
-39
View File
@@ -1,39 +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">
<variable name="logDir" value="${basedir}/logs"/>
<targets>
<target xsi:type="File"
name="f_base"
fileName="${logDir}/${var:codIOB:default=0000}/${shortdate}.log"
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}"
archiveFileName="${logDir}/${var:codIOB:default=0000}/${shortdate}.{###}.log"
archiveNumbering="Sequence"
archiveAboveSize="10240000"
maxArchiveFiles="90"
enableArchiveFileCompression="false"
keepFileOpen="false"
/>
<target xsi:type="File"
name="f_error"
fileName="${logDir}/${var:codIOB:default=0000}/${shortdate}_err.log"
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}${newline}${exception:format=tostring}"
archiveFileName="${logDir}/${var:codIOB:default=0000}/${shortdate}_err.{###}.log"
archiveNumbering="Sequence"
archiveAboveSize="10240000"
maxArchiveFiles="90"
enableArchiveFileCompression="false"
keepFileOpen="false"
/>
</targets>
<rules>
<!-- Logging Levels (Trace, Debug, Info, Warn, Error, Fatal)-->
<logger name="*" minlevel="Trace" maxlevel="Warn" final="true" writeTo="f_base" />
<logger name="*" minlevel="Error" writeTo="f_error" />
</rules>
</nlog>
-5
View File
@@ -19,10 +19,5 @@ namespace IobConf.UI.Pages
{
public partial class Converter
{
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}
}
+8
View File
@@ -1,9 +1,16 @@
using IobConf.UI.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using NLog;
using NLog.Web;
var builder = WebApplication.CreateBuilder(args);
var logger = LogManager.Setup()
.LoadConfigurationFromAppSettings()
.GetCurrentClassLogger();
logger.Info("Program.cs: startup");
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
@@ -28,4 +35,5 @@ app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
logger.Info("Run App");
app.Run();
+44 -1
View File
@@ -5,5 +5,48 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"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"
}
]
}
}