Skip to content

Instantly share code, notes, and snippets.

@sfmskywalker
sfmskywalker / ConfigureJavaScriptEngineWithCustomFunctions1.cs
Last active August 8, 2021 19:27
Building Workflow Driven .NET Applications With Elsa 2 - Part 7
using System;
using System.Threading;
using System.Threading.Tasks;
using Elsa.Scripting.JavaScript.Events;
using Elsa.Scripting.JavaScript.Messages;
using MediatR;
using Microsoft.AspNetCore.StaticFiles;
namespace DocumentManagement.Workflows.Scripting.JavaScript
{
@sfmskywalker
sfmskywalker / ArchiveDocument.cs
Last active August 4, 2021 18:30
Building Workflow Driven .NET Applications With Elsa 2 - Part 6
using System.Threading.Tasks;
using DocumentManagement.Core.Models;
using DocumentManagement.Core.Services;
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Expressions;
using Elsa.Providers.WorkflowStorage;
using Elsa.Services;
using Elsa.Services.Models;
@sfmskywalker
sfmskywalker / StartDocumentWorkflows.cs
Last active August 3, 2021 08:43
Building Workflow Driven .NET Applications With Elsa 2 - Part 5
using System.Threading;
using System.Threading.Tasks;
using DocumentManagement.Core.Events;
using Elsa.Models;
using Elsa.Services;
using MediatR;
using Open.Linq.AsyncExtensions;
namespace DocumentManagement.Workflows.Handlers
{
@sfmskywalker
sfmskywalker / CoreServiceCollectionExtensions.cs
Last active August 2, 2021 17:00
Building Workflow Driven .NET Applications With Elsa 2 - Part 4
using DocumentManagement.Core.Options;
using DocumentManagement.Core.Services;
using Microsoft.Extensions.DependencyInjection;
using Storage.Net;
namespace DocumentManagement.Core.Extensions
{
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddDomainServices(this IServiceCollection services)
@sfmskywalker
sfmskywalker / ServiceCollectionExtensions.cs
Last active August 1, 2021 10:36
Building Workflow Driven .NET Applications With Elsa 2 - Part 3
using System;
using System.IO;
using Elsa.Persistence.EntityFramework.Core.Extensions;
using Elsa.Providers.Workflows;
using Elsa.Server.Hangfire.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Storage.Net;
namespace DocumentManagement.Workflows.Extensions
@sfmskywalker
sfmskywalker / Startup.cs
Last active August 1, 2021 10:22
Building Workflow Driven .NET Applications With Elsa 2 - Part 2
using DocumentManagement.Workflows.Extensions;
using Elsa.Activities.Email.Options;
using Elsa.Activities.Http.Options;
using Elsa.Persistence.EntityFramework.Sqlite;
using Elsa.Server.Hangfire.Extensions;
using Hangfire;
using Hangfire.SQLite;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
class ThisIsMyMonday : IWorkflow
{
private ITrashCleanupService _cleanupService;
private IDogWalkingService _dogWalkingService;
private IDishCleaningService _dishCleaningService;
public CleanTrash(ITrashCleanupService cleanupService, IDogWalkingService dogWalkingService, IDishCleaningService dishCleaningService)
{
_cleanupService = cleanupService;
_dogWalkingService = dogWalkingService;
class CleanTrash : IWorkflow
{
private ITrashCleanupService _cleanupService;
public CleanTrash(ITrashCleanupService cleanupService)
{
_cleanupService = cleanupService;
}
public void Build(IWorkflowBuilder workflow)
@sfmskywalker
sfmskywalker / ElsaWorkflows.snippet.cs
Created December 6, 2020 18:48
Elsa Workflows scheduled task snippet
class MyJob : IWorkflow
{
public void Build(IWorkflowBuilder workflow)
{
workflow
.Cron("* * * * * * *")
.WriteLine(() => $"CRON event at {DateTime.Now}");
}
}
@sfmskywalker
sfmskywalker / QuartzJob.snippet.cs
Created December 6, 2020 18:16
Simple Quartz.NET job example
services.AddQuartz(quartz =>
{
quartz.AddJob<MyJob>(j => j.WithIdentity("MyJob"));
quartz.AddTrigger(t => t
.ForJob("MyJob")
.StartNow()
.WithCronSchedule("* * * * * * *"));
});