Skip to content

Instantly share code, notes, and snippets.

@sfmskywalker
sfmskywalker / ConfigureJavaScriptEngineWithCustomFunctions1.cs
Last active Aug 8, 2021
Building Workflow Driven .NET Applications With Elsa 2 - Part 7
View ConfigureJavaScriptEngineWithCustomFunctions1.cs
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 Aug 4, 2021
Building Workflow Driven .NET Applications With Elsa 2 - Part 6
View ArchiveDocument.cs
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 Aug 3, 2021
Building Workflow Driven .NET Applications With Elsa 2 - Part 5
View StartDocumentWorkflows.cs
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 Aug 2, 2021
Building Workflow Driven .NET Applications With Elsa 2 - Part 4
View CoreServiceCollectionExtensions.cs
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 Aug 1, 2021
Building Workflow Driven .NET Applications With Elsa 2 - Part 3
View ServiceCollectionExtensions.cs
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 Aug 1, 2021
Building Workflow Driven .NET Applications With Elsa 2 - Part 2
View Startup.cs
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;
View ElsaWorkflows.snippet.cs
class ThisIsMyMonday : IWorkflow
{
private ITrashCleanupService _cleanupService;
private IDogWalkingService _dogWalkingService;
private IDishCleaningService _dishCleaningService;
public CleanTrash(ITrashCleanupService cleanupService, IDogWalkingService dogWalkingService, IDishCleaningService dishCleaningService)
{
_cleanupService = cleanupService;
_dogWalkingService = dogWalkingService;
View ElsaWorkflows.snippet.cs
class CleanTrash : IWorkflow
{
private ITrashCleanupService _cleanupService;
public CleanTrash(ITrashCleanupService cleanupService)
{
_cleanupService = cleanupService;
}
public void Build(IWorkflowBuilder workflow)
@sfmskywalker
sfmskywalker / ElsaWorkflows.snippet.cs
Created Dec 6, 2020
Elsa Workflows scheduled task snippet
View ElsaWorkflows.snippet.cs
class MyJob : IWorkflow
{
public void Build(IWorkflowBuilder workflow)
{
workflow
.Cron("* * * * * * *")
.WriteLine(() => $"CRON event at {DateTime.Now}");
}
}
@sfmskywalker
sfmskywalker / QuartzJob.snippet.cs
Created Dec 6, 2020
Simple Quartz.NET job example
View QuartzJob.snippet.cs
services.AddQuartz(quartz =>
{
quartz.AddJob<MyJob>(j => j.WithIdentity("MyJob"));
quartz.AddTrigger(t => t
.ForJob("MyJob")
.StartNow()
.WithCronSchedule("* * * * * * *"));
});