locked
Declarative rule condition evaluation in Parallel replicator RRS feed

  • Question

  • Hi! First of all let me say: "I know WF 3.5 is deprecated", but I'm making improvements on an older application that uses that older WF technology and the porting to version 4.x is out of question. Anyway, my problem is that I have a parallel ReplicatorActivity with a SequenceActivity inside. In the Sequence activity there is a custom activity that collects the result of a question. Next there is an ifElseActivity with the left branch checking if "Answer" property of the question activity is Yes the other branch is empty (else). The workflow uses declarative rule condition to evaluate the condition (that's because workflows are drawn by the user and stored as xoml). Now the access to question activity is guaranteed by a method in the custom workflow file that searches activity by name. It works fine for all activities except for the parallel replicator. All the child activities in the replicatore are childInitialized with the key of the item in the replicator.

    My question is: how can i evaluate the right condition?

    I don't know howto bind the executing ifElseBranch with the corresponding QuestionActivity. I now the replicator holds in the DynamicActivities property the running instances of the activities but I don't know the caller's key. I found that in CodeConditions the sender is the evaluating activity... that could be the chance to get the Key and search for the question activity using the name and key, but in Declarative Rule Editor how can I get the "sender"?

    I'm really stuck! Please if someone can help me I'll really be grateful to eternity.

    Thanks

    Alessandro

    Thursday, March 13, 2014 5:48 PM

All replies

  • Hi, it's me again. I made some steps forward in my search of the lost Ark... I see the light coming in from the exit door but I'm still searching the way to it. I need to know how in a Declarative Rule Condition i can evaluate a property of the ifBranchActivity (is a my custom IfElseBranchActivity) that owns the condition. 

    In a test project I have the CodeCondition version like this:

    private void OnCodeCondition(object sender, ConditionalEventArgs e)
    {
        IReplicable ifta = sender as IReplicable;
    
        if (ifta != null)
        {
            if (ifta.InstanceData != null)
            {
                foreach (var act in replicatorActivity1.DynamicActivities)
                {
                     QuestionActivity qa = act.GetActivityByName("questionActivity1") as QuestionActivity;
    
                     if (qa != null && qa.InstanceData == ifta.InstanceData)
                     {
                         e.Result = qa.Answer;
                         break;
                     }
                 }
             }
             else
             {
                 e.Result = this.questionActivity1.Answer;
             }
        }
    }

    As you can see I can match the InstanceData of the IReplicable container and the QuestionActivity that holds the answer that I have to evaluate in the RuleCondition. I need to do something similar in the Declarative Rule Condition. It seems that in the editor i can reference with "this" keyword the workflow. Can the workflow reference the activity that owns the condition? 

    Thanks

    Alessandro

    Friday, March 14, 2014 4:12 PM