本文介绍了SqlWorkflowInstanceStore可以为我做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,

(1)如何从存储中获取所有持久化实例,哪一个 准备好加载并运行了吗?我有三个这样的实例,但是WaitForEvents()总是只给我一个实例,尽管该方法返回的是List< InstancePersistenceEvent>. 这就是我所拥有的:

(1) How can I get all persisted instances from the store, which  are ready to be loaded and run? I have three instances like that, but WaitForEvents() always gets me just one, although the method returns a List<InstancePersistenceEvent>.  This is what I have:

           List< Guid> readyToRun =新列表< Guid>();

            List<Guid> readyToRun = new List<Guid>();

           bool timeout = false;
           试试
            {
                List< InstancePersistenceEvent> events = _wfstore.WaitForEvents(_wfh,TimeSpan.FromSeconds(5));
                foreach(事件中的InstancePersistenceEvent evt)
                {
                   如果(evt == HasRunnableWorkflowEvent.Value)
                    {
                        TryLoadRunnableWorkflowCommand cmd =新的TryLoadRunnableWorkflowCommand();
                        InstanceView iview = _wfstore.Execute(_wfh,cmd,TimeSpan.FromSeconds(5));
                        readyToRun.Add(iview.InstanceId);
                    }
                   否则,如果(evt是HasActivatableWorkflowEvent)
                    {
                    }
                }
            }
           捕获(TimeoutException)
            {
               返回Guid.Empty;
            }

            bool timeout = false;
            try
            {
                List<InstancePersistenceEvent> events = _wfstore.WaitForEvents(_wfh, TimeSpan.FromSeconds(5));
                foreach (InstancePersistenceEvent evt in events)
                {
                    if (evt == HasRunnableWorkflowEvent.Value)
                    {
                        TryLoadRunnableWorkflowCommand cmd = new TryLoadRunnableWorkflowCommand();
                        InstanceView iview = _wfstore.Execute(_wfh, cmd, TimeSpan.FromSeconds(5));
                        readyToRun.Add(iview.InstanceId);
                    }
                    else if (evt is HasActivatableWorkflowEvent)
                    {
                    }
                }
            }
            catch (TimeoutException)
            {
                return Guid.Empty;
            }

WaitForEvents()是否会返回多个?在什么情况下?然后,具有多个事件与TryLoadRunnableWorkflowCommand检索单个InstanceView有何关系?

Will WaitForEvents() ever return more than one? Under what scenario? And then, how having multiple events relates to the TryLoadRunnableWorkflowCommand retrieving a single InstanceView?

我的假设是WaitForEvents()返回单个持久化实例的事件,因此我必须将以上内容放入循环中以获取所有事件.请确认.

My assumption is that WaitForEvents() returns events for a single persisted instance, so I have to put the above in a loop to get them all. Please confirm.

另外,实例被拿起的顺序是什么?我对此有话要说吗?

Also, what's the order the instances get picked up? Do I have any say in this?

(2)现在,我有了一个InstanceView,如何从中确定要使用哪个工作流程定义(活动),以便可以实例化它的WorkflowApplication(活动),Load()和Run()?我是否在Activity及其所有正在运行的实例之间保留自己的映射?

(2) Now that I have an InstanceView, how do I figure from it which workflow definition (Activity) to use so I can instantiate a WorkflowApplication(Activity), Load() and Run() it? Do I keep my own mapping between an Activity and all of its running instances?

(3)如何使用InstanceHandle?它具有Free()方法.我什么时候必须/应该/可以打电话给它?在获取可运行实例的上述代码之后,我必须调用_wfh.Free(),否则我的WorkflowApplication对象上的Load()会失败,并带有InstanceHandleConflictException ("InstancePersistenceCommand的执行被中断,因为另一个有效的InstanceHandle持有实例'bbf4ad46-62be-421d-bfb3-db051c49ad84'的锁,表明该实例的非陈旧副本已被加载.加载的副本 实例及其关联的InstanceHandle的实例应该被使用或卸载.")

(3) How do I use the InstanceHandle? It has a Free() method. When must/should/may I call it? After the above code for getting a runnable instance I have to call _wfh.Free(), otherwise my Load() on the WorkflowApplication object fails with InstanceHandleConflictException ("The execution of an InstancePersistenceCommand was interrupted because another valid InstanceHandle holds a lock on instance 'bbf4ad46-62be-421d-bfb3-db051c49ad84', indicating that a non-stale copy of the instance is already loaded. The loaded copy of the instance and its associated InstanceHandle should be used or unloaded.")

(4)我可以为我的所有持久性存储需求重用一个SqlWorkflowInstanceStore实例-所有WorkflowApplication实例,任何InstancePersistenceCommand-s Execute()等.

(4) Can I reuse a single SqlWorkflowInstanceStore instance for all my persistence store needs - all WorkflowApplication instances, any InstancePersistenceCommand-s I Execute(), etc.

谢谢!

tjk:)

推荐答案

这里还有另一个讨论类似的话题:

There is another thread with a similar discussion here:

http://social.msdn.microsoft .com/Forums/zh-CN/wfprerelease/thread/49dfd5a8-f937-4787-b4c2-eae1cf7e868c

WF/WCF样本包中有一个新样本,该样本涵盖了在此处加载可运行实例的情况:

There is a new sample in the WF/WCF sample package that covers loading runnable instances available here:

http://www.microsoft.com/downloads/details.aspx?FamilyID=35ec8682-d5fd-4bc3-a51a-d8ad115a8792&displaylang=en

 

提取样本后,路径即为:  WF_WCF_Samples \ WF \ Basic \ Services \ AbsoluteDelay \ CS \ AbsoluteDelay

此示例的文档尚未发布,因此我没有相应的链接,但是它显示了如何加载可运行实例.

The documentation for this sample has not been published so I don't have a link for that, but it shows how to load the runnable instances.

让我检查一下有关您的4个问题的具体答案,但是当我研究此问​​题时,这个新样本可能会提供一些见识.

Let me check into getting specific answers for your 4 questions, but possibly this new sample may provide some insight while I am looking into this.

对于#4,您是说要在不同主机上使用一个数据库吗?或者,您是指在主机中运行的WorkflowApplication的不同实例中使用的对象的单个实例?如果是第二个,那么答案 是的,绝对延迟"示例在应用程序的整个生命周期中使用单个InstanceStore,并使用多个不同的WorkflowApplication实例.

For #4, do you mean a single database to use from your different hosts? Or do you mean a single instance of the object that you use among the different instances of WorkflowApplication that you have running in your host? if it is the second, then the answer is yes, the Absolute Delay sample uses a single InstanceStore throughout the lifetime of the app, and several different WorkflowApplication instances.

史蒂夫·丹尼尔森[Microsoft]
该发布是按原样"提供的.没有任何保证,也不授予任何权利.
使用包含的脚本示例必须遵守中指定的条款.http://www.microsoft.com/info/cpyright.htm

Steve Danielson [Microsoft]
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

 


这篇关于SqlWorkflowInstanceStore可以为我做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 08:11