Is it possible to extract(as xml) a Maintenance Unit and it's components using extensibility rule?
Hello OneStream experts,
We are trying to extract a maintenance unit and all it's components underneath it using a BR/Extensibility rule with the latest OS version - 9.0.1.
But, however after the run we could able to see a empty xml in the fileshare folder.
Below is the snippet of code which we are using.
Any suggestions or help would be greatly appreciated. Thanks!
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
Try
Select Case args.FunctionType
Case Is = ExtenderFunctionType.ExecuteDataMgmtBusinessRuleStep, ExtenderFunctionType.Unknown
'Get Configuration Settings
Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)
'Data Management extract location
Dim folderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, True, configSettings.FileShareRootFolder,
si.AppToken.AppName
) & "\" & DateTime.UtcNow.ToString("yyyyMMdd") & "\Extracts" 'If the directory does not exist create
If Not Directory.Exists(folderPath) Then Directory.CreateDirectory(folderPath)
'Full path and file name for extract
Dim filePath As String = folderPath & "\MaintainanceUnitBkp " & DateTime.UtcNow.ToString("yyyyMMdd") & ".xml"
'If file already exist
If File.Exists(filePath) Then File.Delete(filePath)
'Extract Options
' Dim xmlOptions As New XmlExtractOptions
' xmlOptions.ExtractAllItems = False
Dim xmlOptions As New XmlExtractOptions
Dim dashboardOptions As New DashboardMaintUnit
xmlOptions.ExtractAllItems = False
'Extract Maintainance Unit
Dim extractDict As New Dictionary(Of XmlExtractItemPk, Boolean)
Dim strMaintUnit As String = "DataExtract_Main" 'Maintenance Unit
extractDict.Add(New XmlExtractItemPk(XmlExtractItemType.DashboardMaintUnit, strMaintUnit), True)
'Execute the Metadata Extract
Using dbConnFW As DbConnInfo = BRApi.Database.CreateFrameworkDbConnInfo(si)
Using dbConnApp As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
'Extract XML metadata to target location
File.WriteAllText(filePath, MetadataExtract.ExtractXml(dbConnFW, dbConnApp, xmlOptions, extractDict))
File.WriteAllText(filePath,XmlExtractController.ExtractXML(dbConnFW,dbConnApp,Nothing,xmlOptions,extractDict,XmlLoadExtractType.ApplicationWorkspaces))
End Using
End Using