55
Infor 13560 Morris Road Suite 4100 Alpharetta, Georgia 30004-8508 www.Infor.com Version 8.00 IDO Development Guide

IDO Development Guide

Embed Size (px)

Citation preview

Page 1: IDO Development Guide

Infor13560 Morris Road

Suite 4100Alpharetta, Georgia 30004-8508

www.Infor.com

Version 8.00

IDO Development Guide

Page 2: IDO Development Guide

IDO Development Guide

Published in the USA January 2008

Copyright © 2008 Infor. All rights reserved. The word and design marks set forth herein are trademarks and/or registered trademarks of Infor and/or related affiliates and subsidiaries. All other trademarks listed herein are the property of their respective owners.

Restricted Rights Legend Use, duplication, or disclosure by the Government is subject to

restrictions as set forth in subparagraph (c)(1)(ii) of the Rights inTechnical Data and Computer Software clause at DFARS 252.227-7013,

and Rights in Data-General at FAR 52.227.14, as applicable. Name of Contractor: Infor, 13560 Morris Road Suite 4100 Alpharetta, Georgia 30004-8508

Date Page Description1/10/08 2-21 (SL8.00.10) Modified example to depict use with configuration groups.

2/19/08 2-6 Added ReadMode property to LoadCollection (issue 107944)

Page 3: IDO Development Guide

Contents_________________________________________Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1

For More Information............................................................................................................. 1-1

IDO .NET API and Class Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1Overview.......................................................................................................................................2-1IDO Commands Interface.............................................................................................................2-3

IIDOCommands Interface (C#) ............................................................................................. 2-3IIDOCommands interface (Visual Basic)............................................................................... 2-4IDO Commands Interface - Request/Response Syntax........................................................ 2-4

APIs and Related IDO Protocol Classes - Details ........................................................................2-5GetPropertyInfo..................................................................................................................... 2-5LoadCollection ...................................................................................................................... 2-6UpdateCollection................................................................................................................... 2-9Invoke.................................................................................................................................. 2-11

Assigning and Checking Null Values in IDO Requests ..............................................................2-13Assigning Null Values ......................................................................................................... 2-13Checking Null Values .......................................................................................................... 2-13

Translation/Localization Considerations.....................................................................................2-14Internal Format for Numbers ............................................................................................... 2-14Internal Format for Dates .................................................................................................... 2-14Type Conversions ............................................................................................................... 2-14Setting Property and Parameter Values.............................................................................. 2-14Getting Property and Parameter Values ............................................................................. 2-15Creating Filter Strings ......................................................................................................... 2-16Supported .NET CLR Types ............................................................................................... 2-17

Transactions ...............................................................................................................................2-18Diagnostics and Debugging........................................................................................................2-19

Logging Diagnostic Messages ............................................................................................ 2-19Wire Tap.............................................................................................................................. 2-19

Standalone Application Communications ...................................................................................2-20Open Session...................................................................................................................... 2-20Close Session ..................................................................................................................... 2-20GetConfigurations ............................................................................................................... 2-20MongooseConfigs Class (MGShared.dll Class Library)...................................................... 2-23

IDO Extension Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1About Extension Classes..............................................................................................................3-1Creating a New IDO Extension Class Project ..............................................................................3-1Importing Assemblies ...................................................................................................................3-2Implementing an IDO Extension Class.........................................................................................3-2

Mongoose.IDO.IIDOExtensionClass Interface...................................................................... 3-2Mongoose.IDO.IIDOExtensionClassContext Interface ......................................................... 3-2Declaration of an IDO Extension Class for an IDO ............................................................... 3-3IDO Extension Class Starter Template ................................................................................. 3-3

Adding Methods............................................................................................................................3-4IDOMethod Parameters ........................................................................................................ 3-4

IDO Event Handlers......................................................................................................................3-5Adding an IDO Event Handler............................................................................................... 3-5Event Handler Parameters.................................................................................................... 3-6Special Cases for UpdateCollection Events.......................................................................... 3-8Replacing Standard IDO Processing with Event Handlers ................................................... 3-9Generating Application Events............................................................................................ 3-10

IDO Development Guide i Copyright © 2008 Infor. All rights reserved.

Page 4: IDO Development Guide

Contents

Code Samples ............................................................................................................................3-11LoadCollection Examples.................................................................................................... 3-11UpdateCollection Examples ................................................................................................ 3-12Invoke Example................................................................................................................... 3-13

AppDB Class ..............................................................................................................................3-14Application Database Connections ..................................................................................... 3-14Application Messages ......................................................................................................... 3-14Session Variables ............................................................................................................... 3-15Using AppDB in an Extension Class Method ...................................................................... 3-16

Disposing of IDO Extension Classes..........................................................................................3-16Translation/Localization Considerations.....................................................................................3-16

Type Conversions ............................................................................................................... 3-16Testing Extension Class Assemblies Locally .............................................................................3-18Debugging Extension Classes....................................................................................................3-18

Logging Diagnostic Messages ............................................................................................ 3-19

ii IDO Development Guide Copyright © 2008 Infor. All rights reserved.

Page 5: IDO Development Guide

1Introduction _____________________________________

Use this guide if you are developing your own IDOs based on the Infor framework, or if you are extending the functionality of an existing IDO by adding methods and event handlers.

This guide describes the classes and libraries available to you, and provides some examples of their use.

For More InformationThe following additional resources are available:

• Modifying Infor ERP SL includes a list and descriptions of the tools available for creating and editing forms, IDOs, application events and event handlers. It also describes the administrative and development utilities to use for managing a development project and deploying an application.

That guide also includes information you may need about external touch points, strong data types, application messages, licensing for IDOs, and so on. We strongly recommend that you read through the Modifying Infor ERP SL guide before creating or modifying IDOs.

• Integrating IDOs with External Applications includes an overview of what IDOs are and the different ways that applications can interface with IDOs. It provides examples and syntax showing how to set up IDO requests and responses in different protocols (XML documents, the application event system, .NET Web service, and so on).

• Guide to the Application Event System describes the application event system, which developers and system administrators can use to create events and event handlers that automate tasks. It also contains sample scenarios that will help you understand how you can take advantage of the application event system.

IDO Development Guide 1-1

Copyright © 2008 Infor. All rights reserved.

Page 6: IDO Development Guide

Introduction

1-2 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 7: IDO Development Guide

2IDO .NET API and Class Library ________________

OverviewDevelopers can use the IDO .NET class library to programmatically access the SyteLine business objects, which are called IDOs (Intelligent Data Objects).

Interactions with the IDO are based on requests and responses. The caller constructs an IDO request and sends it to the IDO runtime service to be executed. The IDO runtime service constructs and returns a response to the caller containing the results of the action requested.

All client access to the application database is through the IDOs. The primary responsibilities of the IDO runtime include querying data sets (LoadCollection), saving data (UpdateCollection), and calling methods (Invoke).

Each IDO request has a request type such as OpenSession, LoadCollection, UpdateCollection, or Invoke. It also contains an optional request payload that is dependent on the request type. For example, the payload for an OpenSession request contains logon information for a user such as user ID, password, and configuration.

The API is used by standalone client applications, WinStudio scripts, user controls and within IDO extension classes. The same programming interface is available on the client using the Mongoose.IDO.Client class and from an IDO extension class using the Me.Context.Commands property. This chapter focuses on use of the class library; the extension classes are described in Chapter 3, “IDO Extension Classes."

IDO .NET Class LibraryThe IDORequestClient .NET class library has one class, Client. It is in the Mongoose.IDO.Client namespace. This class library replaces the RSDAO COM library used in previous versions of SyteLine.

The Client class implements the IDO command interface (LoadCollection, UpdateCollection, and Invoke), plus additional commands (OpenSession, GetConfigurations, CloseSession) that are only used for external application communications.

IDO Protocol Class LibraryThe IDOProtocol .NET class library contains classes that correspond to each level in the hierarchy of an IDO request or response. These classes are used to construct IDO requests and responses. All IDOProtocol classes are in the Mongoose.IDO.Protocol namespace.

The top level of the IDOProtocol class hierarchy is implemented by the IDORequestEnvelope class, and the IDO request (RequestHeader in XML) is implemented by the IDORequest class. The request payload implementation (if any) varies depending on the request type. For an OpenSession request, the payload is implemented by the OpenSessionRequestData class. The payload for a LoadCollection request is implemented by the LoadCollectionRequestData class. There are other similar classes for each request type that carries a payload.

IDO Development Guide 2-1

Copyright © 2008 Infor. All rights reserved.

Page 8: IDO Development Guide

IDO .NET API and Class Library

The IDO responses are implemented in classes that mirror the requests, with the IDOResponseEnvelope at the top of the hierarchy.

As an example, the following steps are required to execute an IDO runtime Invoke call using IDOProtocol classes:

1. Create a new IDORequestEnvelope instance.

2. Set the IDORequestEnvelope.SessionID property.

3. Create a new IDORequest instance.

4. Set the IDORequest.Type property = Invoke.

5. Create a new InvokeRequestData instance.

6. Set the InvokeRequestData.IDOName property.

7. Set the InvokeRequestData.MethodName property.

8. Add the parameters to the InvokeRequestData.Parameters collection.

9. Add the IDORequest to the IDORequestEnvelope.Requests collection.

10. Set the payload for the IDORequest using the IDORequest.SetPayload method.

11. Send your completed IDORequestEnvelope to the IDO runtime and receive the IDOResponseEnvelope in return.

IDO Commands InterfaceWhether you are writing code on the client side or in an IDO extension class, the framework also provides wrapper methods through the IDO Commands interface, These wrappers typically reduce IDO interactions to a single line of code.

However, a limitation of using the IDO Commands interface is that you can specify only one IDO request per command, and receive one response per command. When using the IDOProtocols classes instead, you can build one IDORequestEnvelope that includes multiple requests, and then receive one response that includes information for all the requests.

AppDB ClassThe AppDB class, part of the Mongoose.IDO.DataAccess namespace, is available only to extension classes. It provides direct access to the application database, plus access to common framework features such as application messages and session variables. For more information about this class, see “AppDB Class” on page 3-14.

2-2 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 9: IDO Development Guide

IDO .NET API and Class Library

IDO Commands InterfaceThis basic IDO runtime API is defined by the IIDOCommands interface, which is shown below, in both C# and VB format. The properties used in each request type are explained later in this chapter.

IIDOCommands Interface (C#)public interface IIDOCommands{ GetPropertyInfoResponseData GetPropertyInfo( string idoName );

LoadCollectionResponseData LoadCollection( LoadCollectionRequestData requestData );

UpdateCollectionResponseData UpdateCollection( UpdateCollectionRequestData requestData );

InvokeResponseData Invoke( InvokeRequestData requestData );

string[] GetIDONames();

LoadCollectionResponseData LoadCollection( string idoName, string propertyList, string filter, string orderBy, int recordCap );

LoadCollectionResponseData LoadCollection( string idoName, PropertyList propertyList, string filter, string orderBy, int recordCap );

InvokeResponseData Invoke( string idoName, string methodName, params object[] parameters );}

IDO Development Guide 2-3

Copyright © 2008 Infor. All rights reserved.

Page 10: IDO Development Guide

IDO .NET API and Class Library

IIDOCommands interface (Visual Basic)Public Interface IIDOCommands

Function GetIDONames() As String()

Function GetPropertyInfo(ByVal idoName As String) As GetPropertyInfoResponseData

Function GetPropertyInfo(ByVal idoName As String, ByVal includeClassNotesFlag As Boolean) As GetPropertyInfoResponseData

Function Invoke(ByVal requestData As InvokeRequestData) As InvokeResponseData

Function Invoke(ByVal idoName As String, ByVal methodName As String, ByVal ParamArray parameters() As Object) As InvokeResponseData

Function LoadCollection(ByVal requestData As LoadCollectionRequestData) As LoadCollectionResponseData

Function LoadCollection( _ByVal idoName As String, _ByVal propertyList As PropertyList, _ByVal filter As String, _ByVal orderBy As String, _ByVal recordCap As Integer) As LoadCollectionResponseData

Function LoadCollection( _ByVal idoName As String, _ByVal propertyList As String, _ByVal filter As String, _ByVal orderBy As String, _ByVal recordCap As Integer) As LoadCollectionResponseData

Function UpdateCollection(ByVal requestData As UpdateCollectionRequestData) As UpdateCollectionResponseData

End Interface

IDO Commands Interface - Request/Response SyntaxThe IDO Commands interface provides a simple alternative to constructing IDO requests when interacting with IDOs. The process of creating an IDORequestEnvelope, IDORequest and payload class instance for each interaction is replaced by a single method call, which will construct the request for you using the parameter list.

2-4 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 11: IDO Development Guide

IDO .NET API and Class Library

APIs and Related IDO Protocol Classes - DetailsThis section describes each API and associated protocol classes, and provides examples of each.

About the ExamplesThe examples in this section use the syntax of extension class methods, for example:

... Me.Context.Commands.LoadCollection(request)

The syntax for using the IIDOCommands interface will be different in other contexts such as a form script or a standalone client application.

GetPropertyInfoUse GetPropertyInfo to retrieve a list of properties and their attributes for an IDO.

PropertiesThe following table describes the properties available on the LoadCollectionRequestData class

GetPropertyInfo ExampleDim response As GetPropertyInfoResponseData

response = Me.Context.Commands.GetPropertyInfo("SLItems")For Each idoProp As PropertyInfo in response.Properties String propertyName = idoProp.Name ' etcNext

Property Data Type Description

IDOName System.String Identifies the IDO used to execute the request.

IncludeClassNotesFlag System.Boolean If true, set the ClassNotesExist property in the response to indicate if any class notes exist for this IDO (only available if using the Client class GetResponse method).

IDO Development Guide 2-5

Copyright © 2008 Infor. All rights reserved.

Page 12: IDO Development Guide

IDO .NET API and Class Library

LoadCollectionQueries are performed using the LoadCollection API and associated protocol classes. LoadCollection requests can be constructed using the LoadCollectionRequestData IDO protocol class.

PropertiesThe following table describes the properties available on the LoadCollectionRequestData class.

Property Data Type Description

IDOName System.String Identifies the IDO used to execute the request.

ReadMode Mongoose.IDO.Protocol.ReadMode

Specify the collection read mode, which controls the isolation level used when executing queries (see the online help on Process Defaults). Options are:

ReadCommittedReadUncommittedDefault

This property does not apply to custom load methods.

PropertyList Mongoose.IDO.Protocol.PropertyList

A subset of properties published by the IDO to be included in the response.

Filter System.String A filter or WHERE clause to be used for the query. Default: empty

RecordCap System.Int32 The maximum number of items to return in the response. The setting 0 returns all items. The setting -1 uses the default cap (200). Default: -1.

OrderBy System.String A list of property names used to override the default sort order. Only bound properties may be included in OrderBy. Default: empty.

Distinct System.Boolean If this flag is set to True, the request returns a set of items containing only the unique combinations of properties named in the PropertyList property. Default: False.

CustomLoadMethod Mongoose.IDO.Protocol.CustomLoadMethod

Allows the caller to specify a method to perform the query in place of the standard query built by the IDO runtime.

PostQueryCommand System.String Allows the caller to specify a method to be executed for each item returned by the query. The method must be a member of the IDO specified by the IDOName property. Default: empty.

LinkBy Mongoose.IDO.Protocol.PropertyPair array

Applies to inner nested LoadCollection requests only and specifies the relationship between a parent and child IDO in terms of property pairs. Use the SetLinkBy method to set this property. Default: empty.

2-6 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 13: IDO Development Guide

IDO .NET API and Class Library

LoadCollection Example 1: Using the Protocol ClassTo execute a LoadCollection request, first construct an instance of the LoadCollectionRequestData class, and pass it to the LoadCollection method on the IIDOCommands interface.

Dim request As New LoadCollectionRequestDataDim response As LoadCollectionResponseData

request.IDOName = "SLItems"request.PropertyList.SetProperties("Item, Description, QtyOnHand")request.Filter = "Item LIKE N'AB%'"request.OrderBy = "QtyOnHand"request.RecordCap = 0response = Me.Context.Commands.LoadCollection(request)

LoadCollection Example 2: Using the Commands InterfaceIn many cases it will be more convenient to call the overloaded version of the LoadCollection method that accepts parameters for the required and most common LoadCollectionRequestData properties.

Dim response As LoadCollectionResponseData

' this is equivalent to example 1response = Me.Context.Commands.LoadCollection( _ "SLItems", _ "Item, Description, QtyOnHand", _ "Item LIKE N'AB%'", _ "QtyOnHand", _ 0)

NestedRequests System.Collections.ICollection

A collection of additional LoadCollectionRequestData instances used to load child collections.

LoadCap System.Int32 Specifies the maximum number of nested LoadCollection requests to process. For example, if this property is set to 1, and 200 items are returned by the parent LoadCollection request, only the first parent item in the response will contain nested child items.

Property Data Type Description

IDO Development Guide 2-7

Copyright © 2008 Infor. All rights reserved.

Page 14: IDO Development Guide

IDO .NET API and Class Library

LoadCollection Example 3: Accessing Item PropertiesThe LoadCollection methods return an instance of the LoadCollectionResponseData class, which is populated with the same values that were sent in the request plus the results from the query. These results are accessed through the Items property, which is a collection of IDOItem instances. Properties can be accessed through the IDOItem instances or directly using the indexer on the LoadCollectionResponseData class.

' the two loops in this example are equivalentDim x As Integer = response.PropertyList.IndexOf("QtyOnHand")Dim qty As Integer = 0

For Each item As IDOItem In response.Items qty = qty + item.PropertyValues(x).GetValue(Of Integer)()Next

qty = 0For row As Integer = 0 To response.Items.Count qty = qty + response(row, "QtyOnHand").GetValue(Of Integer)()Next

2-8 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 15: IDO Development Guide

IDO .NET API and Class Library

UpdateCollectionUpdates (includes inserts, updates and deletes) are performed using the UpdateCollection API and associated protocol classes. UpdateCollection requests can be constructed using the UpdateCollectionRequestData IDO protocol class. The following table describes the properties available on the UpdateCollectionRequestData class.

Properties

To execute an UpdateCollection request, first construct an instance of the UpdateCollectionRequestData class, and pass it to the UpdateCollection method on the IIDOCommands interface.

UpdateCollection ExampleDim request As New UpdateCollectionRequestDataDim response As UpdateCollectionResponseDataDim newCust As New IDOUpdateItem

request.IDOName = "SLCustomers"request.RefreshAfterUpdate = True

newCust.Action = UpdateAction.InsertnewCust.ItemNumber = 1 ' used for error reportingnewCust.Properties.Add("CustNum", "C000100")newCust.Properties.Add("Name", "Boxmart")newCust.Properties.Add("CurrCode", "USD")newCust.Properties.Add("BankCode", "BK1")

request.Items.Add(newCust)

response = Me.Context.Commands.UpdateCollection(request)

Property Data Type Description

IDOName System.String Identifies the IDO used to execute the request.

CollectionID System.String An identifier associated with this UpdateCollection request.

RefreshAfterUpdate System.Boolean A boolean value used to indicate if the caller wants the response to contain the updated items refreshed after they were saved.

CustomInsert

CustomUpdate

CustomDelete

System.String These properties are used to specify custom actions to use when saving items. Note: same as custom INS/UPD/DEL in WinStudio.

LinkBy Mongoose.IDO.Protocol.PropertyPair array

Applies to inner nested UpdateCollection requests only and specifies the relationship between a parent and child IDO in terms of property pairs. Use the SetLinkBy method to set this property. Default: empty.

Items Mongoose.IDO.Protocol.IDOUpdateItems

An instance of the IDOUpdateItems class that contains zero or more IDOUpdateItem instances. The IDOUpdateItem class contains the update information for a single item.

IDO Development Guide 2-9

Copyright © 2008 Infor. All rights reserved.

Page 16: IDO Development Guide

IDO .NET API and Class Library

LoadCollection/UpdateCollection Example: Saving Changes to Existing RecordsThis example loads data from an IDO, updates the data and saves the collection.

Public Sub DoUpdate()Dim Loadresponse As LoadCollectionResponseDataDim sCoNum As StringDim sFilter As String

sCoNum = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("CoNum")

sFilter = "CoNum = '" & sCoNum & "'"

Loadresponse = Me.IDOClient.LoadCollection("SLCos", "Charfld1, CustNum", sFilter, "", -1)

If Loadresponse.Items.Count > 0 ThenDim updateRequest As UpdateCollectionRequestDataDim updateItem As IDOUpdateItem

' create a new UpdateCollection requestupdateRequest = New UpdateCollectionRequestData("SLCos")

' create a new update item for the row we loadedupdateItem = New IDOUpdateItem(UpdateAction.Update, Loadresponse.Items(0).ItemID)

' add CustNum property from LoadResposne, not modifiedupdateItem.Properties.Add("CustNum", Loadresponse(0, "CustNum").Value, False)

' add Charfld1 property using a new value, modifiedupdateItem.Properties.Add("Charfld1", "Owzat?", True)

' add the update item to update requestupdateRequest.Items.Add(updateItem)

' save changesMe.IDOClient.UpdateCollection(updateRequest)

End If

End Sub

2-10 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 17: IDO Development Guide

IDO .NET API and Class Library

InvokeIDO methods (not including custom load methods) are called uting using the Invoke API and associated protocol classes. Invoke requests can be constructed using the InvokeRequestData IDO protocol class. The following table describes the properties available on the InvokeRequestData class.

Properties

To execute an Invoke request, first construct an instance of the InvokeRequestData class, and pass it to the Invoke method on the IIDOCommands interface.

Invoke Example 1Dim request As New InvokeRequestDataDim response As InvokeResponseData

request.IDOName = "UserNames"request.MethodName = "UserValidSp"request.Parameters.Add("ajones") ' user name, inputrequest.Parameters.Add(IDONull.Value) ' user ID, outputrequest.Parameters.Add(IDONull.Value) ' description, outputrequest.Parameters.Add(IDONull.Value) ' infobar, outputresponse = Me.Context.Commands.Invoke(request)

If response.IsReturnValueStdError Then ' get infobar output parameter Dim errorMsg As String errorMsg = response.Parameters(3).ValueElse Dim userID As Integer Dim desc As String

userID = response.Parameters(1).GetValue(Of Integer)() If Not response.Parameters(2).IsNull Then desc = response.Parameters(2).Value End IfEnd If

In many cases it will be more convenient to call the overloaded version of the Invoke method that accepts parameters for the IDOName, MethodName and method parameters InvokeRequestData properties.

Property Data Type Description

IDOName System.String Identifies the IDO used to execute the request.

MethodName System.String Identifies the IDO method to be executed.

Parameters Mongoose.IDO.Protocol.InvokeParameterList

A collection containing instances of the InvokeParameter class corresponding to the IDO method parameters.

IDO Development Guide 2-11

Copyright © 2008 Infor. All rights reserved.

Page 18: IDO Development Guide

IDO .NET API and Class Library

Invoke Example 2Dim response As InvokeResponseData

response = Me.Context.Commands.Invoke( _ "UserNames", _ "UserValid", _ "ajones", _ IDONull.Value, _ IDONull.Value, _ IDONull.Value)

If response.IsReturnValueStdError Then ' get infobar output parameter Dim errorMsg As String errorMsg = response.Parameters(3).ValueElse Dim userID As Integer Dim desc As String

userID = response.Parameters(1).GetValue(Of Integer)() If Not response.Parameters(2).IsNull Then desc = response.Parameters(2).Value End IfEnd If

2-12 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 19: IDO Development Guide

IDO .NET API and Class Library

Assigning and Checking Null Values in IDO RequestsAssigning Null Values

When assigning a null value to a property or parameter in the IDO protocol classes, the best practice is to use the IDONull.Value static property.

Dim myMethodResponse As InvokeResponseDataDim updateRequest As UpdateCollectionRequestData

' pass NULL for the 3rd parametermyMethodResponse = Me.Invoke("MyMethod", "test", 100, IDONull.Value)

' set the Note property to NULLupdateRequest.Items(0).Properties.Add("Note", IDONull.Value)

Checking Null ValuesWhen checking for null values, the best practice is to use the IDONull.IsNull static method. For parameter or property values in an IDO protocol class, you may also use the IsNull property to check for null values.

' Check for null value in a LoadCollectionResponseDataIf Not loadResponse(0, "UserId").IsNull Then userId = loadResponse(0, "UserId").GetValue(Of Long)(-1)End If

' check for a null parameter valuePublic Function MyFunc(ByVal param As Nullable(Of Integer)) As Integer

If IDONull.IsNull(param) Then ' test for null value ' handle null param End If

IDO Development Guide 2-13

Copyright © 2008 Infor. All rights reserved.

Page 20: IDO Development Guide

IDO .NET API and Class Library

Translation/Localization ConsiderationsAll data values in IDO requests and responses are stored as string values in an "internal" format that is independent of any regional settings for the application or local machine where the code is executing.

Internal Format for NumbersNumeric values are always stored internally using a period for the decimal separator (for non-integer values) and without any digit-grouping characters.

Internal Format for DatesDate values are always stored internally using the format YYYYMMDD HH:MM:SS.mmm for date and time, YYMMDD for date only, and HH:MM:SS.mmm for time only (milliseconds are optional).

Type ConversionsThe IDO protocol classes store all property and parameter values internally as strings in a non-localized internal format. However, the framework also provides methods that allow you to transparently convert between supported native .NET CLR data types and the internal formatted string values. You should always use strongly typed variables when getting values from, or putting values into, any of the IDO protocol classes in order to take advantage of this feature and avoid problems related to systems running with different regional settings. This is especially important when working with date and numeric values.

The built-in VB functions for data type conversions (CStr, CDate, CInt, etc.) are sensitive to the regional settings for the application or local machine.

Setting Property and Parameter ValuesUse the SetValue or Add methods to set parameter and property values into the IDO protocol classes.

Add/SetValue with InvokeRequestDataThe following example shows how to do this with the InvokeRequestData IDO protocol class.

Dim invokeRequest As New InvokeRequestDataDim version As Integer = 600Dim recordDate As DateTime = DateTime.Now

invokeRequest.IDOName = "MyIDO"invokeRequest.MethodName = "MyMethod"invokeRequest.Parameters.Add("Mongoose")invokeRequest.Parameters.Add(version)invokeRequest.Parameters.Add(Guid.NewGuid())invokeRequest.Parameters.Add(recordDate)invokeRequest.Parameters.Add(IDONull.Value) ' set later

' to set the fifth parameter after it has been addedinvokeRequest.Parameters(4).SetValue(100)

Both the Add and SetValue methods accept a value of any supported .NET data type and automatically handle the conversion to internal format, so that the developer does not need to think about conversion issues.

2-14 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 21: IDO Development Guide

IDO .NET API and Class Library

Add/SetValue with UpdateCollectionRequestDataThe code to set property values into the UpdateCollectionRequestData IDO protocol class is very similar to the previous example.

Dim updateRequest As New UpdateCollectionRequestDataDim updateItem As New IDOUpdateItem

updateItem.Action = UpdateAction.InsertupdateItem.Properties.Add("UserId", IDONull.Value) ' set laterupdateItem.Properties.Add("UserName", "MGUser")updateItem.Properties.Add("RecordDate", DateTime.Now)updateItem.Properties.Add("RowPointer", Guid.NewGuid())

updateItem.Properties("UserId").SetValue(100L)

updateRequest.IDOName = "MyIDO"updateRequest.Items.Add(updateItem)

Getting Property and Parameter ValuesUse one of the overloaded GetValue methods to get parameter and property values from the IDO protocol classes. The following examples show how to do this using the LoadCollectionResponseData IDO protocol class.

GetValue with LoadCollectionResponseDataIn this example, the desired native .NET data type is specified as an additional parameter in the call to GetValue (using the .NET Framework's generics feature).

Dim loadResponse As LoadCollectionResponseDataDim userId As LongDim userName As StringDim recordDate As DateTimeDim rowPointer As Guid

loadResponse = Me.Context.Commands.LoadCollection( _ "UserNames", _ "UserId, UserName, RecordDate, RowPointer", _ "", "", 0)

userId = loadResponse(0, "UserId").GetValue(Of Long)()userName = loadResponse(0, "UserName").GetValue(Of String)()recordDate = loadResponse(0, "RecordDate").GetValue(Of DateTime)()rowPointer = loadResponse(0, "RowPointer").GetValue(Of Guid)()

Handling Nullable ValuesBe aware that if any of the values are null, this version of the GetValue method throws an exception. When working with nullable values, you have three options to avoid throwing an exception:

• Check the IsNull property before calling GetValue.

• Call the overloaded GetValue method with a default value to be returned in case of null.

• Use .NET nullable value types.

IDO Development Guide 2-15

Copyright © 2008 Infor. All rights reserved.

Page 22: IDO Development Guide

IDO .NET API and Class Library

Those three techniques are illustrated in this example:

Dim loadResponse As LoadCollectionResponseDataDim userId As LongDim userId2 As Nullable(Of Long)

loadResponse = Me.Context.Commands.LoadCollection( _ "UserNames", _ "UserId, UserName, RecordDate, RowPointer", _ "", "", 0)

' Check for null before calling GetValueIf Not loadResponse(0, "UserId").IsNull Then userId = loadResponse(0, "UserId").GetValue(Of Long)()Else userId = -1End If

' Calling GetValue, return -1 if nulluserId = loadResponse(0, "UserId").GetValue(Of Long)(-1)

' Calling GetValue, check for null return valueuserId = loadResponse(0, "UserId").GetNullableValue(Of Long)()If Not userId.HasValue Then userId = -1

Creating Filter StringsIf you need to dynamically build a SQL filter (WHERE clause) to be used in a LoadCollection request, the framework provides the SqlLiteral class to help build filter strings that contain embedded literals.

SqlLiteral.Format MethodThe static SqlLiteral.Format method accepts any supported .NET CLR typed value and converts it into a literal that can be used when constructing a filter as shown in the following example:

Dim filter As String

filter = String.Format( _ "SessionId = {0} AND trans_num = {1}", _ SqlLiteral.Format(SessionID), _ SqlLiteral.Format(TransNum))

The above example will produce a filter with the appropriate syntax for the literal values, similar to this:

SessionId = N' 7A4930D6-AE9E-4F32-9687-17ABDBF4E818' and trans_num = 1234

You must always pass in a strongly typed value in order to get the correct result. For example, you should not pass a string containing a date value.

2-16 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 23: IDO Development Guide

IDO .NET API and Class Library

The following table shows some examples of input types, values, and the SqlLiteral.Format result for each.

Supported .NET CLR TypesThe following .NET data types are supported by the IDO protocol classes using the GetValue, Add, and SetValue methods.

.NET CLR Type Input Value SqlLiteral.Format Result

System.DateTime 12/31/2006 23:59:59.999 N'20061231 23:59:59.999'

System.Int32 123 123

System.String Joe's Bar N'Joe''s Bar'

System.Decimal 150.32 150.32

System.Guid 7A4930D6-AE9E-4F32-9687-17ABDBF4E818

N' 7A4930D6-AE9E-4F32-9687-17ABDBF4E818'

System.String System.CharSystem.DateTime System.Int32System.UInt32 System.Int16System.UInt16 System.Int64System.UInt64 System.SByteSystem.Byte System.SingleSystem.Double System.GuidSystem.Decimal System.BooleanSystem.Byte[]

IDO Development Guide 2-17

Copyright © 2008 Infor. All rights reserved.

Page 24: IDO Development Guide

IDO .NET API and Class Library

TransactionsThe IDO runtime automatically executes all UpdateCollection requests in a transaction. It also executes IDO methods in a transaction if they are marked as "transactional" methods. All other IDO requests are executed without a transaction. Note that if a method is not marked "transactional" is called from a method that is marked "transactional", then it will still execute in the caller's transaction.

For transactional IDO methods, if the method returns an integer value less than 5, the transaction will be committed. The exception is if the method was executed within an existing outer transaction. Then the transaction will commit if and when the outer transaction commits. If the IDO method returns an integer value greater than or equal to 5 the transaction will be rolled back immediately. The Infor ERP SL standard is to return 16 to indicate a method failed. The transaction will also roll back if the method throws an exception.

If you need finer grained control over transaction scope, which is often necessary for long running processes, this can be achieved while still allowing the IDO runtime to manage transactions.

For example, consider a method that will post a large batch of records. We need a method that will read the batch, loop through each record and attempt to post it. If the post is successful the action should commit, otherwise it should be rolled back. The best way to accomplish this is to create two methods: a top level entry point method that will query the records to be posted, and another method to do the posting. The top level method should not be marked as transactional, while the posting will be transactional. The entry point method will query the records to be posted and loop through each one calling the posting method to post each record. This way if a record fails to post it will not roll back all posted records, only the failed record.

2-18 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 25: IDO Development Guide

IDO .NET API and Class Library

Diagnostics and DebuggingLogging Diagnostic Messages

All applications and services in the Infor framework use a common message logging facility. This enables the framework to provide a single, consolidated view of all activity logged on the local machine. For developers, this log is available in the IDO Runtime Development Server (IDORuntimeHost.exe).

Message Logging APIPublic Shared Sub LogUserMessage( _ ByVal messageSource As String, _ ByVal messageType As UserDefinedMessageType, _ ByVal message As String)

Public Shared Sub LogUserMessage( _ ByVal messageSource As String, _ ByVal messageType As UserDefinedMessageType, _ ByVal format As String, _ ByVal ParamArray args As Object())

Parameters• messageSource - A short, user-defined identifier of the source of a message (for

example, class or project name).

• messageType - One of the UserDefinedMessageType enumeration values; used for searching and filtering log messages.

• message - A string containing the log message text.

• format - A log message format string (see String.Format() in the .NET Framework documentation for more information about formatting strings).

• args - A variable-length list of format-string substitution parameters

ExamplesIDORuntime.LogUserMessage( _ "SLCustomers", _ UserDefinedMessageType.UserDefined0, _ "Method A() called.")

IDORuntime.LogUserMessage( _ "SLCustomers", _ UserDefinedMessageType.UserDefined0, _ "Parameter 1 is {0}.", _ p1)

Wire TapYou can use the Wire Tap feature of the IDO Runtime Development Server to monitor all the IDO request and response documents generated by a specific user session. For more information see the online help for the IDO Runtime Development Server.

IDO Development Guide 2-19

Copyright © 2008 Infor. All rights reserved.

Page 26: IDO Development Guide

IDO .NET API and Class Library

Standalone Application CommunicationsWhen you create an instance of the Client class, it includes some commands (OpenSession, GetConfiguration, CloseSession) that are only used for external application communications.

To open sessions or access configuration information from an external application:

1. Create a VS 2005 .NET executable (C#, VB, etc.) or any other program where you can reference and execute methods on a .NET 2.0 class library.

2. Add references in your project's definition to the following Mongoose framework's class libraries.

• IDOProtocol.dll

• IDORequestClient.dll

• MGShared.dll

Open SessionThe OpenSession method is used to create a new SL session (log in).

OpenSession ExampleThis example creates a new Client instance accessing the IDO runtime using the URL in requestServiceURL, where this URL is similar to the following: "http://servername/IDORequestService/RequestService.aspx"

Dim client As Client = New Client(requestServiceURL)Dim response As OpenSessionResponseData

Using client ' substitute a valid SL user, password and configuration name response = client.OpenSession("user", "password", "config") If response.LogonSucceeded Then Console.WriteLine("Success") End If

' close the session when finished client.CloseSession()End Using ' Using block guarentees client is properly disposed

Close SessionThe CloseSession method is used to close an existing session (log out).

The OpenSession example above also includes an example of CloseSession.

GetConfigurationsWinStudio/SL configuration information is stored in MongooseConfigs.xml. By default, this file is created and resides in c:\Documents and Settings\All Users\Application Data\Mongoose.

The Client class accesses configuration information through the ConfigServer.aspx page (IDORequestService ASP.NET Web server application) in conjunction with the IDO Runtime Service or the IDORuntimeHost.exe developer tool. The Web Server application, IDO Runtime Service and IDORuntimeHost.exe are all installed as part of a Infor ERP SL utility server install. Configuration information obtained via the GetConfigurations static method includes a subset of configuration properties and all of the referenced application properties.

2-20 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 27: IDO Development Guide

IDO .NET API and Class Library

In code that utilizes the Client class, include the following using statements (Import statements if written in a VB project):

using Mongoose.Core.Configuration;using Mongoose.IDO.Protocol;using Mongoose.IDO;

ConfigurationInfo Example 1The following snippet of code retrieves an array of ConfigurationInfo classes through the IDORequestService. (Infor IDO Runtime Service must be running for this method to work.)

//********************************************************************// The following line calls the IDORequestClient ASPX web application// to retrieve the configuration list via an array of ConfigurationInfo// classes.// Parm -> URL to IDORequestClient's ConfigServer.apsx file.//********************************************************************ConfigurationInfoList configList = null;configList = Client.GetConfigurations(@"http://server1/IDORequestService/ConfigServer.aspx", "Acme" );// Config info can be enumerated as followsforeach ( ConfigurationInfo config in configList ){// do whatever}

ConfigurationInfo Example 2The following snippet of code retrieves an array of ConfigurationInfo classes through IDORuntimeHost.exe. (IDORuntimeHost.exe must be running for this method to work.)

//********************************************************************// The following line calls through to the local IDO runtime service // (IPC protocol) to retrieve the configuration list via an array of// ConfigurationInfo classes. // Note: No parameter is passed to the GetConfigurations() method.//********************************************************************ConfigurationInfoList configList = null;configList = Client.GetConfigurations();

// Config info can be enumerated as followsforeach ( ConfigurationInfo config in configList ){ // do whatever}

PropertiesThe following configuration/application properties are available through the ConfigurationInfo class.

public bool ActiveScriptingOnly;

Some information in the MongooseConfigs.xml file related to database connections, user names, passwords, etc., is encrypted. The methods described here simply retrieve the encrypted strings for these entities. If they need programmatic access to this information (that is, decrypted strings), contact Infor Professional Services to discuss methods for decrypting it.

IDO Development Guide 2-21

Copyright © 2008 Infor. All rights reserved.

Page 28: IDO Development Guide

IDO .NET API and Class Library

public string AppName; public string AppURL; public string BaseHelpFile; public bool ColSecurityPrimaryOnly; public string CompanyName; public string Copyright; public string DefFormBGColor; public string DefFormFGColor; public string DefFormFont; public string DefNormalBGColor; public string DefNormalFGColor; public string DefReadOnlyBGColor; public string DefReadOnlyFGColor; public string DefRequiredBGColor; public string DefRequiredFGColor; public string DefTbdBGColor; public string DefTbdFGColor; public string DeleteExistingPrompt; public string DeleteNewPrompt; public bool DisableInvalidValuePrompt; public string FormCLSID; public string FormFileExtension; public string FormsURL; public string HelpBasePath; public string HelpContentsIndexMenuText; public string HorzComponentSpacing; public string IconFilename; public string LoginOverrideProgID; public string Name; public string ObjectMenuName; public bool PrimaryCacheUsesFormCaption; public string ProgIDRootAugment; public string ReportViewerExecutable; public string ReportViewerExecutablePath; public bool RightJustifyNewLabels; public string SplashFilename; public bool UseHtmlHelp; public bool ValidationErrorIndicators; public string VBAFilename; public string Version; public string VertComponentSpacing; public string WallpaperDisplayOption; public string WallpaperFilename; public bool XPVisualStyle;

2-22 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 29: IDO Development Guide

IDO .NET API and Class Library

MongooseConfigs Class (MGShared.dll Class Library)An alternative way to get configuration information programmatically is to use the MongooseConfigs class. It accesses configuration information directly through a set of methods that load an XML file and parse the XML information into retuned classes. An instance of the class must be instantiated and separate methods are used to retrieve the list of configurations, configuration properties, application properties, and DB connection information (DB connection information is returned as an encrypted string.)

To do this:

1. Create a VS 2005 .NET executable (C#, VB, etc.) or any other program where you can reference and execute methods on a .NET 2.0 class library.

2. Add a reference in your project's definition to the MGShared.dll Mongoose framework's class library.

3. In code that utilizes the Client class, include the following using statements (Import statements if written in a VB project)

using Mongoose.Core.Configuration;using Mongoose.Core.Common;

ExampleThe following snippet of code retrieves an array of configuration names, gets the application name and a couple of application properties, and finally retrieves the Runtime Forms Database name (encrypted.)

// Create instance of ManageConfigs classMongooseConfigs ManageConfigs = null;ManageConfigs = new MongooseConfigs();// Load MongooseConfigs.xmlManageConfigs.Load(true);// Get array of the configuration namesstring[] configNames = ManageConfigs.GetConfigNames();foreach ( string configName in configNames ){ // Get config info Configuration config = ManageConfigs.GetConfig( configName ); // Get Application info AppProperties appInfo = ManageConfigs.GetAppProperties( config.Application ); // Get Connection Info (most properties here are encrypted) ConnectionProfile connProfile = ManageConfigs.GetFormsConnection( configName, ConnectionProfileType.Runtime ); // Note: Various information can be retrieved from the Configuration, AppProperties, and // ConnectionProfile classes. You can view the availabe class properties via intellisense // when programming against them. }

IDO Development Guide 2-23

Copyright © 2008 Infor. All rights reserved.

Page 30: IDO Development Guide

IDO .NET API and Class Library

PropertiesThe following configuration/application properties are available through the Configuration class:

public string Application; public string ConfigName; public ArrayList ConnectionRoles; public bool FormControlSSEnabled; public string ObjectStudioProjBuildDir; public bool ObjectStudioSSEnabled; public string SSPassword; (encrypted string) public string SSProjectName; public string SSUNCPath; public string SSUserId; (encrypted string)

The following configuration/application properties are available through the AppProperties class:

public bool ActiveScriptingOnly; public string Application; public string AppName; public string BaseHelpFile; public bool ColSecurityPrimaryOnly; public string CompanyName; public string Copyright; public string DefFormBGColor; public string DefFormFGColor; public string DefFormFont; public string DefNormalBGColor; public string DefNormalFGColor; public string DefReadOnlyBGColor; public string DefReadOnlyFGColor; public string DefRequiredBGColor; public string DefRequiredFGColor; public string DefTbdBGColor; public string DefTbdFGColor; public string DeleteExistingPrompt; public string DeleteNewPrompt; public bool DisableInvalidValuePrompt; public string FormCLSID; public string FormFileExtension; public string HelpBasePath; public string HelpContentsIndexMenuText; public string HorzComponentSpacing; public string IconFilename; public string LoginOverrideProgID; public string ObjectMenuName; public bool PrimaryCacheUsesFormCaption; public string ProgIDRootAugment; public string RelFormServerURL; public string RelWebServerURL; public string ReportViewerExecutable; public string ReportViewerExecutablePath; public bool RightJustifyNewLabels;

2-24 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 31: IDO Development Guide

IDO .NET API and Class Library

public string SplashFilename; public bool UseHtmlHelp; public bool ValidationErrorIndicators; public string VBAFilename; public string Version; public string VertComponentSpacing; public string WallpaperDisplayOption; public string WallpaperFilename; public bool XPVisualStyle;

The following configuration/application properties (encrypted strings) are available through the ConnectionProfile class:

public string ConnectionKey public string DatabaseName public DatabaseType DatabaseType public ProviderType DataProvider public string DataSource public long DBTimeout public ProviderDriver Driver public string MiscConnectionInfo public string Password public string ProfileName public string UserId

IDO Development Guide 2-25

Copyright © 2008 Infor. All rights reserved.

Page 32: IDO Development Guide

IDO .NET API and Class Library

2-26 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 33: IDO Development Guide

3IDO Extension Classes__________________________

About Extension ClassesAn IDO extension class is a .NET class that allows developers to extend the functionality of an existing IDO by adding methods and event handlers. IDO extension classes are compiled into a .NET class library assembly and stored in the IDO metadata database. The IDO runtime loads these assemblies on demand and calls methods and event handlers in the extension classes in response to IDO requests.

An extension class is short-lived; it is created at the start of a request and disposed of immediately when the response is completed. Therefore, no state should be stored in an extension class.

Any public class in an IDO extension class assembly can be identified as the extension class for an IDO in the IDO metadata database.

IDO extension class assemblies are created from VisualStudio 2005 class library projects. The projects can use any of the .NET languages; however, all code samples and procedures described in this document use VB.NET.

Creating a New IDO Extension Class ProjectTo create a new project:

1. Open VisualStudio 2005 and select File > New > Project from the menu.

2. In the New Project dialog, select Visual Basic for the project type, and select the Class Library template.

3. Specify a name and location for your project and click OK.

4. The new project will contain a class file named Class1.vb. Right click on the file in the Solution Explorer and delete it.

5. On the Project menu, select Add Reference.

6. In the Add Reference dialog, click the Browse tab and navigate to the Infor Mongoose Framework installation directory. Add references to these assemblies:

IDOCore.dllIDOProtocol.dll MGShared.dll

7. On the Project menu, select Add New Item.

8. Select Code File, name the new file AssemblyInfo.vb, and click OK.

IDO Development Guide 3-1

Copyright © 2008 Infor. All rights reserved.

Page 34: IDO Development Guide

IDO Extension Classes

9. Open the new AssemblyInfo.vb source file and add this assembly attribute:

<Assembly: Mongoose.IDO.IDOExtensionClassAssembly("assembly-name")>

Substitute a meaningful name for the assembly-name parameter. This can be anything but typically is the name of the IDO project associated with the classes in this assembly. When this class library is imported the IDO Custom Assemblies form, the name you specify here becomes the name of the assembly.

Importing AssembliesUse the IDO Custom Assemblies form in Infor ERP SL to import assemblies.

Link the IDO to the custom assembly on the IDOs form by checking out the IDO and entering the Custom Assembly Name (the Assembly Name from the IDO Custom Assemblies form), the Ext Class Name (the name of the class - usually the same as the IDO), and the Ext Class Namespace (usually the same as the Project Name).

Link the methods in the extension class to the IDO by entering the Method Name and specifying the Parameters list on the IDO Methods form. The Method Type will be Handcoded - Standard Method or Handcoded - Custom Load Method.

Implementing an IDO Extension ClassMongoose.IDO.IIDOExtensionClass Interface

In order for an extension class to access the calling user's context (session information, databases, and so forth), the extension class should implement the IIDOExtensionClass interface in the Mongoose.IDO namespace.

Public Interface IIDOExtensionClass Sub SetContext( _ ByVal context As Mongoose.IDO.IIDOExtensionClassContext)End Interface

Mongoose.IDO.IIDOExtensionClassContext InterfaceThe SetContext method is called once when the extension class is created, passing a reference to the IIDOExtensionClassContext interface for accessing the calling user's context.

Public Interface IIDOExtensionClassContext ReadOnly Property IDO() As Mongoose.IDO.IVirtualIDO ReadOnly Property Commands() As Mongoose.IDO.IIDOCommandHelperEnd Interface

The framework provides a class named Mongoose.IDO.ExtensionClassBase that is intended to be used as the base class for most typical IDO extension classes. This class provides a default implementation of the IIDOExtensionClass interface and provides a number of methods to facilitate calling methods, loading and updating collections, and other common tasks, which will be covered later.

3-2 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 35: IDO Development Guide

IDO Extension Classes

Declaration of an IDO Extension Class for an IDOWhen declaring an IDO extension class, you may add the optional IDOExtensionClass attribute in order to facilitate adding the necessary IDO metadata to associate an extension class with an IDO. The following sample code shows how to associate an extension class with the SLJobMats IDO.

<IDOExtensionClass("SLJobtMats")> _Public Class SLJobtMats Inherits ExtensionClassBase

' ...Implementation goes here...

End Class

It is generally a good idea to import some common framework namespaces to make your code less verbose and clearer, and to enable the Explicit and Strict VB compiler options.

IDO Extension Class Starter TemplateThe following sample code may be used as a template for creating new IDO extension classes.

Option Explicit OnOption Strict On

Imports Mongoose.IDOImports Mongoose.IDO.ProtocolImports Mongoose.IDO.DataAccessImports Mongoose.Core.Common

<IDOExtensionClass("class-name")> _Public Class class-name Inherits ExtensionClassBase

' optionally override the SetContext method 'Public Overrides Sub SetContext( _ ' ByVal context As IIDOExtensionClassContext) ' ' call base class implementation ' MyBase.SetContext(context) ' ' ' Add event handlers here, for example: ' 'AddHandler _ ' ' Me.Context.IDO.PreUpdateCollection, _ ' ' AddressOf Me.PreUpdateCollection ' 'End Sub

' ...Implementation goes here...

End Class

IDO Development Guide 3-3

Copyright © 2008 Infor. All rights reserved.

Page 36: IDO Development Guide

IDO Extension Classes

Adding MethodsIn order to call a method on an IDO extension class, the method must be declared as public and it must also be defined in the IDO metadata as a hand-coded method. This is different from previous versions of the framework, where the metadata for a method was defined by convention, using the Do not generate source attribute, but not required.

A hand-coded method may be either a standard method, which is a Function with zero or more input/output parameters and returns an integer, or a custom load method, which is a Function with zero or more parameters and returns an instance of either an IDataReader or a DataTable (see the .NET Framework documentation for information about these).

When implementing a hand-coded method that will be callable through the IDO runtime, you could add the optional IDOMethod attribute, which may be used in the future to facilitate adding the necessary IDO metadata to make the method accessible.

Sample Standard Method CallFor example, the declaration of a standard method might look like the following Function declaration:

<IDOMethod(MethodFlags.None, "Infobar")> _Public Function DoWork( _ ByVal SessionID As String, _ ByVal TransNum As Long, _ ByRef Infobar As String) As Integer

' ...Implementation goes here...

End Function

IDOMethod ParametersThe IDOMethod attribute takes two optional parameters: flags and messageParm.

FlagsThe flags parameter is one or more of the values defined by the MethodFlags enumeration. This table shows the MethodFlags values:

MessageParmThe messageParm parameter is a string and is the name of the parameter that will be used to return messages to the caller (Infobar). The parameter that is identified should be declared as a String and passed ByRef.

Remember that these attributes are not used at run time. They may be used in the future to facilitate adding and synchronizing the IDO metadata for an extension class and its methods when an assembly is imported.

MethodFlags value Description

None Standard method call.

CustomLoad Custom load method.

RequiresTransaction Method runs in the context of a transaction.

3-4 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 37: IDO Development Guide

IDO Extension Classes

IDO Event HandlersWhen an IDO is processing a LoadCollection or UpdateCollection request, it will fire several events. An IDO extension class can add its own event handlers to these events to get control when these events are fired.

The available events are:

Adding an IDO Event HandlerIDO event handler methods should be declared as private "Sub" methods in your VB.Net IDO extension class. These methods should use the same signature as the following example:

Private Sub HandlePreLoadCollection( _ ByVal sender As Object, _ ByVal args As IDOEventArgs)

These IDO events are available on the IDO property of the IIDOExtensionClassContext interface. To add your handler to an IDO event you must override the ExtensionClassBase.SetContext method in your IDO extension class and use the AddHandler keyword as shown in the following example.

Public Overrides Sub SetContext( _ ByVal context As IIDOExtensionClassContext)

' call base class implementation MyBase.SetContext(context)

' Add event handlers here, for example: AddHandler _ Me.Context.IDO.PreUpdateCollection, _ AddressOf Me.PreUpdateCollection

End Sub

Event Description

PreLoadCollection Fires when a LoadCollection request is received.

PostLoadCollection Fires after a LoadCollection request has been processed.

PreUpdateCollection Fires when an UpdateCollection request is received.

PostUpdateCollection Fires after an UpdateCollection request has been processed.

IDO Development Guide 3-5

Copyright © 2008 Infor. All rights reserved.

Page 38: IDO Development Guide

IDO Extension Classes

Event Handler ParametersThe first parameter on an IDO event handler method is the sender parameter, which is simply a reference to the IDO that initiated the event. This is equivalent to the IIDOExtensionClassContext.IDO property.

The second parameter is an instance of the IDOEventArgs class which will allow you to access the original IDO request that initiated the event, and for the Post events, the IDO response also.

Public Class IDOEventArgs Inherits EventArgs

Public ReadOnly Property RequestPayload() As PayloadBase Public ResponsePayload As PayloadBaseEnd Class

The following table describes the contents of the IDOEventArgs parameter for each IDO event.

An event handler method can access the IDO request and response payloads as shown in the following examples.

Private Sub HandlePreLoadCollection( _ ByVal sender As Object, _ ByVal args As IDOEventArgs)

' Get the original request Dim loadRequest As LoadCollectionRequestData

loadRequest = CType(args.RequestPayload, LoadCollectionRequestData) ' ...additional logic based on loadRequest...

End Sub

Event RequestPayload property ResponsePayload field

PreLoadCollection Contains an instance of the LoadCollectionRequestData class that the IDO is processing

Nothing

PostLoadCollection Contains an instance of the LoadCollectionRequestData class that the IDO processed.

Contains an instance of the LoadCollectionResponseData class that will be returned to the caller.

PreUpdateCollection Contains an instance of the UpdateCollectionRequestData class that the IDO is processing

Nothing

PostUpdateCollection Contains an instance of the UpdateCollectionRequestData class that the IDO processed.

Contains an instance of the UpdateCollectionResponseData class that will be returned to the caller.

3-6 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 39: IDO Development Guide

IDO Extension Classes

Private Sub HandlePostLoadCollection( _ ByVal sender As Object, _ ByVal args As IDOEventArgs)

' Get the original request Dim loadRequest As LoadCollectionRequestData Dim loadResponse As LoadCollectionResponseData

loadRequest = CType(args.RequestPayload, LoadCollectionRequestData) loadResponse = CType(args.ResponsePayload, LoadCollectionResponseData) ' ...additional logic based on loadRequest or loadResponse...

End Sub

Private Sub HandlePreUpdateCollection( _ ByVal sender As Object, _ ByVal args As IDOEventArgs)

' Get the original request Dim updateRequest As UpdateCollectionRequestData

updateRequest = CType(args.RequestPayload, UpdateCollectionRequestData) ' ...additional logic based on updateRequest...

End Sub

Private Sub HandlePostUpdateCollection( _ ByVal sender As Object, _ ByVal args As IDOEventArgs)

' Get the original request Dim updateRequest As UpdateCollectionRequestData Dim updateResponse As UpdateCollectionResponseData

updateRequest = CType(args.RequestPayload, UpdateCollectionRequestData) updateResponse = CType(args.ResponsePayload, UpdateCollectionResponseData) ' ...additional logic based on loadRequest or loadResponse...

End Sub

IDO Development Guide 3-7

Copyright © 2008 Infor. All rights reserved.

Page 40: IDO Development Guide

IDO Extension Classes

Special Cases for UpdateCollection EventsThere are special cases when an IDO UpdateCollection request may not process all items in the update. For example, this may happen when a caller is saving hierarchical data, which is represented as an UpdateCollection request with nested UpdateCollection child requests. The framework will first process only the deleted items in the child requests, then all items in the parent, followed by the inserted or updated items in the child requests. The following example shows how an event handler can determine if the framework is processing inserted, update and/or deleted items.

Private Sub HandlePostUpdateCollection( _ ByVal sender As Object, _ ByVal args As IDOEventArgs)

' Get the original request Dim updateRequest As UpdateCollectionRequestData Dim updateResponse As UpdateCollectionResponseData Dim updateArgs As IDOUpdateEventArgs

updateArgs = CType(args, IDOUpdateEventArgs) updateRequest = CType(args.RequestPayload, UpdateCollectionRequestData) updateResponse = CType(args.ResponsePayload, UpdateCollectionResponseData)

If (updateArgs.ActionMask And UpdateAction.Delete) = UpdateAction.Delete Then ' ...only perform this logic if processing deleted items... End If

If (updateArgs.ActionMask And UpdateAction.Insert) = UpdateAction.Insert Then ' ...only perform this logic if processing inserted items... End If

If (updateArgs.ActionMask And UpdateAction.Update) = UpdateAction.Update Then ' ...only perform this logic if processing updated items... End If

' ...additional logic based on loadRequest or loadResponse...

End Sub

3-8 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 41: IDO Development Guide

IDO Extension Classes

Using the ActionMask PropertyIn the example above, the IDOUpdateEventArgs class inherits from IDOEventArgs, but has one additional property: ActionMask. The ActionMask is declared as an UpdateAction, which is an enum (shown below).

public enum UpdateAction : ushort{

None = (ushort)0x0000,Insert = (ushort)0x0001,Update = (ushort)0x0002,Delete = (ushort)0x0004,All = (ushort)0xffff

}

The ActionMask is usually a combination of Insert, Update and Delete (All), meaning the UpdateCollection that was just performed executed all types of actions.

However, there are certain circumstances when this may be a subset of Insert, Update and Delete, which means only the items that match the mask were actually saved. There are times when the IDO runtime must save items in a particular order (with nested updates), and it may first process only deleted items; then in another pass it will execute all inserts and updates.

ActionMask is valid for both Pre- and PostUpdateCollection. The PreUpdateCollection parameters are the same as the PostUpdateCollection parameters – but the action indicates which items are about to be saved, rather than which items were just saved.

Replacing Standard IDO Processing with Event HandlersBy adding event handlers, not only can you perform additional logic when a particular event fires, but in the case of PreUpdateCollection and PreLoadCollection you can also completely replace the default framework implementation by constructing your own response and setting that in the IDOEventArgs.ResponsePayload field. The following example shows how this is done for an UpdateCollection request.

Private Sub HandlePreUpdateCollection( _ ByVal sender As Object, _ ByVal args As IDOEventArgs)

' Get the original request Dim updateRequest As UpdateCollectionRequestData Dim updateResponse As UpdateCollectionResponseData

updateRequest = CType(args.RequestPayload, UpdateCollectionRequestData)

updateResponse = New UpdateCollectionResponseData(updateRequest) ' ...process items in the request, filling in the response...

' override the standard processing, returning my ' custom response instead: args.ResponsePayload = updateResponse

End Sub

IDO Development Guide 3-9

Copyright © 2008 Infor. All rights reserved.

Page 42: IDO Development Guide

IDO Extension Classes

Generating Application EventsThe ExtensionClassBase class provides a method named FireApplicationEvent that may be used to generate an application event.

Protected Function FireApplicationEvent( _ ByVal eventName As String, _ ByVal sychronous As Boolean, _ ByVal transactional As Boolean, _ ByRef result As String, _ ByRef parameters As ApplicationEventParameter()) As Boolean

Properties

ExampleOption Explicit OnOption Strict On

Imports Mongoose.IDOImports Mongoose.IDO.ProtocolImports Mongoose.IDO.DataAccessImports Mongoose.Core.Common

<IDOExtensionClass("MyIDO")> _Public Class TestFiringEvent Inherits ExtensionClassBase

<IDOMethod(MethodFlags.None, "Infobar")> _ Public Function FireMyEvent( _ ByVal Parm1 As String, _ ByVal Parm2 As Long, _ ByRef Infobar As String) As Integer

Dim ParmList(1) As ApplicationEventParameter Dim result As String

ParmList(0) = New ApplicationEventParameter() ParmList(0).Name = "PString" ParmList(0).Value = Parm1 ParmList(1) = New ApplicationEventParameter() ParmList(1).Name = "PNumeric" ParmList(1).Value = Parm2.ToString()

Property Description

eventName The name of the event to generate

synchronous Determines if the event handlers should be executed synchronously (True) or asynchronously (False).

transactional Determines if the event handlers should be executed in a transaction. If passed as False and one of the synchronous handlers fails, any database activity performed by prior handlers will remain committed.

result The value of the last RESULT() keyword executed on a Finish or Fail action on any handler.

parameters An array of named parameters passed to the event handlers.

3-10 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 43: IDO Development Guide

IDO Extension Classes

If Not FireApplicationEvent("MyEvent", True, True, _result, ParmList) ThenInfobar = result

End If

End FunctionEnd Class

Code Samples

LoadCollection ExamplesThe following sample code demonstrates executing a LoadCollection for the SLTtJobtMatPosts IDO, bringing back the TransNum and TransSeq properties.

Dim loadResponse As LoadCollectionResponseData

loadResponse = Me.Context.Commands.LoadCollection( _ "SLTtJobtMatPosts", _ "TransNum,TransSeq", _ filter, String.Empty, 0)

The following sample demonstrates executing a LoadCollection for the IDO that the extension class belongs to (the current instance of the executing IDO).

Dim loadResponse As LoadCollectionResponseData

loadResponse = Me.LoadCollection( _ "TransNum, EmpNum, EmpEmpType, EmpDept, DerJobPWcDept ", _ filter, _ "Posted, LowLevel DESC, Job, Suffix, CloseJob, TransNum", _ 0)

The following sample demonstrates one way to iterate through items in a LoadCollectionResponseData instance returned from a LoadCollection request, and how to access property values.

Dim empNum As String

For index As Integer = 0 To loadResponse.Items.Count If Not loadResponse(index, "EmpNum").IsNull Then empNum = loadResponse(index, "EmpNum").Value ' ...processing... End IfNext

The examples in this section assume you are writing code in an IDO extension class that inherits from the Mongoose.IDO.ExtensionClassBase class.

IDO Development Guide 3-11

Copyright © 2008 Infor. All rights reserved.

Page 44: IDO Development Guide

IDO Extension Classes

UpdateCollection ExamplesInserting a New ItemThe following sample demonstrates inserting a new item.

Dim request As New UpdateCollectionRequestDataDim response As New UpdateCollectionResponseDataDim customerItem As New IDOUpdateItem

request.IDOName = "SLCustomers"request.RefreshAfterUpdate = True

customerItem.Action = UpdateAction.InsertcustomerItem.Properties.Add("CoNum", "C000100")customerItem.Properties.Add("Name", "New Company")customerItem.Properties.Add("CreditHold", 1I)

request.Items.Add(customerItem)response = Me.Context.Commands.UpdateCollection(request)

Updating an Existing ItemThe following sample demonstrates updating an existing item queried through a LoadCollection request.

Dim loadResponse As New LoadCollectionResponseDataDim request As New UpdateCollectionRequestDataDim response As New UpdateCollectionResponseDataDim customerItem As New IDOUpdateItem

loadResponse = Me.Context.Commands.LoadCollection( _ "SLCustomers", _ "CoNum, Name, CreditHold", _ "CoNum = N'C000100'", _ "", _ 1)

If loadResponse.Items.Count = 1 Then request.IDOName = "SLCustomers" request.RefreshAfterUpdate = True

' must have the ItemID to update or delete customerItem.ItemID = loadResponse.Items(0).ItemID customerItem.Action = UpdateAction.Update customerItem.Properties.Add("CreditHold", 0I)

request.Items.Add(customerItem) response = Me.Context.Commands.UpdateCollection(request)End If

3-12 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 45: IDO Development Guide

IDO Extension Classes

Invoke ExampleThe following sample demonstrates invoking the JobtClsLogErrorSp method on the SLJobtCls IDO, passing two parameters and retrieving the output value for the second parameter.

Dim invokeResponse As New InvokeResponseDataDim message As String

invokeResponse = Me.Context.Commands.Invoke( _ "SLJobtCls", _ "JobtClsLogErrorSp", _ TransNum, IDONull.Value)message = invokeResponse.Parameters(1).Value

IDO Development Guide 3-13

Copyright © 2008 Infor. All rights reserved.

Page 46: IDO Development Guide

IDO Extension Classes

AppDB ClassThe AppDB class, part of the Mongoose.IDO.DataAccess namespace, provides direct access to the application database, plus access to common framework features such as application messages and session variables. You may create a new instance of this class by calling the CreateAppDB method, which is implemented by the ExtensionClassBase class.

Application Database ConnectionsIn general, the best practice for accessing the database to execute queries, updates or stored procedure calls is to go through the Infor framework using IDO requests. However, there may be times when it is necessary or more efficient to access the database directly (for example, building and executing dynamic SQL or iterating through records from an extremely large query result set). Direct database access is accomplished using the standard .NET Framework SQL Server classes: SqlConnection and SqlCommand. See the Microsoft .NET Framework documentation for more information on these classes.

Opening a Connection to the Application SQL Server Database The AppDB.Connection property provides an opened SqlConnection instance pointing to the application database. By going through the AppDB.Connection property, the framework is able to open and initialize the connection based on the calling user's session information.

Executing SQL Server Commands The SqlCommand class is used to execute stored procedures, queries, updates, or any other T-SQL command. The SqlCommand may be created by using the VB New operator and setting the necessary properties on the command, as described in the .NET Framework documentation. However, when the command is executed, you should use the AppDB.ExecuteScalar, AppDB.ExecuteNonQuery, or AppDB.ExecuteReader methods. This allows you to leverage the framework infrastructure for executing SQL commands including logging and exception-message translation.

Application MessagesAccess to translatable strings and messages stored in the application database message tables is implemented by the AppDB class. The strings and messages that are returned are queried and constructed according to the calling session's regional settings. Access is provided through the IMessageProvider interface and makes use of application database messaging stored procedures such as MsgAppSp.

The following methods are published by the IMessageProvider interface:

Method Description

Public Function GetMessage( _ msgID As String ) As String

Get a string or message by message ID.

Public Function GetMessage( _ msgID As String, _ ParamArray args() As Object ) _ As String

Get a string or message by message ID with substitution parameters.

Public Function AppendMessage( _ message As String, _ msgID As String ) As String

Append a string or message by message ID.

Public Function AppendMessage ( _ message As String, _ msgID As String, _ ParamArray args() As Object ) _ As String

Append a string or message by message ID with substitution parameters.

3-14 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 47: IDO Development Guide

IDO Extension Classes

Message Lookup Using the AppDB ClassThe following example shows how to use the AppDB class to retrieve messages.

Dim messageProvider As IMessageProvider = Nothing

Using appDB As AppDB = Me.CreateAppDB() messageProvider = appDB.GetMessageProvider()

Infobar = messageProvider.AppendMessage( _ Infobar, _ "I=CmdMustPerform", _ "@:PostPendingMaterialTransactions")End Using

If you are writing code in an extension class method for a class that derives from ExtensionClassBase, you can simply call the ExtensionClassBase.GetMessageProvider method as a shortcut to getting a reference to the IMessageProvider interface, as shown in this example:

Dim messageProvider As IMessageProvider = Nothing

messageProvider = Me.GetMessageProvider()

Session VariablesThe AppDB class publishes the following methods for manipulating session variables for the caller's session.

Public Function GetErrorMessage( _ objectName As String, _ messageType As AppMessageType ) _ As String

Get a constraint error message by object name and type.

Public Function GetErrorMessage( _ objectName As String, _ messageType As AppMessageType, _ ParamArray args() As Object ) _ As String

Get a constraint error message by object name and type with substitution parameters.

Method Description

Public Sub SetSessionVariable( _ ByVal name As String, _ ByVal varValue As String )

Set the value of a session variable.

Public Function GetSessionVariable( _ ByVal name As String ) As String

Get the value of a session variable.

Public Function GetSessionVariable( _ ByVal name As String, _ ByVal defaultValue As String ) _ As String

Get the value of a session variable, returning the specified default value if it does not exist.

Public Function GetSessionVariable( _ ByVal name As String, _ ByVal defaultValue As String, _ ByVal delete As Boolean ) As String

Get the value of a session variable, returning the specified default value if it does not exist, and delete it if it does exist.

Public Sub DeleteSessionVariable( _ ByVal name As String )

Delete a session variable.

Method Description

IDO Development Guide 3-15

Copyright © 2008 Infor. All rights reserved.

Page 48: IDO Development Guide

IDO Extension Classes

Using AppDB in an Extension Class MethodThe following example shows how to use AppDB in an extension class.

Public Function MyMethod() As Integer

Using appDB As AppDB = Me.CreateAppDB() ' ...use appDB here... End Using

End Function

Note that the AppDB instance is created as part of the Using…End Using block. This ensures that the AppDB instance will be disposed and any resources it is holding will be released as soon as the instance goes out of scope. See the .NET Framework documentation for more information on the Using statement.

Disposing of IDO Extension ClassesIf an IDO extension class implements the IDisposable interface, the Dispose method will be called by the IDO runtime when it is finished with each instance. The ExtensionClassBase class implements IDisposable and provides a virtual method which you can override in a derived class to get control when an instance is disposed.

protected virtual void Dispose( bool disposing );

See the .NET Framework documentation for more information on the IDisposable interface.

Translation/Localization ConsiderationsType Conversions

The built-in VB functions for data type conversions (CStr, CDate, CInt, etc.) are sensitive to the regional settings for the application or local machine, and therefore should not be used for type conversions in IDO extension class methods.

The framework stores all property values internally as strings regardless of their data type. In WinStudio, this is also true for values stored in components, variables and IDO collections. The internal string format is culture independent so the built-in string conversion functions may not work, or may work inconsistently depending on the data or the current culture settings. The internal formatted string value is always available, but when accessing numeric, date or Guid property values programmatically, you should use the APIs provided by the framework that will convert the values from internal string format to the proper “strong” data types.

IDORequest/Response Property Values (IDOProtocol classes)Property values in IDO Request and Response classes are represented using the Mongoose.IDO.Protocol.IDOValueType class, or a class that inherits from this class.

The following example accesses properties in a LoadCollectionResponseData instance:

Dim responseData As LoadCollectionResponseDataDim name As StringDim recordDate As DateTimeDim cost As DecimalDim newCost As Decimal = 100.00Dim id As Guid

3-16 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 49: IDO Development Guide

IDO Extension Classes

'…perform LoadCollection…

name = responseData(0, "Name").Value ' access internal value for stringsrecordDate = responseData(0, "RecordDate").GetValue(Of DateTime)() ' convert internal date to DateTimecost = responseData(0, "Cost").GetValue(Of Decimal)(0.00) ' convert to Decimal, specifying default if property is nullid = responseData(0, "ID").GetValue(Of Guid)()

responseData(0, "Cost").SetValue( newCost ) ' assign a new value to cost

Note that the name property simply gets the internal format, since string values do not need conversion. Also note that the GetValue call for the cost property specifies an optional default value to return if the property is null. You can also check for null values using the IsNull property.

The last line assigns a new value to the cost property. Passing in a decimal value to the SetValue method allows the framework to perform the conversion to the internal string format automatically.

Converting Internal Format Strings to Strong Typed VariablesWinStudio supports a similar set of methods for automatically converting internal format strings to strong typed variables in scripts, as shown in the following example.

Dim name As StringDim recordDate As DateTimeDim cost As DecimalDim newCost As Decimal = 100.00Dim id As Guid

' …perform LoadCollection…

name = ThisForm.Components("NameEdit").Value ' access internal value for stringsrecordDate = ThisForm.Components("DateTimeEdit").GetValueOfDateTime(DateTime.Now)cost = ThisForm.PrimaryIDOCollection(0).Properties("Cost").GetValueOfDecimal(0.0)id = ThisForm.Variables("IDVar").GetValueOfGuid(Guid.Empty)

ThisForm.PrimaryIDOCollection(0).Properties("Cost").SetValue(newCost)

Note that there are individual methods for each data type, instead of a single generic method that is supported in the IDOProtocol classes. Also, the methods all require a default value to return if the requested value is null.

Again, the last line assigns a new value to the cost property. Passing in a decimal value to the SetValue method allows the framework to perform the conversion to the internal string format automatically

IDO Development Guide 3-17

Copyright © 2008 Infor. All rights reserved.

Page 50: IDO Development Guide

IDO Extension Classes

Testing Extension Class Assemblies LocallyTo test a new version of an extension class assembly locally before checking it in, copy the new version of the extension class assembly to a folder named syteline/idoxca/config-name, where syteline is the SyteLine root folder (usually c:\program files\Infor\SyteLine) and config-name is the configuration you will be logging into to test the DLL.

The IDO runtime checks this location first when it loads an assembly.

This may also be useful to developers working on different classes in the same assembly, since only one developer can have an assembly checked out at a time.

You may need to discard the IDO metadata cache to force the IDO runtime to load the new version.

Debugging Extension ClassesIDO extension class code can be debugged using the Visual Studio 2005 debugger. In order to debug an extension class, the developer must:

1. Build a debug version of the extension class assembly.

2. Import the assembly (DLL) and the symbols (PDB) into the objects database using the IDO Custom Assemblies form (first checking out the assembly, if it has been checked in).

3. Run the IDO Runtime Development Server (IDORuntimeHost.exe) on the developer's local machine. Alternatively, you may use the technique described in “Testing Extension Class Assemblies Locally” on page 3-18.

4. Run WinStudio configured to access the IDO runtime on the local machine.

5. Open Visual Studio 2005 and select Attach to Process from the Debug menu.

6. Select IDORuntimeHost.exe in the list of available processes and click the Attach button.

3-18 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 51: IDO Development Guide

IDO Extension Classes

You should now be able to set breakpoints in the Visual Studio 2005 debugger and step through code.

Logging Diagnostic MessagesIDO extension class methods can send messages to the common logging facility IDO Runtime Development Server (IDORuntimeHost.exe) by calling one of the overloaded IDORuntime.LogUserMessage methods. For more information about the facility, see “Diagnostics and Debugging” on page 2-19.

ExampleThis sample sends a message to the log each time the ValidateCreditCard method is called.

• The first parameter is messageSource (String). This is the source identifier that will display in the log viewer.

• The second parameter is messageType (Mongose.IDO.UserDefinedMessageType). This is the type identifier that will display in the log viewer.

• The third parameter is message (String). This is the text of the message to be logged.

IDO Development Guide 3-19

Copyright © 2008 Infor. All rights reserved.

Page 52: IDO Development Guide

IDO Extension Classes

<IDOMethod(MethodFlags.None, "infobar")> _Public Function ValidateCreditCard( _

ByVal cardNumber As String, _ByVal expires As DateTime, _ByVal amount As Decimal, _ByVal infobar As String) As Integer

Dim result As Integer = 0

' Call web service to validate CC infoIDORuntime.LogUserMessage( _"MyExtensionClass", _UserDefinedMessageType.UserDefined0, _"ValidateCreditCard called by user " & IDORuntime.Context.UserName)

Return resultEnd Function

3-20 IDO Development Guide

Copyright © 2008 Infor. All rights reserved.

Page 53: IDO Development Guide

Index ____________________________________________

Symbols.NET CLR data types 2-14.NET data types supported by IDO protocol classes 2-17

AActionMask 3-9ActiveScriptingOnly 2-21, 2-24Add method 2-14AddHandler keyword 3-5AppDB class 2-2, 3-14AppDB class, using in extension class method 3-16AppDB.Connection 3-14AppDB.ExecuteNonQuery 3-14AppDB.ExecuteReader 3-14AppDB.ExecuteScalar 3-14Application database connections 3-14Application messages, accessing 3-14Application property 2-24AppName property 2-22, 2-24AppProperties class 2-24AppURL 2-22Attach to Process 3-18

BBase class 3-2BaseHelpFile 2-22, 2-24

CClient class 2-1CloseSession method 2-1, 2-20CollectionID property 2-9ColSecurityPrimaryOnly 2-22, 2-24CompanyName 2-22, 2-24ConfigName property 2-24ConfigServer.aspx page 2-20Configuration class 2-24Configuration information 2-23Configuration information storage 2-20ConfigurationInfo class, examples 2-21ConnectionKey 2-25ConnectionProfile class 2-25ConnectionRoles 2-24Conversions of data types 2-14Copyright 2-22, 2-24CreateAppDB method 3-14Custom assemblies, importing 3-2CustomDelete property 2-9CustomInsert property 2-9CustomLoadMethod property 2-6CustomUpdate property 2-9

DData type conversions 2-14Data type conversions in IDO extension classes 3-16

Data types, supported 2-17Database, connecting to 3-14DatabaseName 2-25DatabaseType 2-25DataProvider 2-25DataSource 2-25DataTable 3-4Date values, format 2-14DBTimeout 2-25Debug menu 3-18Debugging 2-19Debugging extension classes 3-18Declaring an IDO extension class 3-3DefFormBGColor 2-22, 2-24DefFormFGColor 2-22, 2-24DefFormFont 2-22, 2-24DefNormalBGColor 2-22, 2-24DefNormalFGColor 2-22, 2-24DefReadOnlyBGColor 2-22, 2-24DefReadOnlyFGColor 2-22, 2-24DefRequiredBGColor 2-22, 2-24DefRequiredFGColor 2-22, 2-24DefTbdBGColor 2-22, 2-24DefTbdFGColor 2-22, 2-24DeleteExistingPrompt 2-22, 2-24DeleteNewPrompt 2-22, 2-24DeleteSessionVariable 3-15Diagnostic messages, logging 2-19, 3-19DisableInvalidValuePrompt 2-22, 2-24Dispose method 3-16Disposing of extension classes 3-16Distinct property 2-6

EEvent handlers 3-5Event handlers, replacing standard IDO processing 3-9Events available fo extension classes 3-5Events, generating 3-10Examples, syntax of 2-5Extension class 3-1

Debugging 3-18Disposing of 3-16Examples 3-11Project, creating 3-1Testing assemblies locally 3-18

ExtensionClassBase class 3-2, 3-14ExtensionClassBase.SetContext method 3-5External applications 2-20

FFilter strings. creating 2-16FireApplicationEvent method 3-10Flags parameter 3-4FormCLSID 2-22, 2-24

IDO Development Guide Index-1Copyright © 2008 Infor. All rights reserved.

Page 54: IDO Development Guide

Index

FormControlSSEnabled 2-24FormFileExtension 2-22, 2-24FormsURL 2-22Function 3-4

GGet parameter and property values 2-15GetConfigurations 2-1GetConfigurations static method 2-20GetMessageProvider method 3-15GetPropertyInfo 2-5GetSessionVariable 3-15GetValue call 3-17GetValue methods 2-15

HHelpBasePath 2-22, 2-24HelpContentsIndexMenuText 2-22, 2-24HorzComponentSpacing 2-22, 2-24

IIconFilename 2-22, 2-24IDataReader 3-4IDisposable interface 3-16IDO

Commands interface 2-1, 2-2Definition of 2-1Protocol class library 2-1Runtime Development Server 2-19

IDO Custom Assemblies form 3-2, 3-18IDO Methods form 3-2IDO Runtime Development Server 3-18IDO Runtime Service 2-20IDOCore.dll 3-1IDOEventArgs class 3-6IDOMethod attribute 3-4IDOName property 2-5, 2-6, 2-9, 2-11IDONull.IsNull static method 2-13IDONull.Value static property 2-13IDOProtocol.dll 2-20, 3-1IDORequest class 2-1IDORequestClient .NET class library 2-1IDORequestClient.dll 2-20IDORequestEnvelope class 2-1IDORequestService ASP.NET Web server 2-20IDORuntimeHost.exe 2-19, 2-20, 3-18IDOs form 3-2IDOValueType class 3-16IIDOCommands interface (shown in C#) 2-3IIDOCommands interface (shown in VB) 2-4IIDOExtensionClass interface 3-2IIDOExtensionClassContext interface 3-5IMessageProvider interface 3-14Importing assemblies 3-2IncludeClassNotesFlag property 2-5Internal format strings, converting to strong typedvariables 3-17Invoke 2-1, 2-11Invoke call execution, sample steps 2-2

Invoke examples 2-11, 3-13IsNull property 2-13, 3-17Item, inserting new - example 3-12Item, updating existing - example 3-12Items property 2-9

LLinkBy property 2-6, 2-9LoadCap property 2-7LoadCollection 2-1, 2-6, 2-16, 3-11LoadCollection examples 2-7LoadCollectionRequestData class 2-1Localization 2-14, 3-16Logging diagnostic messages 2-19Logging into a session 2-20Logging out of a session 2-20LoginOverrideProgID 2-22, 2-24LogUserMessage method 3-19Look up application messages 3-15

MMe.Context.Commands property 2-1Message lookup 3-15MessageParm parameter 3-4Messages, accessing 3-14MethodFlags enumeration 3-4MethodName property 2-11Methods, adding in extension class 3-4MGShared.dll 2-20, 2-23, 3-1MiscConnectionInfo 2-25Mongoose.Core.Common 2-23Mongoose.Core.Configuration 2-23Mongoose.IDO namespace 3-2Mongoose.IDO.Client class 2-1Mongoose.IDO.DataAccess namespace 2-2, 3-14Mongoose.IDO.Protocol namespace 2-1MongooseConfigs class 2-23MongooseConfigs.xml 2-20MsgAppSp 3-14msgID 3-14

NName property 2-22NestedRequests property 2-7Null values, assigning and checking 2-13Nullable values, in GetValue method 2-15Numeric values, format 2-14

OObjectMenuName 2-22, 2-24ObjectStudioProjBuildDir 2-24ObjectStudioSSEnabled 2-24OpenSession 2-1OpenSessionRequestData class 2-1OrderBy property 2-6

PParameter values

Retrieving 2-15Setting 2-14

Index-2 IDO Development Guide Copyright © 2008 Infor. All rights reserved.

Page 55: IDO Development Guide

Index

Parameters property 2-11Password 2-25payload 2-1Posting a batch of records 2-18PostLoadCollection event 3-5, 3-6PostQueryCommand property 2-6PostUpdateCollection event 3-5, 3-6PreLoadCollection event 3-5, 3-6PreUpdateCollection event 3-5, 3-6PrimaryCacheUsesFormCaption 2-22, 2-24ProfileName 2-25ProgIDRootAugment 2-22, 2-24Property values 3-16

Retrieving 2-15Setting 2-14

PropertyList property 2-6ProviderDriver 2-25

RReadMode property 2-6RecordCap property 2-6RefreshAfterUpdate property 2-9Regional settings 2-14RelFormServerURL 2-24RelWebServerURL 2-24ReportViewerExecutable 2-22, 2-24ReportViewerExecutablePath 2-22, 2-24RightJustifyNewLabels 2-22, 2-24RSDAO COM library 2-1

SSender parameter on event handler method 3-6Session variables, manipulating 3-15SetContext method 3-2SetSessionVariable 3-15SetValue method 2-14SplashFilename 2-22, 2-25SQL commands, executing 3-14SqlCommand class 3-14SqlConnection instance 3-14SqlLiteral class 2-16SqlLiteral.Format method 2-16

SSPassword 2-24SSProjectName 2-24SSUNCPath 2-24SSUserId 2-24Standalone application communications 2-20Standard Method Cal 3-4Strong typed variables 3-17System.DateTime, use with SqlLiteral.Format 2-17System.Decimal, use with SqlLiteral.Format 2-17System.Guid, use with SqlLiteral.Format 2-17System.Int32, use with SqlLiteral.Format 2-17System.String, use with SqlLiteral.Format 2-17

TTemplate for new IDO extension classes 3-3Testing extension class assemblies 3-18Transaction, executing requests in 2-18Translation 2-14, 3-16

UUpdateCollection 2-1, 2-9, 3-12UpdateCollection events, special cases 3-8UpdateCollection example 2-9UseHtmlHelp 2-22, 2-25UserId 2-25

VValidationErrorIndicators 2-22, 2-25VBAFilename 2-22, 2-25Version 2-22, 2-25VertComponentSpacing 2-22, 2-25

WWallpaperDisplayOption 2-22, 2-25WallpaperFilename 2-22, 2-25Web server application 2-20WHERE clause 2-16Wire Tap feature for debugging 2-19

XXPVisualStyle 2-22, 2-25

IDO Development Guide Index-3Copyright © 2008 Infor. All rights reserved.