Workflow samples
For most examples, it has been used the Purchase workflow sample.
Methods
registerProcessDefinition
Description:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                FileStream fs = new FileStream("E:\\Purchase.par",FileMode.Open);
                ws.registerProcessDefinition(fs);
                fs.Dispose();
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}
deleteProcessDefinition
Description:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                long pdId = 5; // Valid workflow process definition
                ws.deleteProcessDefinition(pdId);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}
getProcessDefinition
Description:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                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:
| Method | Return values | Description | 
|---|---|---|
| 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);
            
            try
            {
                ws.login(user, password);
                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:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                foreach (ProcessDefinition pd in ws.findAllProcessDefinitions()) 
                {
                     System.Console.WriteLine(pd);
                }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }
        }
    }
}
findProcessInstances
Description:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                // 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:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                    ws.login(user, password);
                    // 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:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                ProcessDefinition pd = ws.findLastProcessDefinition("purchase");
                System.Console.WriteLine("WF definition: " + pd);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}
getProcessInstance
Description:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                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:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                // 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:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                // 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:
| Method | Return values | Description | 
|---|---|---|
| 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);
            
            try
            {
                ws.login(user, password);
                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:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                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:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                long tiId = 8110; // Some valid task instance id
                ws.startTaskInstance(tiId);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}
setTaskInstanceActorId
Description:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                long tiId = 8110; // Some valid task instance id
                ws.setTaskInstanceActorId(tiId, "okmAdmin");
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}
endTaskInstance
Description:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);            
            
            try
            {
                ws.login(user, password);
                long tiId = 8110; // Some valid task instance id
                ws.endTaskInstance(tiId, "end");
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}getProcessDefinitionForms
Description:
| Method | Return values | Description | 
|---|---|---|
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);            
           
            try
            {
                 ws.login(user, password);
                 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());
            } 
        }
    }
}
getProcessDefinitionImage
Description:
| Method | Return values | Description | 
|---|---|---|
| getProcessDefinitionImage(string pdId, string uuid) | string | Returns an image as a string. | 
| 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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);            
           
            try
            {
                ws.login(user, password);
                string tiId = "1";
                string res = ws.getProcessDefinitionImage(tiId, "a978f8e6-aa87-4f0f-b7bc-6f44cb090fdf");
                System.Console.WriteLine(res);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}findPooledTaskInstances
Description:
| Method | Return values | Description | 
|---|---|---|
| findPooledTaskInstances() | List<TaskInstance> | Retrieves a list of all pooled task instances. | 
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:8080/openkm";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
            
            try
            {
                ws.login(user, password);
                List<TaskInstance> tasks = ws.findPooledTaskInstances();
                foreach (TaskInstance ti in tasks)
                {
                    System.Console.WriteLine(ti);
                }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
} 
                   
                  