locked
When running my xaml workflow in my Workflow Designer (WorkflowInvoker.Invoke), InArguments do not reach the Root Activity RRS feed

  • Question

  • I am sure I am messing up with the Xaml part! Unit tests for the custom activities work, but they wont run in the WD.The idea is to have a container activity which receives the InArguments, saves it in the context's Properties collection and then schedules child activities. All activities return TResult = bool.

    The Xaml looks like this...

    <Activity mc:Ignorable="sap sads" x:Class="PlanEligibility"
     xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
     xmlns:e="clr-namespace:EmployeeEligibility;assembly=EmployeeEligibility"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
     xmlns:p="clr-namespace:PlanEligibility;assembly=PlanEligibility"
     xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
     xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
     xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <x:Members>
        <x:Property Name="Tenant" Type="InArgument(e:Tenant)" />
        <x:Property Name="DbEmployee" Type="InArgument(e:Employee)" />
        <x:Property Name="CensusEmployee" Type="InArgument(e:Employee)" />
        <x:Property Name="PlanEligibilityCheckLists" Type="InArgument(scg:Dictionary(x:String, x:Object))" />
        <x:Property Name="Eligible" Type="OutArgument(x:Boolean)" />
      </x:Members>
      <sap:VirtualizedContainerService.HintSize>526,319</sap:VirtualizedContainerService.HintSize>
      <mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings>
      <p:EligibilityContainer CensusEmployee="{x:Null}" DbEmployee="{x:Null}" PlanEligibilityCheckLists="{x:Null}" Tenant="{x:Null}" DisplayName="Plan Eligibility WF Container" sap:VirtualizedContainerService.HintSize="486,279">
        <p:LogicalOr sap:VirtualizedContainerService.HintSize="462,203">
          <p:LogicalOr.Left>
            <p:JobTitleCheck Member="{x:Null}" PlanEligibilityCheckLists="{x:Null}" DisplayName="Job Title Check Activity" sap:VirtualizedContainerService.HintSize="200,153" />
          </p:LogicalOr.Left>
          <p:LogicalOr.Right>
            <p:JobTypeCheck Member="{x:Null}" PlanEligibilityCheckLists="{x:Null}" DisplayName="Job Type Check Activity" />
          </p:LogicalOr.Right>
        </p:LogicalOr>
      </p:EligibilityContainer>
    </Activity>

    What I have is a containing activity {TResult = bool} with a bunch of census processing activities which return a bool. The idea is that the user can build expressions in a drag-drop mode. The code that generate the input for the xaml is below...

    public class PlanEligibilityTemplateGenerator
        {
            public static string Create()
            {
                Tenant tenant = new Tenant();
                Employee dbEmployee = new Employee(tenant);
                Employee censusEmployee = new Employee(tenant);
                Dictionary<string, object> planEligibilityCheckLists = new Dictionary<string, object>();
    
                ActivityBuilder builder = new ActivityBuilder();
    
                builder.Name = "PlanEligibility";
    
                builder.Properties.Add(new DynamicActivityProperty
                {
                    Name = "Tenant",
                    Type = typeof(InArgument<Tenant>),
                    //Value = new InArgument<Tenant>(new VisualBasicValue<Tenant>("New Tenant()"))
                });
                builder.Properties.Add(new DynamicActivityProperty
                {
                    Name = "DbEmployee",
                    Type = typeof(InArgument<Employee>),
                    //Value = new InArgument<Employee>(new VisualBasicValue<Employee>("New Employee()"))
                });
                builder.Properties.Add(new DynamicActivityProperty
                {
                    Name = "CensusEmployee",
                    Type = typeof(InArgument<Employee>),
                    //Value = new InArgument<Employee>(new VisualBasicValue<Employee>("New Employee"))
                });
                builder.Properties.Add(new DynamicActivityProperty
                {
                    Name = "PlanEligibilityCheckLists",
                    Type = typeof(InArgument<Dictionary<string, dynamic>>),
                    //Value = new InArgument<Dictionary<string, object>>(new VisualBasicValue<Dictionary<string, object>>("New Dictionary (Of String, Object)"))
                });
                builder.Properties.Add(new DynamicActivityProperty
                {
                    Name = "Eligible",
                    Type = typeof(OutArgument<bool>)
                });
                builder.Implementation = new EligibilityContainer
                {
                    Tenant = builder.Properties["Tenant"].Value as InArgument<Tenant>,
                    CensusEmployee = builder.Properties["CensusEmployee"].Value as InArgument<Employee>,
                    DbEmployee = builder.Properties["DbEmployee"].Value as InArgument<Employee>,
                    PlanEligibilityCheckLists = builder.Properties["PlanEligibilityCheckLists"].Value as InArgument<Dictionary<string, object>>,
                    DisplayName = "Plan Eligibility WF Container",
    
                };
                StringBuilder sb = new StringBuilder();
                StringWriter sw = new StringWriter(sb);
                XamlWriter xw = ActivityXamlServices.CreateBuilderWriter(new XamlXmlWriter(sw, new XamlSchemaContext()));
                XamlServices.Save(xw, builder);
                return sb.ToString();
            }
    

    If I set the properties' values for the Dynamic Activity, the workflow runs but the input arguments are not set with values in the input dictionary when I call WorkflowInvoker.Invoke. Also, the xaml has a namespace "this:clr-namespace:". 

    Like this... The keys are activities' ID references from the context's Properties collection


    When I do not set the values in the DynamicActivityProperties collection, I get 'cannot be null' exception. Like this...



    Tuesday, May 16, 2017 8:15 AM