Is it possible to extract(as xml) a Maintenance Unit and it's components using extensibility rule?
- 4 days ago
The way to do this is to "build up" your xml file with the things you add to the extractDict. If you want a maintenance unit, you need to first add types DashboardWorkspaces, DashboardWorkspace, and DashboardMaintUnits. If you look at the XML for an ApplicationWOrkspace export, it has these types on the outside enclosing the maintenance units.
Look at how the xml file is composed when you export Application Workspaces through the Load/Extract screen. The use that as your pattern to build up your extract dict. Here I'm extracting a maintenance unit with a Workspace Assembly. Use this pattern...
This code will extract the maintenance unit, its assembly, components, adapters, and groups within that maintenance unit:
modify it using this pattern to get what you want out of your maintenance unit.Dim xmlOptions As New XmlExtractOptions() With { .ExtractAllItems = False } ' Define the maintenance unit to extract Dim extractDict As New Dictionary(Of XmlExtractItemPk, Boolean)() Dim maintUnitId As New Guid("A76AC44C-88E0-4115-BE03-B6B29F890998") Dim workspaceId As New Guid("BA09DD97-F470-4865-A4C8-F5B55EC7E03B") Dim assemblyId As New Guid("0ACA5739-73A1-44B5-BE57-A8235B7C9F82") extractDict.Add(New XmlExtractItemPk(XmlExtractItemType.DashboardWorkspaces, SharedConstants.Unknown), True) extractDict.Add(New XmlExtractItemPk(XmlExtractItemType.DashboardWorkspace, workspaceId), True) extractDict.Add(New XmlExtractItemPk(XmlExtractItemType.DashboardMaintUnits, workspaceId), True) extractDict.Add(New XmlExtractItemPk(XmlExtractItemType.DashboardMaintUnit, maintUnitId), True) extractDict.Add(New XmlExtractItemPk(XmlExtractItemType.WorkspaceAssemblies, maintUnitId), True) extractDict.Add(New XmlExtractItemPk(XmlExtractItemType.WorkspaceAssembly, assemblyId), True) extractDict.Add(New XmlExtractItemPk(XmlExtractItemType.DashboardAdapters, maintUnitId), True) extractDict.Add(New XmlExtractItemPk(XmlExtractItemType.DashboardComponents, maintUnitId), True) extractDict.Add(New XmlExtractItemPk(XmlExtractItemType.Groups, maintUnitId), True) ' Execute the metadata extract Using dbConnFW As DbConnInfo = BRApi.Database.CreateFrameworkDbConnInfo(si) Using dbConnApp As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si) Dim xmlContent As String = XmlExtractController.ExtractXml( dbConnFW, dbConnApp, Nothing, xmlOptions, extractDict, XmlLoadExtractType.ApplicationWorkspaces ) BRApi.ErrorLog.LogMessage(si, xmlContent) ' Write output to file File.WriteAllText(filePath, xmlContent) End Using End Using