Workflow samples
Esta página aún no está disponible en tu idioma.
For most examples, it has been used the Purchase workflow sample.
Methods
Section titled “Methods”registerProcessDefinition
Section titled “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: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
Section titled “deleteProcessDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| deleteProcessDefinition(long pdId) | void | Deletes a 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 { long pdId = 5; // Valid workflow process definition ws.deleteProcessDefinition(pdId); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getProcessDefinition
Section titled “getProcessDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| getProcessDefinition(long pdId) | void | Returns a 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
Section titled “runProcessDefinition”Description:
| Method | Return values | Description |
|---|---|---|
| runProcessDefinition(long pdId, String uuid, List |
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
Section titled “findAllProcessDefinitions”Description:
| Method | Return values | Description |
|---|---|---|
| findAllProcessDefinitions() | List |
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
Section titled “findProcessInstances”Description:
| Method | Return values | Description |
|---|---|---|
| findProcessInstances(long pdId) | List |
Retrieves a list of all process instances of some registered workflows 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
Section titled “findLatestProcessDefinitions”Description:
| Method | Return values | Description |
|---|---|---|
| findLatestProcessDefinitions() | List |
Retrieves a list of the last 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 { // 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
Section titled “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.
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
Section titled “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: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
Section titled “findUserTaskInstances”Description:
| Method | Return values | Description |
|---|---|---|
| findUserTaskInstances() | List |
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
Section titled “findTaskInstances”Description:
| Method | Return values | Description |
|---|---|---|
| findTaskInstances(long piId) | List |
Retrieves a list of task instances of some 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
Section titled “setTaskInstanceValues”Description:
| Method | Return values | Description |
|---|---|---|
| setTaskInstanceValues(long tiId, String transName, List |
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
Section titled “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: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
Section titled “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: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
Section titled “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: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
Section titled “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: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
Section titled “getProcessDefinitionForms”Description:
| Method | Return values | Description |
|---|---|---|
| getProcessDefinitionForms(long pdId) | Dictionary<String, List |
Return a map with all the process definition forms. |
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()); } } }}