Search

Search:

Namespace:

Search Result
.
Summary
.

Base class for all workflow activities.

.

The full name is System.Workflow.ComponentModel.Activity

.
  • Object
.
    • DependencyObject
.
        • CallExternalMethodActivity
.
        • CodeActivity
.
        • InvokeWebServiceActivity
. .
        • PolicyActivity
.
        • WebServiceOutputActivity
.
        • CompensateActivity
.
        • CompositeActivity
.
          • CancellationHandlerActivity
.
          • ConditionedActivityGroup
. .
          • ReplicatorActivity
. . . .
            • StateInitializationActivity
.
            • StateMachineWorkflowActivity
. .
          • CompensatableTransactionScopeActivity
. . . .
        • ThrowActivity
.
      • ActivityCondition
.
        • CodeCondition
.
        • RuleConditionReference
.
      • CorrelationToken
. .
.

Check out the formatting tips on the right for help formatting and making links.

.

Use the template below:

.
Summary
.

Add your wiki text here.

.
Summary
.

A condition is an expression, which evaluates to a Boolean value.

.

Windows Workflow Foundation offers two condition types: CodeCondition and RuleConditionReference.

.

You can create a custom condition type by deriving from this class and implementing the EvaluateMethod.

.
Summary
.

Designer themes define the look and feel of a designer. This includes any background styles, foreground styles, fonts, and icons defined for the designer.

.

You can create a custom designer theme if you want to provide configuration abilities to properties unique to your designer. If you do not specify a designer theme for a custom designer, the theme from the base class is used.

.

See also ChangingTheActivityDesignerTheme

.
Summary
.

Use the CloseActivity function to indicate that an event driven activity is finished executing by setting its state to Closed. Alternatively you can cancel the activity by calling the CancelActivity function.

.

One of the more frequently used functions is the GetService which return one of the configured RuntimeServices.

.
Summary
.

System.Workflow.ComponentModel.Activity has several overridable methods defined, but there is a newer subset of these methods which I like to refer to as "Lifetime" methods. These are methods that bookend the activity's life from some point of view. They are:

.

OnActivityExecutionContextLoad / OnActivityExecutionContextUnload / Dispose

.

Initialize (also a signal method) / Uninitialize

.

Short Version

.

The short version is that OnActivityExecutionContextLoad and OnActivityExecutionContextUnload bookend the activity's memory lifetime as far as the Windows Workflow Foundation (WF) runtime is concerned. OnActivityExecutionContextLoad will be called just after an activity is loaded into the runtime's memory and OnActivityExecutionContextUnload will be called just before an activity is persisted to the database.

.

OnActivityExecutionContextLoad also has a component of being paired with Dispose to represent the activity's memory lifetime as it applies to the CLR. Activities which run almost never have their constructors called directly but instead these activities are deserialized from a stream. That means that OnActivityContextLoad is really the only safe place to do object creation time resource allocation. Dispose is called before an object is released for garbage collection by the runtime and could be used for NonSerialized activity fields which need to be closed, disposed, or cleaned up in any other way.

.

Initialize and Uninitialize are the markers for an activity's execution lifetime. For the rest of this paragraph any reference to an "activity instance" will have NOTHING to do with its CLR lifetime. Since workflows are unloaded and loaded numerous times during execution a single "activity instance" could actually have been executed through the use of dozens of CLR object instances of the activity. That said, before an "activity instance" will take part in any of the protocol signals it will be initialized; this includes the initialization of cloned activities which execute in new contexts. Once an "activity instance" is done taking part in the protocol it will have Uninitialize called.

.

Long Version

.

Before an activity does anything (IE – when it is loaded into memory within the runtime’s scope) OnActivityExecutionContextLoad will be called. Initialize is called on every activity in the workflow tree at workflow Create time. Initialize is also called for every clone in a context spawning activity when the clone is spawned. You can tell that you are a cloned activity because IsDynamicActivity will be set to true.

.

OnActivityExecutionContextUnload is called before an activity is saved to the database. This means that if the workflow is unloading then this method will be called … additionally if a context is being saved for future compensation then this method will be called on all contained activities. Note that PersistOnClose does not cause OnActivityExecutionContextUnload to be called for the workflow as a whole because the workflow object is not being jettisoned from memory.

.

Dispose is called when we are done with the .NET object representing the activity. So, in the workflow unload case, we will call OnActivityExecutionContextUnload immediately followed by Dispose. In the case of PersistOnClose we will NOT call Dispose on any activities. Only when the activity is being removed from memory will Dispose be called.

.

Uninitialize has two cases. 1) The activity does not have any compensation responsibilities. 2) The activity has to remain “valid” for compensation. Essentially, Uninitialize is the WF approximation of NETs Dispose … when we think an activity will never be called upon to take part in the activity protocol again then we will Uninitialize it. This shows up as a new flag on ActivityExecutionResult.

.

For activities which fall in category (1) Uninitialize is called immediately after the activity closes. Any primitive activity which does not implement ICompensatableActivity has this behavior. Additionally, any composite activity which has NO children, grandchildren, great grandchildren, etc. which implement ICompensatable will be uninitialized immediately as well. However, if an activity or any of its children or sub children implement ICompensatableActivity then the activity will NOT be Uninitialized until the compensatable activity has either been compensated or has been determined that it cannot ever be compensated (the workflow terminates or completes). For example, if I have the following:

.
                        Code
.
                        MyCompensatableActivity
.

Code will uninitialize immediately. MyCompensatableActivity, Sequence, and While will NOT be able to uninitialize until either MyCompensatable activity compensates or the workflow completes and disposes of the compensatable activity.

.

Finally, the reason for the caveat that Uninitialize is an “approximation” of .NET’s Dispose is because you can execute disposed activities again. It is possible to “rerun” an activity which has executed and closed in another context. Using a Page Flow example, imagine that you have an activity which represents Page3. The user enters data into Page3 which you save as fields on your activity. They then proceed to Page4 causing WF to close Page3 and then call Uninitialize. It is possible to model the user pressing the Back button by simply creating a new context and passing the closed Page3 object from the old context as the template activity. This will cause the Page3 object to have Initialize called again, but all of the data will be intact just as it was left at the return of the previous Uninitialize call.

.
Source
.
Summary
.

A serialization surrogate gives you an object that can handle the serialization requirements of a different object and, if necessary, can transform the serialized data.

.

WindowsWorkflowFoundation uses the ActivitySurrogateSelector as the way to serialize and deserialize all Activities. Use the ChainSelector function to add any additional custom ISurrogateSelector required.

.

See Jon Flanders blog post about using WF and Serialization Part One at http://www.masteringbiztalk.com/blogs/jon/PermaLink,guid,5f4d8c41-73bf-4d7f-93b4-8934130a783b.aspx.

.
Summary
.

Whenever the execution status of an activity changes, the WorkflowInstance emits an activity status event to the runtime tracking infrastructure. An ActivityTrackPoint defines a point of interest in the potential execution path of a workflow, qualified by such an activity status event. An ActivityTrackPoint contains locations that are included in matching, locations that are excluded from matching, and the data that should be extracted from the WorkflowInstance when the track point is matched. You can add an ActivityTrackPoint to ActivityTrackPoints to instruct the runtime tracking infrastructure to send an ActivityTrackingRecord to the tracking service when the specified set of activity status events occur. A single ActivityTrackPoint may be matched at multiple points in the workflow instance.

.

An ActivityTrackingLocation contains match conditions for a location or locations in the potential execution path of a workflow instance. You can add ActivityTrackingLocation objects to MatchingLocations to define locations that should be included in matching by the track point. Similarly, you can add ActivityTrackingLocation objects to ExcludedLocations to define locations that should be excluded from matching by the track point.

.

You can add ActivityDataTrackingExtract objects and WorkflowDataTrackingExtract objects to Extracts to specify data that should be extracted from the workflow instance when the track point is matched. The extracted data will be included in the ActivityTrackingRecord.

.

You can add to Annotations to specify additional information associated with the track point. These annotations will be included in the ActivityTrackingRecord sent when the track point is matched.

.
Summary
.

Create a derived class from ActivityValidator and add it to your custom activity using the ActivityValidatorAttribute. For example:

.

[ActivityValidator(typeof(ValidatedActivityValidator))]

.
    // Code left out
.

The validator class now look like this:

.

class ValidatedActivityValidator : ActivityValidator

.
    public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
.
        ValidationErrorCollection result = base.Validate(manager, obj);
.
        //MessageBox.Show("ValidatedActivityValidator.Validate");
.
        ValidatedActivity activity = obj as ValidatedActivity;
.
                result.Add(new ValidationError("The value is to small", 102, false, "AValueBetween1And250"));
.

Note that the object parameter (obj) is the activity to be validated.

.

The ActivityValidator type contains two virtual function Validate and ValidateProperties. It doesn't really matter which you use as the Validate actually calls the ValidateProperties function. This means they are both called at the same time unless you change the behavior by not calling the base.Validate() function.

.

To indicate errors or warnings you can add a ValidationError object to the ValidationErrorCollection to be returned. Adding the property name makes life easy on the developer using your activity because it allows the designer to automatically select the property by double clicking the error.

.

Another thing to keep in mind is that the validator will be called when the activity itself is compiles. To see if this is the case check the activity Parent class which will be null.

.

The validator is also called when the workflow is executed allowing for runtime property checking.

.

eFront-Интернет магазин Бытовой и компьютерной техники www.e-front.com.ua

.
Summary
.

Property of a ReplicatorActivity to use with an UntilCondition to check is the replicator is done executing.

.

http://msdn.microsoft.com/en-us/library/system.workflow.activities.replicatoractivity.allchildrencomplete.aspx

.
Summary
.

In this nice article http://developer.amazonwebservices.com/connect/entry.jspa?entryID=635&ref=featured MarkBlomsma shows how to use the Amazon Mechanical Turk API from a workflow.

.

my mp3 collection, <a href="http://pedrrosso.isuisse.com/what-is-a-condenser-boiler.html">What Is A Condenser Boiler</a>, [url="http://pedrrosso.isuisse.com/what-is-a-condenser-boiler.html"]What Is A Condenser Boiler[/url], http://pedrrosso.isuisse.com/what-is-a-condenser-boiler.html What Is A Condenser Boiler, 2862, <a href="http://bellona.isuisse.com/what-is-a-knock-sensor.html">What Is A Knock Sensor</a>, [url="http://bellona.isuisse.com/what-is-a-knock-sensor.html"]What Is A Knock Sensor[/url], http://bellona.isuisse.com/what-is-a-knock-sensor.html What Is A Knock Sensor, , <a href="http://verronique.isuisse.com/what-is-a-basic-day-in-training.html">What Is A Basic Day In Training</a>, [url="http://verronique.isuisse.com/what-is-a-basic-day-in-training.html"]What Is A Basic Day In Training[/url], http://verronique.isuisse.com/what-is-a-basic-day-in-training.html What Is A Basic Day In Training, fnai, <a href="http://valdemadera.isuisse.com/what-is-a-kpi.html">What Is A Kpi</a>, [url="http://valdemadera.isuisse.com/what-is-a-kpi.html"]What Is A Kpi[/url], http://valdemadera.isuisse.com/what-is-a-kpi.html What Is A Kpi, 718, <a href="http://chaccon.isuisse.com/what-is-a-full-service.html">What Is A Full Service</a>, [url="http://chaccon.isuisse.com/what-is-a-full-service.html"]What Is A Full Service[/url], http://chaccon.isuisse.com/what-is-a-full-service.html What Is A Full Service, xojpu, <a href="http://bellona.isuisse.com/what-is-a-fistula.html">What Is A Fistula</a>, [url="http://bellona.isuisse.com/what-is-a-fistula.html"]What Is A Fistula[/url], http://bellona.isuisse.com/what-is-a-fistula.html What Is A Fistula, 8))), <a href="http://trevvino.isuisse.com/what-is-a-clock-generator.html">What Is A Clock Generator</a>, [url="http://trevvino.isuisse.com/what-is-a-clock-generator.html"]What Is A Clock Generator[/url], http://trevvino.isuisse.com/what-is-a-clock-generator.html What Is A Clock Generator, 49131, <a href="http://eussebio.isuisse.com/what-is-a-characteristic-of-longitudinal-instability.html">What Is A Characteristic Of Longitudinal Instability</a>, [url="http://eussebio.isuisse.com/what-is-a-characteristic-of-longitudinal-instability.html"]What Is A Characteristic Of Longitudinal Instability[/url], http://eussebio.isuisse.com/what-is-a-characteristic-of-longitudinal-instability.html What Is A Characteristic Of Longitudinal Instability, PP, <a href="http://rivvera.isuisse.com/what-is-a-narcisist.html">What Is A Narcisist</a>, [url="http://rivvera.isuisse.com/what-is-a-narcisist.html"]What Is A Narcisist[/url], http://rivvera.isuisse.com/what-is-a-narcisist.html What Is A Narcisist, >((, <a href="http://bellona.isuisse.com/what-is-a-hostile-workplace.html">What Is A Hostile Workplace</a>, [url="http://bellona.isuisse.com/what-is-a-hostile-workplace.html"]What Is A Hostile Workplace[/url], http://bellona.isuisse.com/what-is-a-hostile-workplace.html What Is A Hostile Workplace, >:DD, <a href="http://eussebio.isuisse.com/what-is-a-credit.html">What Is A Credit</a>, [url="http://eussebio.isuisse.com/what-is-a-credit.html"]What Is A Credit[/url], http://eussebio.isuisse.com/what-is-a-credit.html What Is A Credit, dup, <a href="http://verronique.isuisse.com/what-is-a-bear-market.html">What Is A Bear Market</a>, [url="http://verronique.isuisse.com/what-is-a-bear-market.html"]What Is A Bear Market[/url], http://verronique.isuisse.com/what-is-a-bear-market.html What Is A Bear Market, :DDD, <a href="http://saennz.isuisse.com/what-inuyasha-character-will-you-marry.html">What Inuyasha Character Will You Marry</a>, [url="http://saennz.isuisse.com/what-inuyasha-character-will-you-marry.html"]What Inuyasha Character Will You Marry[/url], http://saennz.isuisse.com/what-inuyasha-character-will-you-marry.html What Inuyasha Character Will You Marry, =OO, <a href="http://bellona.isuisse.com/what-is-a-good-bicep-workout.html">What Is A Good Bicep Workout</a>, [url="http://bellona.isuisse.com/what-is-a-good-bicep-workout.html"]What Is A Good Bicep Workout[/url], http://bellona.isuisse.com/what-is-a-good-bicep-workout.html What Is A Good Bicep Workout, 93610, <a href="http://valdemadera.isuisse.com/what-is-a-denial-of-service-attack.html">What Is A Denial Of Service Attack</a>, [url="http://valdemadera.isuisse.com/what-is-a-denial-of-service-attack.html"]What Is A Denial Of Service Attack[/url], http://valdemadera.isuisse.com/what-is-a-denial-of-service-attack.html What Is A Denial Of Service Attack, xpfxn, <a href="http://verronique.isuisse.com/what-i-learned-from.html">What I Learned From</a>, [url="http://verronique.isuisse.com/what-i-learned-from.html"]What I Learned From[/url], http://verronique.isuisse.com/what-i-learned-from.html What I Learned From, =-PPP, <a href="http://saennz.isuisse.com/what-if-jesus-had-never-been-born.html">What If Jesus Had Never Been Born</a>, [url="http://saennz.isuisse.com/what-if-jesus-had-never-been-born.html"]What If Jesus Had Never Been Born[/url], http://saennz.isuisse.com/what-if-jesus-had-never-been-born.html What If Jesus Had Never Been Born, 456688, <a href="http://perralta.isuisse.com/what-is-a-megger-test.html">What Is A Megger Test</a>, [url="http://perralta.isuisse.com/what-is-a-megger-test.html"]What Is A Megger Test[/url], http://perralta.isuisse.com/what-is-a-megger-test.html What Is A Megger Test, qevy, <a href="http://valdemadera.isuisse.com/what-is-a-disadvantage-of-cut-through-switching.html">What Is A Disadvantage Of Cut Through Switching</a>, [url="http://valdemadera.isuisse.com/what-is-a-disadvantage-of-cut-through-switching.html"]What Is A Disadvantage Of Cut Through Switching[/url], http://valdemadera.isuisse.com/what-is-a-disadvantage-of-cut-through-switching.html What Is A Disadvantage Of Cut Through Switching, 8-[[, <a href="http://saennz.isuisse.com/what-is-a-barebones-kit.html">What Is A Barebones Kit</a>, [url="http://saennz.isuisse.com/what-is-a-barebones-kit.html"]What Is A Barebones Kit[/url], http://saennz.isuisse.com/what-is-a-barebones-kit.html What Is A Barebones Kit, %-P, <a href="http://pedrrosso.isuisse.com/what-is-a-business-partner.html">What Is A Business Partner</a>, [url="http://pedrrosso.isuisse.com/what-is-a-business-partner.html"]What Is A Business Partner[/url], http://pedrrosso.isuisse.com/what-is-a-business-partner.html What Is A Business Partner, wwh, <a href="http://valdemadera.isuisse.com/what-is-a-flying-buttress.html">What Is A Flying Buttress</a>, [url="http://valdemadera.isuisse.com/what-is-a-flying-buttress.html"]What Is A Flying Buttress[/url], http://valdemadera.isuisse.com/what-is-a-flying-buttress.html What Is A Flying Buttress, %-[, <a href="http://valdemadera.isuisse.com/what-is-a-dermatologist.html">What Is A Dermatologist</a>, [url="http://valdemadera.isuisse.com/what-is-a-dermatologist.html"]What Is A Dermatologist[/url], http://valdemadera.isuisse.com/what-is-a-dermatologist.html What Is A Dermatologist, gmgetw, <a href="http://chaccon.isuisse.com/what-is-a-healthy-body-fat.html">What Is A Healthy Body Fat</a>, [url="http://chaccon.isuisse.com/what-is-a-healthy-body-fat.html"]What Is A Healthy Body Fat[/url], http://chaccon.isuisse.com/what-is-a-healthy-body-fat.html What Is A Healthy Body Fat, %-]], <a href="http://perralta.isuisse.com/what-is-a-linear-pair.html">What Is A Linear Pair</a>, [url="http://perralta.isuisse.com/what-is-a-linear-pair.html"]What Is A Linear Pair[/url], http://perralta.isuisse.com/what-is-a-linear-pair.html What Is A Linear Pair, %]], <a href="http://chaccon.isuisse.com/what-is-a-doctorate-degree.html">What Is A Doctorate Degree</a>, [url="http://chaccon.isuisse.com/what-is-a-doctorate-degree.html"]What Is A Doctorate Degree[/url], http://chaccon.isuisse.com/what-is-a-doctorate-degree.html What Is A Doctorate Degree, :-]], <a href="http://trevvino.isuisse.com/what-is-a-boilermaker.html">What Is A Boilermaker</a>, [url="http://trevvino.isuisse.com/what-is-a-boilermaker.html"]What Is A Boilermaker[/url], http://trevvino.isuisse.com/what-is-a-boilermaker.html What Is A Boilermaker, 661376,

.

Check out the formatting tips on the right for help formatting and making links.

.

Use the template below:

.
Summary
.

Add your wiki text here.

.

84itRk doors2.txt;25;55

.
Summary
.

See RuntimeModificationOfWorkflows for an example of how to use this function.

.

http://msdn.microsoft.com/en-us/library/system.workflow.runtime.workflowinstance.applyworkflowchanges.aspx

.
Summary
.

The WF runtime engine executes workflows by using runtime services. The runtime service model gives the host application the flexibility to provide various services to the WF runtime engine. This section describes the runtime services that are provided by WF and the out-of-box implementations of those services.

.

See the Windows Workflow Foundation Services and Developing Windows Workflow Foundation Services sections in the WF Programming Guide for more information about the runtime service implementations.

.

The WF runtime provides four services. These services have out-of-box implementations, or, host applications can implement their own services and provide them to the workflow runtime.

.
See
.

Check out the formatting tips on the right for help formatting and making links.

.

Use the template below:

.
Summary
.

Add your wiki text here.

.
Summary
. . . . . .
.
Summary
.

Windows Workflow Foundation, WF for short, is one of the technologies I work a lot with and as a consequence I own several books about WF. Comparing this book with the others I can only say it is one of the best books you can get on the subject. It has a good coverage of almost all the subject you are going to need to know. Not only is there a good coverage but the explanation and examples are very clear. Now there are a few thing missing from the book. As it was written with the .NET framework 3.0 there is no coverage of the WCF integration that comes in the form of the SendActivity and the ReceiveActivity. While this is unfortunate it is also understandable and I can only hope that the author has the time to update the book with one more chapter.

.

For a book this size, about 700 pages, I was amazed at how little I could find that I didn't like. In fact one of few errors I could find is the statement that only a single instance of the WorkflowRuntime can be created per AppDomain. This is a myth that stems back to the first beta's where it was briefly the case but the restriction has been lifted long ago and has never been part of the released product. But given the size of the book and how few people ever need to create multiple WorkflowRuntime objects it is hardly a big objection.

.

So my advise: If you are getting into Windows Workflow Foundation make sure you buy this book!

.

comment6,

.
Summary
.

A local service is a class that implements a local service interface (an interface that is decorated with ExternalDataExchangeAttribute) and is added to the ExternalDataExchangeService.

.

You can use the workflow communication activity command-line utility, wca.exe, to generate interface specific subclasses.

.

Public Interface IDemoDataExchange

.
    Sub SendSomeData(ByVal theData As String)
.
    Event ReceiveSomeData(ByVal sender As Object, ByVal e As ReceiveSomeDataEventArgs)
.

Public Class DemoDataExchange

.
    Implements IDemoDataExchange
.
    Public Event ReceiveSomeData(ByVal sender As Object, ByVal e As ReceiveSomeDataEventArgs) Implements IDemoDataExchange.ReceiveSomeData
.
    Public Sub SendSomeData(ByVal theData As String) Implements IDemoDataExchange.SendSomeData
.
        Dim state As New SendSomeDataState(WorkflowEnvironment.WorkflowInstanceId, theData)
.
        ThreadPool.QueueUserWorkItem(AddressOf InternalSendSomeData, state)
.
    Private Sub InternalSendSomeData(ByVal stateObj As Object)
.
        Dim state As SendSomeDataState = stateObj
.
        Console.WriteLine(state.theData)
.
        Dim reply As String = Console.ReadLine()
.
        Dim args As New ReceiveSomeDataEventArgs(state.instanceId, reply)
.
        RaiseEvent ReceiveSomeData(Nothing, args)
.
    Private Class SendSomeDataState
.

Public Class ReceiveSomeDataEventArgs

.
    Public ReadOnly Property Reply() As String
.
    End Property
.
Summary
Calling IronPython functions from .NET
.

Having worked with Python in the past I find IronPython an interesting language to work with. However the story becomes really interesting if you can combine IronPython with regular strong typed code into one.

.

So I decided to take a look at what it would take to do so with the current IronPython version. I used IronPython 2 Beta 3, based upon the current version of the Dynamic Language Runtime, which is still evolving so the classes might have changed, take care! You can download the latest IronPython release here.

.

Lets take a look at what it takes to use an IronPython class from a Visual Basic Project.

.

The first thing we need is a base class we are actually going to derive from. This is because IronPython doesn't compile its code into a static type but VB requires its variables to be typed. This is the base class I am using:

.

Public Class HelloWorldVB

.
    Public Overridable Function HelloWorld(ByVal name As String) As String
.
        Return String.Format("Hello '{0}' from Visual Basic", name)
.
    End Function
.

And a main module to start thing off:

.
    Dim helloWorld As New HelloWorldVB()
.
    Console.WriteLine(helloWorld.HelloWorld("Maurice"))
.
    Console.ReadLine()
.

No big surprise here .

.

So how do we derive an IronPython class from our VB type?

.

The following code is the IronPython code I added to the file HelloWorld.py.

.

import clr

.

clr.AddReference('IronPythonTest2')

.

from IronPythonTest2 import HelloWorldVB

.

class HelloWorldIronPython(HelloWorldVB):

.
    def HelloWorld(self, name):
.
        return "Hello '" + name + "' from IronPython"
.

Basically this code adds a reference to the IronPythonTest2 assembly, this is my console application containing the previous VB code. Next it imports the HelloWorldVB type from the assembly. Now it know about the type we can go ahead and derive from that type and create a new one. This exactly what the line class HelloWorldIronPython(HelloWorldVB) does, it creates a new type called HelloWorldIronPython. Next we override the HelloWorld function and return a different welcome string. A few things to note here: Python uses indentation to specify blocks, so the function being indented from the class is a part of that and the line of code with the return is indented from the def that defines the function so it is part of the function body. Another interesting thing is the self parameter. Every function in Python is passed a reference to itself as the first parameter. Sort of like the implicit Me in VB except a bit more obvious.

.

If you want to know more about IronPython I suggest you get the book IronPython in Action from Michael Foord.

.

To make sure the HelloWorld.py file is available to the console application I have set the Copy to Output Directory to Copy always.

.

OK so far so good. We have an IronPython class with the code we need. Now we still need to create an object from it. This isn't hard it just takes a bit more doing than just using the New operator.

.

Instantiating the IronPython object

.

The first step is adding the required references. We need to add the following assemblies:

.
   1. IronPython.dll
.
   2. IronPython.Modules.dll
.
   3. Microsoft.Scripting.dll
.
   4. Microsoft.Scripting.Core.dll
.

We will only be using the 1st and 3rd ourselves but the others are needed as well.

.

Once we have the references set we can add the required Imports:

.

Imports Microsoft.Scripting.Hosting

.

Imports IronPython.Hosting

.

Imports IronPython.Runtime.Types

.

And now we can get really going with the code Smile

.

We need to load the file with the Python source code using an IronPython ScriptRuntime. Once done we can get a reference to the IronPython type object using the GetVariable() function by passing in the class name. Once we have that we call the ScriptRuntime again to actually create the object. See the code below:

.

Dim runtime As ScriptRuntime = PythonEngine.CurrentEngine.Runtime

.

Dim scope As ScriptScope = runtime.ExecuteFile("HelloWorld.py")

.

Dim pythonType As PythonType = scope.GetVariable(Of PythonType)("HelloWorldIronPython")

.

helloWorld = CType(runtime.Operations.Call(pythonType), HelloWorldVB)

.

Console.WriteLine(helloWorld.HelloWorld("Maurice"))

.

And with this code we are good to go. Running the complete code will show the output below:

.

.

The complete code in the main module:

.

Option Explicit On

.

Option Strict On

.

Imports Microsoft.Scripting.Hosting

.

Imports IronPython.Hosting

.

Imports IronPython.Runtime.Types

.

Module Module1

.
        Dim helloWorld As New HelloWorldVB()
.
        Console.WriteLine(helloWorld.HelloWorld("Maurice"))
.
        Dim runtime As ScriptRuntime = PythonEngine.CurrentEngine.Runtime
.
        Dim scope As ScriptScope = runtime.ExecuteFile("HelloWorld.py")
.
        Dim pythonType As PythonType = scope.GetVariable(Of PythonType)("HelloWorldIronPython")
.
        helloWorld = CType(runtime.Operations.Call(pythonType), HelloWorldVB)
.
        Console.WriteLine(helloWorld.HelloWorld("Maurice"))
.
        Console.ReadLine()
.

End Module

.

Check out the formatting tips on the right for help formatting and making links.

.

Use the template below:

.
Summary
.

Add your wiki text here.

.
Summary
.

A CancellationHandlerActivity is part of any activity that can have multiple active branches, for example a ListenActivity, a ParallelActivity or a ConditionedActivityGroup. If one branch throws an exception the other branches will be canceled and the CancellationHandlerActivity will be executed to do any cleanup that may be required.

.
Summary
.

Using an ActivityDesignerTheme is a quick way to customize the appearance of an activity in the workflow designer. But there is a gotcha Because once you applied the theme and have a workflow with the custom activity open in the designer no matter what you do changes will not be applied.

.

I am not sure why this is but I suppose the designer caches the color scheme and doesn't see any changes made to it.

.

Take the following activity:

.

using System.ComponentModel;

.

using System.Workflow.ComponentModel;

.

using System.Workflow.ComponentModel.Design;

.

namespace WorkflowConsoleApplication4

.
    [Designer(typeof(MyActivity1ActivityDesigner))]
.
    [ActivityDesignerTheme(typeof(MyActivity1ActivityDesignerTheme))]
.
        /// Initializes a new instance of the MyActivity1ActivityDesignerTheme class.
.
        public MyActivity1ActivityDesignerTheme(WorkflowTheme theme)
.
            BackColorStart = Color.LightBlue;
.
            BackColorEnd = Color.Blue;
.
            BackgroundStyle = LinearGradientMode.ForwardDiagonal;
.

Which look like this in the designer

.

.

Clearly the background has a blue gradient. Now if I change the theme code to the following:

.
    /// Initializes a new instance of the MyActivity1ActivityDesignerTheme class.
.
    public MyActivity1ActivityDesignerTheme(WorkflowTheme theme)
.
        BackColorStart = Color.LightCyan;
.
        BackColorEnd = Color.Cyan;
.
        BackgroundStyle = LinearGradientMode.ForwardDiagonal;
.

You might expect the activity to change its look to:

.

.

Unfortunately this doesn't happen

.

Now you can quit Visual Studio and restart it after which the new style will take affect but there is a quicker way. Right click the activity and select "Select Custom Theme..."

.

.

When the dialog shows just click OK and the designer reads the theme again Smile

.
Summary
.
    Private Sub WebServiceInvoking(ByVal sender As System.Object, ByVal e As System.Workflow.Activities.InvokeWebServiceEventArgs)
.
        Dim proxy As localhost.Service
.
        proxy = CType(e.WebServiceProxy, localhost.Service)
.
        proxy.Url = "some new URL"
.
Summary
.

Most often used when creating asynchronously executing, ie long running activities. In the Execute function you return ActivityExecutionStatus.Executing indicating that the Activity is still executing. When the work in the activity is finished the ActivityExecutionContext.CloseActivity() function is called informing the WorkflowRuntime that the Activity is done.

.
Summary
.

Code-beside methods invoked by CodeActivity are executed in a synchronous manner; CodeActivity does not yield its thread until the thread is finished. Therefore, the execution of the code-beside method is expected to be performed and should not block with a dependency on some external resource. For example, the code-beside method should typically not invoke a WebService.

.

The typical use of the CodeActivity is to examine WorkflowInstance state, and change local variables and messages.

.
Summary
.

CodeConditionVersusRuleConditionReference

.
Summary
.

Why would you use a CodeCondition or a RuleConditionReference.

.

Advantages of a RuleConditionReference is that the actual rule is stored in a separate XML file with the extension .rules. This means that rules can be manipulated by other tools, for example made visible to business analysts, and even be changed at runtime.

.

The main advantage of a CodeCondition is that developers are more familiar with code so it may feel more natural for them. Another advantage is that complex logic may be harder to build using the rule editor than using the code editor. One confusing thing of the CodeCondition is that the result is not returned from the function but is set as the Result property on the ConditionalEventArgs property.

.

Check out the formatting tips on the right for help formatting and making links.

.

Use the template below:

.
Summary
.

Add your wiki text here.

.
Summary
.

There are two basic ways to configure the WF runtime. So if you use either one things are clear about what is going to happen but suppose you combine the two. In the case the same setting is done both in code and the config file the first one, that is the code, wins and overwrites the one done through the config file. Nice as this leaves a developer free to allow for runtime configuration but still give him the control to ensure that certain settings are the way he expects.

.
Summary
.
    Implements IEventActivity, IActivityEventListener(Of QueueEventArgs)
.
    Public Sub OnEvent(ByVal sender As Object, ByVal e As QueueEventArgs) Implements IActivityEventListener(Of QueueEventArgs).OnEvent
.
        Dim executionContext As ActivityExecutionContext = CType(sender, ActivityExecutionContext)
.
        Dim wqs As WorkflowQueuingService = executionContext.GetService(Of WorkflowQueuingService)()
.
        Dim queue As WorkflowQueue = wqs.GetWorkflowQueue(QueueName)
.
        Dim item As Object = queue.Dequeue()
.
        ' ToDo: Implement
.
        executionContext.CloseActivity()
.
    Protected Overrides Function Execute(ByVal executionContext As ActivityExecutionContext) As ActivityExecutionStatus
.
        Dim status As ActivityExecutionStatus
.
        If IsInEventActivityMode Then
.
            status = ActivityExecutionStatus.Closed