使用Windows工作流和winforms而不是控制台的简单应用程序
我正在寻找一个简单的入门应用程序,允许您输入值 1 - 10,该值将传递给 WF 规则,该规则评估它是否大于、小于或等于 5 并将结果返回到 Windows 窗体应用程序它在标签中显示结果。
我可以找到很多 .net 3.5 控制台应用程序教程,但没有任何内容显示如何使用 Windows 窗体和 .net 4 传入并接收结果!
它不需要是上面的示例,但它需要向我展示如何将值传递到规则中,编写规则并从 .net 4 c# 中的 Windows 窗体应用程序中读取规则的结果。
我迷路了!
我的基本代码现在可以工作,以防它对其他人有帮助:
var workflow = new Activity1();
IDictionary<string, object> inputs = new Dictionary<string, object>();
inputs["firstname"] = textBox1.Text;
IDictionary<string, object> outputs = WorkflowInvoker.Invoke(workflow, inputs);
textBox2.Text= outputs["greeting"].ToString();
名字是一个参数,其方向传递给工作流程。 问候语是一个在工作流程中分配方向的参数。
I'm looking for a simple starter app that allows you to type in a value 1 - 10 this value is passed to a WF rule that evaluates if it is greater, less than or equal to 5 and returns the results to the windows forms app which displays the results in a label.
I can find a lot of .net 3.5 console app tutorials but nothing that shows how to pass into and receive the result back using windows forms and .net 4!
it doesn't need to be the above example but it needs to show me how to pass a value into the rule, write the rule and read the result from the rule from within a windows forms app in .net 4 c#.
I'm lost!
My Basic code now working in case it helps others:
var workflow = new Activity1();
IDictionary<string, object> inputs = new Dictionary<string, object>();
inputs["firstname"] = textBox1.Text;
IDictionary<string, object> outputs = WorkflowInvoker.Invoke(workflow, inputs);
textBox2.Text= outputs["greeting"].ToString();
firstname is an argument with direction in passed to the work flow.
greeting is an argument with direction out assigned within the work flow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是我实现这一目标的方法:
1)创建一个名为WindowsFormsApplication7的Windows窗体应用程序,使用最新的框架。
2) 确保包含所有参考文献
3) 使用以下代码添加一个类。
4) 双击表单并将代码替换为此代码。不要介意这些错误。它们将会消失。
5) 将以下控件添加到表单
标签 1、文本框 1 和按钮 1
6) 添加名为 Activity1.xaml 的工作流活动
7) 编译解决方案 (F6)。 UpdateLabel 活动,如 Class1(公共类 UpdateLabel:CodeActivity)中所述,必须存在于工具箱中
8) 从工具箱中,将 UpdateLabel 和 WriteLine 活动拖到 Activity1
9) 将以下参数 lbl(标签)和 txt(字符串)添加到 Activity1
10) 在 UpdateLabel 活动中单击一次,按 F4(属性)并更新活动的参数,如图所示
11) 按 F5 编译并运行应用程序。在文本框中插入一些文本,然后按按钮。文本必须显示在标签中(由 Activity1 更新)和输出窗口中(由 WriteLine 活动更新)
12)恭喜!!!
Here follows the approach I got to reach this goal:
1) Create a Windows Forms Application called WindowsFormsApplication7, Use the latest Framework.
2) Make sure to include all references
3) Add a Class with the following code.
4) Double click in the form and replace the code with this one. Don't mind the errors. They will vanish.
5) Add the following controls to the form
label1, textbox1 and button1
6) Add an Workflow Activity called Activity1.xaml
7) Compile the solution (F6). The UpdateLabel Activity, as described in the Class1 (public class UpdateLabel : CodeActivity) must be present in the ToolBox
8) From the ToolBox, drag a UpdateLabel and a WriteLine activities into the Activity1
9) Add the following Arguments lbl (Label) and txt (string) to the Activity1
10) Click once in the UpdateLabel activity, press F4 (Properties) and update the parameters of the activity as shown
11) Press F5 to compile and run the application. Insert some text in the textbox and press the button. The text must be shown in the label, updated by the Activity1, and in the Output Window, updated by the WriteLine activity
12) Congrats!!!