Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlcf88 committed Aug 4, 2024
1 parent 0f8cd75 commit 37fd2f5
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 7 deletions.
108 changes: 108 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,110 @@
# ProcessManagement

[![ABP version](https://img.shields.io/badge/dynamic/xml?style=flat-square&color=yellow&label=abp&query=%2F%2FProject%2FPropertyGroup%2FAbpVersion&url=https%3A%2F%2Fraw.githubusercontent.com%2FEasyAbp%2FProcessManagement%2Fmain%2FDirectory.Build.props)](https://abp.io)
[![NuGet](https://img.shields.io/nuget/v/EasyAbp.ProcessManagement.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.ProcessManagement.Domain.Shared)
[![NuGet Download](https://img.shields.io/nuget/dt/EasyAbp.ProcessManagement.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.ProcessManagement.Domain.Shared)
[![Discord online](https://badgen.net/discord/online-members/xyg8TrRa27?label=Discord)](https://discord.gg/xyg8TrRa27)
[![GitHub stars](https://img.shields.io/github/stars/EasyAbp/ProcessManagement?style=social)](https://www.github.com/EasyAbp/ProcessManagement)

An ABP module that helps define and track business processes.

![Notifications](/docs/images/notifications.gif)

![ProcessDetails](/docs/images/process-details.jpg)

## Installation

1. Install the following NuGet packages. ([see how](https://github.com/EasyAbp/EasyAbpGuide/blob/master/docs/How-To.md#add-nuget-packages))

* 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](https://github.com/EasyAbp/EasyAbpGuide/blob/master/docs/How-To.md#add-module-dependencies))

## Usage

1. Define a process and states. For idempotency, stages can only transition from their father state.
```csharp
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.
```csharp
/*
* 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](/docs/images/IProcessStateCustom.jpg)
3. If you want, you can create user actions for states.
```csharp
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](/docs/images/actions1.jpg)

![Actions2](/docs/images/actions2.jpg)

## Road map

- [x] Use websocket to update notifications. [#30](https://github.com/EasyAbp/ProcessManagement/issues/30)
- [ ] Better process details modal.
Binary file added docs/images/IProcessStateCustom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/actions1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/actions2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/notifications.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/process-details.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@ public override void ConfigureServices(ServiceConfigurationContext context)
{
var definition = new ProcessDefinition("FakeExport", new LocalizableString("Process:FakeExport"))
.AddState(new ProcessStateDefinition(
"Ready", new LocalizableString("Process:Ready"),
"Ready", new LocalizableString("State:Ready"),
null, ProcessStateFlag.Information))
.AddState(new ProcessStateDefinition(
"FailedToStartExporting", new LocalizableString("Process:FailedToStartExporting"),
"FailedToStartExporting", new LocalizableString("State:FailedToStartExporting"),
"Ready", ProcessStateFlag.Failure))
.AddState(new ProcessStateDefinition(
"Exporting", new LocalizableString("Process:Exporting"),
"Exporting", new LocalizableString("State:Exporting"),
"Ready", ProcessStateFlag.Running))
.AddState(new ProcessStateDefinition(
"ExportFailed", new LocalizableString("Process:ExportFailed"),
"ExportFailed", new LocalizableString("State:ExportFailed"),
"Exporting", ProcessStateFlag.Failure))
.AddState(new ProcessStateDefinition(
"Succeeded", new LocalizableString("Process:Succeeded"),
"Succeeded", new LocalizableString("State:Succeeded"),
"Exporting", ProcessStateFlag.Success));
options.AddOrUpdateProcessDefinition(definition);
Expand All @@ -145,8 +145,8 @@ public override void ConfigureServices(ServiceConfigurationContext context)
options.Actions.Add(new ProcessStateActionDefinition("FakeExport", "ExportFailed",
new LocalizableString("Action:Ping"),
"alert('Pong')",
"alert('Pong')",
"window.alert('Pong')",
"window.alert('Pong')",
null));
});

Expand Down

0 comments on commit 37fd2f5

Please sign in to comment.