@@ -11,16 +11,13 @@ public class TriliumWorker : BackgroundService
|
|||||||
{
|
{
|
||||||
private readonly Serilog.ILogger _log;
|
private readonly Serilog.ILogger _log;
|
||||||
private readonly AppConfigs _config;
|
private readonly AppConfigs _config;
|
||||||
private readonly IServiceScopeFactory _scopeFactory; // Singleton services cannot directly inject Scoped services.
|
|
||||||
private readonly TriliumService _triliumService;
|
private readonly TriliumService _triliumService;
|
||||||
private readonly Channel<Issue> _issueChannel;
|
private readonly Channel<Issue> _issueChannel;
|
||||||
|
|
||||||
public TriliumWorker(AppConfigs configs, IServiceScopeFactory serviceScopeFactory,
|
public TriliumWorker(AppConfigs configs, TriliumService triliumService, Channel<Issue> issueChannel)
|
||||||
TriliumService triliumService, Channel<Issue> issueChannel)
|
|
||||||
{
|
{
|
||||||
_log = Log.ForContext<TriliumWorker>();
|
_log = Log.ForContext<TriliumWorker>();
|
||||||
_config = configs;
|
_config = configs;
|
||||||
_scopeFactory = serviceScopeFactory;
|
|
||||||
_triliumService = triliumService;
|
_triliumService = triliumService;
|
||||||
_issueChannel = issueChannel;
|
_issueChannel = issueChannel;
|
||||||
}
|
}
|
||||||
@@ -30,15 +27,6 @@ public class TriliumWorker : BackgroundService
|
|||||||
while (!stoppingToken.IsCancellationRequested)
|
while (!stoppingToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
_log.Debug("Worker running at: {time}", DateTimeOffset.Now);
|
_log.Debug("Worker running at: {time}", DateTimeOffset.Now);
|
||||||
|
|
||||||
using var scope = _scopeFactory.CreateScope();
|
|
||||||
var db = scope.ServiceProvider.GetRequiredService<AppDbService>();
|
|
||||||
var unpublishedIssues = await db.GetUnpublishedJiraIssuesAsync(stoppingToken);
|
|
||||||
if (unpublishedIssues != null)
|
|
||||||
{
|
|
||||||
// Publish or update Trilium notes
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.Delay(10 *1000, stoppingToken);
|
await Task.Delay(10 *1000, stoppingToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user