chau Step-by-step Creating a DotNetNuke Module Using C#Adding New Item On the Solution Explorer, right mouse on the root site and click on Add New Item..... Bạn đã sẵn sàng để cài đặt cá
Trang 1chau Step-by-step Creating a DotNetNuke Module Using C#
Adding New Item
On the Solution Explorer, right mouse on the root site and click on Add New Item
You should now see a dialog box asking you to select the item to add DotNetNuke allows you to build modules in either VB or C# In this example, select C# as the preferred language Give your module a name like "HelloWorld"
Trang 2Adjust the Module Folders & Code
You'll quickly notice that the name of the module folder is always "ModuleName" even if I explicitly called it "HelloWorld" in the previous dialog Visual Studio has limited capabilities to customize templates and this limitation is apparent in the screenshot below You'll have to manually rename App_Code\ModuleName to App_Code\HelloWorld and DesktopModules\ModuleName to
DesktopModules\HelloWorld before continuing The files contained within the folder are named correctly and you don't need to modify those
Trang 3Since we're writing our module in C# and DotNetNuke core classes are written in VB,
we need to compile our newly added module as a separate assembly To do that we need to specify it in the web.config the code subdirectory If you're writing in VB, you don't need to do this but it doesn't hurt to do it either
<compilation>
<codesubdirectories>
<add directoryname="HelloWorld" />
</codesubdirectories>
</compilation>
If you're using C# and running on DotNetNuke 4.5.3 Starter Kit, you may encounter some bugs when you try to run your web site The author of the VSI templates forgot
to translate some VB code to C# It's normally not a big deal since the compiler will catch it and indicate on screen precisely where the bug occured You just need to translate one or 2 lines back to C#
For example the comment below:
' Use connection string specified in provider
should be rewritten to C# like:
Trang 4// Use connection string specified in provider
Compile the solution and make sure you don't get any errors
Install the DNN Manifest
You're now ready to install the module From your web site, go to Host > Module
Definitions page from the menu On the top left corner of the title header, click on Create New Module.
Bạn đã sẵn sàng để cài đặt các mô-đun Từ trang web của bạn, hãy đến chủ> Định nghĩa trang Module từ trình đơn Trên góc trái trên cùng của tiêu đề Tiêu đề, nhấp vào Tạo mới Module
The HelloWorld.dnn file contains all the information necesary such as location of
files, version and name Select the HelloWorld.dnn manifest file and click on Create
new Module from selected Manifest file.
Các tập tin HelloWorld.dnn có tất cả các thông tin cần thiết như vị trí của tập tin, phiên bản và tên Chọn HelloWorld.dnn biểu hiện tập tin và click vào Tạo Module mới từ tập tin Manifest chọn
Create Tables and Stored Procedures
To install the HelloWorld module to your web site, you'll need to create a custom table and several stored procedures that performs some simple insert, update and delete operations for the custom table This is part of the simple HelloWorld
functionality when you use the VSI template to create a module A simpler module, if created by hand, would not require any table or stored procedure at all Since we want
to make use of the VSI template, just open the
Trang 5DesktopModules\HelloWorld\01.00.00.SqlDataProvider file using notepad and copy
the SQL content Then from your web site, go to the Host > SQL page from the menu Execute the SQL and check the Run as Script to tell the page to parse the SQL
and replace any special DotNetNuke specific syntax
Để cài đặt module HelloWorld vào trang web của bạn, bạn sẽ cần phải tạo một bảng tùy chỉnh và lưu trữ một số thủ tục mà thực hiện một số nạp đơn giản, cập nhật và xóa các hoạt động cho bảng tùy chỉnh Đây là một phần của chức năng HelloWorld đơn giản khi bạn sử dụng VSI bản mẫu để tạo ra một mô-đun Một module đơn giản, nếu được tạo ra bởi bàn tay, sẽ không yêu cầu bất kỳ bảng hoặc được lưu trữ ở tất cả các thủ tục Vì chúng tôi muốn làm cho việc sử dụng VSI mẫu, chỉ cần mở
DesktopModules \ HelloWorld \ 01.00.00.SqlDataProvider tập tin bằng cách sử dụng notepad và sao chép nội dung SQL Sau đó từ trang web của bạn, hãy vào Lưu trữ> SQL trang từ trình đơn Thực thi SQL và kiểm tra Run as Script để cho các trang để phân tích cú pháp SQL và thay thế bất kỳ cú pháp DotNetNuke đặc biệt cụ thể
Add Module To Page
Congratulations! You've created your first module You can now go to any page and add the HelloWorld on to that page
Lời chúc mừng! Bạn đã tạo ra mô-đun đầu tiên của bạn Bây giờ bạn có thể vào bất kỳ trang nào và thêm HelloWorld vào trang đó
Trang 6The HelloWorld allows you to add, edit and configure settings for the module Have fun !
Code ví dụ mẫu để add 1 user vào 1 role trong Dotnetnuke
nmduc073 posted on January 27, 2010 05:32::28 view(s)
Copy được đoạn code này từ forum dotnetnuke.com và chia sẻ cho những bạn mới tìm hiểu:
//Get the role information
RoleInfo oCurrentRole = oDnnRoleController.GetRoleByName(this.PortalId, "MyRoleName") //Assign to user
oDnnRoleController.AddUserRole(this.PortalId, user.UserID, oCurrentRole.RoleID,
System.DateTime.Now.AddDays(-1), DotNetNuke.Common.Utilities.Null.NullDate);
the oDnnRoleController is an instance of the RoleController within DotNetNuke.
Genneration
http://www.codesmithtools.com/requesttrial/21
http://www.mygenerationsoftware.com/portal/default.aspx
// Thong tin download
Trang 7Download CodeSmith:
http://www.codesmithtools.com/downloads/7b085f0779 Your trial key:
CS50T-2RBKM-7FNFG-YVPRM-S2LLD-BK3E8-X7R9J Your CodeSmithTools.com login information:
User: t0710k123@gmail.com
Password: a075fdcd8a