Giter Site home page Giter Site logo

thomasduft / microwf Goto Github PK

View Code? Open in Web Editor NEW
172.0 20.0 48.0 5.32 MB

A simple finite state machine (FSM) with workflow character where you define your workflows in code.

Home Page: http://www.tomware.ch/2018/04/30/building-a-simple-workflow-system-with-asp-net-core/

License: MIT License

C# 99.73% Shell 0.04% Dockerfile 0.23%
finite-state-machine fsm dotnet workflows workflow workflow-engine

microwf's Introduction

build NuGet Release BuitlWithDot.Net shield

microwf

A simple finite state machine (FSM) with workflow character where you define your workflows in code.

Holiday approval sample

Holiday Aproval

In code it looks like:

public class HolidayApprovalWorkflow : WorkflowDefinitionBase
{
  public override string Type => nameof(HolidayApprovalWorkflow);

  public override List<Transition> Transitions
  {
    get
    {
      return new List<Transition>
      {
        new Transition {
          State = "New",
          Trigger = "Apply",
          TargetState ="Applied",
          CanMakeTransition = MeApplyingForHolidays
        },
        new Transition {
          State = "Applied",
          Trigger = "Approve",
          TargetState ="Approved",
          CanMakeTransition = BossIsApproving,
          AfterTransition = ThankBossForApproving
        },
        new Transition {
          State = "Applied",
          Trigger = "Reject",
          TargetState ="Rejected"
        }
      };
    }
  }

  private bool MeApplyingForHolidays(TransitionContext context)
  {
    var holiday = context.GetInstance<Holiday>();

    return holiday.Me == "Me";
  }

  private bool BossIsApproving(TransitionContext context)
  {
    var holiday = context.GetInstance<Holiday>();
    
    return holiday.Boss == "NiceBoss";
  }
  
  private void ThankBossForApproving(TransitionContext context)
  {
    // SendMail("Thank you!!!");
  }
}

Running the samples

Assuming you downloaded the sources and opened the directory with VS Code you should be good to go! Ahh and of course you need .NET Core and node.js installed on your development environment.

Running the WebApi backend

  1. Open the integrated terminal in VS Code and type

dotnet build

That ensures you are able to build the dotnet related stuff!

  1. Hit F5 or go to the VS Code Debug tab (Ctrl+Shift+D) and run the WebApi project.

  2. Once the project has started head over to your browser of choice and type in https://localhost:5001.

You should see now the login screen.

For developing purpose there exists a compound task named dev:be-fe ๐Ÿš€ that spins up the WebApi project with the dotnet watch run command as well as the Angular based WebClient project with the npm run start command.

Administrator Web UI

A web interface allows an administrator to search for workflow instances and have a look into the current state.

Admin

Happy poking!!

microwf's People

Contributors

dependabot[bot] avatar mguinness avatar pimboden avatar thomasduft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

microwf's Issues

Dynamic Users from database.

Hello Thomas!
I want to know how i can create dynamic mapping users form database and context. Thank you. And how i can change it to dynamic

Feature Request - Support for Child Tasks

Scenario:

  1. Trainee Creates record (Parent Record#1 - Action: New; Status: New)
  2. Trainee Completes work and submits (Parent Record#1 - Action: Submit; Status: Pending for Review)
  3. Floor Manager Review Task gets created automatically. (Child Record#11 - Status: New)
  4. Branch Manager Review Task gets created automatically. (Child Record#12 - Status: New)
  5. Floor Manager approves the review task. (Child Record#11 - Action: Approve; Status: Approved)
  6. Branch Manager approves the review task. As all the tasks are approved the parent case status changes to Approved (Child Record#12 - Action: Approve; Status: Approved; Parent Record#1 - Status: Approved)

Ef not generating

Hello.
I forked your project, to test it (and eventually add some PRs if needed).
I'm trying to add a complete new Workflow, it seams really easy to do. But when I was almost finished i got stuck because I can't generate the migration.
I get the error

Unable to create an object of type 'DomainContext'. For the different patterns supported at
design time, see...
...
System.MissingMethodException: No parameterless constructor defined for this object. ....
....
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass12_3.b__13()

Whenever I execute
dotnet ef migrations add SoftwareRequest001 -c DomainContext

Im executing it under microwf/samples/WebApi
Am I doing something wrong, or have you any clue what this might be?

BTW: Nice work!
I'm not using the docker, because sadly my company doesn't allow us yet to install docker. I will thou try your solution on my ubunto private PC

enable see history from others

how enable to see your workflow, after dispacthing to others, and control all process? it might be seen or not? thank you

how to use formdef for file

How to use formdef for input type="file" ? so i cannot ound this. I define in model File type, and add input type=file, but i cannot see file in form? hwo i do this?

WebClient not working anymore

After merging your fix for #11 (which did solve the problem) in my fork, my WebClient stopped working.
I then cloned your repo again, and I see that the WebClient form your repo isn't working either,
Since I'm a Vue.Js guy and not an angular expert, I don't now where to fix the error, but I see that the request are done to http://localhost:4200 (The url of the Webclient, not the one of the WebAPI)

http://localhost:4200/api/workflow/definitions

It should go to

https://localhost:5001/api/workflow/definitions

I hardcoded the url in the

microwf/samples/WebClient/src/app/shared/services/api.service.ts

because I don't know where the API base url is saved in angular, but then i get tls errors. (I suppose it's because you removed the certification entry in the settings files.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.