Data Management Step Service
- In assembly DevUtilServices, create a Data Management Step Service called HelperDmSvc.
- In the sub
ProcessDataManagementStep, below the commentImplement Data Management Step logic here, add the following code:
If args.DataMgmtArgs.CurrentStep.Step.StepType = DataMgmtStepType.ExecuteBusinessRule _
And args.DataMgmtArgs.CurrentStep.Step.Name.XFEqualsIgnoreCase("Create XFProj") Then
' create a xfProject object
Dim xfPr As New XFProject()
' set basic properties
xfPr.DefaultZipFileName = workspace.Name
xfPr.TopFolderPath = workspace.Name
' create projectItem elements and add them
' Note: for easier maintenance, we use a parameter called XfProjectConfig.
Dim nvb As New NameValueFormatBuilder( _
Brapi.Dashboards.Parameters.GetLiteralParameterValue(si, _
False, workspace.UniqueID, "XfProjectConfig"))
' the list of Maintenance Units has to be parsed
Dim maintUnits As List(Of String) = StringHelper.SplitString( _
nvb.NameValuePairs.XFGetValue("MaintUnits", ""), ",")
' add each unit to the list, wrapped into a xfProjectItem object
For Each maintUnit As String In maintUnits
Dim xfProjItem As New XFProjectItem( _
XFProjectItemType.DashboardMaintenanceUnit, _
"", workspace.Name, maintUnit, True)
xfPr.ProjectItems.Add(xfProjItem)
Next
' Dashboard profiles are not kept in Workspaces,
' so Let's do it again for them.
' Note workspace name was set to Default for these items.
Dim dbdProfiles As List(Of String) = StringHelper.SplitString( _
nvb.NameValuePairs.XFGetValue("DbdProfiles", ""), ",")
For Each dbProfile As String In dbdProfiles
Dim xfProjItem As New XFProjectItem( _
XFProjectItemType.DashboardProfile, _
"", "Default", dbProfile, True)
xfPr.ProjectItems.Add(xfProjItem)
Next
' save xfproj to app filesystem in Documents/Users/YourUser/YourWsName.xfproj
Dim targetFileName As String = Path.Combine( _
"Documents", "Users", _
StringHelper.RemoveSystemCharacters(si.UserName,False,False), _
$"{xfPr.DefaultZipFileName}.xfProj")
Dim targetXFProjInfo As New XFFileInfo(FileSystemLocation.ApplicationDatabase, targetFileName)
Dim targetXFProjFile As New XFFile(targetXFProjInfo, String.Empty, xfPr.WriteXmlStringAsBytes(si))
brapi.FileSystem.InsertOrUpdateFile(si, targetXFProjFile)
' Alternative: save xfProj to FileShare, where it could be picked up by other scripts
' Note: this requires writing rights to the folder for the user...
' Dim folderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, _
' True, "", si.AppToken.AppName)
' If Not Directory.Exists(folderPath) Then
' Dim dirinfo As DirectoryInfo = Directory.CreateDirectory(folderPath)
' End If
' Dim txfpInfo As New XFFileInfo( _
' FileSystemLocation.FileShare, _
' Path.Combine(folderPath, $"{xfPr.DefaultZipFileName}.xfProj"))
' Dim targetXFProjFile As New XFFile(txfpInfo, String.Empty, xfPr.WriteXmlStringAsBytes(si))
' brapi.FileSystem.InsertOrUpdateFile(si, targetXFProjFile)
End If