CUSTOM ACTIVITIES in C#.NET

Drawing Data Matrix ECC200 in C#.NET CUSTOM ACTIVITIES

CHAPTER 8 CUSTOM ACTIVITIES
Generating Data Matrix ECC200 In Visual C#.NET
Using Barcode maker for Visual Studio .NET Control to generate, create Data Matrix image in VS .NET applications.
www.OnBarcode.com
Decode Data Matrix ECC200 In C#.NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Finally, add code to compile the list of errors, throw an exception if there are errors, and either way return the collection: if (Errors.HasErrors) { throw new InvalidOperationException(); } return Errors; The completed code for the Validator class is as follows: class SendEmailCValidator:ActivityValidator { public override ValidationErrorCollection ValidateProperties( ValidationManager manager,object obj) { ValidationErrorCollection Errors = new ValidationErrorCollection(base.ValidateProperties(manager, obj)); SendEmailC sendMailActivityToBeValidated = obj as SendEmailC; if (string.IsNullOrEmpty(sendMailActivityToBeValidated.To)) { ValidationError CustomActivityValidationError = new ValidationError("To Address Not Provided", 1); Errors.Add(CustomActivityValidationError); } if (string.IsNullOrEmpty (sendMailActivityToBeValidated.From)) { ValidationError CustomActivityValidationError = new ValidationError("From Address Not Provided", 1); Errors.Add(CustomActivityValidationError); } if (Errors.HasErrors) { throw new InvalidOperationException(); } return Errors; } } Open the SendEmailC project and the SendEmailC.cs file. You now must add an attribute to the class to tie the class with the Validator class. Make sure you have the underscore (_) at the end of the line: [ActivityValidator(typeof(SendEmailCValidator))] _ To test the validator, open the CSendEmailTest project and click the properties of the SendEmailC activity. Blank out the From property. Build the solution, and the build will fail with an error message that the From e-mail address hasn t been provided.
PDF 417 Generator In C#.NET
Using Barcode printer for .NET framework Control to generate, create PDF-417 2d barcode image in .NET framework applications.
www.OnBarcode.com
UPC A Encoder In Visual C#.NET
Using Barcode maker for .NET Control to generate, create GTIN - 12 image in .NET applications.
www.OnBarcode.com
CHAPTER 8 CUSTOM ACTIVITIES
Printing ECC200 In C#.NET
Using Barcode generator for Visual Studio .NET Control to generate, create Data Matrix 2d barcode image in Visual Studio .NET applications.
www.OnBarcode.com
USS Code 39 Maker In C#.NET
Using Barcode generator for .NET Control to generate, create Code-39 image in .NET applications.
www.OnBarcode.com
Real-World Example
QR Code JIS X 0510 Drawer In Visual C#
Using Barcode drawer for .NET Control to generate, create QR Code 2d barcode image in .NET applications.
www.OnBarcode.com
Identcode Drawer In Visual C#.NET
Using Barcode generator for VS .NET Control to generate, create Identcode image in .NET framework applications.
www.OnBarcode.com
The previous sections of this chapter showed you how to create a custom activity, and had you create a custom activity that sends e-mail. You ll use this activity in 10 as part of the Employee Performance Review application. The existing purchase order application uses a Code activity to execute a SQL statement. This functionality could also be useful in many other workflow applications. For this reason, you re going to create a new activity called ExecuteSQL. You can use this activity to execute a SQL statement that inserts, updates, or deletes data. Create a new VB Sequential Workflow Activity Library project called ExecuteSQL. Set the name of the activity to ExecuteSQL and the description to Use for Insert, Update, Delete. Click the ellipse next to the Base Class property and change the base class to System.Work flow.ComponentModel.Activity, as shown in Figure 8-5.
Data Matrix 2d Barcode Maker In None
Using Barcode printer for Word Control to generate, create ECC200 image in Word applications.
www.OnBarcode.com
Recognizing DataMatrix In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Figure 8-5. Name and Description properties of the new activity This activity needs to accept two parameters. The first is the connection string to use, and the second is the SQL statement to execute. This activity also needs to return two parameters. The first is for success or failure, and the other is a number. You can use this number when inserting a record to show the ID of the newly inserted record. If this doesn t apply, just add a 0. The next step is to define the properties. To do this, view the code of the ExecuteSQL activity, and you ll see the class structure. Add the property code so the class looks like the following: Public Class ExecuteSQL Inherits System.Workflow.ComponentModel.Activity Public Shared ConnectionStringProperty As DependencyProperty = DependencyProperty.Register("ConnectionString", GetType(String), GetType(ExecuteSQL) , New PropertyMetadata("ConnectionString")) Public Shared SQLStatementProperty As DependencyProperty = DependencyProperty.Register("SQLStatement", GetType(String), GetType(ExecuteSQL), New PropertyMetadata("SQL Statement")) Public Shared StatusProperty As DependencyProperty = DependencyProperty.Register("Status", GetType(Boolean), GetType(ExecuteSQL)) Public Shared NewIDProperty As DependencyProperty = DependencyProperty.Register("NewID", GetType(Integer), GetType(ExecuteSQL)) End Class The Status and NewID properties should be read-only because they re return parameters. Create the necessary property statements as follows:
Scan QR Code 2d Barcode In .NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Code128 Generation In Java
Using Barcode printer for Java Control to generate, create ANSI/AIM Code 128 image in Java applications.
www.OnBarcode.com
CHAPTER 8 CUSTOM ACTIVITIES
EAN13 Drawer In Visual Basic .NET
Using Barcode generator for VS .NET Control to generate, create EAN-13 Supplement 5 image in VS .NET applications.
www.OnBarcode.com
Quick Response Code Drawer In None
Using Barcode generation for Online Control to generate, create QR image in Online applications.
www.OnBarcode.com
Public Class ExecuteSQL Inherits System.Workflow.ComponentModel.Activity Public Shared ConnectionStringProperty As DependencyProperty = DependencyProperty.Register("ConnectionString", GetType(String), GetType(ExecuteSQL)) Public Shared SQLStatementProperty As DependencyProperty = DependencyProperty.Register("SQLStatement", GetType(String), GetType(ExecuteSQL)) Public Shared StatusProperty As DependencyProperty = DependencyProperty.Register("Status", GetType(Boolean), GetType(ExecuteSQL)) Public Shared NewIDProperty As DependencyProperty = DependencyProperty.Register("NewID", GetType(Integer), GetType(ExecuteSQL)) <DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility. Visible)> _ <ValidationOption(ValidationOption.Required)> _ <BrowsableAttribute(True)> _ <DescriptionAttribute("The ConnectionString property is used to specify the connection string to use.")> _ Public Property ConnectionString() As String Get Return CType(MyBase.GetValue(ExecuteSQL.ConnectionStringProperty), String) End Get Set(ByVal value As String) MyBase.SetValue(ExecuteSQL.ConnectionStringProperty, value) End Set End Property <DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility. Visible)> _ <ValidationOption(ValidationOption.Required)> _ <BrowsableAttribute(True)> _ <DescriptionAttribute("The SQL Statement property is used to specify the SQL Statement to execute.")> _ Public Property SQLStatement() As String Get Return CType(MyBase.GetValue (ExecuteSQL.SQLStatementProperty), String) End Get Set(ByVal value As String) MyBase.SetValue(ExecuteSQL.SQLStatementProperty, value) End Set End Property <DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility. Visible)> _ <ValidationOption(ValidationOption.None)> _
Barcode Drawer In VS .NET
Using Barcode generator for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Creating ECC200 In Visual Studio .NET
Using Barcode creation for .NET Control to generate, create DataMatrix image in .NET applications.
www.OnBarcode.com
Print DataMatrix In None
Using Barcode generator for Software Control to generate, create DataMatrix image in Software applications.
www.OnBarcode.com
Barcode Printer In None
Using Barcode creation for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
Printing UPC Code In Objective-C
Using Barcode printer for iPhone Control to generate, create UPC A image in iPhone applications.
www.OnBarcode.com
Barcode Scanner In Java
Using Barcode Control SDK for BIRT Control to generate, create, read, scan barcode image in BIRT applications.
www.OnBarcode.com
Copyright © OnBarcode.com . All rights reserved.