Prozesse

Erstelle einen Service, wo du die nötigen Dependencies injecten lässt.

public class LoggingProvider : ILoggingProvider { public LoggingProvider( [NotNull] IDataSessionFactory sessionFactory, [NotNull] ILogger logger) { _dataSessionFactory = sessionFactory ?? throw new ArgumentNullException(nameof(sessionFactory)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } public void SampleService(QuinoProcessContext context) { _logger.Information("{name} started", nameof(DeleteLogsAfternDays)); using var session = _dataSessionFactory.CreateSession(); //TODO: Add action context.Log(LogEntryType.Info,$"SampleService didsomething"); }

Logge in den ILogger oder in den Process-Logger (QuinoProcessContext.Log()), der in die DB geschrieben wird.

Baue eine Builder, der von OptionalMetadataBuilder vererbt. Darin kannst du auch die ProcessGroup definieren.

[UsedImplicitly] public class LoggingBuilder : OptionalMetadataBuilder { protected override void AddCoreElements() { var processGroup = Builder.Add.ProcessGroup("Logging"); Builder.Add.Process( nameof(LoggingProvider.DeleteLogsAfternDays), processGroup) .Body<ILoggingProvider>((loggingProvider, context) => loggingProvider.DeleteLogsAfternDays(context)) .Schedule(@"0 0 0 ? * *") .MaxRandomDelayInSeconds(60 * 60 * 3) .AllowManualExecution() .DeleteLogsAfternDays(30); } }

Injecte den Service und den Builder z.B. in QuinoProcessExtensions

public static class QuinoProcessExtensions { public static IServiceCollection AddQuinoProcess([NotNull] this IServiceCollection serviceCollection) { serviceCollection .UseBuilder<QuinoProcessBuilder>() .UseRegisterSingle<IQuinoProcessExecutor, QuinoProcessService>() .UseDataGenerator<QuinoProcessDataGenerator>() .AddQuartz() .AddQuartzHostedService(config => { config.WaitForJobsToComplete = true; config.StartDelay = TimeSpan.FromSeconds(10); }) .AddHostedService(services => services.GetInstance<IQuinoProcessExecutor>() as QuinoProcessService) .UseBuilder<LoggingBuilder>() .UseRegisterSingle<ILoggingProvider, LoggingProvider>(); return serviceCollection; } }

Danach siehst du deinen neuen Process unter Admin->Processes und du kannst beginnen zu testen.

 

image-20240926-154747.png

Â