Import the Workflow from Workflow Definition Xml
- Last UpdatedJun 10, 2024
- 1 minute read
AVEVA Work Tasks provides a feature to import the workflow from the definition XML in the Process Designer. This can also be done using the AVEVA Work Tasks APIs programmatically. The following code sample demonstrates how to import the workflow.
PROCEDURE
Dll REFERENCE
Workflow.Net.NET2
Skelta.Forms.Core
NAMESPACE USED
Workflow.NET
Skelta.Repository.List
Skelta.Forms.Core.Controls
Try the following code in a console application by adding the above references and name spaces:
//Namespaces
using Skelta.Repository.List;
using Skelta.Forms.Core.Controls;
using Workflow.NET;
//Class level Variables
//Repository Name
string _applicationName = "MyRepo1";
//This value is fixed for workflow lists
string _listName = "Workflow";
ListDefinition _listDef = ListDefinition.GetList(new Skelta.Core.ApplicationObject(_applicationName), _listName);
//specify path of exported workflow Xml file.
string strData = System.IO.File.ReadAllText (@"M:\SkeltaDev3.0\xml.xml");
//Id of ListItem to import the workflow
//This id is obtained from the table SKEWorkflow, value of the column Id corresponding to your
//repository name(Application) and workflow (Title).
Guid gid = new Guid("65caf315-889e-4c46-b8d4-ea9b0e09013b");
Skelta.Repository.List.ListItem ListItemForImport = new Skelta.Repository.List.ListItem(_listDef, gid);
ListTableForm listTableForm1 = ((ListTableForm) ListItemForImport.ListForm.Records[0].FindControlByID("_sys_wfdef_form"));
string fileName = (string)((ListTextDataItem)listTableForm1.Records[0].FindControlByID("_sys_wfdef_filename")).Value;
string workflowname = ListItemForImport.Title;
Workflow.NET.Interfaces.IDataHandler DBHandler = null;
Config ConfigObj = new Config(_applicationName);
Workflow.NET.Storage.Staging stg = new Workflow.NET.Storage.Staging(DBHandler);
stg.Update("MyRepo1", workflowname, fileName, strData);
ListItemForImport.LoggedInUserId = "skeltalist::1AA9AA25-92F8-4635-839B-CB029EB95B2F";
// If the provider is Active Directory the format is "activedirectory::user id"
//1AA9AA25-92F8-4635-839B-CB029EB95B2F is userguid of the user admin in skelta list
//setting logged-In userid is mandatory
ListItemForImport.ChangeStatusAndUpdate(ListItemVersionStatus.Published);