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 AuthenticatingHandler.cs
public class AuthenticatingHandler<T> : DelegatingHandler where T : ISecurityTokenAccessor
{
private readonly Policy<HttpResponseMessage> _policy;
private readonly T _securityTokenAccessor;
private IAccessToken _accessToken;
private AuthenticationHeaderValue _authenticationHeader;
public AuthenticatingHandler(T securityTokenAccessor)
{
_securityTokenAccessor = securityTokenAccessor;
@sfmskywalker
sfmskywalker / JsonWorkflowProvider.cs
Created Sep 11, 2020
Sample implementation of a JSON file-based workflow provider
View JsonWorkflowProvider.cs
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Elsa.Models;
using Elsa.Serialization;
using Elsa.Services;
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)