本文整理汇总了C#中DotNetNuke.Entities.Modules.ModuleController.AddModule方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleController.AddModule方法的具体用法?C# ModuleController.AddModule怎么用?C# ModuleController.AddModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Modules.ModuleController
的用法示例。
在下文中一共展示了ModuleController.AddModule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddModuleToPage
///-----------------------------------------------------------------------------
///<summary>
/// AddModuleToPage adds a module to a Page
///</summary>
///<remarks>
///</remarks>
///<param name = "page">The Page to add the Module to</param>
///<param name = "moduleDefId">The Module Deinition Id for the module to be aded to this tab</param>
///<param name = "moduleTitle">The Module's title</param>
///<param name = "moduleIconFile">The Module's icon</param>
///<param name = "inheritPermissions">Inherit the Pages View Permisions</param>
///<history>
/// [cnurse] 11/16/2004 created
///</history>
///-----------------------------------------------------------------------------
public static int AddModuleToPage(TabInfo page, int moduleDefId, string moduleTitle, string moduleIconFile, bool inheritPermissions)
{
var moduleController = new ModuleController();
ModuleInfo moduleInfo;
int moduleId = Null.NullInteger;
if ((page != null))
{
bool isDuplicate = false;
foreach (var kvp in moduleController.GetTabModules(page.TabID))
{
moduleInfo = kvp.Value;
if (moduleInfo.ModuleDefID == moduleDefId)
{
isDuplicate = true;
moduleId = moduleInfo.ModuleID;
}
}
if (!isDuplicate)
{
moduleInfo = new ModuleInfo
{
ModuleID = Null.NullInteger,
PortalID = page.PortalID,
TabID = page.TabID,
ModuleOrder = -1,
ModuleTitle = moduleTitle,
PaneName = Globals.glbDefaultPane,
ModuleDefID = moduleDefId,
CacheTime = 0,
IconFile = moduleIconFile,
AllTabs = false,
Visibility = VisibilityState.None,
InheritViewPermissions = inheritPermissions
};
moduleId = moduleController.AddModule(moduleInfo);
}
}
return moduleId;
}
示例2: AddModuleToPage
public int AddModuleToPage(TabInfo t, ModuleType type)
{
string DesktopModuleFriendlyName="";
string ModuleDefFriendlyName="";
ModuleDefinitionInfo moduleDefinitionInfo = new ModuleDefinitionInfo();
ModuleInfo moduleInfo = new ModuleInfo();
moduleInfo.PortalID = t.PortalID;
moduleInfo.TabID = t.TabID;
moduleInfo.ModuleOrder = 1;
moduleInfo.ModuleTitle = "";
moduleInfo.DisplayPrint = false;
moduleInfo.IsShareable = true;
moduleInfo.IsShareableViewOnly = true;
switch (type)
{
case ModuleType.DisplayPlugg:
moduleInfo.PaneName = "RowTwo_Grid8_Pane";
DesktopModuleFriendlyName = "DisplayPlugg";
ModuleDefFriendlyName = "DisplayPlugg";
break;
case ModuleType.DisplayCourse:
moduleInfo.PaneName = "RowTwo_Grid8_Pane";
DesktopModuleFriendlyName = "DisplayCourse";
ModuleDefFriendlyName = "DisplayCourse";
break;
case ModuleType.CourseMenu:
moduleInfo.PaneName = "RowTwo_Grid4_Pane";
DesktopModuleFriendlyName = "CourseMenu";
ModuleDefFriendlyName = "CourseMenu";
break;
case ModuleType.Rating:
moduleInfo.PaneName = "RowTwo_Grid4_Pane";
DesktopModuleFriendlyName = "DNNCentric RnC";
ModuleDefFriendlyName = "DNNCentric.RatingAndComments";
break;
case ModuleType.Comments:
moduleInfo.PaneName = "RowTwo_Grid8_Pane";
DesktopModuleFriendlyName = "DNNCentric RnC";
ModuleDefFriendlyName = "DNNCentric.RatingAndComments";
break;
case ModuleType.DisplayPluggeTitle:
moduleInfo.PaneName = "RowTwo_Grid4_Pane";
DesktopModuleFriendlyName = "DisplayPluggeTitle";
ModuleDefFriendlyName = "DisplayPluggeTitle";
break;
}
DesktopModuleInfo myModule = null;
foreach (KeyValuePair<int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(t.PortalID))
{
DesktopModuleInfo mod = kvp.Value;
if (mod != null)
if (mod.FriendlyName == DesktopModuleFriendlyName)
{
myModule = mod;
break;
}
}
int moduleId=0;
if (myModule != null)
{
var mc = new ModuleDefinitionController();
var mInfo = new ModuleDefinitionInfo();
mInfo = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleDefFriendlyName,
myModule.DesktopModuleID);
moduleInfo.ModuleDefID = mInfo.ModuleDefID;
moduleInfo.CacheTime = moduleDefinitionInfo.DefaultCacheTime;//Default Cache Time is 0
moduleInfo.InheritViewPermissions = true; //Inherit View Permissions from Tab
moduleInfo.AllTabs = false;
moduleInfo.Alignment = "Top";
ModuleController moduleController = new ModuleController();
moduleId = moduleController.AddModule(moduleInfo);
}
DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(t.TabID);
DotNetNuke.Common.Utilities.DataCache.ClearTabsCache(t.PortalID);
DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(t.PortalID, false);
//Add settings for RnC
ModuleController m = new ModuleController();
if (type == ModuleType.Rating)
{
AddModuleSettingsRnCCommon(moduleId);
m.UpdateModuleSetting(moduleId, "PRC_settingCommentObject", "tabid:" + t.TabID);
m.UpdateModuleSetting(moduleId, "PRC_settingShow", "OnlyRatings");
m.UpdateModuleSetting(moduleId, "PRC_settingRncWidth", "357");
}
if (type == ModuleType.Comments)
{
AddModuleSettingsRnCCommon(moduleId);
m.UpdateModuleSetting(moduleId, "PRC_settingCommentObject", "tabid:" + t.TabID);
m.UpdateModuleSetting(moduleId, "PRC_settingShow", "OnlyComments");
m.UpdateModuleSetting(moduleId, "PRC_settingRncWidth", "744");
}
//.........这里部分代码省略.........
示例3: DeserializeModule
/// <summary>
/// Deserializes the module.
/// </summary>
/// <param name="nodeModule">The node module.</param>
/// <param name="nodePane">The node pane.</param>
/// <param name="portalId">The portal id.</param>
/// <param name="tabId">The tab id.</param>
/// <param name="mergeTabs">The merge tabs.</param>
/// <param name="hModules">The modules.</param>
public static void DeserializeModule(XmlNode nodeModule, XmlNode nodePane, int portalId, int tabId, PortalTemplateModuleAction mergeTabs, Hashtable hModules)
{
var moduleController = new ModuleController();
var moduleDefinition = GetModuleDefinition(nodeModule);
ModuleInfo module;
//will be instance or module?
int templateModuleID = XmlUtils.GetNodeValueInt(nodeModule, "moduleID");
bool isInstance = CheckIsInstance(templateModuleID, hModules);
if (moduleDefinition != null)
{
//If Mode is Merge Check if Module exists
if (!FindModule(nodeModule, tabId, mergeTabs))
{
module = DeserializeModule(nodeModule, nodePane, portalId, tabId, moduleDefinition.ModuleDefID);
//deserialize Module's settings
XmlNodeList nodeModuleSettings = nodeModule.SelectNodes("modulesettings/modulesetting");
DeserializeModuleSettings(nodeModuleSettings, module);
XmlNodeList nodeTabModuleSettings = nodeModule.SelectNodes("tabmodulesettings/tabmodulesetting");
DeserializeTabModuleSettings(nodeTabModuleSettings, module);
int intModuleId;
if (!isInstance)
{
//Add new module
intModuleId = moduleController.AddModule(module);
if (templateModuleID > 0)
{
hModules.Add(templateModuleID, intModuleId);
}
}
else
{
//Add instance
module.ModuleID = Convert.ToInt32(hModules[templateModuleID]);
intModuleId = moduleController.AddModule(module);
}
if (!String.IsNullOrEmpty(XmlUtils.GetNodeValue(nodeModule.CreateNavigator(), "content")) && !isInstance)
{
GetModuleContent(nodeModule, intModuleId, tabId, portalId);
}
//Process permissions only once
if (!isInstance && portalId != Null.NullInteger)
{
XmlNodeList nodeModulePermissions = nodeModule.SelectNodes("modulepermissions/permission");
DeserializeModulePermissions(nodeModulePermissions, portalId, module);
//Persist the permissions to the Data base
ModulePermissionController.SaveModulePermissions(module);
}
}
}
}
示例4: SaveTabData
//.........这里部分代码省略.........
{
parentTab = objTabs.GetTabByCulture(Tab.ParentId, PortalId, tabLocale);
}
Tab.ParentId = parentTab.TabID;
}
//Fix position TabId
if (positionTabID > Null.NullInteger)
{
var positionTab = objTabs.GetTab(positionTabID, PortalId, false);
if (positionTab.CultureCode != Tab.CultureCode)
{
positionTab = objTabs.GetTabByCulture(positionTabID, PortalId, tabLocale);
}
positionTabID = positionTab.TabID;
}
}
else
{
Tab.CultureCode = Null.NullString;
}
}
//Validate Tab Path
if (string.IsNullOrEmpty(strAction))
{
var tabID = TabController.GetTabByTabPath(Tab.PortalID, Tab.TabPath, Tab.CultureCode);
if (tabID != Null.NullInteger)
{
var existingTab = objTabs.GetTab(tabID, PortalId, false);
if (existingTab != null && existingTab.IsDeleted)
{
UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabRecycled", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
}
else
{
UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
}
return Null.NullInteger;
}
}
Tab.StartDate = datepickerStartDate.SelectedDate != null ? datepickerStartDate.SelectedDate.Value : Null.NullDate;
Tab.EndDate = datepickerEndDate.SelectedDate != null ? datepickerEndDate.SelectedDate.Value : Null.NullDate;
if (Tab.StartDate > Null.NullDate && Tab.EndDate > Null.NullDate && Tab.StartDate.AddDays(1) >= Tab.EndDate)
{
UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("InvalidTabDates", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
return Null.NullInteger;
}
if (txtRefreshInterval.Text.Length > 0 && Regex.IsMatch(txtRefreshInterval.Text, "^\\d+$"))
{
Tab.RefreshInterval = Convert.ToInt32(txtRefreshInterval.Text);
}
Tab.SiteMapPriority = float.Parse(txtPriority.Text);
Tab.PageHeadText = txtPageHeadText.Text;
Tab.IsSecure = chkSecure.Checked;
Tab.PermanentRedirect = chkPermanentRedirect.Checked;
if (strAction == "edit")
{
// trap circular tab reference
if (cboParentTab.SelectedItem != null && Tab.TabID != Int32.Parse(cboParentTab.SelectedItem.Value) && !IsCircularReference(Int32.Parse(cboParentTab.SelectedItem.Value), Tab.PortalID))
{
示例5: AddExistingModule
/// -----------------------------------------------------------------------------
/// <summary>
/// Adds an Existing Module to a Pane
/// </summary>
/// <param name="align">The alignment for the Modue</param>
/// <param name="moduleId">The Id of the existing module</param>
/// <param name="tabId">The id of the tab</param>
/// <param name="paneName">The pane to add the module to</param>
/// <param name="position">The relative position within the pane for the module</param>
/// <history>
/// [cnurse] 01/11/2008 documented
/// </history>
/// -----------------------------------------------------------------------------
protected void AddExistingModule(int moduleId, int tabId, string paneName, int position, string align)
{
var objModules = new ModuleController();
ModuleInfo objModule;
var objEventLog = new EventLogController();
int UserId = -1;
if (Request.IsAuthenticated)
{
UserInfo objUserInfo = UserController.GetCurrentUserInfo();
UserId = objUserInfo.UserID;
}
objModule = objModules.GetModule(moduleId, tabId, false);
if (objModule != null)
{
//clone the module object ( to avoid creating an object reference to the data cache )
ModuleInfo objClone = objModule.Clone();
objClone.TabID = PortalSettings.ActiveTab.TabID;
objClone.ModuleOrder = position;
objClone.PaneName = paneName;
objClone.Alignment = align;
objModules.AddModule(objClone);
objEventLog.AddLog(objClone, PortalSettings, UserId, "", EventLogController.EventLogType.MODULE_CREATED);
}
}
示例6: DoAddNewModule
private int DoAddNewModule(string title, int desktopModuleId, string paneName, int position, int permissionType, string align)
{
var objModules = new ModuleController();
try
{
DesktopModuleInfo desktopModule;
if (!DesktopModuleController.GetDesktopModules(PortalSettings.Current.PortalId).TryGetValue(desktopModuleId, out desktopModule))
{
throw new ArgumentException("desktopModuleId");
}
}
catch (Exception ex)
{
Exceptions.LogException(ex);
}
var tabModuleId = Null.NullInteger;
foreach (ModuleDefinitionInfo objModuleDefinition in
ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
{
var objModule = new ModuleInfo();
objModule.Initialize(PortalSettings.Current.ActiveTab.PortalID);
objModule.PortalID = PortalSettings.Current.ActiveTab.PortalID;
objModule.TabID = PortalSettings.Current.ActiveTab.TabID;
objModule.ModuleOrder = position;
objModule.ModuleTitle = string.IsNullOrEmpty(title) ? objModuleDefinition.FriendlyName : title;
objModule.PaneName = paneName;
objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
if (objModuleDefinition.DefaultCacheTime > 0)
{
objModule.CacheTime = objModuleDefinition.DefaultCacheTime;
if (PortalSettings.Current.DefaultModuleId > Null.NullInteger && PortalSettings.Current.DefaultTabId > Null.NullInteger)
{
ModuleInfo defaultModule = objModules.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true);
if ((defaultModule != null))
{
objModule.CacheTime = defaultModule.CacheTime;
}
}
}
objModules.InitialModulePermission(objModule, objModule.TabID, permissionType);
if (PortalSettings.Current.ContentLocalizationEnabled)
{
Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalSettings.Current.PortalId);
//set the culture of the module to that of the tab
var tabInfo = new TabController().GetTab(objModule.TabID, PortalSettings.Current.PortalId, false);
objModule.CultureCode = tabInfo != null ? tabInfo.CultureCode : defaultLocale.Code;
}
else
{
objModule.CultureCode = Null.NullString;
}
objModule.AllTabs = false;
objModule.Alignment = align;
objModules.AddModule(objModule);
if (tabModuleId == Null.NullInteger)
{
tabModuleId = objModule.ModuleID;
}
//update the position to let later modules with add after previous one.
position = objModules.GetTabModule(objModule.TabModuleID).ModuleOrder + 1;
}
return tabModuleId;
}
示例7: ParsePanes
//.........这里部分代码省略.........
if( moduleFound == false )
{
//Create New Module
objModule = new ModuleInfo();
objModule.PortalID = PortalId;
objModule.TabID = TabId;
objModule.ModuleOrder = -1;
objModule.ModuleTitle = modTitle;
objModule.PaneName = XmlUtils.GetNodeValue( nodePaneWithinLoop, "name", "" );
objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
objModule.CacheTime = XmlUtils.GetNodeValueInt( nodeModuleWithinLoop, "cachetime", 0 );
objModule.Alignment = XmlUtils.GetNodeValue( nodeModuleWithinLoop, "alignment", "" );
objModule.IconFile = ImportFile( PortalId, XmlUtils.GetNodeValue( nodeModuleWithinLoop, "iconfile", "" ) );
objModule.AllTabs = XmlUtils.GetNodeValueBoolean( nodeModuleWithinLoop, "alltabs", false );
switch( XmlUtils.GetNodeValue( nodeModuleWithinLoop, "visibility", "" ) )
{
case "Maximized":
objModule.Visibility = VisibilityState.Maximized;
break;
case "Minimized":
objModule.Visibility = VisibilityState.Minimized;
break;
case "None":
objModule.Visibility = VisibilityState.None;
break;
}
objModule.Color = XmlUtils.GetNodeValue( nodeModuleWithinLoop, "color", "" );
objModule.Border = XmlUtils.GetNodeValue( nodeModuleWithinLoop, "border", "" );
objModule.Header = XmlUtils.GetNodeValue( nodeModuleWithinLoop, "header", "" );
objModule.Footer = XmlUtils.GetNodeValue( nodeModuleWithinLoop, "footer", "" );
objModule.InheritViewPermissions = XmlUtils.GetNodeValueBoolean( nodeModuleWithinLoop, "inheritviewpermissions", false );
objModule.ModulePermissions = new ModulePermissionCollection();
objModule.StartDate = XmlUtils.GetNodeValueDate( nodeModuleWithinLoop, "startdate", Null.NullDate );
objModule.EndDate = XmlUtils.GetNodeValueDate( nodeModuleWithinLoop, "enddate", Null.NullDate );
if( XmlUtils.GetNodeValue( nodeModuleWithinLoop, "containersrc", "" ) != "" )
{
objModule.ContainerSrc = XmlUtils.GetNodeValue( nodeModuleWithinLoop, "containersrc", "" );
}
objModule.DisplayTitle = XmlUtils.GetNodeValueBoolean( nodeModuleWithinLoop, "displaytitle", true );
objModule.DisplayPrint = XmlUtils.GetNodeValueBoolean( nodeModuleWithinLoop, "displayprint", true );
objModule.DisplaySyndicate = XmlUtils.GetNodeValueBoolean( nodeModuleWithinLoop, "displaysyndicate", false );
if( !IsInstance )
{
//Add new module
intModuleId = objModules.AddModule( objModule );
if( templateModuleID > 0 )
{
hModules.Add( templateModuleID, intModuleId );
}
}
else
{
//Add instance
objModule.ModuleID = Convert.ToInt32( hModules[templateModuleID] );
intModuleId = objModules.AddModule( objModule );
}
if( XmlUtils.GetNodeValue( nodeModuleWithinLoop, "content", "" ) != "" & !IsInstance )
{
objModule = objModules.GetModule( intModuleId, TabId, true );
string strVersion = nodeModule.SelectSingleNode( "content" ).Attributes["version"].Value;
string strType = nodeModule.SelectSingleNode( "content" ).Attributes["type"].Value;
string strcontent = nodeModule.SelectSingleNode( "content" ).InnerXml;
strcontent = strcontent.Substring( 9, strcontent.Length - 12 );
strcontent = HttpContext.Current.Server.HtmlDecode( strcontent );
if( objModule.BusinessControllerClass != "" & objModule.IsPortable )
{
try
{
object objObject = Reflection.CreateObject( objModule.BusinessControllerClass, objModule.BusinessControllerClass );
if( objObject is IPortable )
{
( (IPortable)objObject ).ImportModule( objModule.ModuleID, strcontent, strVersion, objportal.AdministratorId );
}
}
catch
{
//ignore errors
}
}
}
// Process permissions only once
if( !IsInstance )
{
XmlNodeList nodeModulePermissions = nodeModule.SelectNodes( "modulepermissions/permission" );
ParseModulePermissions( nodeModulePermissions, PortalId, intModuleId );
}
}
}
}
}
}
}
}
示例8: SaveTabData
/// <summary>
/// SaveTabData saves the Tab to the Database
/// </summary>
/// <param name="action">The action to perform "edit" or "add"</param>
/// <history>
/// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support
/// and localisation
/// </history>
public int SaveTabData( string action )
{
EventLogController objEventLog = new EventLogController();
string strIcon = ctlIcon.Url;
TabController objTabs = new TabController();
TabInfo objTab = new TabInfo();
objTab.TabID = TabId;
objTab.PortalID = PortalId;
objTab.TabName = txtTabName.Text;
objTab.Title = txtTitle.Text;
objTab.Description = txtDescription.Text;
objTab.KeyWords = txtKeyWords.Text;
objTab.IsVisible = ! chkHidden.Checked;
objTab.DisableLink = chkDisableLink.Checked;
objTab.ParentId = int.Parse( cboTab.SelectedItem.Value );
objTab.IconFile = strIcon;
objTab.IsDeleted = false;
objTab.Url = ctlURL.Url;
objTab.TabPermissions = dgPermissions.Permissions;
objTab.SkinSrc = ctlSkin.SkinSrc;
objTab.ContainerSrc = ctlContainer.SkinSrc;
objTab.TabPath = Globals.GenerateTabPath(objTab.ParentId, objTab.TabName);
if( !String.IsNullOrEmpty(txtStartDate.Text) )
{
objTab.StartDate = Convert.ToDateTime( txtStartDate.Text );
}
else
{
objTab.StartDate = Null.NullDate;
}
if( !String.IsNullOrEmpty(txtEndDate.Text) )
{
objTab.EndDate = Convert.ToDateTime( txtEndDate.Text );
}
else
{
objTab.EndDate = Null.NullDate;
}
int refreshInt;
if( txtRefreshInterval.Text.Length > 0 && Int32.TryParse(txtRefreshInterval.Text, out refreshInt ) )
{
objTab.RefreshInterval = Convert.ToInt32( txtRefreshInterval.Text );
}
objTab.PageHeadText = txtPageHeadText.Text;
if( action == "edit" )
{
// trap circular tab reference
if( objTab.TabID != int.Parse( cboTab.SelectedItem.Value ) && ! IsCircularReference( int.Parse( cboTab.SelectedItem.Value ) ) )
{
objTabs.UpdateTab( objTab );
objEventLog.AddLog( objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_UPDATED );
}
}
else // add or copy
{
objTab.TabID = objTabs.AddTab( objTab );
objEventLog.AddLog( objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_CREATED );
if( int.Parse( cboCopyPage.SelectedItem.Value ) != - 1 )
{
ModuleController objModules = new ModuleController();
foreach( DataGridItem objDataGridItem in grdModules.Items )
{
CheckBox chkModule = (CheckBox)objDataGridItem.FindControl( "chkModule" );
if( chkModule.Checked )
{
int intModuleID = Convert.ToInt32( grdModules.DataKeys[ objDataGridItem.ItemIndex ] );
//RadioButton optNew = (RadioButton)objDataGridItem.FindControl( "optNew" );
RadioButton optCopy = (RadioButton)objDataGridItem.FindControl( "optCopy" );
RadioButton optReference = (RadioButton)objDataGridItem.FindControl( "optReference" );
TextBox txtCopyTitle = (TextBox)objDataGridItem.FindControl( "txtCopyTitle" );
ModuleInfo objModule = objModules.GetModule( intModuleID, Int32.Parse( cboCopyPage.SelectedItem.Value ), false );
if( objModule != null )
{
if( ! optReference.Checked )
{
objModule.ModuleID = Null.NullInteger;
}
objModule.TabID = objTab.TabID;
objModule.ModuleTitle = txtCopyTitle.Text;
objModule.ModuleID = objModules.AddModule( objModule );
if( optCopy.Checked )
{
//.........这里部分代码省略.........
示例9: CopyModuleToPage
/// <summary>
/// Copies the module to page.
/// </summary>
/// <param name="moduleToCopy">The module to copy.</param>
/// <param name="destinationTabID">The destination tab ID.</param>
private static void CopyModuleToPage(ModuleInfo moduleToCopy, int destinationTabID)
{
var moduleController = new ModuleController();
// duplicate the module and assign it the new page
ModuleInfo newModule = moduleToCopy.Clone();
newModule.ModuleID = -1;
newModule.TabID = destinationTabID;
// add it to the system - this takes care of adding the
// module and the tab module
newModule.ModuleID = moduleController.AddModule(newModule);
// duplicate the settings for the module
DuplicateModuleSettings(moduleToCopy, newModule.ModuleID);
// duplicate the settings for the tabmodule
moduleController.CopyTabModuleSettings(moduleToCopy, newModule);
}
示例10: AddModuleToPage
/// <summary>
/// AddModuleToPage adds a module to a Page
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="page">The Page to add the Module to</param>
/// <param name="ModuleDefId">The Module Deinition Id for the module to be aded to this tab</param>
/// <param name="ModuleTitle">The Module's title</param>
/// <param name="ModuleIconFile">The Module's icon</param>
/// <param name="InheritPermissions">Inherit the Pages View Permisions</param>
private static void AddModuleToPage(TabInfo page, int ModuleDefId, string ModuleTitle, string ModuleIconFile, bool InheritPermissions)
{
ModuleController objModules = new ModuleController();
ModuleInfo objModule;
bool blnDuplicate = false;
foreach (KeyValuePair<int, ModuleInfo> kvp in objModules.GetTabModules(page.TabID))
{
objModule = kvp.Value;
if (objModule.ModuleDefID == ModuleDefId)
{
blnDuplicate = true;
}
}
if (!blnDuplicate)
{
objModule = new ModuleInfo();
objModule.ModuleID = Null.NullInteger;
objModule.PortalID = page.PortalID;
objModule.TabID = page.TabID;
objModule.ModuleOrder = -1;
objModule.ModuleTitle = ModuleTitle;
objModule.PaneName = Globals.glbDefaultPane;
objModule.ModuleDefID = ModuleDefId;
objModule.CacheTime = 0;
objModule.IconFile = ModuleIconFile;
objModule.AllTabs = false;
objModule.Visibility = VisibilityState.Maximized;
objModule.InheritViewPermissions = InheritPermissions;
try
{
objModules.AddModule(objModule);
}
catch
{
// error adding module
}
}
}
示例11: AddModuleToPage
/// <summary>
/// Adds the module to page.
/// </summary>
/// <param name="portalId">The portal id.</param>
/// <param name="tabId">The tab id.</param>
/// <exception cref="System.ArgumentException">desktopModuleId</exception>
private void AddModuleToPage(int portalId, int tabId)
{
TabPermissionCollection objTabPermissions = new TabController().GetTab(tabId, portalId, false).TabPermissions;
var objPermissionController = new PermissionController();
var objModules = new ModuleController();
new EventLogController();
int desktopModuleId =
DesktopModuleController.GetDesktopModuleByFriendlyName("VanityURLs").DesktopModuleID;
try
{
DesktopModuleInfo desktopModule;
if (!DesktopModuleController.GetDesktopModules(portalId).TryGetValue(desktopModuleId, out desktopModule))
{
throw new ArgumentException("desktopModuleId");
}
}
catch (Exception ex)
{
Exceptions.LogException(ex);
}
foreach (ModuleDefinitionInfo objModuleDefinition in
ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
{
var objModule = new ModuleInfo();
objModule.PortalID = portalId;
objModule.TabID = tabId;
objModule.ModuleOrder = 0;
objModule.ModuleTitle = objModuleDefinition.FriendlyName;
objModule.PaneName = "ContentPane";
objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
objModule.InheritViewPermissions = true;
objModule.CultureCode = Null.NullString;
objModule.AllTabs = false;
objModules.AddModule(objModule);
}
}
示例12: btnAddModule_Click
protected void btnAddModule_Click(object sender, EventArgs e)
{
string DesktopModuleFriendlyName = "DNNDal2";
ModuleDefinitionInfo moduleDefinitionInfo = new ModuleDefinitionInfo();
ModuleInfo moduleInfo = new ModuleInfo();
moduleInfo.PortalID = 0;
moduleInfo.TabID = 150;
moduleInfo.PaneName = "TopPane";
moduleInfo.ModuleDefID = 160;
moduleInfo.CacheTime = moduleDefinitionInfo.DefaultCacheTime;//Default Cache Time is 0
moduleInfo.InheritViewPermissions = true; //Inherit View Permissions from Tab
moduleInfo.AllTabs = false;
moduleInfo.Alignment = "Top";
ModuleController moduleController = new ModuleController();
int moduleId = moduleController.AddModule(moduleInfo);
}
示例13: DeserializeModule
public static void DeserializeModule(XmlNode nodeModule, XmlNode nodePane, int portalId, int tabId,
PortalTemplateModuleAction mergeTabs, Hashtable hModules)
{
var moduleController = new ModuleController();
var objModuleDefinition = GetModuleDefinition(nodeModule);
// will be instance or module
var templateModuleId = XmlUtils.GetNodeValueInt(nodeModule, "moduleID");
var isInstance = CheckIsInstance(templateModuleId, hModules);
//remove containersrc node if container is missing
var containerNode = nodeModule.SelectSingleNode("containersrc");
if (containerNode != null)
{
var container = containerNode.Value;
if (! File.Exists(HttpContext.Current.Server.MapPath(container)))
{
nodeModule.RemoveChild(containerNode);
}
}
if (objModuleDefinition != null)
{
//If Mode is Merge Check if Module exists
if (! FindModule(nodeModule, tabId, mergeTabs))
{
var module = DeserializeModule(nodeModule, nodePane, portalId, tabId,
objModuleDefinition.ModuleDefID);
int intModuleId;
if (! isInstance)
{
//Add new module
intModuleId = moduleController.AddModule(module);
if (templateModuleId > 0)
{
hModules.Add(templateModuleId, intModuleId);
}
}
else
{
//Add instance
module.ModuleID = Convert.ToInt32(hModules[templateModuleId]);
intModuleId = moduleController.AddModule(module);
}
if (XmlUtils.GetNodeValue(nodeModule, "content", "") != "")
{
GetModuleContent(nodeModule, intModuleId, tabId, portalId, isInstance);
}
// Process permissions and moduleSettings only once
if (! isInstance)
{
var nodeModulePermissions = nodeModule.SelectNodes("modulepermissions/permission");
DeserializeModulePermissions(nodeModulePermissions, portalId, module);
//Persist the permissions to the Data base
ModulePermissionController.SaveModulePermissions(module);
var nodeModuleSettings = nodeModule.SelectNodes("modulesettings/setting");
DeserializeModuleSettings(nodeModuleSettings, intModuleId);
}
//apply TabModuleSettings
var nodeTabModuleSettings = nodeModule.SelectNodes("tabmodulesettings/setting");
DeserializeTabModuleSettings(nodeTabModuleSettings, intModuleId, tabId);
}
}
}
示例14: GenerateAdminTab
private static void GenerateAdminTab(int PortalId)
{
var tabID = TabController.GetTabByTabPath(PortalId, @"//Admin//OpenUrlRewriter", Null.NullString);
if (tabID == Null.NullInteger)
{
var adminTabID = TabController.GetTabByTabPath(PortalId, @"//Admin", Null.NullString);
/* dont work on dnn 7 - generate new section "SEO Features" in admin menu
var tabName = "SEO Features";
var tabPath = Globals.GenerateTabPath(adminTabID, tabName);
tabID = TabController.GetTabByTabPath(PortalId, tabPath, Null.NullString);
if (tabID == Null.NullInteger)
{
//Create a new page
var newParentTab = new TabInfo();
newParentTab.TabName = tabName;
newParentTab.ParentId = adminTabID;
newParentTab.PortalID = PortalId;
newParentTab.IsVisible = true;
newParentTab.DisableLink = true;
newParentTab.TabID = new TabController().AddTab(newParentTab);
tabID = newParentTab.TabID;
}
*/
// create new page "Url Rules Cache"
int parentTabID = adminTabID;
var tabName = "Open Url Rewriter";
var tabPath = Globals.GenerateTabPath(parentTabID, tabName);
tabID = TabController.GetTabByTabPath(PortalId, tabPath, Null.NullString);
if (tabID == Null.NullInteger)
{
//Create a new page
var newTab = new TabInfo();
newTab.TabName = tabName;
newTab.ParentId = parentTabID;
newTab.PortalID = PortalId;
newTab.IsVisible = true;
#if DNN71
newTab.IconFile = "~/Icons/Sigma/AdvancedUrlMngmt_16x16.png";
newTab.IconFileLarge = "~/Icons/Sigma/AdvancedUrlMngmt_32x32.png";
#else
newTab.IconFile = "~/Images/icon_search_16px.gif";
newTab.IconFileLarge = "~/Images/icon_search_32px.gif";
#endif
newTab.TabID = new TabController().AddTab(newTab, false);
tabID = newTab.TabID;
}
}
// create new module "OpenUrlRewriter"
var moduleCtl = new ModuleController();
if (moduleCtl.GetTabModules(tabID).Count == 0)
{
var dmc = new DesktopModuleController();
var dm = dmc.GetDesktopModuleByModuleName("OpenUrlRewriter");
var mdc = new ModuleDefinitionController();
var md = mdc.GetModuleDefinitionByName(dm.DesktopModuleID, "OpenUrlRewriter");
var objModule = new ModuleInfo();
//objModule.Initialize(PortalId);
objModule.PortalID = PortalId;
objModule.TabID = tabID;
objModule.ModuleOrder = Null.NullInteger;
objModule.ModuleTitle = "Open Url Rewriter";
objModule.PaneName = Globals.glbDefaultPane;
objModule.ModuleDefID = md.ModuleDefID;
objModule.InheritViewPermissions = true;
objModule.AllTabs = false;
#if DNN71
objModule.IconFile = "~/Icons/Sigma/AdvancedUrlMngmt_16x16.png";
#else
objModule.IconFile = "~/Images/icon_search_32px.gif";
#endif
moduleCtl.AddModule(objModule);
}
}
示例15: DoAddExistingModule
//this has an overload of whether or not to create a cloned module
private void DoAddExistingModule(int moduleId, int tabId, string paneName, int position, string align, bool cloneModule)
{
var moduleCtrl = new ModuleController();
ModuleInfo moduleInfo = moduleCtrl.GetModule(moduleId, tabId, false);
int userID = -1;
if (Request.IsAuthenticated)
{
UserInfo user = UserController.GetCurrentUserInfo();
if (((user != null)))
{
userID = user.UserID;
}
}
if ((moduleInfo != null))
{
// clone the module object ( to avoid creating an object reference to the data cache )
ModuleInfo newModule = moduleInfo.Clone();
newModule.UniqueId = Guid.NewGuid(); // Cloned Module requires a different uniqueID
newModule.TabID = PortalSettings.Current.ActiveTab.TabID;
newModule.ModuleOrder = position;
newModule.PaneName = paneName;
newModule.Alignment = align;
if ((cloneModule))
{
newModule.ModuleID = Null.NullInteger;
//reset the module id
newModule.ModuleID = moduleCtrl.AddModule(newModule);
if (!string.IsNullOrEmpty(newModule.DesktopModule.BusinessControllerClass))
{
object objObject = Reflection.CreateObject(newModule.DesktopModule.BusinessControllerClass, newModule.DesktopModule.BusinessControllerClass);
if (objObject is IPortable)
{
string content = Convert.ToString(((IPortable) objObject).ExportModule(moduleId));
if (!string.IsNullOrEmpty(content))
{
((IPortable) objObject).ImportModule(newModule.ModuleID, content, newModule.DesktopModule.Version, userID);
}
}
}
}
else
{
moduleCtrl.AddModule(newModule);
}
//Add Event Log
var objEventLog = new EventLogController();
objEventLog.AddLog(newModule, PortalSettings.Current, userID, "", EventLogController.EventLogType.MODULE_CREATED);
}
}