What is a Business Object?

cDevWorkflow business object (BO) is an object that gives design and real time access to business objects from other systems/applications.  Think of it as a proxy for business objects.  Business objects are implemented using a simple interface “deIBusinessObject”.

boConfig

Business objects are configured with a class name, namespace and the DLL file they belong to.  Once configured, they become available within the workflow designer for defining objects that are business object type.

For example, open the designer and click the “Manage Business Objects” icon on the toolbar.

manageBO

Once the properties window renders with the UI for managing business objects, let’s define a business object called Person1 and Person 2 that is clsPersonBO type.

defineBOs

After defining these business objects, these business objects can be used within processes to get and set their property values.  By using the step “getBusinessObject”, the business object can be retrieved at runtime and then its properties used within other computations.  Let’s say the “Person1” BO has a property called “age”.  This property can be referenced within other steps such as the “Decision” step to perform a comparison such as the following: int.Parse(“cDevBO.Person1.age”) == 15

Writing a custom Business Object

A custom BO can be implemented using a the interface “deIBusinessObject”.  Below is the sample code the clsPersonBO business object.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using cDevWorkflow.cDevDecisionEngine;

namespace cDevWorkflow.cDevBusinessObjects
{
public class clsPersonBO : deIBusinessObject
{
public object getObject(clsEngineContext oEngineContext, Hashtable oInputParameters)
{
clsPerson oPerson = new clsPerson(oInputParameters["name"].ToString(), int.Parse(oInputParameters["age"].ToString()));

return (oPerson);
}

public List getInputParameterKeys()
{
List oList = new List();
oList.Add("name");
oList.Add("age");
return (oList);
}

public Type getObjectType()
{
return (typeof(clsPerson));
}

public List getDynamicPropertyList()
{
List oList = new List();
oList.Add("alpha");
oList.Add("beta");
return (oList);
}

public string getDynamicPropertyValue(clsEngineContext oContext, string key)
{

return (key + 1.ToString());
}

public bool setDynamicPropertyValue(clsEngineContext oContext, string key, string val)
{
File.AppendAllText(@"c:\temp\eventdata\dyna.txt", key + " - " + val);
return (true);
}
}

public class clsPerson
{
public string name { get; set; }
public int age { get; set; }

public clsData oData { get; set; }

public clsPerson(string name, int age)
{
this.name = name;
this.age = age;

Random rnd = new Random();
this.age = rnd.Next(1, 100);

this.oData = new clsData() { num1 = 5, num2 = 7 };
}
}

public class clsData
{
public int num1 { get; set; }
public int num2 { get; set; }
}
}