1. Home
  2. Getting the Code and Contributing
  3. Creating Custom Tools and Data Connectors

Creating Custom Tools and Data Connectors

Warewolf tools can be categorized into internal and custom tools. Internal tools include any tool that modifies or inspects the internal state of a Warewolf service. Tools like the Length and Assign are examples of these. Their purpose is to interrogate or modify the internal state of a Warewolf service.

Custom tools on the other hand are primarily used to integrate with other systems and platforms or to encapsulate simple reusable operations.
A tool that retrieves the last tweet from a Twitter account is an example of this. Its sole purpose is to perform some operation given a set of inputs and assign some outputs for subsequent use. This type of tool requires no understanding of the internal vagaries of Warewolf and is therefore easier to design and implement.

Steps involved in creating custom tools and data connectors

Custom tools are the preferred method of creating new Warewolf activities. As a contributor, custom tools, should be the first point of call when attempting to add tools to Warewolf.

The high level steps for creating an Add-on tool (including an example of a tool that concatenates strings) are as follows:

  • Define the server side execution logic by inheriting the abstract DsfBaseActivity class
    public class DsfConcatenateActivity : DsfBaseActivity
        {
            #region Overrides of DsfBaseActivity
            public DsfConcatenateActivity()
            {
                DisplayName = "Concatenate";
            }
            public override string DisplayName { get; set; }
            [Inputs("LeftString")]
                    public string Left { get; set; }
            [Inputs("RightString")]
                    public string Right { get; set; }
            protected override string PerformExecution(Dictionary<string, string> evaluatedValues)
            {
                return Left + Right;
            }
            #endregion
        }
    
  • Create the Activity host XAML view and inherit from the ActivityDesigner class, that will host the activity small view

ConcatenateDesigner.xaml

  • Create the Activity View

Small.xaml

  • Create the Activity View Model by inheriting ActivityDesignerViewModel
public class ConcatenateViewModel: ActivityDesignerViewModel,INotifyPropertyChanged
    {
        public ConcatenateViewModel(ModelItem modelItem)
            : base(modelItem)
        {
        }
        public string Left
        {
            get { return GetProperty<string>(); }
            set
            {
                SetProperty(value);
                OnPropertyChanged("Operation");
            }
        }
        public string Right
        {
            get { return GetProperty<string>(); }
            set
            {
                SetProperty(value);
                OnPropertyChanged("Operation");
            }
        }
        public override void Validate()
        {
        }
        public event PropertyChangedEventHandler PropertyChanged;
        [ExcludeFromCodeCoverage]
        protected void OnPropertyChanged(string propertyName = null)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

 

  • Add the tool to the Toolbox user control so that it appears in the studio designer in the buildToolbox Method

 

category.Add(new ToolboxItemWrapper(typeof(DsfConcatenateActivity),"/Images//images/ToolAssign-32.png", "Concatenate"));

 

  • Link the Designer and the backend Activity so that WF can associate the activity with the designer. This is done in the ActivityDesignerHelper class.

 

{ typeof(DsfConcatenateActivity), typeof(ConcatenateDesigner) }

 

Creating a new internal tool

The steps for creating an internal tool are:

  • Inherit DSFNative Activity to create the server side execution unit
  • Create the Activity XAML view and inherit from the ActivityDesigner
  • Create the Activity View Model by inheriting ActivityDesignerViewModel
  • Add the tool to the Toolbox user control so that it appears in the studio designer.

At this point all new tools must be defined in the Dev2.activities and the Dev2.Activities.Designers projects.

 

Not what you were looking for? Ask our expert users in the Community Forum.

FacebookTwitterLinkedInGoogle+Email
Updated on May 29, 2018

Was this article helpful?

Related Articles

Enjoying Warewolf?

Write a review on G2 Crowd
Stars