【问题标题】:Coded flowchart and unable to return OutArgument编码流程图并且无法返回 OutArgument
【发布时间】:2017-06-07 16:05:56
【问题描述】:

我正在使用代码(而不是设计时)创建流程图工作流

代码

static Flowchart CreateFlowChart()
{
    Variable<string> response = new Variable<string>();
    Variable<string> isApproved = new Variable<string>();

    FlowStep approved = new FlowStep
    {
        Action = new Assign
        {
            To = new OutArgument<string> (isApproved),
            Value = new InArgument<string>((context) => response.Get(context))
        }
    };

    FlowStep rejected = new FlowStep
    {
        Action = new Assign
        {
            DisplayName = "Approved",
            To = new OutArgument<string>(isApproved),
            Value = new InArgument<string>((context) => response.Get(context))
        }
    };

    FlowDecision flowDecision = new FlowDecision
    {

        Condition = ExpressionServices.Convert<bool>((ctx) => response.Get(ctx).ToString() == "approved"),
        True = approved,
        False = rejected
    };

    FlowStep LineManagerApproval = new FlowStep
    {
        Action = new ReadLine 
        {
            BookmarkName = readLineBookmark,
            Result = new OutArgument<string>(response)
        },

        Next = flowDecision
    };           

    Flowchart flowChart = new Flowchart
    {
        DisplayName = "Line Manager Approval Process",
        Variables = { response, isApproved },
        StartNode = LineManagerApproval,
        Nodes = 
        {
            LineManagerApproval,
            flowDecision,
            approved,
            rejected
        }
    };
    return flowChart;
}

我在我的活动帖子中设置OutArgument&lt;string&gt; 以进行流量决策。

当工作流程完成时,我希望有 e.OutPuts["isApproved"]e.OutPuts 总是给计数 0;

application.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{

    Console.WriteLine("Workflow {0} Completed.", e.InstanceId);
    //bool isApproved = (bool)e.Outputs["isApproved"];

};

基本上我正在努力从流程图中返回 OutArgument。 请问有什么帮助吗?

【问题讨论】:

    标签: workflow workflow-foundation-4


    【解决方案1】:

    IsApproved 应在工作流级别设置为 outArgument。您似乎将其设置为变量。

    【讨论】:

    • 是的,它被定义为变量,但后来它被用作 OutArgument,例如To = new OutArgument (isApproved),所以不确定你的意思是什么?
    • 是的,但这是作为 Flowstep 的 OutArgument,因此它在该 Flowstep 中具有范围。您需要一个具有 FlowChart 范围的 outArgument。在这里查看莫里斯对类似问题的回答: techqa.info/programming/question/6272553/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-07
    • 2013-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多