Runtime Behavior

Runtime behavior occurs on the AgilePoint Server as the process model is running. The runtime class is inherited from WFProcessPluggableAdapter. The various events that can be handled via runtime AgileExtender are listed below:

The Typical Constructor will look as follows :

using System;
using System.ComponentModel;
using System.Collections;
using Ascentn.Workflow.Base;

namespace Ascentn.AgileExtender.Sample
{
    /// <summary>
    /// This class is AgileExtender runtime class that will be 
    /// invoked by AgilePoint Server.
    /// </summary>
    [AgileExtender("{305F5DC5-14F3-4151-946E-2D594DA695E5}", 
        "AgileExtender Event", typeof(MyAgileExtenderDescriptor))]
        
    public class MyAgileExtender : WFProcessPluggableAdapter
    {
        #region Constructor

        public MyAgileExtender(WFProcessInstance instance)
            : base(instance)
        {
            base.AssignWorkItem += new 
                EventHandler(OnAssignWorkItem);
            base.CancelWorkItem += new 
                EventHandler(OnCancelWorkItem);
            base.CompleteWorkItem += new 
                EventHandler(OnCompleteWorkItem);
            base.EnterActivityInstance += new 
                EventHandler(OnEnterActivityInstance);
            base.LeaveActivityInstance += new 
                EventHandler(OnLeaveActivityInstance);
            base.ReassignWorkItem += new 
                EventHandler(OnReassignWorkItem);
            base.WorkItemOverdue += new 
                EventHandler(OnWorkItemOverdue);
            base.WorkItemAssigned += new 
                EventHandler(OnWorkItemAssigned);
            base.ResolvingPoolMembers += new 
                EventHandler(OnResolvingPoolMembers);

            base.CancelProcessInstance += new 
                EventHandler(OnCancelProcessInstance);
            base.CompleteProcedure += new 
                EventHandler(OnCompleteProcedure);
            base.CreateProcessInstance += new 
                EventHandler(OnCreateProcessInstance);
            base.DeliverNotification += new 
                EventHandler(OnDeliverNotification);
            base.ProcessInstanceFaulting += new 
                EventHandler(OnProcessInstanceFaulting);
            base.ResumeProcessInstance += new 
                EventHandler(OnResumeProcessInstance);
            base.SuspendProcessInstance += new 
                EventHandler(OnSuspendProcessInstance);
            base.StopProcessInstance += new 
                EventHandler(OnStopProcessInstance);
            base.StartProcessInstance += new 
                EventHandler(OnStartProcessInstance);
            base.ScheduledItemTimeout += new 
                EventHandler(OnScheduledItemTimeout);
            base.UpdateCustomAttributes += new 
                EventHandler(OnUpdateCustomAttributes);
            base.RollbackProcessInstance += new 
                EventHandler(OnRollbackProcessInstance);
            base.MigrateProcessInstance += new 
                EventHandler(OnMigrateProcessInstance);
            base.CompletingWorkItem += new 
                EventHandler(OnCompletingWorkItem);
            base.CancallingWorkItem += new 
                EventHandler(OnCancellingWorkItem);
        }

        #endregion

        #region Event Handlers

        private void OnMigrateProcessInstance(Object sender, 
            System.EventArgs e)
        {
            WFMigrateProcessInstanceEventArgs args = e as 
                WFMigrateProcessInstanceEventArgs;
            Logger.WriteLine("MyAgileExtender.OnMigrateProcessInstance, 
                {0}", args.MigrationInstruction);
            //Put your code here
        }

        private void OnRollbackProcessInstance(Object sender, 
            System.EventArgs e)
        {
            WFRollbackProcessInstanceEventArgs args = e as 
                WFRollbackProcessInstanceEventArgs;
            
            //Put your code here
            Logger.WriteLine("MyAgileExtender.OnRollbackProcessInstance, 
                target activity instance ID='{0}'", 
                args.ActivityInstanceID);
        }

        private void OnUpdateCustomAttributes(Object sender, 
            System.EventArgs e)
        {
            WFUpdateCustomAttributesEventArgs args = e as 
                WFUpdateCustomAttributesEventArgs;
            Logger.WriteLine("MyAgileExtender.OnUpdateCustomAttributes,
                ModifiedDate={0}, ModifiedBy={1}, before={2}, 
                after={3}", args.SentDate, args.ModifiedBy, 
                args.BeforeUpdate.AttrXml, args.AfterUpdate.AttrXml);
            
            //Put your code here
        }

        private void OnScheduledItemTimeout(Object sender, 
            System.EventArgs e)
        {
            WFScheduleItemTimeoutEventArgs args = e as 
                WFScheduleItemTimeoutEventArgs;
            Logger.WriteLine("MyAgileExtender.OnScheduledItemTimeout, 
                ItemID={0}, Parameter={1}", args.ItemID, 
                args.Parameter);
            
            //Put your code here
        }

        private void OnStartProcessInstance(Object sender, 
            System.EventArgs e)
        {
            System.Xml.XmlDocument config = base.Configuration;
            Logger.WriteLine("MyAgileExtender.OnStartProcessInstance, 
                config={0}", config.OuterXml);
            
            //Put your code here
        }

        private void OnStopProcessInstance(Object sender, 
            System.EventArgs e)
        {
            Logger.WriteLine("MyAgileExtender.OnStopProcessInstance");
            
            //Put your code here
        }

        private void OnSuspendProcessInstance(Object sender, 
            System.EventArgs e)
        {
            Logger.WriteLine("MyAgileExtender.OnSuspendProcessInstance");
            
            //Put your code here
        }

        private void OnResumeProcessInstance(Object sender, 
            System.EventArgs e)
        {
            Logger.WriteLine("MyAgileExtender.OnResumeProcessInstance");
            
            //Put your code here
        }

        private void OnProcessInstanceFaulting(Object sender, 
            System.EventArgs e)
        {
            WFProcessInstanceFaultingEventArgs args = e as 
                WFProcessInstanceFaultingEventArgs;
            Logger.WriteLine("MyAgileExtender.OnProcessInstanceFaulting, 
                {0}", args.FaultingException);
            
            //Put your code here
        }

        private void OnDeliverNotification(Object sender, 
            System.EventArgs e)
        {
            Logger.WriteLine("MyAgileExtender.OnDeliverNotification");
            
            //Put your code here
        }

        private void OnCompleteProcedure(Object sender, 
            System.EventArgs e)
        {
            Logger.WriteLine("MyAgileExtender.OnCompleteProcedure");
        }

        private void OnCreateProcessInstance(Object sender, 
            System.EventArgs e)
        {
            Logger.WriteLine("MyAgileExtender.OnCreateProcessInstance");
            
            //Put your code here
        }

        private void OnCancelProcessInstance(Object sender, 
            System.EventArgs e)
        {
            Logger.WriteLine("MyAgileExtender.OnCancelProcessInstance");
            
            //Put your code here
        }

        private void OnResolvingPoolMembers(Object sender, 
            System.EventArgs e)
        {
            WFActivityInstanceEventArgs args = e as 
                WFActivityInstanceEventArgs;
            Logger.WriteLine("MyAgileExtender.OnResolvingPoolMembers, 
                Activity  Instance={0}", 
                args.ActivityInstance.DisplayName);
            
            //Put your code here
        }

        private void OnEnterActivityInstance(Object sender, 
            System.EventArgs e)
        {
            WFActivityInstanceEventArgs args = e as 
                WFActivityInstanceEventArgs;
            Logger.WriteLine("MyAgileExtender.OnEnterActivityInstance, 
                Activity Instance={0}", 
                args.ActivityInstance.DisplayName);
            
            //Put your code here
        }

        private void OnAssignWorkItem(Object sender, 
            System.EventArgs e)
        {
            WFGenerateManualWorkItemEventArgs args = e as 
                WFGenerateManualWorkItemEventArgs;
            Logger.WriteLine("MyAgileExtender.OnAssignWorkItem, 
                Activity Instance={0}", 
                args.ActivityInstance.DisplayName);
            
            //Put your code here
        }

        private void OnCancelWorkItem(Object sender, 
            System.EventArgs e)
        {
            WFManualWorkItemEventArgs args = e as 
                WFManualWorkItemEventArgs;
            Logger.WriteLine("MyAgileExtender.OnCancelWorkItem, 
                Activity Instance={0}", 
                args.ActivityInstance.DisplayName);
            
            //Put your code here
        }

        private void OnCompleteWorkItem(Object sender, 
            System.EventArgs e)
        {
            WFManualWorkItemEventArgs args = e as 
                WFManualWorkItemEventArgs;
            Logger.WriteLine("MyAgileExtender.OnCompleteWorkItem, 
                Activity Instance={0}", 
                args.ActivityInstance.DisplayName);
            
            //Put your code here
        }

        private void OnLeaveActivityInstance(Object sender, 
            System.EventArgs e)
        {
            WFActivityInstanceEventArgs args = e as 
                WFActivityInstanceEventArgs;
            Logger.WriteLine("MyAgileExtender.OnLeaveActivityInstance, 
                Activity  Instance={0}", 
                args.ActivityInstance.DisplayName);
            
            //Put your code here
        }

        private void OnReassignWorkItem(Object sender, 
            System.EventArgs e)
        {
            WFManualWorkItemEventArgs args = e as 
                WFManualWorkItemEventArgs;
            Logger.WriteLine("MyAgileExtender.OnReassignWorkItem, 
                Activity Instance={0}", 
                args.ActivityInstance.DisplayName);
            
            //Put your code here
        }

        private void OnWorkItemAssigned(Object sender, 
            System.EventArgs e)
        {
            WFManualWorkItemEventArgs args = e as 
                WFManualWorkItemEventArgs;
            Logger.WriteLine("MyAgileExtender.OnWorkItemAssigned, 
                Activity Instance={0}, {1} workitem(s) assigned", 
                args.ActivityInstance, args.WorkItems.Length);
            
            //Put your code here
        }

        private void OnWorkItemOverdue(Object sender, 
            System.EventArgs e)
        {
            WFOverdueWorkItemEventArgs args = e as 
                WFOverdueWorkItemEventArgs;
            WFManualWorkItem workItem = args.WorkItem as 
                WFManualWorkItem;
            Logger.WriteLine("MyAgileExtender.OnWorkItemOverdue, 
                Activity Instance={0}, {1} is about to overdue", 
                args.ActivityInstance, workItem.Name);
            
            //Put your code here
        }

        private void OnCompletingWorkItem (Object sender, 
            EventArgs e)
        {
           WFManualWorkItemEventArgs args = e as 
                WFManualWorkItemEventArgs;
           Logger.WriteLine("AgileExtender.OnCompleteWorkItem, 
                Activity  Instance={0}",
                args.ActivityInstance.DisplayName);
         
           //Put your code here
        }

        private void OnCancellingWorkItem (Object sender, 
            EventArgs e)
        {
            WFCancellingManualWorkItemEventArgs args = 
                e as WFCancellingManualWorkItemEventArgs;
            Logger.WriteLine("AgileExtender.OnCancellingWorkItem, 
                Activity  Instance={0}",
                args.ActivityInstance.DisplayName);

            //Put your code here
         }

        #endregion
    }
}