[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return to previous step. #373

Open
jmdavid opened this issue Aug 27, 2019 · 5 comments
Open

Return to previous step. #373

jmdavid opened this issue Aug 27, 2019 · 5 comments

Comments

@jmdavid
Copy link
jmdavid commented Aug 27, 2019

Is it possible to get back to previous step?

For example, I have a cleaning process with 3 steps:
-step1 (assignment) for assigning someone to cleaning based on business rules (availibility, proximity, etc).
-step2 (accept or decline) for accepting/rejecting the task (gateway, user task)
if user accept, go to step3 (cleaning), else go back to step1 for assigning task to someone else (then step2 again and so on).

To simulate it, I used a variable in my data named Counter.

I tried this without success:
builder .StartWith<Step1>() .Then<Step2>() .If(data => data.Counter <= 3).Do(then => then .StartWith<Step1>() ) .If(data => data.Counter > 3).Do(then => then .StartWith<Step3>() );

When Counter is set to 5, I get output from Step1, 2 and 3
When Counter is set to 2, I get output from Step1, 2, 1 only (never reach step2 again).

Thanks for project and help.

@ssm-dev
Copy link
ssm-dev commented Aug 28, 2019
builder.StartWith(x => ExecutionResult.Next())
                .While(data => data.Counter <= 3).Do(then => then
                    .StartWith<Step1>()
                    .Then<Step2>()
                )
                .StartWith<Step3>();

@jmdavid
Copy link
Author
jmdavid commented Aug 29, 2019

Hi, thanks but my case is more complex than that, let me explain more precisely.
A clerk is assigned and have the choice to accept/decline; if he declines, we get back to assignment.
If he accept, he move to the room to be cleaned. Once moving, he can get something more urgent to do so he have the option to abandon the task, then we should reassign. If he continue, he begin cleaning room. Again, he can be interrupted and forced to abandon, in that case we should reassign the task to someone else again. The assignment logic should be in step1, other steps are human tasks. Here is an ascii schema:

Assign --> Accept/Decline --> Move/Abandon --> Clean/Abandon --> Finish
└------<-------┘
└---------------------<-------------┘
└-----------------------------------------<----------------┘

Is it possible to achieve this with workflow-core?

Thanks.

@ssm-dev
Copy link
ssm-dev commented Aug 29, 2019

Hi.
I did not use the human tasks, but would try something like this:

class WorkflowData
{
	//...
	public bool IsFinished {get; set;} = false;
	//...
}


builder.StartWith(x => ExecutionResult.Next())
	.While(data => !data.IsFinished).Do(then => then
	    .StartWith<AssignClerk>()	    	
	    .Then<WaitForClerkConfirmation>()
	    
	    .When(d => true).Do(then => then
	    	.StartWith<MoveToRoom>()	    	
	    	.When(d => true).Do(t2 => t2
	    		.StartWith<Clean>()
	    			.Output(d => d.IsFinished, s => s.IsFinished)
	    	)
	    )

	)

@jinbo2015
Copy link

try this(after commited, the indents disappeared, i don't konw why ):

builder .StartWith<Assignment>() .Id("Assignment") .WaitFor("ClerkReply", (data, context) => context.Workflow.Id, data => DateTime.Now) .Output(data => data.ClerkAccepted, step => step.EventData) .If(data => data.ClerkAccepted) .Do(wf => wf .StartWith(a => ExecutionResult.Next()) .WaitFor("ClearMovement", (data, context) => context.Workflow.Id, data => DateTime.Now) .Output(data=>data.ClerkMoved,step=>step.EventData) .If(data=>data.ClerkMoved) .Do(wf2=>wf2 .StartWith(a => ExecutionResult.Next()) .WaitFor("RoomCleaned", (data, context) => context.Workflow.Id, data => DateTime.Now) .Output(data=>data.RoomCleaned,step=>step.EventData) .If(data=>data.RoomCleaned) .Do(wf3=>wf3 .StartWith(a => ExecutionResult.Next()) .Then<Finish>()) .If(data=>data.RoomCleaned==false) .Do(wf3=>wf3 .StartWith(a => ExecutionResult.Next()) .Attach("Assignment")) ) .If(data => data.ClerkMoved == false) .Do(wf2 => wf2 .StartWith(a => ExecutionResult.Next()) .Attach("Assignment")) ) .If(data => data.ClerkAccepted == false) .Do(wf => wf .StartWith(a => ExecutionResult.Next()) .Attach("Assignment"));

@danielgerlag
Copy link
Owner

#486

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants