Unfortunately I can't think of a way because as the error implies, Actions only apply to activities with client events.
Ok, what I have done is changed my event to be a client event (not sure what the implications of this are). Now I can create my actions programatically, but I still don't have any lines coming out of my activity.
My guess would be I have to add the lines programatically, but as I mentioned, the line and linerule classes are abstract.
If there is a better way to do this or if I am barking up the wrong tree, please let me know.
Basically, I have an event which executes some C# code, which calls a web service, which will either succeed or fail, that success or failure should then determine the path the process should follow (e.g. retry, log failure, notify user, etc).
Ok, I realised a few truths today. Firstly, using a client event is not what I need, so I have scrapped that idea.
I also discovered that DefaultLine and DefaultLineRule are the concrete implementations of Line and LineRule. So, in order to add lines to my activity, I need to do the following:
DefaultLine success = new DefaultLine();
success.StartActivity = base.Event.Activity;
success.MetaData = "Success";
success.Name = "Success";
DefaultLineRule successRule = new DefaultLineRule();
successRule.PropertyName = "Outcome";
success.LineRule = successRule;
DefaultLine failure = new DefaultLine();
failure.StartActivity = base.Event.Activity;
failure.MetaData = "Failure";
failure.Name = "Failure";
DefaultLineRule failureRule = new DefaultLineRule();
failureRule.PropertyName = "Outcome";
failure.LineRule = failureRule;
base.Extender.Process.Lines.Add(success);
base.Extender.Process.Lines.Add(failure);
Great, brilliant, sensational.
The problem now is that these lines don't appear to be very well behaved lines. When I try to wizard them to find out if the rules have been set properly, I get the process wizard rather than the line wizard.
Ok, no problem, I add these lines to set the wizard correctly:
success.WizardDefinition = new DefaultLineWizardDefinition();
failure.WizardDefinition = new DefaultLineWizardDefinition();
That works up to a point, but then it complains about a missing "WizardElement", so I am stuck again. I have a feeling it may be related to the corresponding propertywizard, but I am not sure.
It turns out that what I really wanted to do was create outcomes, and then based on those outcomes create a bunch of lines with rules on them, depending on what the outcome was. I have no need for actions because actions are intended to be invoked by a user.
To create outcomes, you first need to create an SucceedingRule of type DefaultOutcomeSucceedingRule:
base.Event.Activity.SucceedingRule = new DefaultOutcomeSucceedingRule();
Once you have this rule, you can attach new OutcomeItem objects to it.
OutcomeItem item = new OutcomeItem(rule);
rule.Outcomes.Add(item);
item.Name = "Success";
Finally, once you have your outcomeitems created and attached to your OutcomeSucceedingRule, you can generate the lines and rules automagically through this call:
SourceCode.Workflow.Design.Outcome.Common.GenerateDefaultLinesForOutcomes(rule);
Now, all I need to do is figure out how to trigger an outcome :)