Solved
Forum Discussion
Yashwant
3 years agoNew Contributor III
Thanks a lot Peter.
Sincere request.
Unfortunately I don't have GulfStream application in our setup. If possible, please share this business rule here.
Our version is 4.1 which is old hope this code is Extensible rule is compatible to our version.
Regards,
Yashwant
PeterFu
3 years agoContributor II
Hi Yashwant,
Here you have the code, I have copied in both XFR_ExportStageDat and XFR_ExportStageArchives
XFR_ExportStageData:
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.XFR_ExportStageData
Public Class MainClass
'------------------------------------------------------------------------------------------------------------
'Reference Code: XFR_ExportStageSourceData
'
'Description: Extender buiness rule that exports the stage source data to a single delimited files
' for all import child workflow pofiles. The files are written to the application
' Data Mgmt Export folder in the file share directory.
'
'Usage: Can be executed from Business Rule editor or run as part of a Data Management sequence.
' Note: If called from a Data Management sequence, the business rule step must supply 3
' paramaters named as follows (WfProfileName, ScenarioName, TimeName)
'
'Created By: Tom Shea
'Date Created: 5-9-2013
'------------------------------------------------------------------------------------------------------------
'Module level variables
Private m_ColNamesWritten As Boolean = False
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
Try
'Define the workflow cluster used as the starting point to extract from
Dim wfClusterPk As New WorkflowUnitClusterPk
Dim wfProfileName As String = String.Empty
Dim scenarioName As String = String.Empty
Dim timeName As String = String.Empty
Select Case args.FunctionType
Case Is = ExtenderFunctionType.Unknown
'Set the parent workflow unit to extract input profiles for
wfProfileName = "Houston"
scenarioName = "Actual"
timeName = "2011M2"
wfClusterPk = BRAPi.Workflow.General.GetWorkflowUnitClusterPk(si, wfProfileName, scenarioName, timeName)
Case Is = ExtenderFunctionType.ExecuteDataMgmtBusinessRuleStep
'Since this is being called from a DataManagement job, get the wfCluster from the parameters defined in the DataMgmt sequence
wfProfileName = args.NameValuePairs("WfProfileName")
scenarioName = args.NameValuePairs("ScenarioName")
timeName = args.NameValuePairs("TimeName")
wfClusterPk = BRAPi.Workflow.General.GetWorkflowUnitClusterPk(si, wfProfileName, scenarioName, timeName)
End Select
'Prepare the Stage Data Extract File path
Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)
Dim folderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, True, configSettings.FileShareRootFolder, si.AppToken.AppName) & "\" & DateTime.UtcNow.ToString("yyyyMMdd") & "\StageData"
If Not Directory.Exists(folderPath) Then Directory.CreateDirectory(folderPath)
Dim filePath As String = folderPath & "\DataExtract_" & scenarioName & "_" & timeName & ".csv"
If File.Exists(filePath) Then File.Delete(filePath)
'Export data for each descendant workflow profile
Dim profileInfos As List(Of WorkflowProfileInfo) = BRAPi.Workflow.Metadata.GetRelatives(si, wfClusterPk, WorkflowProfileRelativeTypes.Descendants, WorkflowProfileTypes.InputImportChild)
If Not profileInfos Is Nothing Then
'Create the list of columns to export
Dim colList As New List(Of String)
colList.Add("WFProfileName")
colList.Add("EtT")
colList.Add("AcT")
colList.Add("RawAmount")
Dim isFirstFile As Boolean = True
For Each profileInfo As WorkflowProfileInfo In profileInfos
Dim wfClusterPkChild As New WorkflowUnitClusterPk(profileInfo.ProfileKey, wfClusterPk.ScenarioKey, wfClusterPk.TimeKey)
If isFirstFile Then
isFirstFile = False
BRAPi.Import.Data.ExportStageData(si, wfClusterPkChild, Nothing, Nothing, True, filePath, False, ".", True)
Else
BRAPi.Import.Data.ExportStageData(si, wfClusterPkChild, Nothing, Nothing, False, filePath, True, ".", True)
End If
Next
End If
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace
XFR_ExportStageArchives:
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.XFR_ExportStageArchives
Public Class MainClass
'------------------------------------------------------------------------------------------------------------
'Reference Code: XFR_ExportStageArchives
'
'Description: Extender buiness rule that exports the stage archive files for all import child workflow
' profiles of the specified parent workflow profile. The files are written to the application
' Data Mgmt Export folder in the file share directory.
'
'Usage: Can be executed from Business Rule editor or run as part of a Data Management sequence.
' Note: If called from a Data Management sequence, the business rule step must supply 3
' paramaters named as follows (WfProfileName, ScenarioName, TimeName)
'
'Created By: Tom Shea
'Date Created: 5-9-2013
'------------------------------------------------------------------------------------------------------------
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
Try
'Define the workflow cluster used as the starting point to extract from
Dim wfClusterPk As New WorkflowUnitClusterPk
Dim wfProfileName As String = String.Empty
Dim scenarioName As String = String.Empty
Dim timeName As String = String.Empty
Select Case args.FunctionType
Case Is = ExtenderFunctionType.Unknown
'Set the parent workflow unit to extract input profiles for
wfProfileName = "Houston"
scenarioName = "Actual"
timeName = "2011M2"
wfClusterPk = BRAPi.Workflow.General.GetWorkflowUnitClusterPk(si, wfProfileName, scenarioName, timeName)
Case Is = ExtenderFunctionType.ExecuteDataMgmtBusinessRuleStep
'Since this is being called from a DataManagement job, get the wfCluster from the parameters defined in the DataMgmt sequence
wfProfileName = args.NameValuePairs("WfProfileName")
scenarioName = args.NameValuePairs("ScenarioName")
timeName = args.NameValuePairs("TimeName")
wfClusterPk = BRAPi.Workflow.General.GetWorkflowUnitClusterPk(si, wfProfileName, scenarioName, timeName)
End Select
'Prepare the Stage Data Extract File path
Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)
Dim folderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, True, configSettings.FileShareRootFolder, si.AppToken.AppName) & "\" & DateTime.UtcNow.ToString("yyyyMMdd") & "\StageArchives\" & scenarioName & "\" & timeName
If Not Directory.Exists(folderPath) Then Directory.CreateDirectory(folderPath)
'Export data for each descendant workflow profile
Dim profileInfos As List(Of WorkflowProfileInfo) = BRAPi.Workflow.Metadata.GetRelatives(si, wfClusterPk, WorkflowProfileRelativeTypes.Descendants, WorkflowProfileTypes.InputImportChild)
If Not profileInfos Is Nothing Then
For Each profileInfo As WorkflowProfileInfo In profileInfos
Dim wfClusterPkChild As New WorkflowUnitClusterPk(profileInfo.ProfileKey, wfClusterPk.ScenarioKey, wfClusterPk.TimeKey)
BRAPi.Import.Data.ExportStageArchives(si, wfClusterPkChild, folderPath, False)
Next
End If
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace
You can get the Golfstream application from the MarketPlace as well.
Regards,
Peter
- Yashwant3 years agoNew Contributor III
Thank You
- sdayringer2 years agoNew Contributor III
Hi Peter, What adjustments to this code need to be made in order to extra the stagearchives for multiperiod loads? I've tried changing the time parameter to the year, but it doesn't work. The filepath is created, but they are just empty.....
Related Content
- 4 years ago