Take the 2-minute tour ×

I am trying to make an invoice processing workflow and I dabbled with the System.Activities.Rules part of WF4 and I kindof like it. However I would like to take the starting point with the rules instead of kicking of an Activity first.

Like this

Incomming collection of invoices = Invoices

For each invoice put it in an envelope wich will contain Workflow metadata like status, nextActivity etc.

Throw the envelope on a set of Rules that if the condition matches sets the next Activity with a set of parameters like this, IF CustomerID = XYZ then setNextActivity(SplitInvoiceActivity(Customer1,Customer2, Percentage))

then the Activity splits the invoice into 2 invoices and puts them back into the loop and when no rules Applies we set the Envelope state to something like "Processed Done" and it exits.

How would I model this with WF4 activities? Wich type of Activity should I derive from, nativeActivity, CodeActivity etc.

Thx in advance!

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Where is the System.Activities.Rules namespace coming from? There is no such thing in WF4. There is a System.Workflow.Activities.Rules namespace in WF3 but it is completely unrelated to WF4. There are some samples on how to interop between the two technologies and use the WF3 rule engine in a WF4 worklfow but I can't really recommend that approach.

With regards to you activity base class action. In general derive from CodeActivity for the simple kind of activities that do some work and are done. Only when you need more powerful activities that are either composed of multiple child activities or need to be long running and create bookmarks do you need to use a NativeActivity. That said, you can just use NativeActivity all the time because there is nothing in CodeActivity that you can't do in a NativeActivity and there is no real performance difference either.

share|improve this answer
Hi, thx for answering! I didnt now that System.Workflow.Activities.Rules was purely Wf3. So then th e real question would be. How would I use the Wf3 rules to kick of some Wf4 activities? Should I use he new state machine in Wf4 and then create som CodeActivities which then checks then invoice against the rules and which then set the next state? –  Stefan May 29 '11 at 6:13
If you use the state machine or a flow chart really depends on the rest of the workflow and how that is being modeled. Depending on the complexity of the rules you can code them up in a CodeActivity or composite activity. The CodeActivity is easier to work with with complex rules but the composite activity is better at showing a business analyst what is happening. –  Maurice May 29 '11 at 12:05
Thx I´ll try to Create A startActivity which then kicks of an codeActivity from where I read the next Invoice to be processed and then check that against the rules. I will use the externalized ruleset db example contained in the WFSamples to store the rules. The rules will either do some simple operation directly on the on invoice object or kick of some activity which will do the operation. –  Stefan May 30 '11 at 6:35
add comment

Your Answer


