Ouvvi Step Handler SDK
You can extend the available step handlers in Ouvvi by writing your own handler with Visual Studio.
To create a Step Handler you need to create a .NET Class Library and add a reference to the Simego.Console.Library.dll
The assembly must have an attribute defined StepHandlerAssembly
so add this to your AssemblyInfo.cs file or class file.
[assembly: StepHandlerAssembly]
Step Handler Basics
Step Handlers have 2 parts:
- Data Class that is used to define the user interface via attribute settings on the public properties.
- Handler Class that is used when the Step is executed by the Ouvvi service.
The Web Interface uses the Data Class to dynamically create the user interface and allow the user to enter configuration settings. The Handler Class is created at runtime by the Service to execute the step, the Data Class is passed to this as a parameter to the Execute method to run your code. You should then return a success or failure result.
Custom Step Handler
Sample C# code for a default step handler that writes a message to the Ouvvi Log.
using Simego.Console.Library;
using Simego.Console.Library.Designer;
using Simego.Console.Library.Handlers;
// Mark this assembly as containing Step Handlers.
[assembly: StepHandlerAssembly]
namespace OuvviStepHandlerSample
{
/// <summary>
/// Data Class for Step Handler, use this to create a user interface and accept input from the user.
/// </summary>
public class MyFirstStepHandlerData
{
[Designer(Description = "Message", ControlType = DesignerControlType.TextBox, RequiredField = true)]
public string Message { get; set; }
}
/// <summary>
/// Class that implements the Step Hander function.
/// </summary>
[Designer(DisplayName = "My First Ouvvi StepHandler", Description = "Writes a message to the log.")]
public class MyFirstStepHandler : StepHandler<MyFirstStepHandlerData>
{
public override StepExecuteResult Execute(MyFirstStepHandlerData data)
{
// Code to Execute when this step runs.
LogInformationMessage("MyFirstStepHandler", data.Message);
return StepExecuteResult.Success;
}
}
}
Deployment
Once your Step handler is created you then upload the assembly dll into Ouvvi under Settings->Assemblies
you can then add this new step type to an Ouvvi Project and run it.
You need to restart the Ouvvi Service for your new Step Handler to be loaded and run.
Testing
You can run the step in Visual Studio for debugging and testing if you Mock the Ouvvi services and run the step with either Unit Testing or a test console application.
using OuvviStepHandlerSample;
using Simego.Console.Library;
using Simego.Console.Library.Configuration;
using Simego.Console.Library.Entities;
using Simego.Console.Library.Interfaces;
using Simego.Console.Library.Queue;
using System;
using System.Collections.Generic;
namespace OuvviStepHandlerSampleRunner
{
class Program
{
static void Main(string[] args)
{
var data = new MyFirstStepHandlerData { Message = "Hello World" };
var step = new MyFirstStepHandler();
step.Init( new MockSettingsService(),
new MockDataService(),
new MockLogService(),
new MockConnectionLibraryService(),
new MockSecurityService(),
new MockSecurityService(),
new MockConsoleServiceControl(),
new MockChangeSetService());
var result = step.Execute(data);
System.Diagnostics.Debug.Assert(result.Type == StepExecuteResultType.Success);
}
}
}
The default mock classes are available in the sample download.