Force _IsWindowsService and change log level
This commit is contained in:
parent
3f7b95c916
commit
58c4b9e487
@ -7,7 +7,8 @@ internal static partial class HelperEAFLog
|
||||
|
||||
internal static bool DeleteFiles(AppSettings appSettings, ILogger<Worker> logger)
|
||||
{
|
||||
IEnumerable<string> files = Directory.EnumerateFiles(appSettings.WatchDirectory, appSettings.EAFLogConfiguration.SearchPattern, SearchOption.AllDirectories);
|
||||
string[] files = Directory.GetFiles(appSettings.WatchDirectory, appSettings.EAFLogConfiguration.SearchPattern, SearchOption.AllDirectories);
|
||||
logger.LogInformation("After {MillisecondsDelay} with search pattern '{SearchPattern}' found {files}", appSettings.MillisecondsDelay, appSettings.EAFLogConfiguration.SearchPattern, files.Length);
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (file.EndsWith(".dll"))
|
||||
@ -19,7 +20,7 @@ internal static partial class HelperEAFLog
|
||||
try
|
||||
{ File.Delete(file); }
|
||||
catch (Exception ex)
|
||||
{ logger.LogError(ex, "Inner loop error!"); }
|
||||
{ logger.LogInformation(ex, "Inner loop error!"); }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using File_Watcher.Models;
|
||||
using Microsoft.Extensions.Hosting.WindowsServices;
|
||||
using System.Data;
|
||||
|
||||
namespace File_Watcher;
|
||||
|
||||
@ -41,6 +42,8 @@ public partial class Worker : BackgroundService
|
||||
|
||||
private async Task Body(CancellationToken stoppingToken)
|
||||
{
|
||||
if (!_IsWindowsService)
|
||||
throw new EvaluateException("Set break point and skip!");
|
||||
while (_IsWindowsService && !stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
Body();
|
||||
|
Loading…
x
Reference in New Issue
Block a user