Smart Integration Connector Guide 1 (1)
Smart Integration Connector Guide 1 (1)
Connector Guide
8.1.0 Release
Copyright © 2023 OneStream Software LLC. All rights reserved.
Any warranty with respect to the software or its functionality will be expressly given in the
Subscription License Agreement or Software License and Services Agreement between
OneStream and the warrantee. This document does not itself constitute a representation or
warranty with respect to the software or any related matter.
OneStream Software, OneStream, Extensible Dimensionality and the OneStream logo are
trademarks of OneStream Software LLC in the United States and other countries. Microsoft,
Microsoft Azure, Microsoft Office, Windows, Windows Server, Excel, .NET Framework, Internet
Information Services, Windows Communication Foundation and SQL Server are registered
trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.
DevExpress is a registered trademark of Developer Express, Inc. Cisco is a registered trademark
of Cisco Systems, Inc. Intel is a trademark of Intel Corporation. AMD64 is a trademark of
Advanced Micro Devices, Inc. Other names may be trademarks of their respective owners.
Table of Contents
Table of Contents
Revision History 1
About This Guide 2
Benefits 3
Common Understanding 3
OneStream Client Application Terms 3
OneStream Local Gateway Configuration Terms 5
Architecture 6
Additional Considerations 8
Requirements 9
OneStream Smart Integration Connector Environment Setup 9
Advanced Networking and Whitelisting 10
Upgrade Smart Integration Connector for Private Preview or Limited
Availability Customers 11
Upgrade from 7.2, 7.3, 7.4, or 8.0 to 8.1 11
Upgrade from 7.1 to 8.1 13
Migration from VPN Considerations 15
Setup and Installation 16
Smart Integration Connector Setup 16
Gateway Terms 16
Revision History
Date Smart Integration Summary of Changes
Connector Version
l Assisting with the installation of Smart Integration Connector Local Gateway Server in your
environment.
Benefits
OneStream applications are strategic components in your financial environment. Data from
financial systems is imported to OneStream and contributes to financial closing and reporting
processes. While performing analysis, you leverage data lineage capabilities to make contextual
associations to data sources in your network.
You will need to set up and configure data sources that may be accessed by OneStream
processes. Traditionally, data connectivity between a OneStream Cloud instance and local data
sources is established using a Virtual Private Network (VPN) and all data source credentials and
supporting files are located on OneStream application servers.
The goals for Smart Integration Connector are to establish all required data source connections
without VPN and establish residency and management of data source connections solely in your
network.
l Securely establish connectivity between OneStream Cloud and data sources in your
network without a VPN connection.
l Create and manage network data source integration using OneStream administration
interfaces.
Common Understanding
Use the reference charts below to understand common terms used throughout the product and
this document.
OneStream Local Gateway This utility is where you configure the Local
Configuration Gateway Server, Local Gateways and Local
Gateway Connections to data sources.
Architecture
In contrast to a direct data source connection established using a VPN, Smart Integration
Connector makes an indirect connection to data sources. Smart Integration local gateways
integrate with on-premises customer environments through a cloud hosted service called Azure
Relay. The locally installed and configured local gateway server makes the direct connection to
data sources and responds to the OneStream application.
l Local Gateway Server: Instances of the Smart Integration Connector Local Gateway
Server are installed inside your network and configured to make direct connections to
designated data sources. The Smart Integration Connector Local Gateway Server runs as
a Windows service and brokers communication between local data sources and Azure
Relay using an outbound connection over port 443.
l A Custom Database Connection to the local gateway data source. Custom Database
Connections are configured in System > System Configuration > Application Server
Configuration > Database Server Connections.
Additional Considerations
l To provide high availability, there can be multiple instances of a designated local gateway
server, each running on a separate server bound to the same gateway where the services
run in an active / passive (fail over) manner.
l Multiple local gateways can be installed to establish global connectivity to data sources in
different subnetworks.
l Local gateway configuration must align to the corresponding gateway as defined in the
OneStream Windows application. An export process from the OneStream Windows
application gateway user interface can assist with the alignment to ensure corresponding
names and keys are identical.
Requirements
OneStream Smart Integration Connector
Environment Setup
Smart Integration Connector is Generally Available to all SaaS customers starting with
OneStream version 8.0.
l Install or upgrade OneStream to the latest version. See Setup and Installation.
l Work with your IT team to install the latest version of the Smart Integration Connector Local
Gateway Server in your environment.
o Windows Server 2019+
o .NET Framework 4.8
o Minimum of 8 GB of RAM
l Create a valid database connection string and internally test the connection from the
Windows server to the database. See Create a Database Connection for more information.
l A copy of the original configuration file from the prior version will be saved.
l Existing gateways should continue to function as they did prior to the install.
l If the Smart Integration Connector Windows Service is running, then the service will
automatically be started after install.
l Previous versions of Smart Integration Connector are compatible with newer versions of
OneStream. For example, the OneStream Local Gateway Configuration is compatible with
OneStream Platform version 8.1.0. However, it is always recommended to upgrade to the
latest version.
If you perform an upgrade and have issues or do not achieve these results, contact OneStream
Support.
1. Install the latest version of OneStream. The latest version can be requested and scheduled
through the OneStream Software Cloud Customer Service Catalog. Make a note in the
details section of the ticket that you want to install and configure the Smart Integration
Connector.
5. (Optional) If you are using any Custom DLLs in the Gateway Installation folder
C:\Program Files\OneStream Software\OneStream Gateway, create a backup copy.
NOTE: For OneStream Platform version 8.1 and above, the default location for
Reference Assembly Folder is C:\Program Files\OneStream Software\OneStream
Gateway\Referenced Assemblies.
Previously, it was required that a OneStream Business Rule developer invoking a remote Smart
Integration Function be aware of the data type returned and convert accordingly after the result is
returned.
The Smart Integration Connector Gateway now provides this type of information back to
OneStream and streamlines this conversion process using a newly added property called
ObjectResultValue, which is populated.
When invoking the same operation shown above that previously required the type to be
converted, a BR developer can do the following:
bytesFromFile = objRemoteRequestResultDto.ObjectResultValue
1. Remove all gateways under System > Administration > Smart Integration Connector.
TIP: Make a copy of the gateway name. You will use this name when creating the
gateway in a version 8.1.
2. After all the gateways are removed, remove all Custom Gateway Connections under
System > System Configuration > Application Server Configuration > Database
Server Connections > Custom.
a. Make a copy of the Database Server Name, Gateway, and Gateway Connection.
You will use these to recreate your Custom Gateway Connections in 8.1.
3. Uninstall the previous version of Smart Integration Connector Gateway from your
OneStream Windows Application Server completely.
4. After gateways and custom connections are removed, you can upgrade to 8.1.
5. After 8.1 is installed, you can follow the rest of this guide. Make sure you use the same
values you copied before removing the gateway and custom database connection.
NOTE: If you used any BR APIs, you will need to update them with Gateway in the
name. For example, if you used BRApi.Utilities.ExecRemoteRelayBusinessRule,
the new business rule name is BRApi.Utilities.ExecRemoteGatewayBusinessRule.
Likewise, any existing business rules specifying a DbProviderType as
DbProviderType.Relay needs to be migrated to DbProviderType.Gateway:
Example:
NOTE: While migrating, a VPN and Smart Integration Connector can be used in
tandem. This allows for A/B testing and validation prior to disconnecting the VPN
tunnel.
Establish and confirm connectivity for all your data sources including any □
supporting DLL files that need to be migrated.
Plan the setup and configuration through Smart Integration Connector for □
inventoried Data Sources. Determine connection type (Database or Direct)
for each Data Source.
Take inventory of what you currently use for example, business rules, □
dashboards, queries, grid views, drill-backs, and whitelisted endpoints for
each plan for any updates needed when using Smart Integration
Connector.
3. Export the gateway configuration and import this configuration to the Gateway Settings in
the OneStream Local Gateway Configuration.
b. Test any configured Data Sources to confirm they are communicating properly.
Note that testing direct connections may involve building test business rules to
perform proper validation.
When installation is complete, you can access remote data sources using business rules,
member formulas, or dashboard data adapters in OneStream through the Smart Integration
Connector.
Gateway Terms
The Smart Integration fields define the gateway. You can find more information about this below.
mysite.servicebus.windows.net.
IPv4 Whitelist Contains the list of IPs or CIDR addresses that are
allowed to transfer data via SIC.
Gateway Server Name This is the name of the gateway Server that the
gateway is associated with. Select an existing
gateway server or enter a new one.
Web API Key This is an editable field. You can change your key
(Database Connections only) as needed. If changed, it must also be changed in
the Smart Integration Connector Local Gateway
Server. It is designed to offer an additional layer of
protection within your network when invoking APIs
embedded in the Smart Integration Connector
Local Gateway Server. The purpose of the Web
API Key is to give you full control on who can
access the data sources in your network.
Bound Port in OneStream This is an optional customer defined port that can
be referenced in data management or business
(Direct Connections Only) rules to directly access services such as sFTP and
WebAPI. This must be a globally unique port in a
OneStream deployment per direct connection and
should be a TCP port number > 1024 and <65535.
When creating the gateway, use the default of -1
and OneStream will automatically assign an open
port.
Gateway failures reporting interval Minutes to wait between reporting gateway failures
(min) into the OneStream Error Log. The default is five
minutes and the max is 1440 minutes. If a gateway
is unreachable, an item is put in the error log using
this interval value in minutes and can be adjusted.
2. Copy the Smart Integration Connector Local Gateway Server installer to a Windows
Server within your environment.
3. Run the installer as an administrator. Accept all the default prompts. When completed, the
Local Gateway Server will be installed on your Windows Server.
3. Enter the Name and Description. For descriptions of the fields in steps 3-6, refer to the
Gateway Information section.
4. Select the Gateway Server from the drop-down, or enter a new Gateway Server name.
5. From Connection Type, select a Database Connection or Direct Connection. You will have
to enter different information depending on the connection type you select.
NOTE: The Gateway name cannot be changed once created and must be
deleted and re-created.
After you create a new gateway, you can complete the database connection by following these
steps:
1. From Connection Type, select Database Connection. For descriptions of the fields in
steps 1 and 2, refer to the Gateway Information section.
NOTE: The Web API Key is used as an additional layer of security when
communicating with the Smart Integration Connector Local Gateway Server
internal APIs. WebAPI keys are not required, but recommended to enhance
security and can be modified or added at anytime. The Local Gateway Service
introduces a WebAPI exposed only to OneStream and bound only to localhost on
the server it is deployed to. This WebAPI is inaccessible on the remote network. If
the Local Gateway Service is bound to other network interfaces, it's suggested to
use the WebAPI as a mechanism to enhance security on the remote network
preventing unauthorized use of OneStream WebAPIs.
The existence of a database connection does not necessarily mean it must be used
or configured if only Direct Connections are desired.
After you create a new gateway, you can configure the direct connection by following these steps:
1. From Connection Type, select Direct Connection (e.g, SFTP, WebAPI). For
descriptions of the fields in steps 1-4, refer to the Gateway Information section.
2. Enter the Bound Port at Gateway. This port represents the well-known TCP service to
expose from an on-premises host such as sFTP which would equate to port 22.
NOTE: Note that the remote service port is required to configure the
connection and may require consultation with network or IT resources to
obtain. It is also required that any firewalls between the Local Gateway Server
and the remote host allows traffic to the destination port specified.
3. Enter the Remote Gateway Host (for example, localhost). This represents the remote host
name or IP address accessible by the OneStream Smart Integration Connector Local
Gateway Server. If the host or IP address is accessible or resolvable from the OneStream
Smart Integration Connector Gateway service, or using remote resources accessible
through on-premises WAN, it can be exposed for use.
4. Enter a Bound Port in OneStream. It is recommended to use -1 for this value as the
OneStream application servers will locate an unused and available port to map to this
connection This port number must be globally unique across all application servers in a
OneStream deployment and care should be taken if a specific port is specified. This is the
port that is then used to access the remote host via business rules, data management jobs,
and so on. from OneStream application servers to allow network traffic to traverse to the
remote host and port.
5. Using this direct connection in OneStream is done by accessing localhost: [Bound Port In
OneStream] which will tunnel traffic back to the configured remote Gateway Host to the
configured bound port at gateway.
b. Bound Port in OneStream is configured as port 45000. Note that when -1 is used, the
selected port number is available/displayed after saving and also surfaced in the
OneStream Error Log.
c. In OneStream Business Rules, you can access the remote host by connecting to
localhost:45000.
d. In a OneStream Business Rule, this port can also be obtained in code allowing this
port number to be changed without updating Business Rules:
3. Click Export Gateway Configuration. The Gateway Configuration Details are copied to
the clipboard.
4. On your Windows Server, open the OneStream Local Gateway Configuration. This runs
as administrator by default.
8. Click Apply.
12. Click Yes to apply the changes and restart the Local Gateway Server.
3. You must re-export your Gateway Configuration and apply the new settings through the
OneStream Local Gateway Configuration.
4. Click OK.
2. Click to configure Local Gateway Connections details to set up the Data Sources to
local databases, APIs, or other on-premises resources.
5. Enter the Data Source Name, Connection String, and select a Database Provider. You
can add as many data sources as necessary. The Data Source Name must be unique for
each connection defined within a specific OneStream Smart Integration Connector Local
Gateway Server. Names can be re-used across deployed instances of the Windows
Service across your network. See the examples below for connection string examples to a
variety of relational data sources such as PostgreSQL, SQL, and ODBC, and Oracle.
Connection Strings are encrypted automatically. You can edit the plain text string by
clicking the ellipsis.
NOTE: The connection strings below include user IDs and passwords. If Integrated
security is desired, you can configure the OneStream Smart Integration Connector
Gateway Service to run under a specific service account versus saving usernames
and passwords in connection strings.
4. Connection String:
with UserID / Password: Data Source=localhost;Initial Catalog=Sales_DB;Persist Security
Info=True;User ID=sa;Password=*****;Max Pool Size=1000;Connect Timeout=60;
7. Click OK to save.
7. Click OK to save.
1. Go to the latest web page for Oracle .NET and Visual Studio ODAC Downloads for Oracle
Database.
2. After installation, the ODP.NET Provider will display as an available Database Provider in
the utility when adding a new data source.
3. The connection string for Oracle databases can be set up to either reference or require a
locally defined tnsnames.ora file for the requested data sources.
7. Click OK to save.
7. Click OK to save.
7. Click OK to save.
7. Click OK to save.
8. Click Save.
3. Navigate to the Connection String and use an Integrated or Trusted Security string. For
example: Data Source=localhost,Initial Catalog=OneStream_GolfStreamDemo_
2022;Trusted_Connection=True;
NOTE: Trusted Connections use the UserID and password you use to log into
the Windows Server.
NOTE: The example above is for SQL server. Trusted connections vary by
Data Provider type.
4. Click OK.
4. Click the Log On tab. Typically, this will default to the Local System account.
IMPORTANT: Before moving on to the next step, ensure that you have the
appropriate permissions and approvals from your IT Administrators to complete
the Log On change. You may need to access Microsoft SQL Server Management
Studio to verify permissions.
5. Change this from Local System account to This account and enter your domain and/or
login that has access to the datasource. Depending on how your SSO is configured, your
account could require your domain name, UserID, and password. Contact your IT
Administrator if you have questions on your account domain.
6. Click Apply.
7. Click OK.
NOTE: If the command window output does not proceed beyond the
"APIServiceHostController Start Relay API startup successful." line, this
indicates that the outbound traffic over port 443 to the Azure Relay is blocked.
Open the port to resolve this issue.
3. In the OneStream Windows Application client, refresh Gateway Details from System >
Administration > Smart Integration Connector > Your gateway.
l The Status change from Offline to Online. Additionally, status indicators turns green
on the side menu if the Gateway is Online, red if the Gateway is Offline, and yellow
if the Gateway is Offline but there is a newer version of the Local Gateway Server
available. See the second screenshot under this step for a close up of the indicators.
l The Version field will show the version of the running Smart Integration Connector
Gateway.
4. Press Enter twice on the keyboard to stop the service in the command window and then
close the command window.
The Smart Integration Connector Local Gateway Server can be installed on a separate Windows
Server to operate as a fail-over. The Local Gateway Server Gateway establishes connection to
the Relay that becomes the ac/primary Local Gateway Server instance while the second Local
Gateway Server environment remains idle until the primary goes offline. The second Local
Gateway Server Gateway would be the fail-over in this scenario and automatically accept traffic if
the primary server instance were to go offline.
1. a. Since the Data Source Connection Strings are encrypted, you will need to re-enter
the connection string for each Data Source.
d. Delete the encrypted text and replace it with a valid connection string from the
primary server.
e. Select OK to encrypt the connection string and close the dialog box.
NOTE: If the only fields displayed are Name and External Database
properties, verify that the current user is assigned to the
ManageSystemConfiguration role.
6. The Gateway Name drop-down menu will be populated with a list of configured Gateways.
Select the Gateway.
7. After the Gateway is selected, the Data Source Name drop-down menu populates with a list
of the Local Gateway Server Database Connections.
NOTE: If the remote data source is not displayed or the Gateway is offline,
you can select Custom to allow the data source to be manually specified.
Once you open a configuration file within the utility, open Local Application Data Settings.
You can:
l Reference a location to additional DLLs that will be used in remote business rules.
l Adjust the number of records returned. These are optional and are only defined if needed or
if further tuning is necessary by a consultant or as instructed by Support.
NOTE: If you are integrating with SAP, according to OneStream Platform version
8.0 and above, ERPConnect45.dll are not included by default. ERPConnect and
supporting DLLs will need to be added to your Referenced Assemblies Folder.
Refer to Support for SAP Integration .
This location path is used to locate Referenced Assemblies (DLLs) required to run remote Smart
Integration Functions. You will need to add the DLL name to the Smart Integration Functions
Referenced Assemblies property.
Defaults to 1000000 and defines the number of rows to return per page/block to OneStream APIs.
This value is used only when greater than the "Row Count to Begin Paging Operations" rows are
returned from a query. Example: If the query returns 3 million rows and Row Count to Begin
Paging is set to 1 million, there would be 3 blocks of 1 million rows returned to OneStream.
Defaults to 5000000 and is the maximum number of rows that can be returned from any one
query.
The maximum recommended number of records to return is 5 million and is the default. Additional
RAM/CPU resources would be required on the Smart Integration Connector Gateway Server and
on the remote database server to surface large quantities of data. If this limit is exceeded, you will
receive a "Smart Integration Connector Remote Query" error.
NOTE: Maximum Records and Row Counts Settings: When large data volumes are
returned (over 1000000 rows), to maintain performance and reliability, Smart
Integration Connector automatically transfers the data in pages.
NOTE: Smart Integration Connector has a threshold limit of 5 million rows and
5GB.
NOTE: It is strongly recommended that you review any queries that return more
than 1 million rows with your Database Administrator, because additional tuning
may be required. Tuning these queries will improve performance, reduce resource
usage, and make them more efficient.
Defaults to 1000000 and is the number of rows returned before the dataset is returned through
pages/blocks.
For example, the Configuration Parameter Name is sftpPassword. Sensitive information, such
as the password, is stored in the Configuration Parameter Value on the Local Gateway Server
and does not need to be stored in the OneStream Windows Application.
Then, in a business rule, you can reference the Configuration Parameter Name and do not need
to know the password or other sensitive information that is stored in the Configuration Parameter
Value. For example, in the following business rule the sftpPassword Configuration Parameter
Name is referenced. The GetSmartIntegrationConfigValue API can be used in a Smart Integration
Function to reference the Configuration Parameter Name, which may be needed in a business
rule to access a local data source.
Log Settings
The service uses Serilog for application-level logging and exposes options for controlling naming
convention, growth limits, and retention details. For example you can change the verbosity of log
messages by changing the minimum-level setting from Verbose to Informational. If a
catastrophic error happens, you can check the Windows event logs to review the errors. You can
edit the Log Settings from the OneStream Local Gateway Configuration Utility.
l File Size Limit in Bytes: The maximum size for the log file, in bytes, before creating a new
file for the day. The default is 20 MB.
l Roll On File Size Limit: When a log file reaches the specified number of bytes, a new log
file is generated.
l Retained File Count Limit: Number of log files to retain. If logs do not exceed the limit in
bytes (one file/day), this would allow for the configured value (with 40 days being the
default) of log retention. If the Smart Integration Service is used heavily and log files are set
to higher levels of verbosity, this could result in fewer days of log retention. Ensure that the
growth rate and retention periods align with your organizational requirements.
b. The Relay Name is the namespace of the Azure Relay. Add this namespace to your
firewall rules to restrict traffic from this Azure Relay. The namespace should have a
NOTE: The namespace will be different for your development and production
environments.
2. (Optional) Additionally, you can limit traffic further from an IP address by following these
Azure-specific instructions:
2. From the OneStream Windows Application client go to System > Administration > Smart
Integration Connector > Relay.
Examples
Data Adapters Example
1. Go to Application > Presentation > Dashboards > Workspaces > [choose
Workspace] > [choose Maintenance Unit] > Data Adapters.
3. Verify that the Database Location is External and the External Database Connection is
the custom connection that you defined earlier.
l External Database Connection is the custom connection that you defined earlier,
l Table Name is defined as the table you want to return data from.
4. Open the associated dashboard and run the query. The OneStream Smart Integration
Connector will connect to the external database. If it connects correctly, the query will
populate.
3. Open Connector.
NOTE: This example assumes that you have completed the setup and
installation process and configured a custom database connection in the
System Configuration as a Gateway type. Refer to Define Database Location
in OneStream for more information.
7. Enter the connection name. In this example, “Northeast Sales” is the Gateway Connection
Name as defined in the application configuration.
'Create a Connection string to the External Database (prior to using the gateway)
Private Function GetConnectionString(ByVal si As Sessioninfo, ByVal globals As BRGlobals,
ByVal api As Transformer) As String
Try
'Named External Connection
'-------------------------------------------
Return "Revenue Mgmt System"
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
If args.DrillCode.Equals(StageConstants.TransformationGeneral.DrillCodeDefaultValue,
StringComparison.InvariantCulturelgnoreCase) Then
'Source GL Drill Down
drillTypes.Add(New DrillBackTypeInfo(ConnectorDrillBackDisplayTypes.FileShareFile, New
NameAndDesc("InvoiceDocument","Invoice Document")))
drillTypes.Add(New DrillBackTypeInfo(ConnectorDrillBackDisplayTypes.DataGrid, New
NameAndDesc("MaterialTypeDetail","Material Type Detail")))
drillTypes.Add(New DrillBackTypeInfo(ConnectorDrillBackDisplayTypes.DataGrid, New
NameAndDesc("MaterialTypeDetail_Gateway","Material Type Detail (Smart Integration)")))
Else If args.DrillBackType.NameAndDescription.Name.Equals("MaterialTypeDetail",
StringComparison.InvariantCultureIgnoreCase) Then
'Level 1: Return Drill Back Detail
Dim dri1lBackSQL As String - GetDrillBackSQL_Ll(si, globais, api, args)
Dim drillBackInfo As New DrillBackResultInfo
drillBackInfo.DisplayType = ConnectorDrillBackDisplayTypes.OataGrid
drillBackInfo.DataTable = api.Parser.GetXFDataTableForSQLQuery(si, DbProviderType.SqlServer,
connectionstring. True, drillBackSQL, False, args.PageSize, args.PageNumber)
Return drillBacklnfo
Else If args.DrillBackType.NameAndDescription.Name.Equals("MaterialTypeDetail_Gateway",
StringComparison.lnvariantCultureIgnoreCase) Then
'Level 1: Return Drill Back Detail
Dim drillBackSQL As String = GetDrillBackSQL_Ll(si, globais, api, args)
Dim drillBackInfo As New DrillBackResultInfo
drillBackInfo.DisplayType = ConnectorDrillBackDisplayTypes.OataGrid
drillBackInfo.DataTable = api.Parser.GetXFDataTableForSQLQuery(si, DbProviderType.Gateway,
connectionstring_gateway. True, drillBackSQL, False, args.PageSize, args.PageNumber)
Return drillBacklnfo
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
Imports OneStream.Shared.Common
Imports OneStream.Shared.Database
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Wcf
Imports OneStream.Stage.Database
Imports OneStream.Stage.Engine
Namespace OneStream.BusinessRule.Extender.SIC_BulkCopyExample
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api
As Object, ByVal args As ExtenderArgs) As Object
Try
' SIC Gateway name
Dim sicGatewayName As String = "jl-db-achqa1-gateway"
' Compress data table before passing into remote business rule
Dim dtCompress As CompressionResult = CompressionHelper.CompressJsonObject
(Of DataTable)(si, dt, XFCompressionAlgorithm.DeflateStream)
Dim dtObj(2) As Object ' Create object to store arguments for remote business rule
dtObj(0) = dtCompress ' compressed datatable
dtObj(1) = "SIC_WriteBack" ' remote database table name
dtObj(2) = "RevenueMgmt" ' remote data source name
End If
(si,bulkRemoteResults.resultDataCompressed)
BRAPi.ErrorLog.LogMessage(si,returnedMsg)
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace
The Extensibility Rule above calls the following Smart Integration Function:
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports System.Data.SqlClient
Imports OneStream.Shared.Common
Imports OneStreamGatewayService
Namespace OneStream.BusinessRule.SmartIntegrationFunction.SIC_Functions
Public Class MainClass
' Function to bulk copy a compressed data table to a SQL database table
' Pass in compressed data table, database table name and data source name
Public Shared Function RunOperation(dtCompress As CompressionResult,tablename As String,
datasource As String) As String
' --------------------------------------------------------------------------------------
---------
' Get SQL connection string
Dim connString As String = APILibrary.GetRemoteDataSourceConnection(datasource)
End Using
End Using
Else
Throw New Exception("Problem uncompressing data in SIC gateway")
End If
End Function
End Class
End Namespace
NOTE: You must have an sFTP server available on a port. The port must be
allowed for inbound and outbound connections on the Local Gateway Server. For
this example, we have used port 22.
1. Login to OneStream.
3. Create a New Gateway and fill out all of the corresponding details for your Gateway and the
Gateway Server.
6. For Remote Gateway Host, enter the IP address or resolvable host name of the machine
where your SFTP server is located.
7. For Bound Port in OneStream, enter -1 to automatically assign an unused port number.
You can also specify your own port number by entering a value greater than 1024 and less
than 65535. It is recommended to use a higher value because it is less likely that number
will be in use as this port number must be globally unique across all applications hosted on
the OneStream servers.
8. Click OK.
9. Copy the Gateway to the OneStream Smart Integration Connector Local Gateway
Server Configuration.
10. Save the Local Gateway Server configuration and restart the Smart Integration Connector
Gateway service.
NOTE: You will need to add WinSCPnet.DLL to your business rule Referenced
Assemblies from the Properties tab in the business rule.
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
Imports OneStream.Shared.Common
Imports OneStream.Shared.Database
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Wcf
Imports OneStream.Stage.Database
Imports OneStream.Stage.Engine
Imports WinSCP
Namespace OneStream.BusinessRule.Extender.SFTP_Example
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api
As Object, ByVal args As ExtenderArgs) As Object
Try
session.Open(sessionOptions)
' Download
fileDNpath = fileDNPath & "\SFTP_TEST_DOWNLOAD.txt"
transferResult = session.GetFiles("\SFTP_TEST_DOWNLOAD.txt", fileDNpath, False,
transferOptions)
End Using
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
Return Nothing
End Try
End Function
End Class
End Namespace
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using System.IO;
using System.Linq;
namespace OneStream.BusinessRule.SmartIntegrationFunction.TestFileRead
{
public class MainClass
{
public byte[] RunOperation(string year)
{
string fname = @"c:\temp\hw_" + year + ".csv";
byte[] buffer = System.IO.File.ReadAllBytes(fname);
return buffer;
}
}
}
Imports System
Imports System.Data
Imports System.Data.Common
Imports System.IO
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Linq
Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Imports OneStream.Shared.Common
Imports OneStream.Shared.Wcf
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Database
Imports OneStream.Stage.Engine
Imports OneStream.Stage.Database
Imports OneStream.Finance.Engine
Imports OneStream.Finance.Database
Namespace OneStream.BusinessRule.Extender.ProcessRemoteFileData
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api
As Object, ByVal args As ExtenderArgs) As Object
Try
Dim stepNumber As String = "1"
Case Is = "1"
GetData(si)
Return Nothing
Case Is = "2"
CleanupData(si)
Return Nothing
End Select
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
Return Nothing
End Function
End Sub
' This is where you can allow caching of the remote function. We are passing
in true at the end to force the cache to be updated
' We are also allowing the function to run for 90 seconds.
' String.empty means this will look for a remote function/method called
"RunOperation"
Dim objRemoteRequestResultDto As RemoteRequestResultDto =
BRApi.Utilities.ExecRemoteGatewayBusinessRule(si, "TestFileRead", argTest,
"ryantestconnection2", String.Empty,"TestFileRead", True, 90)
If (objRemoteRequestResultDto.RemoteResultStatus =
RemoteMessageResultType.RunOperationReturnObject) Then
Dim bytesFromFile As Byte()
bytesFromFile = objRemoteRequestResultDto.ObjectResultValue
Dim valueAsString As String = System.Text.Encoding.UTF8.GetString
(bytesFromFile)
Return valueAsString
bytesFromFile = Convert.FromBase64String
(objRemoteRequestResultDto.ObjectResultValue)
'bytesFromFile = objRemoteRequestResultDto.ObjectResultValue
End Class
End Namespace
5. Test your Extender Business Rule via the Execute Extender button in the toolbar.
Direct connections are preferred for this method and can be invoked using business rules within
OneStream similar to the sFTP example provided above.
See Multiple WebAPI Connections for best practices on scenarios with multiple WebAPIs.
2. Export the Configuration and import to your Local Gateway Server. See the Export and
Import the Gateway Configuration section for more information on this process.
IMPORTANT: Copy your Bound Port in OneStream. You will reference this later
in the extensibility rule.
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using System.IO;
using System.Linq;
using OneStream.Shared.Common;
using OneStream.Shared.Database;
using OneStream.Shared.Engine;
using OneStream.Shared.Wcf;
using System.Net;
using System.Net.Http;
using Newtonsoft.Json;
using System.Net.Http.Headers;
namespace OneStream.BusinessRule.Extender.SIC_WebAPI
{
public class MainClass
{
private static readonly HttpClient internalHttpClient = new HttpClient();
public object Main(SessionInfo si, BRGlobals globals, object api, ExtenderArgs args)
{
try
{
internalHttpClient.DefaultRequestHeaders.Accept.Clear();
internalHttpClient.DefaultRequestHeaders.Accept.Add
(new MediaTypeWithQualityHeaderValue("application/json"));
internalHttpClient.DefaultRequestHeaders.Accept.Add
(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
internalHttpClient.DefaultRequestHeaders.Accept.Add
(new MediaTypeWithQualityHeaderValue("application/octet-stream"));
internalHttpClient.DefaultRequestHeaders.Accept.Add
(new MediaTypeWithQualityHeaderValue("text/plain"));
internalHttpClient.DefaultRequestHeaders.Accept.Add
(new MediaTypeWithQualityHeaderValue("*/*"));
// In this example, 20540 is the Bound Port in OneStream for the Gateway being
used.
var stringTask = internalHttpClient.GetStringAsync
("https://localhost:20540/v1/forecast?latitude=40.73&longitude=-73.94&daily=temperature_2m_
max,temperature_2m_min&temperature_unit=fahrenheit&timezone=America%2FNew_York");
5. Compile and test the business rule. If the extensibility ran successfully, you should see the
correct data that corresponds with the business rule in the Exception dialog box:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using Newtonsoft.Json;
using System.Net.Http.Headers;
namespace OneStream.BusinessRule.SmartIntegrationFunction.RemoteWebAPISample
{
public class MainClass
{
private static readonly HttpClient internalHttpClient = new HttpClient();
static MainClass()
{
internalHttpClient.DefaultRequestHeaders.Accept.Clear();
internalHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue
("application/json"));
internalHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue
("application/x-www-form-urlencoded"));
internalHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue
("application/octet-stream"));
internalHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue
("text/plain"));
internalHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue
("*/*"));
}
(https://localhost:44388/WeatherForecast);
return dt;
}
}
}
3. The file path under Referenced Assemblies Folder opens to the default location.
See the following SAP example for this process in use. See Smart Integration Connector Settings
for more information on these fields.
To get started:
1. From the Platform page of the Solution Exchange, download the DLL Packages, which
contains the ERPConnectStandard20.dll file.
4. From SAP, download and copy SAP NetWeaver RFC Library DLL (sapnwrfc.dll) and
associated icudt50.dll, icuin50.dll, icuuc50.dll to your Referenced Assemblies Folder. See
Theobald Software ERPConnect Requirements for additional information.
Business Rules
The Smart Integration Connector Capabilities introduce additional business rule APIs (BR APIs)
to allow for execution and management of remote business rules inside the context of the Smart
Integration Connector gateway. These rules are transported using https to the Smart Integration
Connector local gateway, compiled locally, executed, and the results returned to the caller for
further processing. They provide a mechanism for complex drill backs, data processing scenarios
or to invoke remote webAPIs hosted in your network.
NOTE: Gateways must have a local data source defined to invoke remote business
rules.
There are two ways business rules can be used with the Smart Integration Connector Gateway:
l OneStream BRAPIs interact with a specific local gateway and run on OneStream
application servers.
l Business rules that reference DLLs that are only accessible by the Local Gateway Server.
These BRs are compiled and executed on the local gateway (Remote Business Rules
when creating them in the Windows Desktop Client).
In these scenarios, the local gateway must have the allowRemoteCodeExec setting configured to
True to enable remote execution.
ExecRemoteGatewayRequest
ExecRemoteGatewayCachedBusinessRule
ExecRemoteGatewayJob
ExecRemoteGatewayBusinessRule
GetRemoteDataSourceConnection
GetRemoteGatewayJobStatus
GetSmartIntegrationConfigValue
GetGatewayConnectionInfo
ExecRemoteGatewayRequest
Initiates a request to a local gateway as specified in the remote request object. This request is
dispatched to the Smart Integration Connector local gateway connection data source with the
specified command remote invoked.
NOTE: This method is used for request and response type interactions to a remote
endpoint that runs for three or less minutes. The default execution timeout is 90
seconds and can be overridden by setting the CommandTimeout property on the
RemoteRequestDTO instance provided.
Parameter details:
l RemoteRequestDTO: Remote request object populated with the remote command and
endpoint
Following is an example connector business rule that would run on the OneStream application
server sending a remote request and block of code to a Local Gateway Connection:
This BR API can also be used to invoke arbitrary SQL commands against a Smart Integration
Connector local gateway connection data source at your site:
Else
If (Not (objRemoteRequestResultDto.remoteException Is Nothing)) Then
Throw ErrorHandler.LogWrite(si, New XFException(si,
objRemoteRequestResultDto.remoteException))
End If
End If
ExecRemoteGatewayCachedBusinessRule
When a cache flag and key is provided to the ExecRemoteGatewayBusinessRule BR API, this
method is used to invoke a previously cached method. This is intended to be used for high-
frequency remote business rules to avoid the performance impact of recompiling a remote
method on each invocation.
Parameter details:
l remoteHost: Name of remote host to invoke operation. (Smart Integration Connector Local
Gateway Name)
try
{
// Caches a SIC BR called GetDataFromDB on SIC Gateway called TestConnection
// and caches the function with the name GetDataFromDB with a cache key of GetDataFromDBCached
RemoteRequestResultDto objRemoteRequestResultDto = BRApi.Utilities.ExecRemoteGatewayBusinessRule
(si, "GetDataFromDB", null, "TestConnection", "RunOperation", " GetDataFromDBCached ", false, 90);
if (objRemoteRequestResultDto.RemoteResultStatus == RemoteMessageResultType.Success
&& objRemoteRequestResultDto.ResultSet != null
&& objRemoteRequestResultDto.ResultType == RemoteResultType.DataTable)
{
else
{
if (objRemoteRequestResultDto.RemoteException != null)
{
throw ErrorHandler.LogWrite(si, new XFException(si, objRemoteRequestResultDto.RemoteException));
}
else
{
BRApi.ErrorLog.LogMessage(si, "Remote Smart Integration Function Succeeded - no data/datatable
returned");
}
}
// Subsequent invocations of the remote BR can be run by specifying the endpoint and the cached
key name
RemoteRequestResultDto objRemoteRequestResultDtoCached =
BRApi.Utilities.ExecRemoteGatewayCachedBusinessRule(si, " GetDataFromDBCached",null, "
TestConnection ", 90);
return null;
}
catch (Exception ex)
{
throw ErrorHandler.LogWrite(si, new XFException(si, ex));
}
'Here we are telling it to specifically call a remote Smart Integration function called
'TestFileread at a remote gateway called TestConnection and caching the compiled
'result as a key called TestFileReadCache with a 90 second timeout
Dim objRemoteRequestResultDto As RemoteRequestResultDto =
BRApi.Utilities.ExecRemoteGatewayBusinessRule(si, "TestFileRead", argTest, " TestConnection ",
"DeleteOldFileData","TestFileReadCache", false, 90)
If (objRemoteRequestResultDto.RemoteResultStatus =
RemoteMessageResultType.RunOperationReturnObject) Then
ExecRemoteGatewayJob
There may be instances where a remote operation on the Smart Integration Connector Local
Gateway host would need to process and assemble data that may take several minutes to run. In
this situation, you could use this BR API to queue and run a remote business rule in an
asynchronous manner where the remote Smart Integration Connector Local Gateway host
returns a Job ID (GUID) that can later be used to obtain the job’s status or the results if the job is
complete. When invoking this method, if the RemoteMessageResultStatus is returned as
JobRunning (as shown in the example below), the RequestJobID is populated with the ID of the
queued job that can later be used to obtain status.
Here is a basic overview of invoking a remote job and displaying the returned remote Job ID in
VB.NET.
NOTE: This is required to call back into GetRemoteJobStatus with the returned ID
to obtain the result:
argTest(0) = 100
argTest(1) = "test"
Here is the rule in VB.NET to invoke a job, obtain the job ID, and 'poll' until completion:
Try
Dim jobID As Guid
‘ Invoking a long-running Job with a Smart Integration Function called GetDataFromDB on SIC Gateway
called testConneciton
Dim objRemoteRequestResultDto As RemoteRequestResultDto = BRApi.Utilities.ExecRemoteGatewayJob
(si, "GetDataFromDB", Nothing, "TestConnection",String.Empty)
' If Successful, the status is retuned indicating the job is running with the job ID – Use this
ID to interrogate if the job is compleed.
If (objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.JobRunning)
Then
jobID = objRemoteRequestResultDto.RequestJobID
BRApi.ErrorLog.LogMessage(si, "Remote Job Queued and Running - JobID: " & jobID.ToString())
If (objJobStatus.RemoteJobState = RemoteJobState.Running)
BRApi.ErrorLog.LogMessage(si, "Remote Job Still running - JobID: " & jobID.ToString())
Else If (objJobStatus.RemoteJobState = RemoteJobState.Completed)
Return Nothing
End If
Else If (objJobStatus.RemoteJobState = RemoteJobState.JobNotFound)
BRApi.ErrorLog.LogMessage(si, "Remote Job Not Found - JobID: " & jobID.ToString())
Return Nothing
Else If (objJobStatus.RemoteJobState = RemoteJobState.RequestTimeOut)
BRApi.ErrorLog.LogMessage(si, "Remote Job Timed Out - JobID: " & jobID.ToString())
Return Nothing
Else If (objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.Exception)
BRApi.ErrorLog.LogMessage(si, "Exception During Exeuction of Job: " &
objRemoteRequestResultDto.RemoteException.ToString())
End If
Next
Else
' Exception occurred immediately during compile/initial run
If (objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.Exception)
BRApi.ErrorLog.LogMessage(si, "Exception Executing Job: " &
objRemoteRequestResultDto.RemoteException.ToString())
Else
BRApi.ErrorLog.LogMessage(si, "General Job Execution Error - State: " &
objRemoteRequestResultDto.RemoteResultStatus.ToString())
End If
End If
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
Here is the rule in C# to invoke a job, obtain the job ID, and 'poll' until completion:
try
{
Guid jobID;
RemoteRequestResultDto objRemoteRequestResultDto = BRApi.Utilities.ExecRemoteGatewayJob(si,
"GetDataFromDB", null, " TestConnection ",string.Empty);
if (objRemoteRequestResultDto.RemoteResultStatus == RemoteMessageResultType.JobRunning)
{
jobID = objRemoteRequestResultDto.RequestJobID;
BRApi.ErrorLog.LogMessage(si, "Remote Job Queued and Running - JobID: " + jobID.ToString());
if (objJobStatus.RemoteJobState == RemoteJobState.Running)
{
BRApi.ErrorLog.LogMessage(si, "Remote Job Still running - JobID: " + jobID.ToString());
}
else if (objJobStatus.RemoteJobState == RemoteJobState.Completed)
{
// Checking the return type from the remote job
if (objJobStatus.RemoteJobResult.ResultSet != null)
{
XFDataTable xfDT = new XFDataTable(si,objJobStatus.RemoteJobResult.ResultSet,null,1000);
BRApi.ErrorLog.LogMessage(si, "Remote Job Completed - Datatable Returned - JobID: " +
jobID.ToString());
return null;
}
else if (objJobStatus.RemoteJobResult.ResultDataSet != null)
{
XFDataTable xfDT = new XFDataTable
(si,objJobStatus.RemoteJobResult.ResultDataSet.Tables[0],null,1000);
BRApi.ErrorLog.LogMessage(si, "Remote Job Completed - Dataset Returned - JobID:
" + jobID.ToString());
return null;
}
else if (objJobStatus.RemoteJobResult.ObjectResultValue !=null)
{
BRApi.ErrorLog.LogMessage(si, "Remote Job Completed - Object Returned -
JobID: " + jobID.ToString());
return null;
}
else if (objJobStatus.RemoteJobState == RemoteJobState.JobNotFound)
{
BRApi.ErrorLog.LogMessage(si, "Remote Job Not Found - JobID: " +
jobID.ToString());
return null;
}
else if (objJobStatus.RemoteJobState == RemoteJobState.RequestTimeOut)
{
BRApi.ErrorLog.LogMessage(si, "Remote Job Timed Out - JobID: " + jobID.ToString());
return null;
}
else if (objRemoteRequestResultDto.RemoteResultStatus ==
RemoteMessageResultType.Exception)
{
BRApi.ErrorLog.LogMessage(si, "Exception During Exeuction of Job: "+
objRemoteRequestResultDto.RemoteException.ToString());
return null;
}
}
}
// End for loop
}
else
{
// Exception occurring immediately during compile/initial run
if (objRemoteRequestResultDto.RemoteResultStatus == RemoteMessageResultType.Exception)
BRApi.ErrorLog.LogMessage(si, "Exception Executing Job: " +
objRemoteRequestResultDto.RemoteException.ToString());
else
BRApi.ErrorLog.LogMessage(si, "General Job Execution Error - State: " +
objRemoteRequestResultDto.RemoteResultStatus.ToString());
return null;
}
}
catch (Exception ex)
{
throw ErrorHandler.LogWrite(si, new XFException(si, ex));
}
return null;
ExecRemoteGatewayBusinessRule
This is a core BR API that can be used to remotely invoke Smart Integration functions on a
specified remote Smart Integration Connector Local Gateway host. The Smart Integration
Connector Local Gateway must have allowRemoteCodeExec set to True for this BR API to invoke
an operation successfully, otherwise the Smart Integration Connector Local Gateway host returns
a result indicating that remote code execution is disabled.
This method takes a previously authored Smart Integration function, written in VB.NET or C#, in
the OneStream application and passes it to the remote host for execution. With this BR API, it is
expected that remote calls should take no more than 2-3 minutes to return a result to the caller as
this BR API will block until a result is returned. If longer running or sync operations are needed,
consider using the execRemoteGatewayJob BR API.
Parameter details:
l brName: Name of the locally defined (within the OneStream Application scope) Smart
Integration function
l remoteHost: Name of remote host to invoke operation. (Smart Integration Connector name)
l functionName: Name of the function in the Smart Integration function to invoke. If null or
empty, a function/method with the name RunOperation is expected to exist within the
authored code.
l executionTimeOut: Timeout (in seconds) on the remote job (In 7.4, this is now an optional
parameter and defaults to 90 seconds if the parameter is missing.)
Here is a VB.NETdrill-back example that invokes a remote business rule accepting 2 parameters:
'Remote Smart Integration Function Signature: ' Public Shared Function RunOperation2(testval As
Integer, teststr As String) As ArrayList
If (objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.RunOperationReturnObject)
Then
Dim returnVal As System.Collections.ArrayList returnVal =
objRemoteRequestResultDto.ObjectResultValue
'Simple demonstration without error checking to look at the first element of the arraylist
drillbackinfo.TextMessage =
"Completed! " & returnVal(0).ToString() drillBackInfo.DisplayType =
ConnectorDrillBackDisplayTypes.TextMessage
Return drillBackInfo
Else If (objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.Success)
' Demonstrating a 'pattern' whereby the caller can verify what the type is that's returned and
handle properly.
Dim xfDT = New XFDataTable(si,objRemoteRequestResultDto.resultSet,Nothing,1000)
drillBackInfo.DataTable = xfDT
drillBackInfo.DisplayType = ConnectorDrillBackDisplayTypes.DataGrid
Return drillBackInfo
Else If (Not (objRemoteRequestResultDto.remoteException Is Nothing)) Then
Throw ErrorHandler.LogWrite(si, New XFException(si,objRemoteRequestResultDto.remoteException))
End If
Return Nothing
End If
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Data.SqlClient;
using OneStreamGatewayService;
namespace OneStream.BusinessRule.SmartIntegrationFunction.GetDataFromDB
{
public class MainClass
{
public DataTable RunOperation()
{
DataTable dataTableResults = new DataTable();
string connectionString, sql;
// The API Below is only available in 7.4 and allows the ability to
// Obtain a remotely defined connection string.
connectionString = APILibrary.GetRemoteDataSourceConnection("RevenueMgmt");
SqlConnection conn;
conn = new SqlConnection(connectionStringconn.Open();
sql = "Select * FROM InvoiceMaterialDetail";
SqlCommand cmd = new SqlCommand(sql, conn);
var dbreader = cmd.ExecuteReader();
dataTableResults.Load(dbreader);
return dataTableResults;
}
}
}
'Here we are telling it to specifically call a remote Smart Integration Function called
TestFileRead at SIC Gateway
'called TestConnection with a method called DeleteOldFileData
Dim objRemoteRequestResultDto As
RemoteRequestResultDto = BRApi.Utilities.ExecRemoteGatewayBusinessRule(si, "TestFileRead",
argTest, "TestConnection", "DeleteOldFileData")
If (objRemoteRequestResultDto.RemoteResultStatus =
RemoteMessageResultType.RunOperationReturnObject) Then
'The delete method returns a true/false return type
'Previous to v7.4, The result was returned in a compressed format and it is required that
'InfateJsonObject was invoked
'result = CompressionHelper.InflateJsonObject(Of Object)
'(si,objRemoteRequestResultDto.resultDataCompressed)
try
{
object[] argTest = new object[1];
argTest[0] = "2023";
'Here we are telling it to specifically call a remote Smart Integration Function called
TestFileRead at SIC Gateway
'called TestConnection with a method called DeleteOldFileData
RemoteRequestResultDto objRemoteRequestResultDto =
BRApi.Utilities.ExecRemoteGatewayBusinessRule(si, "TestFileRead", argTest, " TestConnection",
"DeleteOldFileData");
if (objRemoteRequestResultDto.RemoteResultStatus ==
RemoteMessageResultType.RunOperationReturnObject
&& objRemoteRequestResultDto.ObjectResultValue != null)
bool result;
return null;
catch (Exception ex)
throw ErrorHandler.LogWrite(si, new XFException(si, ex))
End Try
try
{
// Here we are telling it to specifically call a remote Smart Integration Function called
GetDataFromDB at SIC Gateway called TestConnection with a method called RunOperation
RemoteRequestResultDto objRemoteRequestResultDto = BRApi.Utilities.ExecRemoteGatewayBusinessRule
(si, "GetDataFromDB", null, "TestConnection", "RunOperation");
if (objRemoteRequestResultDto.RemoteResultStatus == RemoteMessageResultType.Success
&& objRemoteRequestResultDto.ResultSet != null
&& objRemoteRequestResultDto.ResultType == RemoteResultType.DataTable)
{
return null;
}
catch (Exception ex)
{
throw ErrorHandler.LogWrite(si, new XFException(si, ex));
}
GetRemoteDataSourceConnection
This remote business rule will return the connection string associated with a Local Gateway
Configuration Data Source.
Parameter details:
l Data Source: The name of the Local Gateway Configuration Data Source.
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Namespace OneStream.BusinessRule.SmartIntegrationFunction.GetRemoteDataSource_VB
Public Class MainClass
Public Shared Function RunOperation() As DataTable
Dim dataTableResults As New DataTable
Return dataTableResults
End Function
End Class
End Namespace
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Data.SqlClient;
namespace OneStream.BusinessRule.SmartIntegrationFunction.GetRemoteDataSourceSample
{
public class MainClass
{
public DataTable RunOperation()
{
DataTable dataTableResults = new DataTable();
return dataTableResults;
}
}
}
GetRemoteGatewayJobStatus
This BR API returns the status or the results of a previously remotely queued job invoked against
a specified Smart Integration Connector Local Gateway host.
Parameter details:
l remoteHost: Name of remote host to invoke operation (Smart Integration Connector Name)
The sample below invokes a job as part of a data management job inside a OneStream
extenderrule. The example demonstrates a simple Smart Integration Function that sleeps 2
seconds 1000 times in a loop simulating a long running task. The corresponding extender rule
illustrates how this long running function can be invoked as a job, returning a job ID and
subsequently polled until it's completed.
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports System.Threading
Namespace OneStream.BusinessRule.SmartIntegrationFunction.LongRunningTest
Public Class MainClass
Public Shared Function RunOperation() As DataTable
For i As Integer = 1 To 1000
thread.Sleep (2000)
Next
Table1.Columns.Add(column1)
Table1.Rows.Add(result)
Return Table1
End Function
End Class
End Namespace
It would be typical to invoke long running jobs as part of a Data management/Extender Rule and
the code below is an example on how this could be accomplished inVB.NET:
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal
args As ExtenderArgs) As Object
Try
Dim jobID As Guid
Dim objRemoteRequestResultDto As RemoteRequestResultDto = BRApi.Utilities.ExecRemoteGatewayJob
(si, "LongRunningTest", Nothing, "testConnection",String.Empty)
"testconnection2")
If (objJobStatus.RemoteJobState = RemoteJobState.Running)
BRApi.ErrorLog.LogMessage(si, "Remote Job Still running - JobID: " & jobID.ToString())
Else If (objJobStatus.RemoteJobState = RemoteJobState.Completed)
' Checking the return type from the remote job
If (Not objJobStatus.RemoteJobResult.ResultSet Is Nothing) Then
Dim xfDT = New XFDataTable(si,objJobStatus.RemoteJobResult.ResultSet,Nothing,1000)
BRApi.ErrorLog.LogMessage(si, "Remote Job Completed - Datatable Returned - JobID: " & jobID.ToString
())
Return Nothing
Else If (Not objJobStatus.RemoteJobResult.ResultDataSet Is Nothing)
Then Dim xfDT = New XFDataTable(si,objJobStatus.RemoteJobResult.ResultDataSet.Tables
(0),Nothing,1000)
BRApi.ErrorLog.LogMessage(si, "Remote Job Completed - Dataset Returned - JobID: " & jobID.ToString
()) Return Nothing
Else If (Not objJobStatus.RemoteJobResult.ObjectResultValue Is Nothing) Then
BRApi.ErrorLog.LogMessage
(si, "Remote Job Completed - Object Returned - JobID: " & jobID.ToString())
Return Nothing
End If
Else If (objJobStatus.RemoteJobState = RemoteJobState.JobNotFound) BRApi.ErrorLog.LogMessage
(si, "Remote Job Not Found - JobID: " & jobID.ToString()) Return Nothing
Else If (objJobStatus.RemoteJobState = RemoteJobState.RequestTimeOut) BRApi.ErrorLog.LogMessage
(si, "Remote Job Timed Out - JobID: " & jobID.ToString()) Return Nothing
Else If (objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.Exception)
BRApi.ErrorLog.LogMessage(si, "Exception During Exeuction of Job: " &
objRemoteRequestResultDto.RemoteException.ToString())
End If
Next
Else ' Exception occuring immediately during compile/initial run
If (objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.Exception)
BRApi.ErrorLog.LogMessage(si, "Exception Executing Job: " &
objRemoteRequestResultDto.RemoteException.ToString())
Else
BRApi.ErrorLog.LogMessage(si, "General Job Execution Error - State: " &
objRemoteRequestResultDto.RemoteResultStatus.ToString())
End If
End If
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
GetSmartIntegrationConfigValue
This BR API allows access to the Local Gateway Local Application Data Settings. Accessing the
remotely stored secret or customer-defined configuration values is done using a new "Remote"
equivalent of the BR API namespace. This feature can be used to:
l Store credentials to network resources allowing the developer of remote business rules to
reference values stored in the configuration file instead of having them hard-coded and
viewable by anyone with permission to edit a business rule.
These configuration values are defined and edited using the Smart Integration Connector Local
Gateway Configuration Utility. The API used to obtain these values is demonstrated in the full
business rule example below:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Data.SqlClient;
namespace OneStream.BusinessRule.SmartIntegrationFunction.GetRemoteDataSourceSample
{
public class MainClass
{
public DataTable RunOperation()
{
DataTable dataTableResults = new DataTable();
return dataTableResults;
}
}
}
Imports System
Imports System.Data
Imports System.Data.Common
Imports System.IO
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Linq
Imports Microsoft.VisualBasic
Imports OneStream.Shared.Wcf
Imports OneStreamGatewayService
Namespace OneStream.BusinessRule.SmartIntegrationFunction.SecretTester
GetGatewayConnectionInfo
From a OneStream business rule, you can invoke this API to obtain gateway details such as:
l RemoteGatewayPortNumber: Bound Port at Gateway, the port of the remote service this
direct connection is associated with.
l RemoteGatewayHost: Name of the remote host associated with the direct connection.
This API is useful for direct connections where the port number is required before connecting to
remote services such as sFTP or remote Web APIs because each endpoint defined in OneStream
to Smart Integration Connector Local Gateways has a different port number and would need to be
known by the business rule developer at design time. This API makes it easy to look up the
remote port by knowing the name of the direct connection defined in OneStream. It returns other
useful information outlined below:
sessionOpts.PortNumber = objGatewayDetails.OneStreamPortNumber
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
Imports OneStream.Shared.Common
Imports OneStream.Shared.Database
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Wcf
Imports OneStream.Stage.Database
Imports OneStream.Stage.Engine
Imports WinSCP
Namespace OneStream.BusinessRule.Extender.SFTP_Example
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api
As Object, ByVal args As ExtenderArgs) As Object
Try
' Download
fileDNpath = fileDNPath & "\SFTP_TEST_DOWNLOAD.txt"
transferResult = session.GetFiles("\SFTP_TEST_DOWNLOAD.txt", fileDNpath, False,
transferOptions)
transferResult.Check()
End Using
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
Return Nothing
End Try
End Function
End Class
End Namespace
l CreateSAPConnection
l BRApi.Database.SaveCustomDataTable
If you attempt to use these business rules you will run into an error.
Troubleshooting
This section provides help on addressing errors in Smart Integration Connector.
Error Log
To view the error log, click System > Logging > Error Log.
Every five minutes, by default, the Smart Integration Connector tries to connect to an established
Smart Integration Connector local gateway from each application server used in a deployment. If
the gateway is unable to connect, it times out and adds an error to the error log. These errors are
recorded in the OneStream error log along with other errors related to the OneStream application.
You can configure the interval at which OneStream application servers monitor this gateway from
1 minute to 1440 minutes (1 day) to reduce the volume of logged failures for infrequently online
test or validation environments.
NOTE: It is recommended to increase the time intervals for queries that run longer
than five minutes. For example, if you have a query that runs ten minutes long, you
need to set your time interval to above ten minutes (such as fifteen minutes). Time
intervals can be adjusted from System > Smart Integration Connector > Your
connection > Gateway failures reporting interval (min).
Common Errors
Memory Issues
If you receive any of the following errors, increase the memory in your Smart Integration
Connector Local Gateway Server. For queries returning over 1 million records, 32 GB or more
RAM is recommended.
l "Error while copying content to a stream. Received an unexpected EOF or 0 bytes from the
transport stream."
l "An error occurred while sending the request. The response ended prematurely."
Example:
You must comment out the following line <!--<add name="Oracle Data Provider for .NET"
invariant="Oracle.DataAccess.Client" description=".Net Framework Data Provider for Oracle"
type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess" />--> when editing
your OneStreamLocalGatewayConfiguration.exe.config to resolve this error.
<DbProviderFactories>
<add name="Npgsql Data Provider" invariant="Npgsql" description="Data Provider for
PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework
Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
<!--<add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client"
description=".Net Framework Data Provider for Oracle"
type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess" />-->
Namespace OneStream.BusinessRule.SmartIntegrationFunction.DataTableTest
Public Class MainClass
Public Shared Function RunOperation(ByVal dt As DataTable) As String
Dim log As New System.Text.StringBuilder
log.AppendLine(system.DateTime.Now.ToString & " successfully opened connection. Bulk
inserting " & dt.Rows.Count & " rows")
Return log.ToString
End Function
End Class
End Namespace
When this method is invoked with a datatable passed from a OneStream BR, an error as
presented below will be emitted into the ErrorLog:
l at System.Text.Json.Serialization.Converters.UnsupportedTypeConverter`1.Write
(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
l at
System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson
(Object obj, WriteStack& state, Utf8JsonWriter writer)
l at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite
(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
l at System.Text.Json.Serialization.JsonConverter`1.TryWriteAsObject(Utf8JsonWriter
writer, Object value, JsonSerializerOptions options, WriteStack& state)
l at System.Text.Json.Serialization.Converters.IEnumerableConverter`1.OnWriteResume
(Utf8JsonWriter writer, TCollection value, JsonSerializerOptions options, WriteStack&
state)
l at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryWrite(Utf8JsonWriter
writer, TCollection value, JsonSerializerOptions options, WriteStack& state)
l at
System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson
(Object obj, WriteStack& state, Utf8JsonWriter writer)
l at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite
(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
l at System.Text.Json.Serialization.JsonConverter`1.TryWriteAsObject(Utf8JsonWriter
writer, Object value, JsonSerializerOptions options, WriteStack& state)
l at System.Text.Json.Serialization.Converters.ArrayConverter`2.OnWriteResume
(Utf8JsonWriter writer, TElement[] array, JsonSerializerOptions options, WriteStack& state)
l at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryWrite(Utf8JsonWriter
writer, TCollection value, JsonSerializerOptions options, WriteStack& state)
l at System.Text.Json.Serialization.JsonConverter`1.TryWriteAsObject(Utf8JsonWriter
writer, Object value, JsonSerializerOptions options, WriteStack& state)
l at System.Text.Json.Serialization.Converters.ArrayConverter`2.OnWriteResume
(Utf8JsonWriter writer, TElement[] array, JsonSerializerOptions options, WriteStack& state)
l at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryWrite(Utf8JsonWriter
writer, TCollection value, JsonSerializerOptions options, WriteStack& state)
l at
System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson
(Object obj, WriteStack& state, Utf8JsonWriter writer)
l at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite
(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
In certain cases, if you receive the error "The method or operation is not implemented" then you
can use a remote business rule to transfer data. This occurs when returning the varbinary(max)
datatype.
3. Select Stop.
Communication Error
If you see the following error in the Windows Service Log, it means that you have a mismatched
WebAPIKey. This could occur if the WebAPI key is changed in OneStream and the configuration
for the Smart Integration Local Gateway service is not exported from OneStream and re-imported
into the Local Gateway Server service using the configuration utility.
You can resolve this error by matching the WebAPIKey in the configuration utility.
A connection was successfully established with the server, but then an error occurred during the
login process. (provider: SSL provider, error: 0 - The certificate chain was issued by an authority
that is not trusted.)
To resolve this error, include TrustServerCertificate=True; to your connection string within the
function.
[2023-10-04 07:10:00 ERR] Unable to connect: Generic: Ip has been prevented to connect to the
endpoint.
To resolve this issue, verify that the IP addresses in your Whitelisting to the Azure Relay is set up
properly. See Advanced Networking and Whitelisting.