Write an extension to add functionality to a Task Execute procedure. Task Execute occurs on the following operations:
- Submit
- Fetch
- Return
- Assign
- Others
This example shows how to perform an action during submit, fetch, or return operations.
Activate the Code
- Add a class library to your solution. Add the relevant references.
- PNMsoft.Sequence
- PNMsoft.Sequence.Forms
- PNMsoft.Sequence.Security
- PNMsoft.Sequence.Extension
- Strongly sign the project.
- Complete the code in the relevant places, and compile the assembly.
- Put the assembly in the GAC.
- Insert a new record into tblTemplateWorkflowExtensions.
- In fldType, type the assembly strong name.
- In fldGuid, type the GUID in the class decorator.
NOTE: If your code raises an exception, execution will continue.
//*************************************************** // // Copyright (C) PNMsoft. All rights reserved. // // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. // //*************************************************** using System; using PNMsoft.Sequence; using PNMsoft.Sequence.Forms.Activities; using PNMsoft.Sequence.Forms.Activities.Operations; namespace SequenceEx.Tasks.Samples { [WorkflowElementExtension("Generated Guid", Name = "TaskActivityExtension")] public sealed class TaskActivityExtension : WorkflowElementExtension<TaskActivity> { public TaskActivityExtension() { } protected override void OnAttached() { base.OnAttached(); this.Owner.Executed += new EventHandler<ActivityExecutedEventArgs>(OnActivityExecuted); } protected override void OnDetached() { base.OnDetached(); this.Owner.Executed -= new EventHandler<ActivityExecutedEventArgs>(OnActivityExecuted); } private void OnActivityExecuted(object sender, ActivityExecutedEventArgs e) { object inputData = e.Context.InputData; if (inputData is SubmitTaskOperationContext) { SubmitTaskOperationContext submitTaskOperationContext = (SubmitTaskOperationContext)inputData; //Insert your code here. } else if (inputData is FetchTaskOperationContext) { FetchTaskOperationContext fetchTaskOperationContext = (FetchTaskOperationContext)inputData; //Insert your code here. } else if (inputData is ReturnTaskOperationContext) { ReturnTaskOperationContext returnTaskOperationContext = (ReturnTaskOperationContext)inputData; //Insert your code here. } } } }