Skip to content

Instantly share code, notes, and snippets.

@sfmskywalker
Last active December 7, 2020 19:17
Show Gist options
  • Save sfmskywalker/d2d5c8150c93c5ba128b45acd65d19c9 to your computer and use it in GitHub Desktop.
Save sfmskywalker/d2d5c8150c93c5ba128b45acd65d19c9 to your computer and use it in GitHub Desktop.

Revisions

  1. sfmskywalker revised this gist Dec 7, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions ElsaWorkflows.snippet.cs
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,6 @@ public void Build(IWorkflowBuilder workflow)
    }

    private ValueTask CleanoutTrash(ActivityExecutionContext context) => _cleanupService.CleanupTrashAsync(context.CancellationToken);
    private ValueTask WalkTheDog(ActivityExecutionContext context) => dogWalkingService.WalkTheDogAsync(context.CancellationToken);
    private ValueTask DoTheDishes(ActivityExecutionContext context) => dishCleaningService.DoDishesAsync(context.CancellationToken);
    private ValueTask WalkTheDog(ActivityExecutionContext context) => _dogWalkingService.WalkTheDogAsync(context.CancellationToken);
    private ValueTask DoTheDishes(ActivityExecutionContext context) => _dishCleaningService.DoDishesAsync(context.CancellationToken);
    }
  2. sfmskywalker created this gist Dec 6, 2020.
    27 changes: 27 additions & 0 deletions ElsaWorkflows.snippet.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    class ThisIsMyMonday : IWorkflow
    {
    private ITrashCleanupService _cleanupService;
    private IDogWalkingService _dogWalkingService;
    private IDishCleaningService _dishCleaningService;

    public CleanTrash(ITrashCleanupService cleanupService, IDogWalkingService dogWalkingService, IDishCleaningService dishCleaningService)
    {
    _cleanupService = cleanupService;
    _dogWalkingService = dogWalkingService;
    _dishCleaningService = dishCleaningService;
    }

    public void Build(IWorkflowBuilder workflow)
    {
    workflow
    .Cron("0 0 8 ? * MON *")
    .Then(CleanoutTrash)
    .Timer(Duration.FromHours(2)) // Sleep for 2 hours
    .Then(WalkTheDog)
    .Then(DoTheDishes);
    }

    private ValueTask CleanoutTrash(ActivityExecutionContext context) => _cleanupService.CleanupTrashAsync(context.CancellationToken);
    private ValueTask WalkTheDog(ActivityExecutionContext context) => dogWalkingService.WalkTheDogAsync(context.CancellationToken);
    private ValueTask DoTheDishes(ActivityExecutionContext context) => dishCleaningService.DoDishesAsync(context.CancellationToken);
    }