WF 4.0:在客户端获取WF InstanceID [英] WF 4.0: Get WF InstanceID on client side

查看:161
本文介绍了WF 4.0:在客户端获取WF InstanceID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!我有一个非常简单的WCF WF服务(4.0 beta2),这是VS 2010 Bet2为"WCF WF服务应用程序"创建的简单模板.我有一个用于此WF的WCF客户端.
如何获取在客户端上已在其中创建WCF代理的激活的WF的insatnceID.
IContextManager contextManager =客户端. InnerChannel.GetProperty< IContextManager>()返回null.
谢谢.

Hello!
I have a very simple WCF WF service (4.0 beta2), simple template that VS 2010 Bet2 creates for "WCF WF Service Application". I have a WCF client for this WF.
How can I obtain insatnceID of WF activated on client side (where I have created proxy for WCF).
IContextManager contextManager = client.InnerChannel.GetProperty<IContextManager>() return null.
Thanks.

推荐答案

一种方法是让WF发送实例客户端的ID.

在服务器端,您可以编写一个自定义活动来获取实例ID.您可以使用此CodeActivity的结果绑定到一些发送回客户端的数据.
我们已将其包含在RC示例中,但这是代码:

//- -------------------------------------------------- --------------------------
//版权所有(c)Microsoft Corporation.保留所有权利.
//---------------------------------------- -------------------------------------

One way to do this is to have your WF send the instance id to the client.

On the server side, you can write a custom activity to get the instance id. You can use the result from this CodeActivity to bind to some data you send back to the client.
We've included this in the RC samples, but here's the code:

//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

使用System;
使用System.Activities;

using System;
using System.Activities;

命名空间Microsoft.Samples.Activities.Statements
{

namespace Microsoft.Samples.Activities.Statements
{

///< summary>
///此活动返回其在
中执行的工作流的实例ID.///
///我们选择CodeActivity作为基础类型,因为我们需要访问CodeActivityContext才能访问工作流实例ID.
///
///此活动返回实例ID的System.Guid
///< ;/summary>
////
公共密封类GetWorkflowInstanceId:CodeActivity< Guid>
返回context.WorkflowInstanceId;
}
}
}

话虽如此,为什么要在工作端上添加工作流实例ID?

    /// <summary>
    /// This activity returns the instance id of the workflow it is executing in
    ///
    /// We choose CodeActivity as the base type because we need access to the CodeActivityContext for getting access to the workflow instance ID.
    ///
    /// This activity returns a System.Guid for the instance ID
    /// </summary>
    ///
    public sealed class GetWorkflowInstanceId : CodeActivity<Guid>
    {
        protected override Guid Execute(CodeActivityContext context)
        {
            return context.WorkflowInstanceId;
        }
    }
}

All that said, why do you want the workflow instance id on the clietn side?


这篇关于WF 4.0:在客户端获取WF InstanceID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆