问题标签 [workflow-foundation-4.5]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
.net - .NET 工作流:通过代码在状态之间转换
我正在构建一个用于错误跟踪的简单应用程序,并且我正在使用带有状态机的 .NET 工作流活动库项目,其中各个状态代表错误的状态 - 已报告、已分配和已完成。
我可以使用 WorkflowInspectionServices 类来获取每个状态的错误的状态转换列表。但是,我正在尝试:
- 确定特定错误所处的当前状态,以及
- 更改当前状态,不使用触发条件(我想在用户从下拉列表中选择状态时通过代码触发更改)
- 读取工作流中变量的值
如何使用 .NET 工作流来完成这些工作?
workflow-foundation-4.5 - 使用 dynamicUpdateMap 更新正在运行的工作流
我有一个工作流程正在运行,我正在尝试动态更新它。这是一个流程图,我正在尝试更改 FlowStep 的 Next 属性。问题是在加载 WorkflowApplication.Load(workflowApplicationInstance, map); 时 带有地图的实例,我得到了错误:
为了将实现映射直接应用于工作流实例,定义的根不得有任何公共/导入的子级或公共/导入的委托。
我尝试将地图保存到文件和数据库,因为我在其他示例中看到,地图保存为扩展名为 file.map 而不是 file.xml 的 file.xaml。无论如何它是无用的,它仍然没有加载。
c# - WF4.5 动态更新 - 使用自定义活动更新大型、长时间运行的流程时出现问题
我正在为我们的大型工作流程实施更新流程,这些流程有可能持续数年甚至数十年。我正在接手以前的开发人员离开的地方,并且在花了一周时间试图让现有代码(主要基于 Microsoft 提供的示例)工作之后,我已经废弃它并构建了我自己的 WorkflowVersioning 实用程序。虽然我已经能够成功地将持久实例更新到新版本,但在测试中我发现在更新过程中以及在恢复受影响的工作流时,各种更改都可能导致异常。由于我们工作流程的复杂性,我相信还有更多工作要做,但目前还没有攻击计划。
我列出了我遇到的 2 个具体问题,以及我的代码的重要部分。如果我需要提供代码的其他部分,请告诉我。此外,如果您自己在类似情况下实现了 DynamicUpdate,或者知道资源、代码示例或其他可能有帮助的文档,我愿意为此提供任何帮助!作为 WF 的新手(以及一般的专业发展),这是一个相当不错的学习过程,我一直在努力寻找特定于 WF4.5 的资源。
背景
我们目前正在开发的 3 个主要业务流程由大型流程组成,每个流程都有多个子流程,它们本身是由许多自定义活动构建的。每个进程中的主要步骤(我们称之为“任务”)由一个 NativeActivity 以及几个拖到 Xaml 设计图面上的 CodeActivities 组成。(我也有让设计师表现的问题,但我会把它留到一个单独的问题上)。
具体问题
1) 对流程进行更改时,如果我添加或删除参数,我会在应用更新时遇到异常:
根据 MSDN(不会让我发布第三个链接,我会在评论中添加它),您应该能够添加和删除参数:是否需要进一步的代码来解决这个问题?至少可以说,谷歌的结果很薄弱。但是,在分析生成的 DynamicUpdateMap 时,我发现它确实跟踪了 New 和 Old 参数,所以我假设一定有办法!
2)当我向主流程添加变量时,恢复任务时出现异常:
我能找到的唯一结果是这篇关于 IIS的帖子,但是当我只是从 Visual Studio 运行桌面应用程序时,为什么会出现这个错误呢?我似乎找不到任何其他结果来为我指明这个方向..
WorkflowVersioning 实用程序项目
免责声明:此代码大部分归功于 Matt Milner 的 WF4.5 复数课程,这是我能找到的关于该主题的为数不多的(有些最新的)资源之一。我很想看到更多动态更新过程的例子,但现在:
准备更新流
首先,我从主进程的(父工作流).xaml 中获得一个 ActivityBuilder:
然后我调用 PrepareForUpdate:
然后使用现在添加的 DynamicUpdate 元数据将 ActivityBuilder 保存回文件。
在执行更新准备过程后,我使用设计器对工作流程进行更改,或者通过添加/删除参数/变量/活动来修改 NativeActivities。
创建一个 DynamicUpdateMap
在对工作流程进行任何必要的更改后,我会生成一个动态更新图:
将更新映射应用于受影响的实例
最后,我在持久性中遍历每个实例,并应用更新:
c# - 使用可视化设计器进行动态更新:将流转换为代码是否可能或更好?
与我之前关于使用多个子流和自定义活动更新长期运行的流的问题相关,我正在实施计划以及在工作流发布到生产后修改工作流的代码。
除了另一个问题中概述的各种问题外,我还试图调试在准备好进行动态更新后出现混乱的视觉设计器。在 .xaml 上运行差异后,WorkflowViewState 变得混乱似乎是一个问题。
根据之前的帖子,似乎放弃视觉设计师是解决这个问题的一种可靠方法。但是,我发现似乎几乎可以让我到达那里的代码。这是我在调用DynamicUpdateServices.PrepareForUpdate
方法后将 MainProcessFlow.xaml 保存回文件的方式:
调用此方法并在可视化设计器中打开 .xaml 后,活动出现故障。流程仍然“正确”,因为箭头指向正确的方向,但布局混乱。在进行更改、创建更新映射并在没有动态更新信息的情况下将 .xaml 保存回来后,顺序仍然不正确。关于在 xaml 中设置 Viewstate 的文档(我可以找到)并不多。我错过了什么吗?
或者,放弃视觉设计师是更好的选择吗?我们有将近一年的工作流程,所以这将是一项艰巨的任务,但让 DynamicUpdate 工作是一个更高的优先级。
c# - 在工作流c#中设置参数的值
我正在使用 Windows Workflow Foundation .NET 4.5.2。我有一个关于bool
从 CodeActivity 内部在设计器中设置类型参数(也可能是变量)的问题。
在设计器中,我将newProject
type的参数设置为bool
direction In
。(它应该有另一个方向吗?即InOut
)。
在代码中,我想将参数从设计器设置为 value true
。
设计器中的论点在使我能够进入下一个状态的转换中得到验证。如果是true
,我可以进入下一个状态。问题是设计器中的参数没有收到上面代码中设置的新值。怎么做到呢?
c#-6.0 - 如果 InvokeMethod 活动返回对象,如何在工作流中分配变量?
我在 Windows Workflow Foundation 中有一个 InvokeMethod 活动。这个工作流程非常简单:
- 询问用户他/她的身高
- 如果身高大于 5.9,则询问他/她的个人资料详细信息
- 显示个人资料详细信息
如何分配从 InvokeMethod 返回的对象作为变量?
workflow-foundation-4 - 如何在代码中获取 OutArgument 的强类型值?
给定Activity
具有多个属性的(通过设计器创建的),是否OutArgument
可以在调用工作流后从属性中获取它们的强类型值?
代码如下所示:
该T Get()
方法OutArgument<T>
需要一个ActivityContext
我不确定如何在代码中获得的方法。
我也意识到可以从 and 中获取未类型化的值result["Bar"]
并result["Baz"]
对其进行转换,但我希望有另一种方法。
更新以明确存在多个Out
值,尽管即使只有一个问题仍然适用。
asp.net-mvc - User-defined dynamic workflows and user input
I have recently been tasked to look into Workflow Foundation. The actual goal would be to implement a system in which the end users can define custom workflows in the deployed application (and of course, use them). Personally I have never used WF before (and reading around here on SO people are very doubtful about it - so am I reading those questions/answers), and I am having a hard time finding my way around it given the sparse learning resources available.
Anyway, there are some questions, for example, this, which mention something they call dynamic or user-defined workflows. They point out that WF makes it possible to "rehost" the designer, so that end-users can define their own new workflows after the application is deployed (without developer intervention (?), this is the part I am not really sure about).
I have been told by fellow employees that this way we could implement an application in which once this feature is implemented we would no longer have to keep modifying the application every time a new workflow is to be implemented. However, they also pointed out that they just "heard it", they don't have firsthand experience themselves either.
I have been looking around for samples online but the best thing I could find was a number guess app - barely more than a simple hello world. So not much that would point me to the right direction of how this user-defined workflow feature actually works and how it can be used, what its limitations are etc.
My primary concern is this: it is alright that one can define custom workflows but no workflow is worth a penny without the possibility of actually inputting data throughout the process. For example, even if the only thing I need to do is to register a customer in a complaint management system, I would need the customer's name, contact, etc. If the end user should be able to define any workflow the given toolset makes possible then of course there needs to be a way to provide the workflow consumers with a way of inputting data through forms. If the workflow can be of pretty much any nature then so needs to be the data - otherwise if we need to implement the UIs ourselves then this "end-user throws together a workflow" feature is kind of useless because they would still end up at us requiring to implement a form or some sort of data input for the individual steps.
So I guess that there should be a way of defining the "shape" of the data that needs to be filled at any given user interaction phase of the workflow which I can investigate and dynamically generate forms based on the data. So for example, if I found that the required data was made up of a name and a date of birth, then I would need to render a textbox and a datepicker on the page.
What I couldn't really figure out from the Q&As here and elsewhere is whether this is even possible. Can I define and then later "query" the structure of the data to be passed to the workflow at any point? If so, how? If not, how should this user-defined workflow feature even be used, what is it good for?
To clarify it a little, I could imagine something as specifying a complex type, which would be the view model (input model) in a regular MVC app, and then I could reflect over it, get the properties and render input fields based on that.
c# - Windows Workflow Foundation 未编译“CSharpValue”表达式
我有一个 WWF 活动工作流,它使用 VS2015 中的可视化编辑器在 XAML 文件中定义。工作流编译为 .NET 类型,该类型被实例化并传递到 WorkflowApplication 实例中。因此,换句话说,工作流不是动态活动,XAML 不会在运行时加载。
我面临的问题是没有构建表达式,这导致System.NotSupportedException: Expression Activity type 'CSharpValue1' requires compilation in order to run. Please ensure that the workflow has been compiled
我已经检查过了,工作流的自定义工具设置为MSBuild:Compile,构建操作设置为XamlAppDef。
与此有关,但没有解决方案。
有任何想法吗?
c# - 为什么卸载后工作流不唤醒?
我试图更好地理解 .NET Workflow Foundation,尤其是持久/卸载和恢复功能的工作原理。
因此,出于测试目的,我创建了一个非常简单的 Activity 并尝试将其托管在WorkflowApplication
. 我想学习如何使用在工作流实例空闲时持久化它们的能力。所以我写了以下代码:
Activity 启动时工作流被卸载Delay
,但Delay
结束时不会恢复。我不是 Workflow Foundation 专家,所以我意识到我一定是错误地使用了 API。根据我的同事的说法,工作流应该在结束时自动唤醒并恢复执行Delay
。
我已阅读有关该主题的MSDN 文章,但似乎并没有很好地解释这一方面。