void ProcessResult(IRunState context, WorkflowRun run) { if (run.WorkflowRunStatus_Enum != WorkflowRunState_Enumeration.WorkflowRunCompleted) { throw new InnerWorkflowFailedException(string.Format("Inner workflow '{0}' failed", run.WorkflowBeingRun.Name)); } var proxyExitPoint = run.GetExitPoint(); var matchingExitPoint = context.Metadata.GetExitpointsForActivity(ActivityInstance.Id).SingleOrDefault(ep => ep.Name == proxyExitPoint.Name); if (matchingExitPoint == null) { throw new WorkflowRunException("Workflow proxy returned using an exit point that doesn't match anything in the parent"); } context.ExitPointId = matchingExitPoint; var outputs = run.GetOutput(); var outArgs = ActivityInstance.GetOutputArguments(); // copy the values from the results into the arguments witht eh same name foreach (var arg in outArgs) { var name = arg.Name; object value = null; if (outputs.TryGetValue(name, out value)) { context.SetArgValue(ActivityInstance, arg, value); } } }
Notification RunNotify(IEntity person, TwilioNotifier notifier, bool waitForReplies, IEntity linkTo = null, string replyWorkflowString = null, Workflow replyWorkflow = null) { var inputs = new Dictionary <string, object> { { "People", person.ToEnumerable() }, { "LinkToRecord", linkTo }, }; var wf = new Workflow { Name = "RunNotify " + DateTime.UtcNow.ToString() }; wf .AddDefaultExitPoint() .AddInput <ResourceListArgument>("People", Person.Person_Type) .AddInput <ResourceArgument>("LinkToRecord", UserResource.UserResource_Type) .AddOutput <ResourceArgument>("NotificationRecord", Notification.Notification_Type) .AddNotify( "Notify", "People", "'Test'", waitForReplies, linkToRecordExpression: "LinkToRecord", replyMap: replyWorkflowString == null ? null : new Dictionary <string, Workflow> { { replyWorkflowString, replyWorkflow } }) .AddAssignToVar("Assign", "[Notify_Notification Record]", "NotificationRecord"); wf.Save(); ToDelete.Add(wf.Id); using (var scope = Factory.Current.BeginLifetimeScope(builder => { builder.Register(c => new TenantSmsNotifier(notifier.Id)).As <INotifier>(); })) using (Factory.SetCurrentScope(scope)) { WorkflowRun run = null; using (new TestWfRunContext()) { run = RunWorkflow(wf, inputs); run.Save(); } Thread.Sleep(1000); Assert.That(run.WorkflowRunStatus_Enum, Is.EqualTo(WorkflowRunState_Enumeration.WorkflowRunCompleted)); var results = run.GetOutput(); Assert.That(results.Keys, Has.Member("NotificationRecord")); var entity = (IEntity)results["NotificationRecord"]; return(entity.As <Notification>()); } }