Skip to content

Instantly share code, notes, and snippets.

@sfmskywalker
Last active August 15, 2024 07:42
Show Gist options
  • Select an option

  • Save sfmskywalker/5fd7aeb74c439cd92ef225aaafd75e06 to your computer and use it in GitHub Desktop.

Select an option

Save sfmskywalker/5fd7aeb74c439cd92ef225aaafd75e06 to your computer and use it in GitHub Desktop.

Revisions

  1. sfmskywalker revised this gist Aug 1, 2021. 1 changed file with 122 additions and 0 deletions.
    122 changes: 122 additions & 0 deletions hello-world.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,122 @@
    {
    "$id": "1",
    "definitionId": "21c8e4c36dee486d8fca566881ea79b4",
    "versionId": "05f9f30ee43147b5b2edbb5f723f94d2",
    "name": "HelloWorld",
    "displayName": "Hello World",
    "version": 1,
    "variables": {
    "$id": "2",
    "data": {}
    },
    "customAttributes": {
    "$id": "3",
    "data": {}
    },
    "isSingleton": false,
    "persistenceBehavior": "WorkflowBurst",
    "deleteCompletedInstances": false,
    "isPublished": true,
    "isLatest": true,
    "activities": [
    {
    "$id": "4",
    "activityId": "06b927c7-be55-4958-97b5-ab84393eebc6",
    "type": "HttpEndpoint",
    "displayName": "HTTP Endpoint",
    "persistWorkflow": false,
    "loadWorkflowContext": false,
    "saveWorkflowContext": false,
    "properties": [
    {
    "$id": "5",
    "name": "Path",
    "expressions": {
    "$id": "6",
    "Literal": "/hello-world"
    }
    },
    {
    "$id": "7",
    "name": "Methods",
    "expressions": {
    "$id": "8",
    "Json": "[\"GET\"]"
    }
    },
    {
    "$id": "9",
    "name": "ReadContent",
    "expressions": {
    "$id": "10"
    }
    },
    {
    "$id": "11",
    "name": "TargetType",
    "expressions": {
    "$id": "12"
    }
    }
    ],
    "propertyStorageProviders": {}
    },
    {
    "$id": "13",
    "activityId": "bbca4608-e55f-4d81-a87d-f2c10b336f58",
    "type": "WriteHttpResponse",
    "displayName": "HTTP Response",
    "persistWorkflow": false,
    "loadWorkflowContext": false,
    "saveWorkflowContext": false,
    "properties": [
    {
    "$id": "14",
    "name": "Content",
    "expressions": {
    "$id": "15",
    "Literal": "Hello World"
    }
    },
    {
    "$id": "16",
    "name": "ContentType",
    "expressions": {
    "$id": "17"
    }
    },
    {
    "$id": "18",
    "name": "StatusCode",
    "expressions": {
    "$id": "19"
    }
    },
    {
    "$id": "20",
    "name": "CharSet",
    "expressions": {
    "$id": "21"
    }
    },
    {
    "$id": "22",
    "name": "ResponseHeaders",
    "expressions": {
    "$id": "23"
    }
    }
    ],
    "propertyStorageProviders": {}
    }
    ],
    "connections": [
    {
    "$id": "24",
    "sourceActivityId": "06b927c7-be55-4958-97b5-ab84393eebc6",
    "targetActivityId": "bbca4608-e55f-4d81-a87d-f2c10b336f58",
    "outcome": "Done"
    }
    ],
    "id": "05f9f30ee43147b5b2edbb5f723f94d2"
    }
  2. sfmskywalker revised this gist Aug 1, 2021. 2 changed files with 49 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions ServiceCollectionExtensions-diff.cs
    Original file line number Diff line number Diff line change
    @@ -1,5 +0,0 @@
    // Get directory path to current assembly.
    var currentAssemblyPath = Path.GetDirectoryName(typeof(ServiceCollectionExtensions).Assembly.Location);

    // Configure Storage for BlobStorageWorkflowProvider with a directory on disk from where to load workflow definition JSON files from the local "Workflows" folder.
    services.Configure<BlobStorageWorkflowProviderOptions>(options => options.BlobStorageFactory = () => StorageFactory.Blobs.DirectoryFiles(Path.Combine(currentAssemblyPath, "Workflows")));
    49 changes: 49 additions & 0 deletions ServiceCollectionExtensions.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    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
    {
    public static class ServiceCollectionExtensions
    {
    public static IServiceCollection AddWorkflowServices(this IServiceCollection services, Action<DbContextOptionsBuilder> configureDb)
    {
    return services.AddElsa(configureDb);
    }

    private static IServiceCollection AddElsa(this IServiceCollection services, Action<DbContextOptionsBuilder> configureDb)
    {
    services
    .AddElsa(elsa => elsa

    // Use EF Core's SQLite provider to store workflow instances and bookmarks.
    .UseEntityFrameworkPersistence(configureDb)

    // Use Console activities for testing & demo purposes.
    .AddConsoleActivities()

    // Use Hangfire to dispatch workflows from.
    .UseHangfireDispatchers()

    // Configure Email activities.
    .AddEmailActivities()

    // Configure HTTP activities.
    .AddHttpActivities()
    );

    // Get directory path to current assembly.
    var currentAssemblyPath = Path.GetDirectoryName(typeof(ServiceCollectionExtensions).Assembly.Location);

    // Configure Storage for BlobStorageWorkflowProvider with a directory on disk from where to load workflow definition JSON files from the local "Workflows" folder.
    services.Configure<BlobStorageWorkflowProviderOptions>(options => options.BlobStorageFactory = () => StorageFactory.Blobs.DirectoryFiles(Path.Combine(currentAssemblyPath, "Workflows")));

    return services;
    }
    }
    }
  3. sfmskywalker created this gist Aug 1, 2021.
    5 changes: 5 additions & 0 deletions ServiceCollectionExtensions-diff.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    // Get directory path to current assembly.
    var currentAssemblyPath = Path.GetDirectoryName(typeof(ServiceCollectionExtensions).Assembly.Location);

    // Configure Storage for BlobStorageWorkflowProvider with a directory on disk from where to load workflow definition JSON files from the local "Workflows" folder.
    services.Configure<BlobStorageWorkflowProviderOptions>(options => options.BlobStorageFactory = () => StorageFactory.Blobs.DirectoryFiles(Path.Combine(currentAssemblyPath, "Workflows")));