Start Ouvvi Project Programmatically

9 September 2013

Projects you have loaded and configured in Ouvvi Automation Server can be started and monitored from external processes on any machine that has network connectivity. For example this project here can be started programmatically with a very simple script or program.

Ouvvi Project

To start an Ouvvi Project programmatically is as simple as issuing a HTTP Request to the Start Endpoint i.e. This will Start Project '1' on our DEV instance of Ouvvi.

This returns a simple XML Document with the result and Instance ID of the project.

<result ProjectID="1" InstanceID="11" Status="OK"/>

Then to Query the result of this project instance you would call the Project Query Endpoint passing the Instance ID returned before.

This then returns a simple XML Document with the Result and Log Details.

<Results ID="11" ProjectID="1" StatusID="1" Status="Success" StartTime="2013-09-09 14:41:41.053" EndTime="2013-09-09 14:42:00.103">
<Result ID="21" StepID="1" StepName="ProductsToProducts" StatusID="0" Status="Idle" StartTime="2013-09-09 14:41:41.087" EndTime="2013-09-09 14:41:42.350"/>

This makes in incredibly easy to integrate Ouvvi Project execution from your client applications. For example this could be used to start SSIS Projects on the SQL Server Integration Server by calling a simple HTTP Request.

For example below is sample code for a Console Application that starts an Ouvvi project and waits for it to complete.

using System;
using System.Net;
using System.Threading;
using System.Xml;

namespace ConsoleApplication1
    class Program
        static int Main(string[] args)
            int projectID = 1;

            //Start the Project
            //returns <result ProjectID="1" InstanceID="11" Status="OK"/>            
            XmlDocument document = new XmlDocument();
            document.XmlResolver = new XmlUrlResolver { Credentials = CredentialCache.DefaultCredentials };

            document.Load(string.Format("{0}", projectID));

            long instanceID = -1;
            string result = "NOT_OK";

            var resultNode = document.SelectSingleNode("/result/@Status");
            if (resultNode != null) result = resultNode.InnerText;

            var instanceNode = document.SelectSingleNode("/result/@InstanceID");
            if (instanceNode != null) instanceID = Convert.ToInt64(instanceNode.InnerText);

            Console.WriteLine("Project: {0} Started: {1}, Instance ID: {2}", projectID, result, instanceID);

            //Query the Project and Wait for Completion

            //<Results ID="14" ProjectID="1" StatusID="1" Status="Success" StartTime="2013-09-09 15:04:03.827" EndTime="2013-09-09 15:04:05.213">
            //<Result ID="24" StepID="1" StepName="ProductsToProducts" StatusID="0" Status="Idle" StartTime="2013-09-09 15:04:03.903" EndTime="2013-09-09 15:04:05.213"/>

            while (true)
                string projectResult = null;

                XmlDocument statusdocument = new XmlDocument();
                statusdocument.XmlResolver = new XmlUrlResolver { Credentials = CredentialCache.DefaultCredentials };

                statusdocument.Load(string.Format("{0}", instanceID));

                var projectResultNode = statusdocument.SelectSingleNode("/Results/@Status");
                if (projectResultNode != null) projectResult = projectResultNode.InnerText;

                if (!string.IsNullOrEmpty(projectResult))
                    if (projectResult.Equals("Success"))
                        Console.WriteLine("Project Completed Succesfully.");
                        return 0;
                    if (projectResult.Equals("Failure"))
                        Console.WriteLine("Project Failed.");
                        return 1;
                    Console.WriteLine("Project Status:{0}", projectResult);



| |