WorkerServiceExample
Overview
This sample project contains a simple agent which scans a directory in File System, optionally retrieving the contents of the files.
Adapter is implemented as the .NET Core BackgroundService
which is a .NET core component of a service: Windows Service
on a Windows machine, Daemon on a Linux machine.
Although this sample uses cross-platform .NET 6, it is currently only compatible with the Windows operating system. This limitation will be removed in subsequent releases.
Running the Sample
This sample adapter can be either installed as Windows Service and started from the Services console, or as a console application.
Running as the Console Application
After the sample is built, the console application WorkerServiceExample.exe
can be started from command prompt or
simply by double-clicking on the .exe
.
The account running the .exe
must be the same as the account running other Fusion Services.
This means that to start the Worker as a console app, all of the Fusion Agent services should be changed to your user account or
you will need to use the PsExec utility.
Installing the Windows Service
After building the sample, open Powershell as the Administrator in the output directory (bin\debug\net7.0-windows
by
default).
Run the following command:
sc create "MyCustomAdapter" -binpath="c:\AdapterSdk\WorkerServiceExample.exe"
MyCustomAdapter
is the service name - it'll be displayed the Services console. You can choose whatever name you
like.
Open Services console (Win
+R
and type services.msc
).
There should be a service with MyCustomAdapter name.
⚠️ Make sure that the Logon As setting has the same account as the rest of Fusion services (it's required for the encryption).
Start the service.
Check the MyAdapter.log
file and verify there're no errors.
You should now be able to scan a repository as explained in the Building and Running Console Application.