Business Object Proxies

Running server-side business logic with support for customizations

Starting with version 16 we added the possibility to run business object methods on the server-side, similar to what the old BusinessFunctions could do, with the addition of being able to run customized code as well, with each customization being specific to each server mandant.

Enabling customizations for a server mandant can be done by editing the tlx.ini file where the server has been installed and adding a 'CustomPath' key with the value pointing to a custom path directory, just like we do to client mandants.

Example: CustomPath = C:\Customizations\CustomServer16_Testing

Invoking business logic on the server is straightforward, by using the newly added TimeLine.Framework.Business.BusinessObjectProxy<T> type. You can also use the non-generic version TimeLine.Framework.Business.BusinessObjectProxy type.

Here's an example of a simple business object that returns a simple hello world message:

public class busHelloWorld : xObject
{
    protected busHelloWorld()
    {
    }

    public string SayHello(string name)
    {
        return "Hello world! My name is " + name;
    }
}

You can easily invoke the SayHello method on the server by creating a Proxy instance, as follows:

var proxy = BusinessObjectProxy.Get<busHelloWorld>();
var messageFromServer = proxy.Invoke(x => x.SayHello("John Smith"));
xMessageBox.Show(messageFromServer);

Using the non-generic BusinessObjectProxy.Get(businessObjectId) method will allow you to invoke methods dynamically, like so:

var proxy = BusinessObjectProxy.Get("busHelloWorld");
var messageFromServer = proxy.DynamicInvoke("SayHello", "John Smith");
xMessageBox.Show(messageFromServer);

DynamicInvoke accepts the name or ToString() representation of a MethodInfo object as the method identifier and the following parameters are passed into the methods' arguments.

Dynamic invocation might be preferred when the caller does not know the called type.

The above code creates a busHelloWorld instance on the server and invoke the method with the parameters that were passed in from the client, before returning the result back to the client.

Serialization is done automatically and supports all basic .NET Framework types (+ADO.NET) as well as xDataSet. You can also implement custom Newtonsoft.Json serializers for your custom data types.

Both the dynamic and strongly typed invocation APIs have async variants and all APIs support passing in an optional xTransaction object that will be used when initializing the business object on the server-side. This way you can call multiple methods using the same transaction between these calls.

Keep in mind that calling a method on a customized business object will require that both the client and the server point to the same customization (the customization will need to be deployed and updated on the server machine as well).

Last updated