如何访问工作流服务的工作流参数? [英] How can I get access to workflow arguments of workflow service?

查看:109
本文介绍了如何访问工作流服务的工作流参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

我读了
http://msdn.microsoft .com / zh-cn / library / ff729688.aspx
和所有描述的作品都很棒。但我无法理解如何在工作流中使用输入参数。有一个字典< string,objects>用于在OnGetCreationContext中将参数传递到工作流中。
Dictionary确实包含从客户端传输的有效数据。例如,有没有办法在CodeActivity中读取输入参数?

I read the http://msdn.microsoft.com/en-us/library/ff729688.aspx and all of described works great. But I can't understand how can I use input arguments in workflow. There is a Dictionary<string, objects> used to pass arguments into workflow in OnGetCreationContext. Dictionary really contains valid data transfered from client. Is there a way to read input parameters in CodeActivity for example?

 

推荐答案

一种可能的方法是在CodeActivity中定义InArgument,然后在工作流中,通过此InArgument传递值。

One possible way is to define an InArgument in the CodeActivity, and then in the workflow, pass the value via this InArgument.

示例:

1。在wokrlfow项目中,添加一个带有一些InArgument的新CodeActvitiy。在下面的示例中,有2个参数,1个InArgument从外部获取值,1个InOutArgument从外部获取值,然后修改它,以便外部工作流可以知道
更改

1. In a wokrlfow project, add a new CodeActvitiy with some InArgument. In the below example, there are 2 arguments, 1 InArgument to get the value from outside, 1 InOutArgument to take the value from outside, then modify it, so that outside workflow can know the change


using System.Activities;

namespace WorkflowConsoleApplication1
{

  public sealed class Increment : CodeActivity
  {
    InOutArgument<int> counter;
    InArgument<int> incrementCount;

    public Increment()
      : this(1)
    {
    }

    public Increment(int incrementCount)
    {
      this.IncrementCount = new InArgument<int>(incrementCount);
    }

    public InArgument<int> IncrementCount
    {
      get
      {
        return this.incrementCount;
      }
      set
      {
        this.incrementCount = value;
      }
    }

    public InOutArgument<int> Counter
    {
      get
      {
        return this.counter;
      }
      set
      {
        this.counter = value;
      }
    }

    protected override void Execute(CodeActivityContext context)
    {
      this.Counter.Set(
        context,
        this.Counter.Get(context) + this.IncrementCount.Get(context)
        );
    }
  }
}


这篇关于如何访问工作流服务的工作流参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆