日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

调用子流程

發(fā)布時間:2023/12/15 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 调用子流程 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
InvokeWorkflowActivity是干嗎用的,CallExternalMethodActivity與HandleExternalEventActivity還好,知道等等外面干活的,InvokeWorkflowActivity可到好,傻小子放炮,點(diǎn)上就跑,也不知站住看一下,看看MS對它的解釋:

Asynchronously runs one workflow from another. This class cannot be inherited.
InvokeWorkflowActivity then creates and invokes a workflow instance of the specified type, passing the parameters that have been provided. As soon as the workflow has been invoked, the InvokeWorkflowActivity finishes immediately.
Use the InvokeWorkflowActivity to start one workflow from another. The InvokeWorkflowActivity completes before the launched workflow starts executing and the next activity in the workflow branch is executed.

?異步,而且還沒回調(diào),異步我要你干嗎。

?看一下這個例子吧,用了一個多線程常用的方式解決了調(diào)用子流程的問題,看這個例子注意以下幾點(diǎn):

1.不用InvokeWorkflowActivity也能實(shí)現(xiàn)調(diào)用子流程
2.這個例子的中心思想不是如何用InvokeWorkflowActivity調(diào)用子流程,我有N多比這簡單的方法,這個例子的主要演示了如何將工作流的業(yè)務(wù)處理封裝到自定義引擎中?

調(diào)用子流程思路如下


本例是通過重寫WorkflowRuntime實(shí)現(xiàn),也就是說以上活動沒在在宿主中實(shí)現(xiàn),全過程對宿主來說是一個黑盒

?public?class?控制類
????
{
?????
????????
//外部事件
????????[Serializable()]
????????
public?class?事件標(biāo)志?:?System.Workflow.Activities.ExternalDataEventArgs
????
{
????????
private?Guid?實(shí)例GUID_存值;

????????
public?string?自定義存值;

????????
public?事件標(biāo)志(Guid?instanceId)
????????????:?
base(instanceId)
????????
{
????????????
this.實(shí)例GUID_存值?=?instanceId;
????????}


????????
public?Guid?實(shí)例GUID
????????
{
????????????
get?{?return?this.實(shí)例GUID_存值;?}
????????????
set?{?this.實(shí)例GUID_存值?=?value;?}
????????}

????}

???????
????????[System.Workflow.Activities.ExternalDataExchange()]
????????
public?interface?外部事件映射接口
????????
{
????????????
event?System.EventHandler<事件標(biāo)志>?子流程完成事件;
????????}

????????
????????
public?class?功能類_外部事件?:?外部事件映射接口
????????
{
????????????
public?event?EventHandler<事件標(biāo)志>?子流程完成事件;
????????????
public?void?觸發(fā)子流程完成事件(object?sender,?Guid?id,?string?自定義存值)
????????????
{
????????????????事件標(biāo)志?e?
=?new?事件標(biāo)志(id);
????????????????e.自定義存值?
=?自定義存值;
????????????????子流程完成事件(sender,?e);
????????????}

????????}


????????
//外部方法
????????[System.Workflow.Activities.ExternalDataExchange()]
????????
public?interface?外部方法映射接口
????????
{?void?子流程完成(string?所屬父流程ID,?string?流程ID);}
???
????????
public?class?功能類_外部方法?:?外部方法映射接口
????????
{
????????????
public?string?父流程ID=null;
????????????
public?string?當(dāng)前流程ID?=?null;
????????????
public?void?子流程完成(string?所屬父流程ID,?string?流程ID)
????????????
{
????????????????當(dāng)前流程ID?
=?流程ID;
????????????????父流程ID?
=?所屬父流程ID;
????????????????Console.WriteLine(
"方法已被觸發(fā)");
????????????}

???
????????}


????????
//改寫引擎
????????public?class?自定義工作流引擎?:?System.Workflow.Runtime.WorkflowRuntime
????????
{
????????????System.Workflow.Activities.ExternalDataExchangeService?外部數(shù)據(jù)通信服務(wù);
????????????功能類_外部事件?外事
=new?功能類_外部事件();
????????????功能類_外部方法?外方
=new?功能類_外部方法();

????????????
public?自定義工作流引擎()
????????????????:
base()
????????????
{
????????????????外部數(shù)據(jù)通信服務(wù)?
=?new?System.Workflow.Activities.ExternalDataExchangeService();
????????????????test.宿主(
"自定義引擎中",?"準(zhǔn)備向引擎添加外部數(shù)據(jù)通信服務(wù)");
????????????????
this.AddService(外部數(shù)據(jù)通信服務(wù));
????????????????外部數(shù)據(jù)通信服務(wù).AddService(外事);
????????????????外部數(shù)據(jù)通信服務(wù).AddService(外方);
????????????????
this.WorkflowCompleted?+=?new?EventHandler<System.Workflow.Runtime.WorkflowCompletedEventArgs>(自定義工作流引擎_WorkflowCompleted);
????????????}


????????????
void?自定義工作流引擎_WorkflowCompleted(object?sender,?System.Workflow.Runtime.WorkflowCompletedEventArgs?e)
????????????
{
??????????
????????????????
if?(外方.父流程ID?!=null?)
????????????????
{
????????????????????Console.WriteLine(
"內(nèi)部完成事件:觸發(fā):子流程完成事件");
????????????????????外事.觸發(fā)子流程完成事件(
"wxd",new?Guid(外方.父流程ID),"wxwinter");
????????????????????外方.父流程ID?
=?null;
????????????????}

????????????????Console.WriteLine(
"內(nèi)部完成事件:工作流完成");
????????????}


????????????
????????????
????????}

????????
}

例子 WWF調(diào)試模板(子流程).rar


?

轉(zhuǎn)載于:https://www.cnblogs.com/foundation/archive/2006/10/25/540033.html

總結(jié)

以上是生活随笔為你收集整理的调用子流程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。