简体   繁体   English

WF和WPF交互的真实世界示例

[英]Real World Examples of WF and WPF Interaction

I'm looking for some good real-world examples of interaction between Windows Presentation Foundation and Workflow Foundation. 我正在寻找Windows Presentation Foundation和Workflow Foundation之间交互的一些很好的实际例子。 Most of the WF tutorials I see demonstrate use within console applications. 我看到的大多数WF教程都在控制台应用程序中使用。 I'm more curious about applications that use a rich WPF interface and WF. 我对使用丰富的WPF接口和WF的应用程序更感兴趣。 Particularly if they allow user defined workflows (allow users to design and run their own workflows on the fly). 特别是如果它们允许用户定义的工作流程(允许用户动态设计和运行他们自己的工作流程)。

I'm not sure what exactly you're looking for, but here are some links to information about actual real world applications using Workflow in desktop (WPF) applications in one way or another: 我不确定你究竟在寻找什么,但是这里有一些链接,以某种方式使用桌面(WPF)应用程序中的Workflow实际真实应用程序的信息:

Let me take the example of trying to make two workflows communicate with each other. 让我举一个例子,试图让两个工作流程相互通信。

  1. First you need to write a host. 首先,您需要编写主机。 This is an extremely loaded proposition, because for two WF hosts to talk to each other, you will then also need to know WCF, and all mushy concepts of threading. 这是一个非常有用的命题,因为要让两个WF主机相互通信,您还需要知道WCF以及线程的所有糊涂概念。
  2. Then your WF will need to communicate with other WFs via the hosts. 然后你的WF需要通过主机与其他WF进行通信。 This makes sense because a WF doesn't keep running in memory for 3 months, when it is waiting for another WF to send an event. 这是有道理的,因为当WF等待另一个WF发送事件时,WF不会在内存中运行3个月。 The WF sits in the database, and the communication occurs through the hosts. WF位于数据库中,通过主机进行通信。
  3. Okay, even for simpler scenarios, for local in-process communication, you have the CallExternalMethod activity, and HandleExternalEvent activities. 好的,即使对于更简单的场景,对于本地进程内通信,您也有CallExternalMethod活动和HandleExternalEvent活动。 Even in this case, you have to talk via the host, because the WF might have been passivated to the database. 即使在这种情况下,您也必须通过主机进行通信,因为WF可能已被钝化到数据库。 So in order to do so, you have to remember to do 3 things, decorate your interface with the ExternalDataExchangeAttribute, eventargs needs to derive from ExternalDataEventArgs, and event args is serializable. 所以为了做到这一点,你必须记住做3件事,用ExternalDataExchangeAttribute修饰你的接口,eventargs需要从ExternalDataEventArgs派生,而事件args是可序列化的。
  4. If you mess up in any of the items in #3, you get a very non-intuitive "InvalidOperationException". 如果你搞砸了#3中的任何一个项目,你会得到一个非常直观的“InvalidOperationException”。 Sure the message says, "Service does not implement an interface with the ExternalDataExchange attribute", but it isn't until you look at the inner exception, that you really know what happened - ie you forgot to make it serializable. 当然消息说,“服务没有实现具有ExternalDataExchange属性的接口”,但是直到你看到内部异常,你才真正知道发生了什么 - 即你忘了让它可序列化。 doh! 卫生署! But I did mark it as serializable. 但我确实将它标记为可序列化。 Actually, everything needs to be serializable, even the sender. 实际上,一切都需要序列化,甚至是发件人。
  5. Then you have to connect the WF activities, via the proper interface names and method names you are using to communicate. 然后,您必须通过用于通信的正确接口名称和方法名称连接WF活动。
  6. Finally, for even in-process WF communication, you have to remember to add your service to the ExternalDataExchangeService, and not the WF runtime. 最后,对于即使在进程中的WF通信,您必须记住将服务添加到ExternalDataExchangeService,而不是WF运行时。 Otherwise, it will look like nobody is subscribing to the event. 否则,看起来没有人订阅该活动。 Not to mention, that this is one of those bug, that doesn't really throw an error. 更不用说,这是其中一个bug,它并没有真正引发错误。 ie hard to track down! 即难以追查!

So, in short, for the simplistic scenario of trying to make two workflows communicate, you need to have a good handle on the following: 因此,简而言之,对于尝试使两个工作流程进行通信的简单方案,您需要对以下内容进行良好处理:

*Writing windows apps (for the host), *Threading, *WCF, *OOP Concepts, *All concepts of serialization, *Plenty of hooking up and non-intuitive details of WF itself, *Ninja debugging skills. *编写Windows应用程序(用于主机),*线程,* WCF,* OOP概念,*所有序列化概念,*大量连接和WF本身的非直观细节,*忍者调试技能。

Source:http://blah.winsmarts.com/2008-2-I've_been_here_before.aspx 出处:http://blah.winsmarts.com/2008-2-I've_been_here_before.aspx

Here is a sample project I did, which combines WF and WPF to simulate a ATM machine. 这是我做的一个示例项目,它结合了WF和WPF来模拟ATM机。 The code works on some issues like handling the bookmarks, how to keep the workflow alive, and how to manipulate the UI from the workflow. 该代码适用于处理书签,如何使工作流保持活动以及如何从工作流操纵UI等一些问题。

https://wpfwf.codeplex.com/ https://wpfwf.codeplex.com/

The question is pretty vague but here is a possible awnser in this blog post I wrote. 这个问题非常模糊,但在我写的这篇博客文章中, 是一个可能的问题。 Basically I am rehosting the workflow designer to let end users change workflows as needed and let them run them right there and then. 基本上我正在重新设置工作流设计器,让最终用户根据需要更改工作流,然后让他们在那里运行它们。 Of course you question could mean pretty much anything, like how to call a workflow service from a WPF form. 当然,你的问题可能意味着什么,比如如何从WPF表单调用工作流服务。

这是一种自我推销,因为链接是我的, 但看看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM