Skip to content

jeremycook/WorkflowCoreWebsite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WorkflowCoreWebsite

A small example of using Workflow Core as part of an ASP.NET Core 5 web application.

Usage:

  1. Clone this repository.
  2. Create a C:\Development\SmtpPickupDirectory directory. Emails generated by the system get placed here.
  3. Open the solution in Visual Studio 2019.
  4. Run WorkflowCoreWebsite project.
  5. Browse to https://localhost:44389/Home/Contact
  6. Submit the contact form.
  7. [GUID].eml files should get added to the C:\Development\SmtpPickupDirectory folder.
  8. Use an email client like Outlook or Thunderbird to view the .eml files.
  9. Watch a couple emails get added to that folder by waiting for a couple minutes. It'll be the same email repeated.
  10. Clicking the "Acknowledge receipt" link in an email will stop the emails from being sent for that contact form submission.

Explanation:

  1. When the form on the Home/Contact page is submitted a "ContactFormWorkflow" is started with the data from the form.
  2. The ContactFormWorkflow.cs waits for a "ContactFormAcknowledged" event, and starts a recurring step in parallel that resends an email with the information in the form every 30 seconds until the email is acknowledged by going to the URL provided by the "Acknowledge receipt" link.
  3. Clicking the "Acknowledge receipt" runs the Home/Ack/{id} controller action, which fires the "ContactFormAcknowledged" with the key (id in the context of the action) that is provided.
  4. The "ContactFormAcknowledged" event triggers wait for event step in the ContactFormWorkflow that then changes ContactForm.Acknowledged from false to true using the Output step. That finishes the wait for step.
  5. The next time the recurring step checks its until condition (remember, it runs every 30 seconds) it will see that ContactForm.Acknowledged is now true, skip performing its action, and finish the step.
  6. The completion of both steps within the parallel step will result in the parallel step finishing.
  7. The parallel step is the last step, once it completes, the workflow completes.

Key classes and methods:

  • Controllers.HomeController.Contact methods
  • Controllers.HomeController.Ack method
  • Workflows.ContactFormWorkflow class
  • Workflows.Steps.EmailAdmins class
  • Startup class

About

A small example of using Workflow Core (https://github.com/danielgerlag/workflow-core) as part of an ASP.NET Core 5 web application.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published