如何获取活动中的工作流实例?

发布于 2024-09-15 10:26:42 字数 414 浏览 4 评论 0原文

我无法在工作流程的代码活动中获取工作流程实例。如何获取它?我确实检查了 WorkflowEventArgs.WorkflowInstance 属性 但在我的代码活动中,我没有 WorkflowEventArgs。相反,我有 EventArgs

我想要做什么:

基本上,我需要访问工作流队列数据以获取队列中的值。在上面的网址中,代码是相同的,但是它不在代码活动中?访问队列的正确方法是什么?

I was not able get the workflow instance in code activity of my workflow.how do I get it? I did check WorkflowEventArgs.WorkflowInstance Property but in my code activity i do not have WorkflowEventArgs. instead i have EventArgs.

What I am trying to do:

basically, i need to access the Workflow queue data to get the values in queue. in the above url, the code is for the same but, its not in a code activity? what is the correct way to access the queue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ˉ厌 2024-09-22 10:26:43

来自获取您的工作流实例:

public sealed class LogState : CodeActivity
{
    protected override void Execute(CodeActivityContext context)
    {
        Guid instanceId = context.WorkflowInstanceId;
        var connection = ConfigurationManager.ConnectionStrings["ConnectionString"];


        WorkflowInstanceProxy proxy = context.GetExtension<WorkflowInstanceInfo>().GetProxy();
        //...
    }

    protected override void CacheMetadata(CodeActivityMetadata metadata)
    {
        base.CacheMetadata(metadata);
        metadata.AddDefaultExtensionProvider<WorkflowInstanceInfo>(() => new WorkflowInstanceInfo());
    }

    public class WorkflowInstanceInfo : IWorkflowInstanceExtension
    {
        WorkflowInstanceProxy proxy;

        public IEnumerable<object> GetAdditionalExtensions()
        {
            yield break;
        }

        public void SetInstance(WorkflowInstanceProxy instance)
        {

            this.proxy = instance;
        }

        public WorkflowInstanceProxy GetProxy() { return proxy; }
    }

From Getting Your Workflow Instance:

public sealed class LogState : CodeActivity
{
    protected override void Execute(CodeActivityContext context)
    {
        Guid instanceId = context.WorkflowInstanceId;
        var connection = ConfigurationManager.ConnectionStrings["ConnectionString"];


        WorkflowInstanceProxy proxy = context.GetExtension<WorkflowInstanceInfo>().GetProxy();
        //...
    }

    protected override void CacheMetadata(CodeActivityMetadata metadata)
    {
        base.CacheMetadata(metadata);
        metadata.AddDefaultExtensionProvider<WorkflowInstanceInfo>(() => new WorkflowInstanceInfo());
    }

    public class WorkflowInstanceInfo : IWorkflowInstanceExtension
    {
        WorkflowInstanceProxy proxy;

        public IEnumerable<object> GetAdditionalExtensions()
        {
            yield break;
        }

        public void SetInstance(WorkflowInstanceProxy instance)
        {

            this.proxy = instance;
        }

        public WorkflowInstanceProxy GetProxy() { return proxy; }
    }
你的背包 2024-09-22 10:26:43

我对你的问题有点困惑。这是你想要的吗?

public sealed class GetWorkflowIdActivity : CodeActivity<string>
{
    protected override string Execute(CodeActivityContext context)
    {
        return context.WorkflowInstanceId.ToString();
    }
}

I'm a little confused by your question. Is this what you want?

public sealed class GetWorkflowIdActivity : CodeActivity<string>
{
    protected override string Execute(CodeActivityContext context)
    {
        return context.WorkflowInstanceId.ToString();
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文