210 likes | 464 Vues
Scott Wilkinson @DotNetNuclear. Module Programming 101 . Outline. IIS Setup and DNN install Install Christoc’s DNN7, DAL2 Template using vsix install Create RestaurantMenu project Build project in Release mode (fix missing /package folder issue if applicable)
E N D
Scott Wilkinson @DotNetNuclear Module Programming 101
Outline IIS Setup and DNN install Install Christoc’s DNN7, DAL2 Template using vsix install Create RestaurantMenu project Build project in Release mode (fix missing /package folder issue if applicable) Find RestaurantMenu Source package and install in DNN Demonstrate the default Item Module functionality and discuss the basics view controls of the template: view, edit, settings (DotNetNuke.Entities.Modules.PortalModuleBase) Build Database scripts Build DAL2 model: RestaurantMenuItem.cs Build DAL2 controller: RestaurantMenuItemRepository.cs Comment out broken code in the edit control and build project in Debug Discuss debugging Build ‘edit’ view [Breakout: student do 30 minutes of coding on their own] Discuss: Use ClientResourceManagement to register scripts and css Discuss: UI guidelines to follow: http://uxguide.dotnetnuke.com/ Build ‘view’ view [Breakout: student do 30 minutes of coding on their own] Build ‘settings’ view together and discuss PortalSettingsBase Error handling: DotNetNuke.Services.Exceptions Discuss build process and dnn manifest: versions, scripts, moduledefinitions, license/releasenotes Test package with evs.dotnetnuke.com
IIS Setup and DNN Installation Unzip DNN Install package to folder on harddrive (give full permissions to folder to yourself and Network Service) Create empty database Create IIS application and pool. Add host header: dnndev.me, port 80 Browse site, should redirect to /Install.aspx Follow installation instructions
Install Module Development Template Download from christoctemplate.codeplex.com DNN7 DAL2 vsix Double click the vsix installer to install in VS2012 Older versions, copy zip file to My Documents\Visual Studio 20XX\Templates\ProjectTemplates\Visual C#\
Create Module Project Open VS2012, click New Project Name it RestaurantMenu Browse to [DNN7 Install Root]\DesktopModules\ Select DotNetNuke 7 C#(or VB) DAL2 Compiled Module Uncheck ‘Create directory for solution’
Build in Release mode Should compile and initiate Build Scripts References: DotNetNuke.dll (core) DotNetNuke.Web.Client (ClientResourceManager) DotNetNuke.Web.Utility (ClientAPI, BrowserCaps)
Register Module In DNN Using Package /install should have 2 packages: RestaurantMenu_01.00.00_Source and RestaurantMenu_01.00.00_Install Browse to DNN and install Source package
The Components of a Module Module controls: view, edit, settings PortalModuleBase, ModuleSettingsBase IActionable DNN Controller: ISearchable, IUpgradeable, IPortable
Database scripts 00.00.01.SqlDataProvider, Uninstall.SqlDataProvider What is this? {databaseOwner}{objectQualifier}
DAL2 Model DotNetNuke.ComponentModel.DataAnnotations Use [ColumnName("Desc")] to enable different column name than model attribute Use [IgnoreColumn] to have computed attributes in Model that don’t save to database
DAL2 Controller (Model Repository) I like to use the name *Repository Using DotNetNuke.Data Create, Delete, Update, Get
Debugging our Module Build in debug mode Attach to w3wp process for IIS Attach to iisexpress process for IISExpress
The ‘Edit’ View Allows admin users to add or update the menu items Uses DnnFilePicker to upload a picture Uses dnn Label control and dnnFormItem class for consistent form UI
ClientResourceManager API RegisterStyleSheet(), RegisterScript()
UI Guidelines http://uxguide.dotnetnuke.com/ Helps merge your module’s UI into the DNN UI to make it consistent Tabs, Tooltips, Alerts, Confirms, etc
The ‘View’ view View type control that users without edit permissions can use Use ClientResourceManager to register css or scripts Implement IActionable to add the Edit to the context menu
The ‘Settings’ view Implements ModuleSettingsBase LoadSettings() to recall settings UpdateSettings() to save settings changes Settings[“name”] associative array of settings for the current module.
Error Handling Use DotNetNuke.Services.Exceptions Exceptions.ProcessModuleLoadException() in Module events Exceptions.LogException(ex) to log generic exception in your components
Packaging (DNN Manifest) dependency type="CoreVersion” is the minimum version DNN your module is build from component type="ResourceFile“ contains all module files besides the assembly and SQL files Module definition: 2 control types: view, edit (settings is considered a special edit type)
Test Install Package http://evs.dotnetnuke.com/