Table of Contents

Building a GQI custom operator that calculates a duration

In this tutorial, you will learn how you can create a GQI custom operator that can be used to calculate a duration.

Expected duration: 15 minutes.

Note

This tutorial uses DataMiner version 10.3.9.

Prerequisites

Overview

Step 1: Get a quick start from the catalog

  1. Go to https://catalog.dataminer.services/details/package/5408

  2. Deploy the catalog item to your DataMiner Agent by clicking the Deploy button.

Step 2: Open the custom operator in Visual Studio

  1. Open Visual Studio and select Extensions > DIS > DMA > Connect to connect DIS to your DMA.

  2. Select Extensions > DIS > DMA > Import Automation Script.

  3. Select Duration - GQIO and click Import.

  4. Go to the C# code of the imported Automation script by clicking the C# icon.

    C# icon

Note

If certain types cannot be found in the file, verify if the Skyline.DataMiner.Dev.Automation NuGet package has the correct version. Go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution. Select Skyline.DataMiner.Dev.Automation, and verify whether the version installed for the current project is at least 10.3.2.

Step 3: Provide the input arguments for the custom operator

This is the first step to implement the custom operator.

  1. Add the IGQIInputArguments interface to the DurationOperator class.

    public class DurationOperator : IGQIInputArguments
    
  2. Implement the GetInputArguments method to provide GQI with the arguments that the user should fill in.

    public GQIArgument[] GetInputArguments()
    {
       return new GQIArgument[] { _startColumnArg, _endColumnArg };
    }
    
  3. Implement the OnArgumentsProcessed method to store the values that the user has filled in through the arguments.

    public OnArgumentsProcessedOutputArgs OnArgumentsProcessed(OnArgumentsProcessedInputArgs args)
    {
       _startColumn =  args.GetArgumentValue(_startColumnArg);
       _endColumn = args.GetArgumentValue(_endColumnArg);
       return default;
    }
    

Step 4: Create a new column to show the duration

  1. Add the IGQIColumnOperator interface to the DurationOperator class.

    public class DurationOperator : IGQIInputArguments, IGQIColumnOperator
    
  2. Implement the HandleColumns method to let GQI know that a new column should be added.

    public void HandleColumns(GQIEditableHeader header)
    {
       header.AddColumns(_durationColumn);
    }
    

Step 5: Add the duration to the added column

  1. Add the IGQIRowOperator interface to the DurationOperator class.

    public class DurationOperator : IGQIInputArguments, IGQIColumnOperator, IGQIRowOperator
    
  2. Implement the HandleRow method to calculate the duration and set that value in the cell matching the new duration column.

    public void HandleRow(GQIEditableRow row)
    {
       var start = row.GetValue<DateTime>(_startColumn);
       var end = row.GetValue<DateTime>(_endColumn);
       var duration = end - start;
       row.SetValue(_durationColumn, duration);
    }
    

Step 6: Use the data source

  1. Open the Dashboards app and create a new dashboard.

  2. In the data pane on the right, go to Queries and click the "+" icon to create a query.

    + icon to create query

  3. Select a data source that has at least two columns containing datetime values.

    Note

    If you do not have an applicable data source, you can download one from the catalog.

  4. Add a custom operator to the query and select Duration.

  5. Fill in the input arguments matching with the necessary columns.

  6. Drag the query to the dashboard.

  7. Select a table visualization for the component.

The table should now also contain a Duration column containing the calculated duration.