Workflow samples

 For most examples, it has been used the Purchase workflow sample.

Methods

registerProcessDefinition

Description:

MethodReturn valuesDescription

registerProcessDefinition(FileStream fs)

void

Registers a new workflow.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using System.IO;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                FileStream fs = new FileStream("E:\\Purchase.par",FileMode.Open);
                ws.registerProcessDefinition(fs);
                fs.Dispose();
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

deleteProcessDefinition

Description:

MethodReturn valuesDescription

deleteProcessDefinition(long pdId)

void

Deletes a workflow.

The parameter pdId value is a valid workflow process definition.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using System.IO;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                long pdId = 5; // Valid workflow process definition
                ws.deleteProcessDefinition(pdId);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

getProcessDefinition

Description:

MethodReturn valuesDescription

getProcessDefinition(long pdId)

void

Returns a workflow process definition.

The parameter pdId value is a valid workflow process definition.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                long pdId = 1; // Valid workflow process definition
                ProcessDefinition pd = ws.getProcessDefinition(pdId);
                System.Console.WriteLine(pd);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

runProcessDefinition

Description:

MethodReturn valuesDescription

runProcessDefinition(long pdId, String uuid, List<FormElement> values)

ProcessInstance

Executes a workflow on some node.

The parameter pdId value is a valid workflow process definition.

The parameter uuid can be any document, mail, folder or record UUID.

The parameter values are form element values needed for starting the workflow ( not all workflows need form values for starting ).

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
using com.openkm.sdk4csharp.bean.form;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            try
            {
                long pdId = 8041; // Some valid workflow process definition id
                List<FormElement> feList = new List<FormElement>();
                Input price = new Input();
                price.name = "price";
                price.value = "1000";
                feList.Add(price);
                TextArea textArea = new TextArea();
                textArea.name = "description";
                textArea.value = "some description here";
                feList.Add(textArea);
                ws.runProcessDefinition(pdId, "7aa523e0-06cf-4733-b8c8-cc74d8b2716d", feList);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

findAllProcessDefinitions

Description:

MethodReturn valuesDescription

findAllProcessDefinitions()

List<ProcessDefinition>

Retrieves a list of all registered workflows definitions.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                foreach (ProcessDefinition pd in ws.findAllProcessDefinitions()) 
                {
                     System.Console.WriteLine(pd);
                }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }
        }
    }
}

findProcessInstances

Description:

MethodReturn valuesDescription

findProcessInstances(long pdId)

List<ProcessInstance>

Retrieves a list of all process instances of some registered workflows definition.

The parameter pdId value is a valid workflow process definition.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                // Get all workflow definitions
                foreach (ProcessDefinition pd in ws.findAllProcessDefinitions()) 
                {
                    System.Console.WriteLine("WF definition: "+pd);
                    // Get all process of some workflow definition
                    foreach (ProcessInstance pi in ws.findProcessInstances(pd.id)) 
                    {
                         System.Console.WriteLine("PI: "+pi);
                    }
                }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

findLatestProcessDefinitions

Description:

MethodReturn valuesDescription

findLatestProcessDefinitions()

List<ProcessDefinition>

Retrieves a list of the last workflows definitions.

Can be several versions of the same workflow registered.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                    // Get all latest workflow definitions
        	    foreach (ProcessDefinition pd in ws.findLatestProcessDefinitions()) 
                    {
                        System.Console.WriteLine("WF definition: " + pd);
        	    }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

findLastProcessDefinition

Description:

MethodReturn valuesDescription

findLastProcessDefinition(String name)

ProcessDefinition

Retrieves the last workflow definition of some specific workflow.

The parameter name identifies a specific workflow definitions group.

Several workflow definition versions can have the same name.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                ProcessDefinition pd = ws.findLastProcessDefinition("purchase");
                System.Console.WriteLine("WF definition: " + pd);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

getProcessInstance

Description:

MethodReturn valuesDescription

getProcessInstance(long piId)

ProcessInstance

Returns the process instance.

The parameter piId is a valid process instance id.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                long piId = 5868; // Some valid process instance id
        	ProcessInstance pi = ws.getProcessInstance(piId);
                System.Console.WriteLine("PI: " + pi);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

findUserTaskInstances

Description:

MethodReturn valuesDescription

findUserTaskInstances()

List<TaskInstance>

Retrieves a list of task instances assigned to the user.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                // Get all user task intances
                foreach(TaskInstance ti in ws.findUserTaskInstances()) 
                {
                     System.Console.WriteLine(ti);
                }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

findTaskInstances

Description:

MethodReturn valuesDescription

findTaskInstances(long piId)

List<TaskInstance>

Retrieves a list of task instances of some process instance id.

The parameter piId is a valid process instance id.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                // Get all task instances of some process instance
                long piId = 8108; // Some valid process instance id
                foreach (TaskInstance ti in ws.findTaskInstances(piId)) 
                {
                    System.Console.WriteLine(ti);
                }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

setTaskInstanceValues

Description:

MethodReturn valuesDescription

setTaskInstanceValues(long tiId, String transName, List<FormeElement> valuess)

void

Retrieves a list of task intances of some process instance id.

The parameter tiId is a valid task instance id.

The parameter transName is the chosen transaction.

The parameter values are form element values needed for starting the workflow ( not all workflow tasks need form values ).

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
using com.openkm.sdk4csharp.bean.form;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            try
            {
                long tiId = 8110; // Some valid task instance id
                List<FormElement> feList = new List<FormElement>();
                ws.setTaskInstanceValues(tiId, "approve", feList);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

getTaskInstance

Description:

MethodReturn valuesDescription

getTaskInstance(long tiId)

TaskInstance

Returns a task instance.

The parameter tiId is a valid task instance id.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                long tiId = 8110; // Some valid task instance id
                TaskInstance ti = ws.getTaskInstance(tiId);
                System.Console.WriteLine(ti);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

startTaskInstance

Description:

MethodReturn valuesDescription

startTaskInstance(long tiId)

void

Starts a task instance.

The parameter tiId is a valid task instance id.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                long tiId = 8110; // Some valid task instance id
                ws.startTaskInstance(tiId);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

setTaskInstanceActorId

Description:

MethodReturn valuesDescription

setTaskInstanceActorId(long tiId, String actorId)

void

Starts a task instance.

The parameter tiId is a valid task instance id.

The parameter actorId must be a valid OpenKM userId.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
            
            try
            {
                long tiId = 8110; // Some valid task instance id
                ws.setTaskInstanceActorId(tiId, "okmAdmin");
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

endTaskInstance

Description:

MethodReturn valuesDescription

endTaskInstance(long tiId, String transName)

void

Starts a task instance.

The parameter tiId is a valid task instance id.

The parameter transName is a transaction name.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);            
            try
            {
                long tiId = 8110; // Some valid task instance id
                ws.endTaskInstance(tiId, "end");
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

getProcessDefinitionForms

Description:

MethodReturn valuesDescription

getProcessDefinitionForms(long pdId)

Dictionary<String, List<FormElement>>

Return a map with all the process definition forms.

The parameter pdId value is a valid workflow process definition.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean.form;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8180/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);            
            try
            {
                 Dictionary<String, List<FormElement>> forms = ws.getProcessDefinitionForms(1);
                 foreach (KeyValuePair<String, List<FormElement>> pair in forms)
                 {
                    System.Console.WriteLine("Key:"+ pair.Key);
                        foreach (FormElement fe in pair.Value) 
                        {
                            System.Console.WriteLine("Fe:"+ fe);
                        }
                 }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}