besley / Slickflow

.NET Open Source Workflow Engine, .NET 开源工作流
http://www.slickflow.net
Other
795 stars 248 forks source link

Event driven state transition #4

Closed divyeshBhartiya closed 2 years ago

divyeshBhartiya commented 6 years ago

Hi @besley , I'm facing issues in implementing Event driven State Transition. What I need is, if a workflow/process is at Task 1 and next step is Task 2, then the process should not proceed until an Event/API Request/Message is triggered.

Is that possible in Slickflow? If yes, can I get some sample implementation/code for the same, as I'm unable to find any sample for such a scenario. Also, there is an Enum: EventTriggerEnum,which has almost 10 types of Events, but in the sample code only one of them is used (EventTriggerEnum.Timer), so it would be really helpful if you could provide me with the samples of other Trigger Type as well.

Thanks :-)

besley commented 6 years ago

Hi @divyeshBhartiya , It's a pity that we have the timer event feature firstly, we will realize other event types by the programmers one by one, and the new features will be shown in the process designer when we have done them. But you can describe which event type is your most concern about, we will create a new development plan laterly.

besley commented 5 years ago

The intermediate event node in BPMN is the choice for your requriement, and the delegatetion service we have implemented in the community version, you can found there.

            IWorkflowService wfService = new WorkflowService();
            var wfResult = wfService.CreateRunner(runner.UserID, runner.UserName)
                     .UseApp(runner.AppInstanceID, runner.AppName, runner.AppInstanceCode)
                     .UseProcess(runner.ProcessGUID, runner.Version)
                     .NextStep(runner.NextActivityPerformers)
                     .IfCondition(runner.Conditions)
                     .Subscribe(EventFireTypeEnum.OnActivityExecuting, (activityInstanceID, activityCode, delegateService) => {
                         if (activityCode == "Task1")
                         {
                             delegateService.SetVariable("name", "book-task1");
                             delegateService.SetVariable("amount", "50");
                         }
                         return true;
                     })
                     .Run();