安装
安装NuGet包 "WorkflowCore.Users"
PM> Install-Package WorkflowCore.Users
使用
Use the .UserStep extension method when building your workflow. Parameter 2 is a lambda function to resolve the user or group this step will be assigned to.
在构建工作流时使用. userstep扩展方法。参数2是一个lambda函数,用于解析此步骤将分配给哪些用户或组。
public class HumanWorkflow : IWorkflow
{
...
public void Build(IWorkflowBuilder<object> builder)
{
builder
.StartWith(context => .WriteLine("start"))
.UserTask("Do you approve", data => "MYDOMAIN\\user")
.WithOption("yes", "I approve").Do(then => then
.StartWith(context => Console.WriteLine("You approved"))
)
.WithOption("no", "I do not approve").Do(then => then
.StartWith(context => Console.WriteLine("You did not approve"))
)
.Then(context => Console.WriteLine("end"));
}
}
Get a list of available user actions for a given workflow with the .GetOpenUserActions on the WorkflowHost service.
使用WorkflowHost服务上的. getopenuseractions获取给定工作流的可用用户操作列表。
var openItems = host.GetOpenUserActions(workflowId);
Respond to an open user action for a given workflow with the .PublishUserAction on the WorkflowHost service.
使用WorkflowHost服务上的. publishuseraction响应给定工作流的开放用户操作。
host.PublishUserAction(openItems.First().Key, "MYDOMAIN\\someuser", chosenValue);