📘
TimeLine E3
  • TimeLine E3 Documentation
  • Framework
    • Introduction
    • DataSet Definition
    • Window Handling Object
      • Input/Output arguments
      • Open
      • BindDataControls
      • Item Changes
      • Item Search
      • MenuItemClicked
      • Print
      • ModuleOpened (BlueArrow)
      • BlueArrowArguments
      • New Row
      • Delete Row
      • Save
      • Transactions
      • Locking [deprecated]
      • Locking (new)
      • Resizing a response window
      • ParaPanel
      • Adding DMS Tab to a Module
    • BusinessObject
    • Controls
      • BindingFormat
      • LookupGrid and SearchDef
      • ComboBox
      • RadioButton
      • Multiline Textbox
      • xTextBoxSearch
      • xFileBrowse [v16+]
      • DxDispoColumn
      • DxProgressColumn
      • DxTemplateColumn
      • Change control caption programmatically
      • TabControl
      • Navigation
      • Enable controls programmatically
      • Enable a MenuItem programmatically
      • Filter search values
      • Jumping to another module
      • Messages, Notifications, Log, Exceptions, Translation
      • LoggerSink [deprecated]
      • Log
      • OpenFile, FolderBrowsing and SaveFile
      • Execute Actions while displaying an Hourglass
      • Using Progress
      • Async methods with progress bar
      • Wizard
      • Customizing controls using xBehaviors
      • TLProperty.AllowInReadOnly [v16+]
    • DataSet Operations
    • Business-related functionality
      • Getting the next primary key
      • Hybrids
      • Enums
      • Get Current User
    • SQL
    • SQL (using named parameters)
    • Advanced SQL
    • Expression Binding
    • Server-side logic & customization [v16+]
      • Service Hoster
      • Starting / stopping hosted services
      • Changes to scheduled jobs!
      • Business Object Proxies
      • Business Object API
    • Colors in Expression Bindings [v15+]
    • Theming
      • Icons
  • TimeLine Developer (TLD)
    • Debugging in TLD
    • Targets
    • Custom Project Rework [v16+]
  • TimeLine-specific LL functions
  • Stunnel proxy
    • Pre-requisites
    • 1. Initial setup
    • 2. Generate the server/web certificates
    • 3.a. Generating client certificates using the CSR flow
    • 3.b. Generate client certificates from the server console
    • 4. Setting up the E3 client connection
    • 5. Setting up the browser certificates
  • Configuration
    • Configuring the WCF timeout
  • Troubleshooting the E3 Bridge
  • [Deprecated]
    • TimeLine WEB - deprecated in v16+
      • Prerequisites for running the WASM modules on the server
      • Prerequisites for developing WASM modules with TLD
      • Creating a small web module with TLD
      • Terminal Configuration
    • Customization Examples - deprecated in v16+
    • Codestore [deprecated]
    • Configuring the scheduled jobs timeout - deprecated in v16+
Powered by GitBook
On this page
  1. Framework
  2. Server-side logic & customization [v16+]

Business Object Proxies

Running server-side business logic with support for customizations

As of version 16 the old BusinessFunctions are no longer usable. The recommended way of running server-side business logic is via the Business Object Proxies.

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.

Business object methods that are to be called via the proxy should be designed with immutability in mind - each method call should receive all data it requires through it's parameters. State is not kept between proxy calls on the business object created on the server between methods.

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).

PreviousChanges to scheduled jobs!NextBusiness Object API

Last updated 1 year ago