Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

Implementation of Custom WorkItemForm

  • Last UpdatedJun 10, 2024
  • 5 minute read

The WorkItemForm interface exposes different events available for a work item. For example, when a work item is created for an actor, a work item is updated by an actor etc.

Procedure

Dll Reference

System

System.Data

System.Xml

Workflow.NET.NET2

Skelta.HWS

Namespace Used

System

System.Collections.Generic

System.Text

System.Xml

Workflow.NET

Skelta.HWS.WorkListChannel

Skelta.HWS.WorkListChannel.Web

Skelta.HWS

Skelta.Core

To create a Custom Property

  1. Go to Start->Visual Studio 2005->New->Projects->Class Library->CustomWorkItemForm. This step will create a Class Library project in the path specified by the name CustomWorkItemForm.

  2. Create a class file under the project CustomWorkItemForm.cs.

  3. Inherit the WorkItemFormBase class which internally implementing the IWorkItemForm interface and implement the interface ISkeltaAddInProvider. Activity and work item level information is maintained within the application by overriding the methods OnWorkItemTransaction, OnActivityTransaction, and OnWorkItemCreation. Suppose we want to perform some extra step when a work item is forwarded by the user, for this we can handle it in the method OnWorkItemTransaction.

    using System;

    using System.Collections.Generic;

    using System.Text;

    using System.Xml;

    using Workflow.NET;

    using Skelta.HWS.WorkListChannel;

    using Skelta.HWS.WorkListChannel.Web;

    using Skelta.HWS;

    using Skelta.Core;


    namespace Skelta.HWS.WorkListChannel.Web

    {

    public class CustomWorkItemForm : WorkItemFormBase, ISkeltaAddInProvider

    {

    string _Name = null;

    Workflow.NET.Log logger = new Workflow.NET.Log();

    #region IWorkItemForm Members

    public override string InitialFormUri

    {

    get

    {

    return "";

    }

    }


    /// <summary>

    /// Gets the boolean flag to check if new instance of form type can be added.

    /// </summary>

    public override bool CanAddNewInstance

    {

    get

    {

    bool found = false;

    if (ParentFormsCollection != null)

    {

    foreach (IWorkItemForm form in ParentFormsCollection.SelectedFormInstances.Values)

    {

    if (form.FormType == this.FormType)

    {

    found = true;

    break;

    }

    }

    }


    if (found)

    return false;

    else

    return true;

    }

    }


    /// <summary>

    /// Gets fired for all the transactions for a workitem.

    /// </summary>

    /// <param name="transactionType">Transactiontype</param>

    /// <param name="workItem">Current workitem instance.</param>

    /// <param name="transactionData">Transaction data.</param>

    /// <remarks>

    /// Few of the transactiontypes are update, forward, pause, resume , abort.

    /// Transactiondata contains the actor object if the transaction type is forward  and it contains the activity output details if the transaction type is  submitting a workitem.

    /// </remarks>

    public override void OnWorkItemTransaction(string transactionType, WorkItem workItem, Dictionary<string, object> transactionData)

    {

    logger.LogInformation("*****************************************");

    logger.LogInformation("Called During Workitem transaction");

    logger.LogInformation("*****************************************");

    logger.LogInformation("Status of the workitem is "+workItem.Status);


    }

     

     

    /// <summary>

    /// Gets fired for all the transactions for an activity.

    /// </summary>

    /// <param name="transactionType">Transaction type.</param>

    /// <param name="hwsActivity">Current hws activity instance.</param>

    /// <param name="transactionData">Transaction data.</param>

    /// <remarks>

    /// Few of the transactiontypes are timeout, pause, resume, abort,  actioncompletion.

    /// </remarks>

    public override void OnActivityTransaction(string transactionType, HWSActivity hwsActivity, Dictionary<string, object> transactionData)

    {  

    logger.LogInformation("*****************************************");

    logger.LogInformation("Called for On Activity transaction");

    logger.LogInformation("*****************************************");

    logger.LogInformation("Transaction type is "+transactionType+" and activity name is "+hwsActivity.ActivityName);

    }


     

    /// <summary>

    ///  Gets fired when a workitem is created while executing a resource activity.

    /// </summary>

    /// <param name="workItem">Workitem Instance</param>

    public override void OnWorkItemCreation(WorkItem workItem)

    {

    logger.LogInformation("*****************************************");

    logger.LogInformation("Called during the Worktem creation");

    logger.LogInformation("Workitem : "+workItem.ActivityDisplayName+" and the Workitem status is: "+workItem.Status);

    logger.LogInformation("*****************************************");


    }


    /// <summary>

    /// Gets custom configuration settings page. This page is loaded through the  channel property in the Process Designer.

    /// </summary>

    public override string FormConfigurationUserInterfaceURL

    {

    get

    {

     return "";

    }

    }


    /// <summary>

    /// Gets or sets the form name.

    /// </summary>


    public override string Name

    {

    get

    {

    return _Name;

    }


    set

    {

    _Name = value;

    }

    }


    /// <summary>

    /// Gets the form type.

    /// </summary>


    public override string FormType

    {

    get

    {

    return "CustomWorkItemForm";

    }

    }


    /// <summary>

    /// Gets an array of supported  technology types.  

    /// </summary>

    /// <remarks>

    /// e.g: "Web", "Mail".

    /// </remarks>


    public override string[] SupportedTechnologyTypes

    {

    get

    {

    return new string[] { "Web" };

    }

    }


    /// <summary>

    /// Returns default form instances.

    /// </summary>

    /// <returns>Default form instances of type IWorkItemForm</returns>

    public override IWorkItemForm[] GiveDefaultInstances()

    {

    Skelta.HWS.WorkListChannel.Web.CustomWorkItemForm frm = new Skelta.HWS.WorkListChannel.Web.CustomWorkItemForm();

    frm.Name = "Custom Workitem Form";


    IWorkItemForm[] formins = new IWorkItemForm[] { frm };

    return formins;


    }


    /// <summary>

    /// Returns a cloned form instance

    /// </summary>

    /// <returns>Cloned form instance</returns>

    public override IWorkItemForm Clone()

    {


    Skelta.HWS.WorkListChannel.Web.CustomWorkItemForm nativeWebForm = (Skelta.HWS.WorkListChannel.Web.CustomWorkItemForm)MemberwiseClone();

    if (this.Roles != null && this.Roles.Length > 0)

    nativeWebForm.Roles = new List<string>(this.Roles).ToArray();


    if (this.Actors != null && this.Actors.Length > 0)

    nativeWebForm.Actors = new List<Guid>(this.Actors).ToArray();

    nativeWebForm._RunTimeProperties = new Dictionary<string, object>();


    foreach (string key in this._RunTimeProperties.Keys)

    {

    nativeWebForm._RunTimeProperties.Add(key, _RunTimeProperties[key]);

    }


    return nativeWebForm;


    }


    /// <summary>

    /// Gets a list of errors after validation of form type.

    /// </summary>

    /// <param name="currentActivity">current activity</param>

    /// <returns>list of errors.</returns>

    /// <remarks>

    /// Useful for performing configuration settings validation.

    /// </remarks>

    public override List<Workflow.NET.ProcessValidationError> IsValid(Workflow.NET.Action currentActivity)

    {


    List<ProcessValidationError> errors = new List<ProcessValidationError>();

    return errors;

    }


    #endregion




    #region ISkeltaAddInProvider Members


    string _Settings;

    Guid _Id;

    public Guid Id

    {

    get { return _Id; }

    }


    public void InitializeProvider(string settings, Guid id)

    {

    this._Settings = settings;

    this._Id = id;

    }


    public string Settings

    {

    get { return _Settings; }

    }


    #endregion

    }

    }

    All these methods are executed in the Transaction mode.

  4. Compile the project and place the dll in the [AVEVA Work Tasks Installed Path]\AVEVA\Work TasksBPM.Net\bin folder.

  5. Configuration of Custom Work Item Form in the SKAddinProviders table of the Repository Database. Add a row in the SKAddInProviders table mentioning the type as Form and Name as return value of the method "FormType". i.e. CustomWorkItemForm as mentioned in the sample. The class name and the Assembly path should be provided accordingly. The following figure illustrates this entry:

    Insert into SKAddinProviders(Type,Name,Description,ClassName,Assembly,LastUpdatedDateTime)

    values('Form','CustomWorkItemForm',NULL,'Skelta.HWS.WorkListChannel.Web.CustomWorkItemForm',

    'bin\CustomWorkItemForm.dll',getutcdate())

    GO

     

  6. After the configuration of the Custom Work Item Form in the SKAddinProviders table, the CustomWorkItemForm will get displayed in the Delivery Channels Property, as shown below. The figure below shows the Approval Activity's Delivery Channels Property.

  7. The messages put in the Custom Work Item form like Called for On Work Item Creation, etc can be seen in the Logger Console when we execute the workflow.

Related Links
TitleResults for “How to create a CRG?”Also Available in