Upgrade packages, fixed potential logging issue?

This commit is contained in:
Roger Far 2024-02-12 19:38:00 -07:00
parent a78ff95643
commit ed01900f69
8 changed files with 25 additions and 58 deletions

View file

@ -1,15 +1,16 @@
using System.ComponentModel;
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using RdtClient.Data.Models.Data;
using RdtClient.Data.Models.Internal;
using Serilog;
namespace RdtClient.Data.Data;
public class SettingData
{
private readonly DataContext _dataContext;
private readonly ILogger<SettingData> _logger;
public static DbSettings Get { get; } = new DbSettings();
@ -18,9 +19,10 @@ public class SettingData
return GetSettings(Get, null).ToList();
}
public SettingData(DataContext dataContext)
public SettingData(DataContext dataContext, ILogger<SettingData> logger)
{
_dataContext = dataContext;
_logger = logger;
}
public async Task Update(IList<SettingProperty> settings)
@ -157,7 +159,7 @@ public class SettingData
return result;
}
private static void SetSettings(IList<Setting> settings, Object defaultSetting, String? parent)
private void SetSettings(IList<Setting> settings, Object defaultSetting, String? parent)
{
var properties = defaultSetting.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
@ -198,7 +200,7 @@ public class SettingData
}
else
{
Log.Warning($"Invalid value for setting {propertyName}: {setting.Value}");
_logger.LogWarning($"Invalid value for setting {propertyName}: {setting.Value}");
}
}
}

View file

@ -8,11 +8,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0">
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View file

@ -2,9 +2,10 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using RdtClient.Data.Data;
using RdtClient.Service.Services;
using Serilog;
namespace RdtClient.Service.BackgroundServices;
@ -22,9 +23,11 @@ public class Startup : IHostedService
public async Task StartAsync(CancellationToken cancellationToken)
{
var version = Assembly.GetEntryAssembly()?.GetName().Version;
Log.Warning($"Starting host on version {version}");
using var scope = _serviceProvider.CreateScope();
var logger = scope.ServiceProvider.GetRequiredService<ILogger<Startup>>();
logger.LogWarning($"Starting host on version {version}");
var dbContext = scope.ServiceProvider.GetRequiredService<DataContext>();
await dbContext.Database.MigrateAsync(cancellationToken);

View file

@ -18,7 +18,7 @@
<PackageReference Include="RD.NET" Version="2.1.4" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="SharpCompress" Version="0.35.0" />
<PackageReference Include="SharpCompress" Version="0.36.0" />
</ItemGroup>
<ItemGroup>

View file

@ -18,16 +18,14 @@ public class TorrentRunner
public static readonly ConcurrentDictionary<Guid, UnpackClient> ActiveUnpackClients = new();
private readonly ILogger<TorrentRunner> _logger;
private readonly ILoggerFactory _loggerFactory;
private readonly Torrents _torrents;
private readonly Downloads _downloads;
private readonly RemoteService _remoteService;
private readonly HttpClient _httpClient;
public TorrentRunner(ILogger<TorrentRunner> logger, ILoggerFactory loggerFactory, Torrents torrents, Downloads downloads, RemoteService remoteService)
public TorrentRunner(ILogger<TorrentRunner> logger, Torrents torrents, Downloads downloads, RemoteService remoteService)
{
_logger = logger;
_loggerFactory = loggerFactory;
_torrents = torrents;
_downloads = downloads;
_remoteService = remoteService;

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>net5.0</TargetFramework>
<ProjectGuid>a8c7f095-89c6-4cd1-afb2-27106f470d62</ProjectGuid>
<SelfContained>false</SelfContained>
<publishUrl>..\..\publish\</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>

View file

@ -1,23 +1,8 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:6500",
"sslPort": 0
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"RdtClient.Web": {
"commandName": "Project",
"launchUrl": "",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},

View file

@ -29,17 +29,17 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0">
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.1" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>