如何正确地将参数添加到工作流程中?

发布于 2025-02-09 21:45:16 字数 1337 浏览 1 评论 0原文

我正在尝试将一个简单的参数添加到我的一个活动中,该参数是序列中的openbrowser,之后,我创建了一个具有该序列的简单工作流,然后我运行它。

尽管变量已添加到序列中,但字典是正确创建的,并且正确命名的变量以及传递到工作流的字典,但它仍然使我在帖子底部的错误。

我一直在尝试弄清楚几天,但没有成功,应该如何写这件事?

    private void Button_Click(object sender, RoutedEventArgs e)
    {

        Variable<String> myVariable = new Variable<string>(Name = "Hehe");

        Dictionary<string, object> mainInputs = new Dictionary<string, object>();
        mainInputs.Add("Hehe","www.youtube.com");

        OpenBrowser samsungPortalBrowser = new OpenBrowser();
        samsungPortalBrowser.NewSession = true;
        samsungPortalBrowser.BrowserType = BrowserType.Chrome;
        samsungPortalBrowser.Url = myVariable;

        Sequence createSequence = new Sequence();
        createSequence.Activities.Add(samsungPortalBrowser);
        createSequence.Variables.Add(myVariable);
        WorkflowApplication app = new WorkflowApplication(createSequence, mainInputs);

        app.Run();


    }



System.ArgumentException: 'The values provided for the root activity's arguments did not satisfy the root activity's requirements:
'Sequence': The following keys from the input dictionary do not map to arguments and must be removed: Hehe.  Please note that argument names are case sensitive.
Parameter name: rootArgumentValues'

I am trying to add a simple argument to one of my activities which is OpenBrowser in a sequence, afterwards I create a simple workflow that has owns that sequence, then I run it.

Although the variables are added to the Sequence, the dictionary is properly created and the variables named properly as well as the dictionary being passed to the workflow, it still gives me the error at the bottom of the post.

I have been trying to figure this out for a few days now with no success, how should this be written?

    private void Button_Click(object sender, RoutedEventArgs e)
    {

        Variable<String> myVariable = new Variable<string>(Name = "Hehe");

        Dictionary<string, object> mainInputs = new Dictionary<string, object>();
        mainInputs.Add("Hehe","www.youtube.com");

        OpenBrowser samsungPortalBrowser = new OpenBrowser();
        samsungPortalBrowser.NewSession = true;
        samsungPortalBrowser.BrowserType = BrowserType.Chrome;
        samsungPortalBrowser.Url = myVariable;

        Sequence createSequence = new Sequence();
        createSequence.Activities.Add(samsungPortalBrowser);
        createSequence.Variables.Add(myVariable);
        WorkflowApplication app = new WorkflowApplication(createSequence, mainInputs);

        app.Run();


    }



System.ArgumentException: 'The values provided for the root activity's arguments did not satisfy the root activity's requirements:
'Sequence': The following keys from the input dictionary do not map to arguments and must be removed: Hehe.  Please note that argument names are case sensitive.
Parameter name: rootArgumentValues'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幼儿园老大 2025-02-16 21:45:16

无需发表评论,请自己尝试剪!

internal class Program
{
static void Main(string args)
{
IDictionary<string, object> input = new Dictionary<string, object>();
input.Add(“inMSG”, “www.youtube.com”);
//input.Add(“myBrowser”, null);

        IDictionary<string, object> output = new Dictionary<string, object>();

        MyCodeWorkflow activity = new MyCodeWorkflow();
        output = WorkflowInvoker.Invoke(activity, input);
        //wtf
    }

    public class MyCodeWorkflow : Activity
    {
        public InArgument<String> inMSG { get; set; }
        public OutArgument<String> outMSG { get; set; }

        public OutArgument<Browser> myBrowser { get; set; }

        public MyCodeWorkflow()
        {
            this.Implementation = () => new Sequence
            {
                Activities =
                {
                    new OpenBrowser()
                    {
                        BrowserType = BrowserType.Chrome,
                        NewSession = true,
                        Url = new InArgument<string>((activityContext)=>this.inMSG.Get(activityContext)),
                        UiBrowser = new OutArgument<Browser>((ActivityContext)=> this.myBrowser.Get(ActivityContext))
                    },

                    new Assign<String>
                    {
                        To=new ArgumentReference<String>("outMSG"),
                        Value=new InArgument<String>((activityContext)=>this.inMSG.Get(activityContext))
                    }
                }
            };
        }
    }
}

No need for comments, try the snip by yourself!

internal class Program
{
static void Main(string args)
{
IDictionary<string, object> input = new Dictionary<string, object>();
input.Add(“inMSG”, “www.youtube.com”);
//input.Add(“myBrowser”, null);

        IDictionary<string, object> output = new Dictionary<string, object>();

        MyCodeWorkflow activity = new MyCodeWorkflow();
        output = WorkflowInvoker.Invoke(activity, input);
        //wtf
    }

    public class MyCodeWorkflow : Activity
    {
        public InArgument<String> inMSG { get; set; }
        public OutArgument<String> outMSG { get; set; }

        public OutArgument<Browser> myBrowser { get; set; }

        public MyCodeWorkflow()
        {
            this.Implementation = () => new Sequence
            {
                Activities =
                {
                    new OpenBrowser()
                    {
                        BrowserType = BrowserType.Chrome,
                        NewSession = true,
                        Url = new InArgument<string>((activityContext)=>this.inMSG.Get(activityContext)),
                        UiBrowser = new OutArgument<Browser>((ActivityContext)=> this.myBrowser.Get(ActivityContext))
                    },

                    new Assign<String>
                    {
                        To=new ArgumentReference<String>("outMSG"),
                        Value=new InArgument<String>((activityContext)=>this.inMSG.Get(activityContext))
                    }
                }
            };
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文