Last active
December 4, 2024 09:33
-
-
Save toyg/4a6643e1a9cce5b1df055c44619c55e9 to your computer and use it in GitHub Desktop.
DataSet Business Rule for Menu Component in OneStream 8.5+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System | |
Imports System.Collections.Generic | |
Imports System.Data | |
Imports System.Data.Common | |
Imports System.Globalization | |
Imports System.IO | |
Imports System.Linq | |
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.DashboardDataSet.MenuDataSet | |
Public Class MainClass | |
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardDataSetArgs) As Object | |
Try | |
Select Case args.FunctionType | |
Case Is = DashboardDataSetFunctionType.GetDataSetNames | |
Dim names As New List(Of String)() | |
names.Add("MainMenu") | |
Return names | |
Case Is = DashboardDataSetFunctionType.GetDataSet | |
If args.DataSetName.XFEqualsIgnoreCase("MainMenu") Then | |
' create the menu object | |
Dim menu As New XFMenuItemCollection() | |
' create top-level items | |
Dim parentMenuItemOne As New XFMenuItem("1", "Parent 1", _ | |
"White", "SlateGray", False, False, True, False, Nothing) | |
' create items for the second level | |
Dim childMenuItemOne As New XFMenuItem("1.1", "Child 1", _ | |
"Black", "White", True, True, True, False, Nothing) | |
Dim childMenuItemTwo As New XFMenuItem("1.2", "Child 2", _ | |
"Black", "White", True, True, True, False, Nothing) | |
' create items for the third level | |
Dim grandChildMenuItemOne As New XFMenuItem("1.1.1", "Grandchild 1", _ | |
"White", "SlateGray", True, True, True, False, Nothing) | |
' create the hierarchy by adding children to direct parents as a List | |
childMenuItemOne.Children = New List(Of XFMenuItem) _ | |
From {grandChildMenuItemOne} | |
parentMenuItemOne.Children = New List(Of XFMenuItem) _ | |
From {childMenuItemOne} | |
' you can also manipulate the list once created | |
parentMenuItemOne.Children.Add(childMenuItemTwo) | |
' add top-level items to the menu object | |
menu.MenuItems.Add(parentMenuItemOne) | |
' generate the dataset and return it | |
Return menu.CreateDataSet(si) | |
End If | |
End Select | |
Return Nothing | |
Catch ex As Exception | |
Throw ErrorHandler.LogWrite(si, New XFException(si, ex)) | |
End Try | |
End Function | |
End Class | |
End Namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment