Added IWorkflowLaunchpad to FS watcher worker

This commit is contained in:
Cameron Cowen 2021-09-03 22:18:38 +01:00
parent a2f2b9d9b3
commit 4b4491b559
2 changed files with 10 additions and 1 deletions

View file

@ -7,6 +7,7 @@ using Elsa.Runtime;
using System;
using Elsa.Options;
using Elsa.Activities.File.MapperProfiles;
using Elsa.Services;
// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection
@ -34,6 +35,7 @@ namespace Microsoft.Extensions.DependencyInjection
builder.Services.AddBookmarkProvider<FileCreatedBookmarkProvider>()
.AddAutoMapperProfile<FileSystemEventProfile>()
.AddSingleton<FileSystemWatchersStarter>()
.AddSingleton<Scoped<IWorkflowLaunchpad>>()
.AddStartupTask<StartFileSystemWatchers>();
return builder;

View file

@ -1,5 +1,6 @@
using AutoMapper;
using Elsa.Activities.File.Models;
using Elsa.Services;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@ -13,13 +14,19 @@ namespace Elsa.Activities.File.Services
private readonly ILogger _logger;
private readonly IMapper _mapper;
private readonly FileSystemWatcher _watcher;
private readonly Scoped<IWorkflowLaunchpad> _workflowLaunchpad;
public FileSystemWatcherWorker(string path, string pattern, ILogger<FileSystemWatcherWorker> logger, IMapper mapper)
public FileSystemWatcherWorker(string path,
string pattern,
ILogger<FileSystemWatcherWorker> logger,
IMapper mapper,
Scoped<IWorkflowLaunchpad> workflowLaunchpad)
{
Path = path;
Pattern = pattern;
_logger = logger;
_mapper = mapper;
_workflowLaunchpad = workflowLaunchpad;
_watcher = new FileSystemWatcher()
{
Path = path,