workflow-foundation-4

AsyncTaskCodeActivity and lost context after await

喜夏-厌秋 提交于 2019-12-07 07:18:12
问题 AsyncTaskCodeActivity fails when the context parameter is accessed after the first await is performed. For example: public class TestAsyncTaskCodeActivity : AsyncTaskCodeActivity<int> { protected async override Task<int> ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) { await Task.Delay(50); // context has already been disposed and the next line throws // ObjectDisposedException with the message: // An ActivityContext can only be accessed within the scope

WF4RC, WriteLine activity throws error on StringWriter assigned to TextWriter

假如想象 提交于 2019-12-07 04:51:27
问题 am new to Windows Workflow [WF], and interested in evaluating WF for business purposes. I decided to work through an introduction [TestMethod] public void TestMethod () { TextWriter writer = new StringWriter (); Sequence sequence = new Sequence { Activities = { // so, assigning a reference type [eg StringWriter] // as target is prohibited in WF4RC. what or how do // i assign a target? introduction cited above may // not be current [ie may be Beta2, not RC] so ... ? new WriteLine { Text =

Loading a workflow stored as XAML in .NET 4.0

有些话、适合烂在心里 提交于 2019-12-07 03:16:34
问题 What is the syntax for loading a .NET 4.0 Beta2 workflow that was previously created and stored as XAML. The WorkflowElement and WorkflowXamlServices classes no longer exist. I am trying to do something like this (that worked in Beta 1): WorkflowElement wf = WorkflowXamlServices.Load(File.OpenRead("Workflow.xaml")) as WorkflowElement; 回答1: Found my own answer after further research. The WorkflowElement and WorkflowXamlServices classes have been removed from Beta2. The approach above requires

Get a list of persistent objects stored in database

给你一囗甜甜゛ 提交于 2019-12-06 19:43:32
I should insert a list of objects in a database using a workflow for each object, the inserting process could take several time and waiting for some external input so I have to save persistent state in db, and it works correctly. Now I need to show pending objects in my user interface, how can I retrieve variables of stored data?? Thank you, Marco See How to: Deserialize Instance Data Properties 来源: https://stackoverflow.com/questions/7530839/get-a-list-of-persistent-objects-stored-in-database

Validate an Activity from within an ActivityDesigner?

送分小仙女□ 提交于 2019-12-06 15:42:08
I'd like to validate the workflow within the design surface (in this case, Visual Studio) from within one of the child Activities' designer. I'd like to prevent users from moving forward until other errors are corrected in order to simplify the design experience later down the road. The naiive implementation doesn't work: var activity = (this.ModelItem.Root.GetCurrentValue() as ActivityBuilder) .Implementation as Activity; var validationResult = ActivityValidationServices.Validate(activity); if (validationResult.Errors.Count > 0)) { MessageBox.Show("The Workflow is invalid. Fix it.", "Derp");

Solution for “XamlInjector–Cannot create unknown type errors” does not work

给你一囗甜甜゛ 提交于 2019-12-06 14:56:06
In unit test, i passed the assembly of Custom Activity to the ctor as the local assembly var xamlInjector = new XamlInjector("CreditAtRenewalFlow.xaml", typeof(CreateFollowUp).Assembly); CreateFollowUp is a AsynCodeActivity I got error "'Unexpected 'PROPERTYELEMENT' in parse rule 'Element ::= . EmptyElement | ( StartElement ElementBody ).'.' Line number '2' and line position '4'." at execution of the following line var host = WorkflowInvokerTest.Create(xamlInjector.GetActivity()); The sample of the unit test is [TestMethod] [DeploymentItem(@"src\ProcessFlows\Activity1.xaml")] public void

Windows Workflow 4.5 Version Mapping

做~自己de王妃 提交于 2019-12-06 14:53:08
问题 Suppose if there are two versions of the workflow, some instances are running on version1 and some on version2 , Is there any way so that we can call version1 workflow instead of version2 for a new instance, as we create a instance of workflow it will by default create the instance of version2. 回答1: .net Framework 4.5 introduces Workflow Versioning which seems to be exactly what you need. These two links should be enough to get started: Using WorkflowIdentity and Versioning How to: Host

Working with sub-workflow in rehosted designer?

六月ゝ 毕业季﹏ 提交于 2019-12-06 14:43:31
Is it possible to work with a sub-workflow (i.e. subset of the workflow in the designer). For example a sequence, a flowchart, or any activity inside the workflow. My idea is something like these: Save the subworkflow to a file (for example, save the selected Sequence activity) Load a saved subworkflow and add it into current workflow Add a sub-workflow as an item in toolbox Are these even possible in WF4? Sounds very much like your sub worklfows are just composite activities. Doing so is easy if you compile them as they become regular activity types and you can do with them as you like. If

Registering custom tracking participants through code in workflow foundation 4.0

醉酒当歌 提交于 2019-12-06 13:51:32
I'm having trouble trying to attach a custom tracking participant in workflow foundation 4.0. I have a class that inherits from TrackingParticipant but I cannot see any other way of attaching it to my WorkflowServiceHost other than through lots of messy app.config entries like the SDK example demonstrates below (in the system.servicemodel element). This option seems to require a lot of extra overhead and classes to be created, when I just want a simple custom tracking participant to listen to my CustomTrackingRecord.Data.Add(key, value) calls. public class CustomTracking : TrackingParticipant

Resuming a persisted Window Workflow 4 Activity without knowing concrete type of activity

我的未来我决定 提交于 2019-12-06 13:13:40
I am trying to understand how one can resume (load) a previously persisted WF4 activity without knowing the concrete type of the activity. In order to load a persisted activity, I not only need its workflowId (which I have), but I need to pass in an instance of the activity too - so I need to know it's type: var workflowApplication = new WorkflowApplication(activity); // what type is activity? workflowApplication.Load(workflowId); The problem is that it could be one of a number of types - this activity is intended to be used within other activities and workflows: it sends a message to a