About Dnn Module Config

Private Sub CreateDnnManifest(ByVal objDesktopModule As DesktopModuleInfo)

Dim filename As String
= ""
_Name
= objDesktopModule.ModuleName

'Create Manifest Document
Dim xmlManifest As New XmlDocument

'Root Element
Dim nodeRoot As XmlNode = xmlManifest.CreateElement("dotnetnuke")
nodeRoot.Attributes.Append(XmlUtils.CreateAttribute(xmlManifest,
"version", "3.0"))
nodeRoot.Attributes.Append(XmlUtils.CreateAttribute(xmlManifest,
"type", "Module"))

'Folders Element
Dim nodeFolders As XmlNode = xmlManifest.CreateElement("folders")
nodeRoot.AppendChild(nodeFolders)

'Folder Element
Dim nodeFolder As XmlNode = xmlManifest.CreateElement("folder")
nodeFolders.AppendChild(nodeFolder)

'Desktop Module Info
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "name", _Name))
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"friendlyname", objDesktopModule.FriendlyName))
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"foldername", objDesktopModule.FolderName))
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"modulename", _Name))
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"description", objDesktopModule.Description))
If objDesktopModule.Version
= Null.NullString Then
objDesktopModule.Version
= "01.00.00"
End If
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"version", objDesktopModule.Version))
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"businesscontrollerclass", objDesktopModule.BusinessControllerClass))
If objDesktopModule.CompatibleVersions
<> "" Then
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"compatibleversions", objDesktopModule.CompatibleVersions))
End If
If objDesktopModule.Dependencies
<> "" Then
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"dependencies", objDesktopModule.Dependencies))
End If
If objDesktopModule.Permissions
<> "" Then
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"permissions", objDesktopModule.Permissions))
End If
If SupportsProbingPrivatePath Then
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"supportsprobingprivatepath", SupportsProbingPrivatePath.ToString))
End If

'Add Source files
If IncludeSource Then
nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest,
"resourcefile", ResourceFileName))
End If

'Modules Element
Dim nodeModules As XmlNode = xmlManifest.CreateElement("modules")
nodeFolder.AppendChild(nodeModules)

'Get the Module Definitions for this Module
Dim objModuleDefinitionController As New ModuleDefinitionController
Dim arrModuleDefinitions As ArrayList
= objModuleDefinitionController.GetModuleDefinitions(objDesktopModule.DesktopModuleID)

'Iterate through Module Definitions
For Each objModuleInfo As ModuleDefinitionInfo In arrModuleDefinitions
Dim nodeModule As XmlNode
= xmlManifest.CreateElement("module")

'Add module definition properties
nodeModule.AppendChild(XmlUtils.CreateElement(xmlManifest, "friendlyname", objModuleInfo.FriendlyName))

'Add Cache properties
nodeModule.AppendChild(XmlUtils.CreateElement(xmlManifest, "cachetime", objModuleInfo.DefaultCacheTime.ToString))

'Get the Module Controls for this Module Definition
Dim arrModuleControls As ArrayList = ModuleControlController.GetModuleControls(objModuleInfo.ModuleDefID)

'Controls Element
Dim nodeControls As XmlNode = xmlManifest.CreateElement("controls")
nodeModule.AppendChild(nodeControls)

'Iterate through Module Controls
For Each objModuleControl As ModuleControlInfo In arrModuleControls
Dim nodeControl As XmlNode
= xmlManifest.CreateElement("control")

'Add module control properties
XmlUtils.AppendElement(xmlManifest, nodeControl, "key", objModuleControl.ControlKey, False)
XmlUtils.AppendElement(xmlManifest, nodeControl,
"title", objModuleControl.ControlTitle, False)

XmlUtils.AppendElement(xmlManifest, nodeControl,
"src", objModuleControl.ControlSrc, True)
XmlUtils.AppendElement(xmlManifest, nodeControl,
"iconfile", objModuleControl.IconFile, False)
XmlUtils.AppendElement(xmlManifest, nodeControl,
"type", objModuleControl.ControlType.ToString, True)
XmlUtils.AppendElement(xmlManifest, nodeControl,
"helpurl", objModuleControl.HelpURL, False)

If objModuleControl.SupportsPartialRendering Then
XmlUtils.AppendElement(xmlManifest, nodeControl,
"supportspartialrendering", "true", False)
End If

'Add control Node to controls
nodeControls.AppendChild(nodeControl)

'Determine the filename for the Manifest file (It should be saved with the other Module files)
If filename = "" Then
filename
= Folder & "\" & objDesktopModule.ModuleName + ".dnn"
End If
Next

'Add module Node to modules
nodeModules.AppendChild(nodeModule)
Next

'Files Element
Dim nodeFiles As XmlNode = xmlManifest.CreateElement("files")
nodeFolder.AppendChild(nodeFiles)

'Add the files
For Each file As PaFileInfo In _Files
Dim nodeFile As XmlNode
= xmlManifest.CreateElement("file")

'Add file properties
XmlUtils.AppendElement(xmlManifest, nodeFile, "path", file.Path, False)
XmlUtils.AppendElement(xmlManifest, nodeFile,
"name", file.Name, False)

'Add file Node to files
nodeFiles.AppendChild(nodeFile)
Next

'Add Root element to document
xmlManifest.AppendChild(nodeRoot)

'Save Manifest file
xmlManifest.Save(filename)

End Sub

posted on 2008-11-06 20:08  天使也疯狂  阅读(304)  评论(0编辑  收藏  举报

导航