Quick Start (Base64): Searching for Process Instances using the web service API

The following C# code example searches for process instances that are based on the MortgageLoan - Prebuilt process.

using System; 
using System.Collections; 
using System.ComponentModel; 
using System.Data; 
using System.IO ;  
 
namespace SearchProcesses 
{ 
    class Class1 
    { 
        [STAThread] 
        static void Main(string[] args) 
        { 
            try 
            { 
                //Create a TaskManagerQueryServiceService  object 
                TaskManagerQueryServiceService  tmqs = new TaskManagerQueryServiceService (); 
     
                //Provide authentication credentials to the service 
                tmqs.Credentials = new System.Net.NetworkCredential( 
                    "administrator", 
                    "password" 
                    ); 
 
                //Search for process instances based on a process named 
                //MortgageLoan - Prebuilt 
                ProcessSearchFilter processFilter = new ProcessSearchFilter();  
                processFilter.serviceName = "MortgageLoan - Prebuilt" ;  
                Object[] allProcess = tmqs.processSearch(processFilter); 
                 
                //Determine the number of ProcessInstanceRow instances returned 
                int num = allProcess.Length; 
                 
                //Iterate through the process instances 
                for (int i=0; i<num;i++) 
                { 
                    //Get a ProcssInstanceRow instance 
                    ProcessInstanceRow processInstance = (ProcessInstanceRow)allProcess[i];     
 
                    if (processInstance.processInstanceStatus == 4) 
                    { 
                        Console.WriteLine("This process instance was terminated"); 
                    } 
                } 
            } 
            catch (Exception ee) 
            { 
                Console.WriteLine(ee.Message); 
            } 
 
        } 
    } 
}