ACTIVITIES in Microsoft Word

Drawer Data Matrix in Microsoft Word ACTIVITIES

CHAPTER 5 ACTIVITIES
ECC200 Drawer In None
Using Barcode creation for Word Control to generate, create Data Matrix ECC200 image in Microsoft Word applications.
www.OnBarcode.com
Barcode Creator In None
Using Barcode generation for Office Word Control to generate, create Barcode image in Word applications.
www.OnBarcode.com
Line 24 actually executes our child activity within the context passed in for our activity. Line 25 sets our ActivityStarted variable so that we know that we have launched at least one child activity. Because they are contained within the loop started on line 18, lines 23 25 execute once for each enabled child activity. Line 28 sets up our return value based on whether or not we started up any child activities. If we did, we return a value indicating that our activity is still running. We ll take care of closing out our activity when we handle the close events for our children. If we did not fire up any child activities, we just pass back a value indicating that our activity is closed and done processing. Listing 5-19. The Execute Method for Our Composite Activity 1 2 3 4 5 6 7 8 9 10 11 12 13 protected override ActivityExecutionStatus Execute( ActivityExecutionContext executionContext) { this.Running = true; bool ActivityStarted = false; If (this.Condition.Evaluate(this, executionContext)) { for (int i = 0; i < this.Activities.Count; i++) { if ((string)this.Activities[i].UserData["logger"] == "logger") { LogToHistoryListActivity logger = ( LogToHistoryListActivity)this.Activities[i]; logger.HistoryDescription = string.Format(@"Begin Activity Execution:{0} with {1} enabled Children", this.QualifiedName, this.EnabledActivities.Count.ToString()); break; } } } for (int childNum = 0; childNum < this.EnabledActivities.Count; childNum++) { Activity child = this.EnabledActivities[childNum] as Activity; if (null != child) { child.RegisterForStatusChange(Activity.ClosedEvent, this); executionContext.ExecuteActivity(child); ActivityStarted = true; } }
Encoding Barcode In None
Using Barcode creation for Microsoft Word Control to generate, create Barcode image in Word applications.
www.OnBarcode.com
Making ECC200 In None
Using Barcode encoder for Microsoft Word Control to generate, create Data Matrix image in Office Word applications.
www.OnBarcode.com
14 15 16 17 18 19 20 21 22 23 24 25 26 27
Encoding EAN13 In None
Using Barcode encoder for Word Control to generate, create EAN-13 Supplement 5 image in Microsoft Word applications.
www.OnBarcode.com
QR-Code Encoder In None
Using Barcode creation for Word Control to generate, create Denso QR Bar Code image in Office Word applications.
www.OnBarcode.com
CHAPTER 5 ACTIVITIES
Creating Code-39 In None
Using Barcode generation for Office Word Control to generate, create Code 3/9 image in Office Word applications.
www.OnBarcode.com
USD8 Encoder In None
Using Barcode creator for Word Control to generate, create USD8 image in Microsoft Word applications.
www.OnBarcode.com
28 29 }
Creating Data Matrix In Objective-C
Using Barcode maker for iPhone Control to generate, create Data Matrix ECC200 image in iPhone applications.
www.OnBarcode.com
Data Matrix ECC200 Scanner In Visual C#
Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
return ActivityStarted ActivityExecutionStatus.Executing : ActivityExecutionStatus.Closed;
EAN13 Creation In Java
Using Barcode creation for Android Control to generate, create EAN-13 image in Android applications.
www.OnBarcode.com
Code39 Decoder In Visual Basic .NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Next up is our event to process our child activities as they close. Listing 5-20 shows the code for this, and here is a rundown of the highlights: Line 6 causes our activity to stop listening to events for the particular child that we re running for now. Since we have already received the Closed event for this child, there is no need to keep listening. Line 12 is the real meat of this method. It is contained within another loop through all enabled child activities so it will process for all child activities. It is responsible for checking the execution status of all of the child activities of our activity. If one of those children has a status of anything other than Initialized or Closed, then we can t close yet. If, however, all of the child activities are in one of those two states, then it is safe to close our activity. Line 16 handles the process of notifying our workflow host that we are done processing. It will only execute if the check in line 15 indicates that we are done; all of our child activities are done processing. Listing 5-20. Listening for Our Child Activities to Finish 1 2 3 4 5 6 7 8 9 10 11 12 void IActivityEventListener<ActivityExecutionStatusChangedEventArgs>. OnEvent(object sender, ActivityExecutionStatusChangedEventArgs e) { ActivityExecutionContext context = sender as ActivityExecutionContext; if (e.ExecutionStatus == ActivityExecutionStatus.Closed) { e.Activity.UnregisterForStatusChange(Activity.ClosedEvent, this); LoggerActivity lgr = context.Activity as LoggerActivity; bool finished = true; for (int childNum = 0; childNum < lgr.EnabledActivities.Count; childNum++) { Activity child = lgr.EnabledActivities[childNum]; if ((child.ExecutionStatus != ActivityExecutionStatus. Initialized) && (child.ExecutionStatus != ActivityExecutionStatus.Closed)) finished = false; } if (finished) context.CloseActivity(); } }
Draw EAN13 In None
Using Barcode generation for Microsoft Excel Control to generate, create EAN-13 image in Microsoft Excel applications.
www.OnBarcode.com
Creating Linear 1D Barcode In Java
Using Barcode printer for Java Control to generate, create Linear 1D Barcode image in Java applications.
www.OnBarcode.com
13 14 15 16 17 18
Making Barcode In .NET Framework
Using Barcode creator for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Encode 2D In C#.NET
Using Barcode encoder for VS .NET Control to generate, create 2D Barcode image in VS .NET applications.
www.OnBarcode.com
CHAPTER 5 ACTIVITIES
GS1 - 13 Encoder In None
Using Barcode generator for Font Control to generate, create EAN13 image in Font applications.
www.OnBarcode.com
UPC A Generation In Java
Using Barcode creation for Java Control to generate, create UPC Code image in Java applications.
www.OnBarcode.com
The last code for our Activity Definition class is to handle the cancellation of our activity for any number of reasons. We ll cover cancellation in 9, but for now, just know that if our composite activity is canceled, we need to handle canceling all of our child activities. Listing 5-21 shows this code. The code for this method is pretty straightforward. As with the previous two listings, we loop through all of our enabled child activities (lines 4 through 14). Line 7 checks to see whether our current child activity is currently executing. If it is, line 9 cancels it and line 10 sets a local variable that indicates we have just canceled a child activity. Lines 12 through 14 repeat a similar pattern, this time for child activities in a Faulting state. Finally in line 15 we determine our return value. If all of our child activities were closed before we got to them, we can tell our host that we are finished. If we had to signal a child activity to close, we return a value of Canceling. Listing 5-21. Handling the Potentiality of Canceling Our Children When We Are Canceled 1 2 3 4 5 6 7 8 9 10 11 12 protected override ActivityExecutionStatus Cancel(ActivityExecutionContext executionContext) { bool cancelled = true; for (int childNum = 0; childNum < this.EnabledActivities.Count; childNum++) { Activity child = this.EnabledActivities[childNum]; if (child.ExecutionStatus == ActivityExecutionStatus.Executing) { executionContext.CancelActivity(child); cancelled = false; } else if ((child.ExecutionStatus == ActivityExecutionStatus.Canceling) || (child.ExecutionStatus == ActivityExecutionStatus.Faulting)) cancelled = false; } return cancelled ActivityExecutionStatus.Canceling : ActivityExecutionStatus.Closed; }
Generating Barcode In None
Using Barcode creator for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
GTIN - 13 Printer In C#.NET
Using Barcode encoder for VS .NET Control to generate, create EAN / UCC - 13 image in .NET framework applications.
www.OnBarcode.com
13 14 15 16
That does it for the Activity Definition class. Just as with our simple activity earlier, a composite activity is made up of multiple classes. We covered all the standard ones back in the simple activity. We re going to touch on some of them again here, but only as deep as we need to in order to build our composite activity. If you re interested in looking at these in further detail, we took care of that earlier in the chapter. The first other class we re going to look at is the ActivityToolboxItem class. The class file is not listed in the Solution Explorer in Visual Studio so we re going to have to add it fresh. Add a new class file named LoggerActivityToolboxItem.cs. The first thing we need to add is some using statements, and then set up our class and a few constructors. Listing 5-22 shows the code for this. There s nothing overly special about any of this except for the serialization elements, but even that is pretty standard .NET stuff.
Copyright © OnBarcode.com . All rights reserved.