Skip to content

An ABP module that helps define and track business processes.

License

Notifications You must be signed in to change notification settings

EasyAbp/ProcessManagement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProcessManagement

ABP version NuGet NuGet Download Discord online GitHub stars

An ABP module that helps define and track business processes.

Notifications

ProcessDetails

Installation

  1. Install the following NuGet packages. (see how)

    • EasyAbp.ProcessManagement.Application
    • EasyAbp.ProcessManagement.Application.Contracts
    • EasyAbp.ProcessManagement.Domain
    • EasyAbp.ProcessManagement.Domain.Shared
    • EasyAbp.ProcessManagement.EntityFramework
    • EasyAbp.ProcessManagement.HttpApi
    • EasyAbp.ProcessManagement.HttpApi.Client
    • EasyAbp.ProcessManagement.Web
  2. Add DependsOn(typeof(Abp.ProcessManagementXxxModule)) attribute to configure the module dependencies. (see how)

Usage

  1. Define a process and states. For idempotency, stages can only transition from their father state.

    Configure<ProcessManagementOptions>(options =>
    {
        var definition = new ProcessDefinition("MyProcess", new LocalizableString("Process:MyProcess"))
            .AddState(new ProcessStateDefinition(
                name: "Ready",
                displayName: new LocalizableString("State:Ready"),
                fatherStateName: null,
                defaultStateFlag: ProcessStateFlag.Information))
            .AddState(new ProcessStateDefinition(
                name: "Failed",
                displayName: new LocalizableString("State:Failed"),
                fatherStateName: "Ready",
                defaultStateFlag: ProcessStateFlag.Failure))
            .AddState(new ProcessStateDefinition(
                name: "Succeeded",
                displayName: new LocalizableString("State:Succeeded"),
                fatherStateName: "Ready",
                defaultStateFlag: ProcessStateFlag.Success));
    
        options.AddOrUpdateProcessDefinition(definition);
    });
  2. Now you can create a process and update its state anytime, anywhere.

    /*
     * Only a specific user can view this process. You can implement IUserGroupContributor yourself
     * to specify more than one user to view this process, e.g. OrganizationUnitUserGroupContributor.
     */
    var groupKey = await _userIdUserGroupContributor.CreateGroupKeyAsync(adminUser!.Id.ToString());
    
    // Create a process.
    var process1 = await _processManager.CreateAsync(
        new CreateProcessModel(
            processName: "MyProcess",
            correlationId: null, // If null, this value will be auto-set to the value of the Id of the Process entity.
            groupKey: groupKey
        ), Clock.Now);
    
    // When your process is moving forward.
    await _processManager.UpdateStateAsync(process1,
        new UpdateProcessStateModel(
            stateUpdateTime: Clock.Now,
            stateName: "Succeeded"));
    
    // Or add more information.
    await _processManager.UpdateStateAsync(process1,
        new UpdateProcessStateModel(
            stateUpdateTime: Clock.Now,
            stateName: "Succeeded",
            actionName: "Export is done!",
            stateFlag: ProcessStateFlag.Success, // If null, use the default value you defined.
            stateSummaryText: "Congratulations! Export successful."));

    IProcessStateCustom

  3. If you want, you can create user actions for states.

    Configure<ProcessManagementWebOptions>(options =>
    {
        options.Actions.Add(new ProcessStateActionDefinition(
            processName: "MyProcess",
            stateName: "Failed",
            displayName: new LocalizableString("Action:Ping"),
            tableOnClickCallbackCode: "window.alert('Pong')", // Not shown in process list page if null.
            offcanvasOnClickCallbackCode: "window.alert('Pong')", // Not shown in notifications offcanvas if null.
            visibleCheckCode: "abp.auth.isGranted('MyProject.MyProcess.Ping')"));
    });

    Actions1

    Actions2

Road map

  • Use websocket to update notifications. #30
  • Better process details modal.