Get All the Workflows Present in the Selected Repository
- Last UpdatedJun 10, 2024
- 2 minute read
PROCEDURE
Dll REFERENCE
Workflow.Net.NET2
Skelta.Forms.Core
NAMESPACE USED
Workflow.NET
Skelta.Repository.List
Skelta.Forms.Core.Controls
Get all the Workflow Names
The code below demonstrates how to get all the workflow names present in the specified repository.
//Namespaces
using Skelta.Repository.List;
using Skelta.Forms.Core.Controls;
using Workflow.NET;
//Class level Variables
string _applicationName = "MyRepo1"; //Repository Name
string _listName = "Workflow"; //This value is fixed for workflow list
string UserId="skeltalist::1AA9AA25-92F8-4635-839B-CB029EB95B2F";
//1AA9AA25-92F8-4635-839B-CB029EB95B2F is userguid of the user admin in AVEVA Work Tasks list
Guid parentItemId=Guid.Empty; //This is the Id of Parent workflow
string[] wfarray; //An array of string consisting of all the workflow names
//Creating a hashtable for storing column names
//AVEVA Work Tasks stores table information as virtual columns, so we are using Hashtable here
Hashtable _colNames=new Hashtable();
//Create an object of ListDefinition class (_listDef) by passing //Repository name and List name(Workflow) or Guid as parameters
ListDefinition _listDef = ListDefinition.GetList (new Skelta.Core.ApplicationObject(_applicationName),
_listName);
//Creating ListItemCollection object for the workflow
ListItemCollection _listItemCollection=new ListItemCollection(_listDef);
//Create WorkflowListColumns for all the workflow(ListItems) in the Workflow list
//SortedDictionary is used to map the virtual columns and physical columns
SortedDictionary<string,Skelta.Forms.Core.Controls.BaseDataControl> fields=_ listItemCollection.GetRecordsFieldMapping();
if(_colNames.Count>0)
{
_colNames.Clear();
}
foreach(KeyValuePair<string, Skelta.Forms.Core.Controls.BaseDataControl> wfInfo in fields)
{
_colNames.Add(wfInfo.Value.Name.ToString(),wfInfo.Key.ToString());
}
//Calling GetRecordsForConsume API to get all workflow(ListItems)
DataTable WfItems=_ listItemCollection.GetRecordsForConsume(parentItemId, UserId);
int itemCount=0;
wfarray=new string[WfItems.Rows.Count];
foreach(DataRow dr in WfItems.Rows)
{
wfarray[itemCount]=dr[_colNames["Title"].ToString()].ToString();
itemCount++;
}
Get all the Workflow with description
The code below demonstrates how to get all the workflow names with descriptions present in the specified repository.
//Namespaces
using Skelta.Repository.List;
using Skelta.Forms.Core.Controls;
using Workflow.NET;
//Class level Variables
string _applicationName = "MyRepo1"; //Repository Name
string _listName = "Workflow"; //This value is fixed for workflow list
string UserId="skeltalist::1AA9AA25-92F8-4635-839B-CB029EB95B2F";
//1AA9AA25-92F8-4635-839B-CB029EB95B2F is userguid of the user admin in AVEVA Work Tasks list
Guid parentItemId=Guid.Empty; //This is the Id of Parent workflow
string workflowDescription=""; //All workflow with Name and Description
//Creating a hashtable for storing column names
//AVEVA Work Tasks stores table information as virtual columns, so we are using Hashtable here
Hashtable _colNames=new Hashtable();
//Create an object of ListDefinition class (_listDef) by passing //Repository name and List name(Workflow) or Guid as parameters
ListDefinition _listDef=new ListDefinition(new Skelta.Core.ApplicationObject(_applicationName), _listName);
//Creating ListItemCollection object for the workflow
ListItemCollection _listItemCollection=new ListItemCollection(_listDef);
//Create WorkflowListColumns for all the workflow(ListItems) in the Workflow list
//SortedDictionary is used to map the virtual columns and physical columns
SortedDictionary<string,Skelta.Forms.Core.Controls.BaseDataControl> fields=_ listItemCollection.GetRecordsFieldMapping();
if(_colNames.Count>0)
{
_colNames.Clear();
}
foreach(KeyValuePair<string, Skelta.Forms.Core.Controls.BaseDataControl> wfInfo in fields)
{
_colNames.Add(wfInfo.Value.Name.ToString(),wfInfo.Key.ToString());
}
//Calling GetRecordsForConsume API to get all workflow(ListItems)
DataTable WfItems=_ listItemCollection.GetRecordsForConsume(parentItemId, UserId);
int itemCount=0;
StringBuilder strBuilder=new StringBuilder();
strBuilder.Append("<Workflows>");
foreach(DataRow dr in WfItems.Rows)
{
strBuilder.Append("<workflow name=\""+dr[_colNames["Title"].ToString()].ToString()+"\">"+dr[_colNames["Description"].ToString()].ToString()+"</workflow>");
itemCount++;
}
strBuilder.Append("</Workflows>");
//Returns all the workflow with Name and Description
workflowDescription=strBuilder.ToString();