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!
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.