The IRtConnection interface exposes the methods listed in the following table:
Methods | Description |
---|---|
Allows the client to execute an Action method that is processed on the UI thread. | |
Returns a DataModel object based on a specified class name. | |
Returns the type of the DataModel based on a specified ispec or class. | |
Returns a collection of types defined by the class name. | |
Returns a collection of types defined by the class name. | |
Returns a collection of list items for a specified list name containing all columns in the list as individual properties of the ListItem class. | |
Returns a collection of list items for a specified list name, list format, display column index, and host column index. | |
Returns a list of T elements for a specified list name and type. | |
Returns a list of T elements for a specified list name and type. | |
IRtConnection.GetList<T> Method (String, IFromStringConverter) | Gets a list of primitives and allows you to specify a converter to convert the strings in the list to their primitive types. |
IRtConnection.GetListAsync<T> Method (String, IFromStringConverter) | Gets a list of primitives and allows you to specify a converter to convert the strings in the list to their primitive types. |
Loads a specified ispec or class in the runtime system for a session through a synchronous call. As this a synchronous call, the calling process is blocked until the method completes. | |
Loads a specified ispec or class in the runtime system for a session through an asynchronous call. As this is an asynchronous call, the calling process is not blocked. An event handler receives a new TransmissionObject when the method completes. | |
Sends data in the specified DataModel to the runtime system through a synchronous call and waits for a reply. As this is a synchronous call, it blocks the calling process. | |
Sends the data in the specified DataModel to the runtime system through an asynchronous call. It does not wait for a reply and thus does not block the calling process. The result of the transaction is handled by a specified callback handler method. |
The BeginInvokeAction method is for clients that require an Action method to be processed on the UI thread to avoid Cross Thread Operation exceptions. Note that this method is mainly used by remote clients that access the WCF Gateway.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
void BeginInvokeAction(
Action action
)
Argument
action – System.Action
This argument specifies the action method to be invoked.
Using the IRtConnection Interface for the BeginInvokeAction Method
The following code is an example of using the BeginInvokeAction method to fire the TransmissionObjectChanged event with a new TransmissionObject:
this.host.BeginInvokeAction(() => { this.host.FireTransmissionObjectChanged(new ConnectionEventArgs(new TransmissionObject() { State = entity.Status == ReturnCode.DataModelVersionCheckFailed ? TransmissionReturnCode.DataModelVersionCheckFailed : TransmissionReturnCode.Ok, ObjectClassName = entity.Name, Datamodel = Serializer.Deserialize<object>(entity.Value, this.host.GetDataModelType(entity.Name)) })); });
The GetDataModelObject method returns an instance of a DataModel based on a specified class name.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
Object GetDataModelObject(
string className
)
Argument
className – System.String
This argument provides the name of an ispec or a class to be loaded.
Return Value
The GetDataModelObject returns a generic object type that can be cast to a specific DataModel type, if required.
Using the IRtConnection Interface for the GetDataModelObject Method
The following code is an example of using the GetDataModelObject method:
// Create an instance of a PRODModel class by using // GetDataModelObject() // ABSConnection is an instance IConnection // DataHandler is an instance of IRtConnection PRODModel pModel = (PRODModel) ABSConnection.DataHandler.GetDataModelObject("PROD"); // Populate the PRODModel pModel._UserMAINT = "FIR";
The GetDataModelType method returns the type of DataModel for a specific ispec or class.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
Type GetDataModelType(
string className
)
Argument
className – System.String
This argument provides the name of an ispec or a class to be checked.
Return Value
If this method succeeds, it returns the type of the object.
Using the IRtConnection Interface for the GetDataModelType Method
The following code is an example of using the GetDataModelType method:
// Check the DataModel type in the returned TransmissionObject by // using the ObjectClassName as the name of the Ispec. If it is a // type of PRODModel, extract the data. if (ABSConnection.DataHandler.GetDataModelType(tObject.ObjectClassName) == typeof(PRODModel)) { // Extract the Data from the PRDOModel object returned by the // Connector pModel = (PRODModel)tObject.Datamodel; string Name = pModel.NAM; string ID = pModel.PRODUCT; decimal price = pModel.SELLPRICE; Int32 reOrderLevel = pModel.REORDLEV; }
The GetList method (String, String) returns a collection of types defined by the class name.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
IEnumerable GetList( string listName, string className )
Arguments
listName – System.String
This argument provides the name of the list.
className – System.String
This argument provides the name of the class.
Return Value
This method returns a collection of types defined by the class name.
Using the IRtConnection Interface for the GetList Method (String, String)
The following code is an example of using the GetList method (String, String):
// Load the PROD ispec, which returns the PROD.PRODUCTS list // Access the list items according to the type definition for the list LoadIspec("PROD"); IEnumerable myList = ABSConnection.DataHandler.GetList("PROD.PRODUCTS", “NameIdInfoModel”); NameIdInfoModel item = myList.elementAt(0) as NameIdInfoModel; string id = item.Id; string name = item.Name;
The GetListAsync method (String, String) returns a collection of types defined by the class name.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
Task<IEnumerable> GetListAsync( string listName, string className )
Argument
listName – System.String
This argument provides the name of the list.
className – System.String
This argument provides the name of the class.
Using the IRtConnection Interface for the GetListAsync Method (String, String)
The following code is an example of using the GetListAsync method (String, String):
connection.GetListAsync("CUST.Customers", "NameIdInfoModel").ContinueWith ((t) => { var myList = t.Result; foreach(NameIdInfoModel item in myList) { // Process the item } });
The GetList method (String, String[]) returns a collection of ListItems for a specified list name. The ListItems include all columns in the list as individual properties of the ListItem class.
For example, if the list sent from the host system contains five columns, then the ListItem objects in the returned collection contains properties named “Column1”, “Column2”, “Column3”, “Column4”, and “Column5”. These can then be processed by the client application individually. You can also supply an array of names to label the columns in the ListItem collection, if you prefer specific names rather than the default names, such as “Column1”, “Column2”, and “Column3”.
Note: This method should only be used with traditional lists that were created by using SendListDynamic or SendListStatic.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
IEnumerable<ListItem> GetList( string listName, string[] names = null )
Arguments
listName – System.String
This argument provides the name of the list to be retrieved.
names – System.String
This argument provides an array of names for the individual columns containing the list items.
Return Value
If this method succeeds, it returns a collection of list items that can be iterated, bound to a ViewModel, or sent directly to a list-based control, such as a list box.
Using the IRtConnection Interface for the GetList Method (String,String[])
The following code is an example of using the interface for the GetList (String,String[]) method:
// Load the SREP ispec that returns the SREP.SALESREP list // Substitute the column names to use ID and Name instead of the // default Column0, Column1, etc… LoadIspec("SREP"); IEnumerable<ListItem> myList = ABSConnection.DataHandler.GetList("SREP.SALESREP", new string[] { "ID", "Name" }); // Retrieve the first item in the list and extract the details // using the ID and Name keys ListItem item = myList.First<ListItem>(); string id = item["ID"]; string name = item["Name"];
The GetList method (String, String, Int32, Int32) returns a collection of ListItems for a specified list name, list format, host column index, and display column index.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
IEnumerable<ListItem> GetList( string listName, string lFormat, int hostColumn, int displayColumn )
Arguments
listName – System.String
This argument provides the name of the required list, as designed in the AB Suite system.
lFormat – System.String
This argument provides the format string for the list, indicating the required columns to be used. For example, %2%3%4 uses columns 2, 3, and 4. This concatenates the content and returns it to the client for display. If this argument is not required it must be set to null.
hostColumn – System.Int32
This argument provides an integer value specifying the column used for the host value.
displayColumn – System.Int32
This argument provides an integer value specifying the column used for displaying the value.
Note: This is not used if a Format string is specified in the lFormat parameter.
Return Value
The return value is an IEnumerable of the type ListItem. This can be used to process the contents of a list or bind the list directly to a list-based control.
Note: This method should only be used with traditional lists that were created by using SendListDynamic or SendListStatic.
Using the IRtConnection Interface for the GetList Method (String, String, Int32, Int32)
The following code is an example of using the GetList (String, String, Int32, Int32) method:
// Load the SREP ispec that returns the SREP.SALESREP list LoadIspec("SREP"); IEnumerable<ListItem> myList = ABSConnection.DataHandler.GetList("SREP.SALESREP", "1%2", 1, 2); ListItem item = myList.First<ListItem>(); // Access the ListItem contents using the hc and dc properties // In this example, the dc contents contain a // concatenation of columns 1&2. string id = item.hc; string name = item.dc;
The GetList<T> Method (String) returns a list of T elements for a specified list name and type. The type specifier in the GetList<T> definition specifies the type of list template as defined in System Modeler. For example, if you define a List template in System Modeler, named NameIdInfo and it contains the attributes “Id” and “Name”, then a DataModel named NameIdInfoModel is generated in the Access Layer DataModels assembly with the same attributes. The type of this DataModel (NameIdInfoModel) can be specified for the GetList<T>() method. The resulting IEnumerable contains a collection of list items of the same type (NameIdInfoModel).
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
IEnumerable<T> GetList<T>(
string listName
)
The type specifier T should be set to the List model type that is generated in the Access Layer API based on the List Template definition in System Modeler.
Argument
listName – System.String
This argument provides the name of the list to be retrieved, which is set up in the host application logic by using the Glb.ClientManager’s SendDynamic() or SendStatic() methods. If you supply a list name parameter in these methods, the specified name must be used in the GetList<T>() method (for example, PRODUCTLIST). If a name is not provided in the SendDynamic() or SendStatic() call, the default format for this argument is “ClassName”.”Attribute Name”, where Attribute Name is the name of the List instance in System Modeler (for example, PROD.Products).
Return Value
If this method succeeds, it returns a collection of list items of a specified type.
Using the IRtConnection Interface for the GetList<T> Method (String)
The following code is an example of using the GetList<T> (String) method:
// Load the PROD ispec that returns the PROD.PRODUCTS list // Access the list items according to the type definition for the list LoadIspec("PROD"); IEnumerable<NameIdInfoModel> myList = ABSConnection.DataHandler.GetList<NameIdInfoModel>("PROD.PRODUCTS"); NameIdInfoModel item = myList.First<NameIdInfoModel>(); string id = item.Id; string name = item.Name;
The GetListAsync<T> method returns a list of T elements for a specified list name and type.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
Task<IEnumerable<T>> GetListAsync<T>(
string listName
)
Argument
listName – System.String
This argument provides the name of the list.
Using the IRtConnection Interface for the GetListAsync<T> Method (String)
The following code is an example of using the GetListAsync<T> method (String):
connection.GetListAsync<NameIdInfoModel>("CUST.Customers").ContinueWith ((t) => { var myList = t.Result; foreach(NameIdInfoModel item in myList) { // Process the item } });
The GetList<T> method (String, IFromStringConverter) gets a list of primitives and allows you to specify a converter to convert the strings in the list to their primitive types.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
IEnumerable<T> GetList<T>( string listName, IFromStringConverter converter )
Arguments
listName – System.String
This argument provides the name of the list.
converter – IFromStringConverter
This argument specifies the converter.
Using the IRtConnection Interface for the GetList<T> Method (String, IFromStringConverter)
The following code is an example of using the GetList<T> method (String, IFromStringConverter):
Assume you have a list of primitives in your model, such as a list of dates, Boolean, or numbers. You can then get that list by using the following code:
connection.GetList<bool>("MyClass.BoolItems", new CLRBoolStringConverter()); connection.GetList<DateTime>("MyClasss.DateItems", new CLRDateUK8StringConverter()); connection.GetList<int>("MyClass.NumberItems", new CLRIntStringConverter());
The GetListAsync<T> method (String, IFromStringConverter) gets an asynchronous list of primitives and allows you to specify a converter.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
Task<IEnumerable<T>> GetListAsync<T>( string listName, IFromStringConverter converter )
Arguments
listName – System.String
This argument provides the name of the list.
converter – IFromStringConverter
This argument specifies the converter.
Using the IRtConnection Interface for the GetListAsync<T> Method (String, IFromStringConverter)
The following code is an example of using the GetListAsync<T> method (String, IFromStringConverter):
await connection.GetListAsync<bool>("MyClass.BoolItems", new CLRBoolStringConverter()); await connection.GetListAsync<DateTime>("MyClasss.DateItems", new CLRDateUK8StringConverter()); await connection.GetListAsync<int>("MyClass.NumberItems", new CLRIntStringConverter());
The Load method loads a specified ispec or class in the runtime system for a session through a synchronous call. As this is a synchronous call, the calling process is blocked until the method completes.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
TransmissionObject Load( string name, bool withSwitch = true )
Arguments
name – System.String
This argument provides the name of the ispec or class to be loaded.
withSwitch – System.Boolean
This argument is optional. It determines whether a TransmissionObjectChanged event is raised. By default, this is set to true.
Return Value
If this method succeeds, it returns a TransmissionObject containing the DataModel for the specified class to be loaded.
Using the IRtConnection Interface for the Load Method
The following code is an example of using the Load method:
connection.Load("Cust")
The LoadAsync method loads a specified ispec or class in the runtime system for a session through an asynchronous call. As this is an asynchronous call, the calling process is not blocked. An event handler receives a new TransmissionObject when the call completes.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
Task<TransmissionObject> LoadAsync( string name, bool withSwitch = true )
Arguments
name – System.String
This argument provides the name of the ispec or class to be loaded.
withSwitch – System.Boolean
This argument is optional. It determines whether a TransmissionObjectChanged event is raised. By default, this is set to true.
Return Value
This method returns a transmission object.
Using the IRtConnection Interface for the LoadAsync Method
The following code is an example of using the LoadAsync method:
await connection.LoadAsync("Cust")
The Transmit method sends the data held by the supplied DataModel to the runtime system and waits for a reply. This is a synchronous call and thus blocks the calling process.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
TransmissionObject Transmit(
Object datamodel
)
Argument
datamodel – System.Object
This argument provides a DataModel object containing the data to be sent to the host system for a specific ispec transaction.
Return Value
If this method succeeds, it returns a TransmissionObject containing the results of the transaction.
The TransimissionReturnCode indicates success or failure of the method. The DataModel object contains information about the response received from the host system.
Using the IRtConnection Interface for the Transmit Method
The following code is an example of using the Transmit method:
// Create an instance of a PRODModel class PRODModel pModel = (PRODModel) ABSConnection.DataHandler.GetDataModelObject("PROD"); // Populate the PRODModel pModel._UserMAINT = "FIR"; // Transmit the PRODModel to the host system TransmissionObject tObject = ABSConnection.DataHandler.Transmit(pModel); // Check the return state and whether the current context is // for the PROD ispec if (tObject.State == TransmissionReturnCode.Ok) { // Check the DataModel type in the returned // TransmissionObject by using the // ObjectClassName as the name of the Ispec // If it is a type of PRODModel, extract the data if (ABSConnection.DataHandler.GetDataModelType(tObject.ObjectClassName) == typeof(PRODModel)) { // Extract the Data from the PRDOModel object returned // by the Connector pModel = (PRODModel)tObject.Datamodel; string Name = pModel.NAM; string ID = pModel.PRODUCT; decimal price = pModel.SELLPRICE; Int32 reOrderLevel = pModel.REORDLEV; } }
The TransmitAsync method sends the data held by the supplied DataModel to the runtime system. This call is asynchronous. The TransmitAsync method does not wait for a reply and thus does not block the calling process. The call must supply a callback method, which is executed when the TransmitAsync processing completes.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
Task<TransmissionObject> TransmitAsync(
Object datamodel
)
Arguments
datamodel – System.Object
This argument provides a DataModel object containing the data to be sent to the host system for a specific ispec transaction.
Return Value
None. The specified callback method handles the result of the transaction. It receives a TransmissionObject containing a DataModel with the response data from the host system.
Using the IRtConnection Interface for the TransmitAsync Method
The following code is an example of using the TransmitAsync method:
// In the main execution logic, call the TransmitAsync method // Create an instance of a PRODModel class PRODModel pModel = (PRODModel) ABSConnection.DataHandler.GetDataModelObject("PROD"); // Populate the PRODModel pModel._UserMAINT = "FIR"; // Transmit the PRODModel by using the asynchronous method and // supply a callback to handle the response from //the host system TransmissionObject trObj = await ABSConnection.DataHandler.TransmitAsync(pModel); if (trObj != null && (trObj.State == TransmissionReturnCode.Ok) { // Check the DataModel type in the returned // TransmissionObject by using the ObjectClassName as the name of // the Ispec. // If it is a type of PRODModel, extract the data. if (ABSConnection.DataHandler.GetDataModelType(trObj.ObjectClassName) == typeof(PRODModel)) { // Extract the Data from the PRDOModel object // returned by the Connector. PRODModel pModel = (PRODModel)trObj.Datamodel; string Name = pModel.NAM; string ID = pModel.PRODUCT; decimal price = pModel.SELLPRICE; Int32 reOrderLevel = pModel.REORDLEV; } }