[Dnn module development] enables the module to support the "import" and "Export" Functions

Source: Internet
Author: User
The dnn module supports the Import and Export function. By importing the module content to an XML file, you can easily back up and transfer the module content, you can also save the module content in XML format in advance and import the module content in batches.

To implement the module Import and Export function, you need to implement the iportable interface in the module's business logic Access Object (** Controller:
1. iportable Interface (Components \ modules \ iportable. VB) Namespace dotnetnuke Namespace Dotnetnuke. Entities. Modules
' Interface for exporting and importing modules
Public   Interface iportable Interface Iportable
' Module Export
Function exportmodule () Function Exportmodule ( Byval Moduleid As   Integer ) As   String
' Module Import
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. Implement the iportable interface in the business logic class of the corresponding module (This step can be modified based on the specific circumstances of the module. You can refer to the existing dnn module, for example, links) Namespace dotnetnuke Namespace Dotnetnuke. modules. Links
Public   Class linkcontroller Class Linkcontroller
Implements Entities. modules. iportable

' Interface for exporting functions
Public   Function exportmodule () Function Exportmodule ( Byval Moduleid As   Integer ) As   String   Implements Dotnetnuke. Entities. modules. iportable. exportmodule
' Obtain all link information of this module
Dim Strxml As   String   =   " "
Dim Arrlinks As Arraylist = Getlinks (moduleid)
' Determine the XML Node Based on the field of this module
If Arrlinks. Count <>   0   Then
Strxml + =   " <Links>"
Dim Objlink As Linkinfo
For   Each Objlink In Arrlinks
' Write each record of the module content
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

' Interface for implementing the import 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 " )
' Parse each record from 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

Note:When packaging the installation file, you must specify the business logic class of the module in the <businesscontrollerclass> node of the dnn file, for example:<Businesscontrollerclass>Dnnchina. modules. clinks. clinkscontroller, dnnchina. modules. clinks</Businesscontrollerclass>

Related content:
Hierarchy of dnn modules: http://www.cnblogs.com/esshs/archive/2005/07/27/201190.html
About module File structure: http://www.cnblogs.com/esshs/archive/2005/07/21/197198.html
About dnn file structure: http://www.cnblogs.com/esshs/archive/2005/07/26/200154.html

More>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.