C#-ELSA工作流程 - 儿童工作流 - 如何获得父级工作流的工作流程
我有一个elsa workflow parent
,该调用某些child
workflows。 每个子工作流程都有一些自定义活动(基于sendhttprequest
elsa活动)。 这些自定义活动需要调用外部API并提供parent> parent> parent> parent
工作流的workflowInstanceID
。
我尝试通过workflowinstanceid
parent> parent
作为condect> contextId
of子工作流 - 由于儿童工作流的内部被覆盖,因此无法工作(这很有意义(这很有意义)当然)。
我如何获得(服务器端)workflowinstanceid
parent> parent> parent
从一个在子工作流程上运行的代码的工作流程 (假设来自onexecuteasync(ActivityExecutionContext上下文上下文)
of Child Workflow自定义活动)?
I have an elsa workflow parent
which is calling some child
workflows.
Every child workflow has some custom activities (based on SendHttpRequest
elsa activity).
These custom activities need to call an external api and provide the workflowInstanceId
of parent
workflow.
I tried to pass the workflowInstanceId
of parent
as ContextId
of child workflow – not working since is overridden inside of child workflow custom activity (which makes sense of course).
How could I get (server-side) the workflowInstanceId
of parent
workflow from a piece of code which is running on a child workflow
(let’s say from OnExecuteAsync(ActivityExecutionContext context)
of child workflow custom activity)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管ELSA 2(写作时2.6)没有亲子工作流的真实概念(即其他工作流调用的工作流程没有任何参考),但您可以使用
runworkflow
活动为子工作流提供任意输入。包括其自己的工作流实例ID。例如,使用
runworkflow
活动上的以下JS表达
setVariable
活动:既然您已经存储在工作流变量中的父工作流程ID,则可以从子女工作流中的任何地方访问它。
这是您可以通过设计师导入的父工作流程的示例:
这是您可以导入的孩子:
导入后,请确保两个工作流都发布。
然后,您可以通过其HTTP端点调用父工作流,例如:
https:// localhost:11000/parent
,它将导致与此类似的响应:
此响应是由Child Workflow生成的(哪个)成功收到了父工作流实例ID)
Although Elsa 2 (2.6 at the time of writing) does not have a real notion of parent-child workflows (i.e. workflows invoked by other workflows do not have any reference to their parent), you can use the
RunWorkflow
activity to provide arbitrary input to the child workflow. Including its own workflow instance ID.For example, use the following JS expression on the
RunWorkflow
activity to send the workflow instance to the child workflow:Then, from your child workflow, your first activity should be the one to capture this value, e.g. using a
SetVariable
activity:Now that you have the parent workflow instance ID stored in a workflow variable, you can access it from anywhere in your child workflow.
Here is an example of a parent workflow you can import via the designer:
And here is the Child you can import:
Once imported, make sure both workflows are published.
You can then invoke the parent workflow via its HTTP endpoint, e.g.:
https://localhost:11000/parent
Which will result in a response similar to this:
This response is generated by the Child workflow (which successfully received the parent workflow instance ID)