Ability to update settings. Take effect on next reboot.
This commit is contained in:
parent
e60f795410
commit
1050fa4e54
21 changed files with 953 additions and 146 deletions
41
API/Helpers/Converters/CronConverter.cs
Normal file
41
API/Helpers/Converters/CronConverter.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System.Collections.Generic;
|
||||
using Hangfire;
|
||||
|
||||
namespace API.Helpers.Converters
|
||||
{
|
||||
public static class CronConverter
|
||||
{
|
||||
public static readonly IEnumerable<string> Options = new []
|
||||
{
|
||||
"disabled",
|
||||
"daily",
|
||||
"weekly",
|
||||
};
|
||||
public static string ConvertToCronNotation(string source)
|
||||
{
|
||||
string destination = "";
|
||||
destination = source.ToLower() switch
|
||||
{
|
||||
"daily" => Cron.Daily(),
|
||||
"weekly" => Cron.Weekly(),
|
||||
"disabled" => Cron.Never(),
|
||||
"" => Cron.Never(),
|
||||
_ => destination
|
||||
};
|
||||
|
||||
return destination;
|
||||
}
|
||||
|
||||
public static string ConvertFromCronNotation(string cronNotation)
|
||||
{
|
||||
string destination = "";
|
||||
destination = cronNotation.ToLower() switch
|
||||
{
|
||||
"0 0 31 2 *" => "disabled",
|
||||
_ => destination
|
||||
};
|
||||
|
||||
return destination;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,16 +9,24 @@ namespace API.Helpers.Converters
|
|||
{
|
||||
public ServerSettingDto Convert(IEnumerable<ServerSetting> source, ServerSettingDto destination, ResolutionContext context)
|
||||
{
|
||||
destination = new ServerSettingDto();
|
||||
destination ??= new ServerSettingDto();
|
||||
foreach (var row in source)
|
||||
{
|
||||
switch (row.Key)
|
||||
{
|
||||
case "CacheDirectory":
|
||||
case ServerSettingKey.CacheDirectory:
|
||||
destination.CacheDirectory = row.Value;
|
||||
break;
|
||||
default:
|
||||
case ServerSettingKey.TaskScan:
|
||||
destination.TaskScan = row.Value;
|
||||
break;
|
||||
case ServerSettingKey.LoggingLevel:
|
||||
destination.LoggingLevel = row.Value;
|
||||
break;
|
||||
case ServerSettingKey.TaskBackup:
|
||||
destination.TaskBackup = row.Value;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue