日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

让模块支持“导入”“导出”功能

發布時間:2023/11/29 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 让模块支持“导入”“导出”功能 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
讓模塊支持“導入”“導出”功能

DNN模塊可以支持導入導出功能,通過將模塊內容導入到XML文件可以便于模塊內容備份和轉移,也可將模塊內容事先以XML格式保存通過導入功能實現模塊內容的批量錄入。
如圖:

[img]http://esshs.cnblogs.com/images/cnblogs_com/esshs/20050804.gif[/img]

要實現模塊的導入導出功能,需要在模塊的業務邏輯訪問對象(***Controller)中實現IPortable接口:

1、IPortable接口(components\Modules\IPortable.vb)
Namespace DotNetNukeNamespace DotNetNuke.Entities.Modules
? ? ' 模塊導出導入功能接口
? ? Public Interface IPortableInterface IPortable
? ?? ???' 模塊導出
? ?? ???Function ExportModule()Function ExportModule(ByVal ModuleID As Integer) As String
? ?? ???' 模塊導入
? ?? ???Sub ImportModule()Sub ImportModule(ByVal ModuleID As Integer, ByVal Content As String, ByVal Version As String, ByVal UserID As Integer)
? ? End Interface
End Namespace
2、在相應模塊的業務邏輯類中實現IPortable接口(這一步可根據模塊具體情況作出相應的修改,可參照DNN已有模塊做,如:Links)
Namespace DotNetNukeNamespace DotNetNuke.Modules.Links
? ? Public Class LinkControllerClass LinkController
? ?? ???Implements Entities.Modules.IPortable

? ?? ???' 實現導出功能接口
? ?? ???Public Function ExportModule()Function ExportModule(ByVal ModuleID As Integer) As String Implements DotNetNuke.Entities.Modules.IPortable.ExportModule
? ?? ?? ?? ?' 獲取該模塊的全部鏈接信息
? ?? ?? ?? ?Dim strXML As String = ""
? ?? ?? ?? ?Dim arrLinks As ArrayList = GetLinks(ModuleID)
? ?? ?? ?? ?' 根據該模塊的字段決定XML的節點
? ?? ?? ?? ?If arrLinks.Count <> 0 Then
? ?? ?? ?? ?? ? strXML += "<links>"
? ?? ?? ?? ?? ? Dim objLink As LinkInfo
? ?? ?? ?? ?? ? For Each objLink In arrLinks
? ?? ?? ?? ?? ?? ???' 編寫模塊內容的每一條記錄
? ?? ?? ?? ?? ?? ???strXML += "<link>"
? ?? ?? ?? ?? ?? ???strXML += "<title>" & XMLEncode(objLink.Title) & "</title>"
? ?? ?? ?? ?? ?? ???strXML += "<url>" & XMLEncode(objLink.Url) & "</url>"
? ?? ?? ?? ?? ?? ???strXML += "<vieworder>" & XMLEncode(objLink.ViewOrder.ToString) & "</vieworder>"
? ?? ?? ?? ?? ?? ???strXML += "<description>" & XMLEncode(objLink.Description) & "</description>"
? ?? ?? ?? ?? ?? ???strXML += "<newwindow>" & XMLEncode(objLink.NewWindow.ToString) & "</newwindow>"
? ?? ?? ?? ?? ?? ???strXML += "</link>"
? ?? ?? ?? ?? ? Next
? ?? ?? ?? ?? ? strXML += "</links>"
? ?? ?? ?? ?End If
? ?? ?? ?? ?Return strXML
? ?? ???End Function

? ?? ???' 實現導入功能接口
? ?? ???Public Sub ImportModule()Sub ImportModule(ByVal ModuleID As Integer, ByVal Content As String, ByVal Version As String, ByVal UserID As Integer) Implements DotNetNuke.Entities.Modules.IPortable.ImportModule
? ?? ?? ?? ?Dim xmlLink As XmlNode
? ?? ?? ?? ?Dim xmlLinks As XmlNode = GetContent(Content, "links")
? ?? ?? ?? ?' 從XML中解析每一條記錄
? ?? ?? ?? ?For Each xmlLink In xmlLinks.SelectNodes("link")
? ?? ?? ?? ?? ? Dim objLink As New LinkInfo
? ?? ?? ?? ?? ? objLink.ModuleId = ModuleID
? ?? ?? ?? ?? ? objLink.Title = xmlLink.Item("title").InnerText
? ?? ?? ?? ?? ? objLink.Url = ImportUrl(ModuleID, xmlLink.Item("url").InnerText)
? ?? ?? ?? ?? ? objLink.ViewOrder = Integer.Parse(xmlLink.Item("vieworder").InnerText)
? ?? ?? ?? ?? ? objLink.Description = xmlLink.Item("description").InnerText
? ?? ?? ?? ?? ? objLink.NewWindow = Boolean.Parse(xmlLink.Item("newwindow").InnerText)
? ?? ?? ?? ?? ? objLink.CreatedByUser = UserId.ToString
? ?? ?? ?? ?? ? AddLink(objLink)
? ?? ?? ?? ?Next
? ?? ???End Sub

? ? End Class
End Namespace
注意:在打包安裝文件時,需要在DNN文件的<businesscontrollerclass>節點寫明該模塊的業務邏輯類,如:
<businesscontrollerclass>DNNChina.Modules.CLinks.CLinksController, DNNChina.Modules.CLinks</businesscontrollerclass>

總結

以上是生活随笔為你收集整理的让模块支持“导入”“导出”功能的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。