本文整理汇总了C#中DotNetNuke.Entities.Modules.ModuleInfo.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleInfo.Initialize方法的具体用法?C# ModuleInfo.Initialize怎么用?C# ModuleInfo.Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Modules.ModuleInfo
的用法示例。
在下文中一共展示了ModuleInfo.Initialize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
private void Create()
{
//Create new Folder
string folderMapPath = Server.MapPath(string.Format("~/DesktopModules/RazorModules/{0}", txtFolder.Text));
if (Directory.Exists(folderMapPath))
{
UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("FolderExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
return;
}
else
{
//Create folder
Directory.CreateDirectory(folderMapPath);
}
//Create new Module Control
string moduleControlMapPath = folderMapPath + "/" + ModuleControl;
try
{
using (var moduleControlWriter = new StreamWriter(moduleControlMapPath))
{
moduleControlWriter.Write(Localization.GetString("ModuleControlText.Text", LocalResourceFile));
moduleControlWriter.Flush();
}
}
catch (Exception ex)
{
Exceptions.LogException(ex);
UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ModuleControlCreationError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
return;
}
//Copy Script to new Folder
string scriptSourceFile = Server.MapPath(string.Format(razorScriptFileFormatString, scriptList.SelectedValue));
string scriptTargetFile = folderMapPath + "/" + scriptList.SelectedValue;
try
{
File.Copy(scriptSourceFile, scriptTargetFile);
}
catch (Exception ex)
{
Exceptions.LogException(ex);
UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ScriptCopyError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
return;
}
//Create new Manifest in target folder
string manifestMapPath = folderMapPath + "/" + ModuleControl.Replace(".ascx", ".dnn");
try
{
using (var manifestWriter = new StreamWriter(manifestMapPath))
{
string manifestTemplate = Localization.GetString("ManifestText.Text", LocalResourceFile);
string manifest = string.Format(manifestTemplate, txtName.Text, txtDescription.Text, txtFolder.Text, ModuleControl, scriptList.SelectedValue);
manifestWriter.Write(manifest);
manifestWriter.Flush();
}
}
catch (Exception ex)
{
Exceptions.LogException(ex);
UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ManifestCreationError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
return;
}
//Register Module
ModuleDefinitionInfo moduleDefinition = ImportManifest(manifestMapPath);
//remove the manifest file
try
{
FileWrapper.Instance.Delete(manifestMapPath);
}
catch (Exception ex)
{
Logger.Error(ex);
}
//Optionally goto new Page
if (chkAddPage.Checked)
{
string tabName = "Test " + txtName.Text + " Page";
string tabPath = Globals.GenerateTabPath(Null.NullInteger, tabName);
int tabID = TabController.GetTabByTabPath(ModuleContext.PortalId, tabPath, ModuleContext.PortalSettings.CultureCode);
if (tabID == Null.NullInteger)
{
//Create a new page
var newTab = new TabInfo();
newTab.TabName = "Test " + txtName.Text + " Page";
newTab.ParentId = Null.NullInteger;
newTab.PortalID = ModuleContext.PortalId;
newTab.IsVisible = true;
newTab.TabID = TabController.Instance.AddTabBefore(newTab, ModuleContext.PortalSettings.AdminTabId);
var objModule = new ModuleInfo();
objModule.Initialize(ModuleContext.PortalId);
objModule.PortalID = ModuleContext.PortalId;
//.........这里部分代码省略.........
示例2: AddNewModule
/// -----------------------------------------------------------------------------
/// <summary>
/// Adds a New Module to a Pane
/// </summary>
/// <param name="align">The alignment for the Modue</param>
/// <param name="desktopModuleId">The Id of the DesktopModule</param>
/// <param name="permissionType">The View Permission Type for the Module</param>
/// <param name="title">The Title for the resulting module</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 AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align)
{
TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions;
var objPermissionController = new PermissionController();
try
{
DesktopModuleInfo desktopModule;
if (!DesktopModuleController.GetDesktopModules(PortalSettings.PortalId).TryGetValue(desktopModuleId, out desktopModule))
{
throw new ArgumentException("desktopModuleId");
}
}
catch (Exception ex)
{
Exceptions.LogException(ex);
}
int UserId = -1;
if (Request.IsAuthenticated)
{
UserInfo objUserInfo = UserController.Instance.GetCurrentUserInfo();
UserId = objUserInfo.UserID;
}
foreach (ModuleDefinitionInfo objModuleDefinition in
ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
{
var objModule = new ModuleInfo();
objModule.Initialize(PortalSettings.PortalId);
objModule.PortalID = PortalSettings.PortalId;
objModule.TabID = PortalSettings.ActiveTab.TabID;
objModule.ModuleOrder = position;
if (String.IsNullOrEmpty(title))
{
objModule.ModuleTitle = objModuleDefinition.FriendlyName;
}
else
{
objModule.ModuleTitle = 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 = ModuleController.Instance.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true);
if (defaultModule != null)
{
objModule.CacheTime = defaultModule.CacheTime;
}
}
}
switch (permissionType)
{
case ViewPermissionType.View:
objModule.InheritViewPermissions = true;
break;
case ViewPermissionType.Edit:
objModule.InheritViewPermissions = false;
break;
}
//get the default module view permissions
ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");
//get the permissions from the page
foreach (TabPermissionInfo objTabPermission in objTabPermissions)
{
if (objTabPermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.View)
{
//Don't need to explicitly add View permisisons if "Same As Page"
continue;
}
//get the system module permissions for the permissionkey
ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
//loop through the system module permissions
int j;
for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++)
{
PermissionInfo objSystemModulePermission;
objSystemModulePermission = (PermissionInfo) arrSystemModulePermissions[j];
if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.Edit && objTabPermission.PermissionKey != "EDIT")
{
//Only Page Editors get View permissions if "Page Editors Only"
continue;
//.........这里部分代码省略.........
示例3: cmdCreate_Click
//.........这里部分代码省略.........
}
var uniqueName = true;
var packages = new List<PackageInfo>();
foreach (var package in PackageController.GetPackages())
{
if (package.Name == txtName.Text || package.FriendlyName == txtName.Text)
{
uniqueName = false;
break;
}
}
if (!uniqueName)
{
strMessage = Localization.GetString("NonuniqueName", LocalResourceFile);
break;
}
//First create the control
strMessage = CreateControl(controlSrc);
if (String.IsNullOrEmpty(strMessage))
{
//Next import the control
moduleDefinition = ImportControl(controlSrc);
}
break;
case "Control":
if (!String.IsNullOrEmpty(cboFile.SelectedValue))
{
moduleDefinition = ImportControl(cboFile.SelectedValue);
}
else
{
strMessage = Localization.GetString("NoControl", LocalResourceFile);
}
break;
case "Template":
break;
case "Manifest":
if (String.IsNullOrEmpty(cboFile.SelectedValue))
{
strMessage = Localization.GetString("MissingManifest", LocalResourceFile);
}
else
{
moduleDefinition = ImportManifest();
}
break;
}
if (moduleDefinition == null)
{
UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.RedError);
}
else
{
if (!string.IsNullOrEmpty(cboCreate.SelectedValue) && chkAddPage.Checked)
{
var tabName = "Test " + txtName.Text + " Page";
var tabPath = Globals.GenerateTabPath(Null.NullInteger, tabName);
var tabID = TabController.GetTabByTabPath(ModuleContext.PortalId, tabPath, Null.NullString);
if (tabID == Null.NullInteger)
{
//Create a new page
var newTab = new TabInfo();
newTab.TabName = "Test " + txtName.Text + " Page";
newTab.ParentId = Null.NullInteger;
newTab.PortalID = ModuleContext.PortalId;
newTab.IsVisible = true;
newTab.TabID = new TabController().AddTabBefore(newTab, ModuleContext.PortalSettings.AdminTabId);
var objModule = new ModuleInfo();
objModule.Initialize(ModuleContext.PortalId);
objModule.PortalID = ModuleContext.PortalId;
objModule.TabID = newTab.TabID;
objModule.ModuleOrder = Null.NullInteger;
objModule.ModuleTitle = moduleDefinition.FriendlyName;
objModule.PaneName = Globals.glbDefaultPane;
objModule.ModuleDefID = moduleDefinition.ModuleDefID;
objModule.InheritViewPermissions = true;
objModule.AllTabs = false;
var moduleCtl = new ModuleController();
moduleCtl.AddModule(objModule);
Response.Redirect(Globals.NavigateURL(newTab.TabID), true);
}
else
{
UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
}
}
else
{
//Redirect to main extensions page
Response.Redirect(Globals.NavigateURL(), true);
}
}
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
示例4: 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;
}
示例5: AddNewModule
private int AddNewModule(TabInfo tab, string title, int desktopModuleId, string paneName, int permissionType, string align)
{
TabPermissionCollection objTabPermissions = tab.TabPermissions;
var objPermissionController = new PermissionController();
var objModules = new ModuleController();
int j;
var mdc = new ModuleDefinitionController();
foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
{
var objModule = new ModuleInfo();
objModule.Initialize(tab.PortalID);
objModule.PortalID = tab.PortalID;
objModule.TabID = tab.TabID;
if (string.IsNullOrEmpty(title))
{
objModule.ModuleTitle = objModuleDefinition.FriendlyName;
}
else
{
objModule.ModuleTitle = title;
}
objModule.PaneName = paneName;
objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
objModule.CacheTime = 0;
objModule.InheritViewPermissions = true;
objModule.DisplayTitle = false;
// get the default module view permissions
ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");
// get the permissions from the page
foreach (TabPermissionInfo objTabPermission in objTabPermissions)
{
if (objTabPermission.PermissionKey == "VIEW" && permissionType == 0)
{
//Don't need to explicitly add View permisisons if "Same As Page"
continue;
}
// get the system module permissions for the permissionkey
ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
// loop through the system module permissions
for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++)
{
// create the module permission
PermissionInfo objSystemModulePermission = default(PermissionInfo);
objSystemModulePermission = (PermissionInfo) arrSystemModulePermissions[j];
if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == 1 && objTabPermission.PermissionKey != "EDIT")
{
//Only Page Editors get View permissions if "Page Editors Only"
continue;
}
ModulePermissionInfo objModulePermission = AddModulePermission(objModule,
objSystemModulePermission,
objTabPermission.RoleID,
objTabPermission.UserID,
objTabPermission.AllowAccess);
// ensure that every EDIT permission which allows access also provides VIEW permission
if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess)
{
ModulePermissionInfo objModuleViewperm = AddModulePermission(objModule,
(PermissionInfo) arrSystemModuleViewPermissions[0],
objModulePermission.RoleID,
objModulePermission.UserID,
true);
}
}
}
objModule.AllTabs = false;
objModule.Alignment = align;
return objModules.AddModule(objModule);
}
return -1;
}
示例6: DoAddNewModule
private static void DoAddNewModule(string title, int desktopModuleId, string paneName, int position, int permissionType, string align)
{
try
{
DesktopModuleInfo desktopModule;
if (!DesktopModuleController.GetDesktopModules(PortalSettings.Current.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.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 = ModuleController.Instance.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true);
if ((defaultModule != null))
{
objModule.CacheTime = defaultModule.CacheTime;
}
}
}
ModuleController.Instance.InitialModulePermission(objModule, objModule.TabID, permissionType);
if (PortalSettings.Current.ContentLocalizationEnabled)
{
Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalSettings.Current.PortalId);
//check whether original tab is exists, if true then set culture code to default language,
//otherwise set culture code to current.
if (TabController.Instance.GetTabByCulture(objModule.TabID, PortalSettings.Current.PortalId, defaultLocale) != null)
{
objModule.CultureCode = defaultLocale.Code;
}
else
{
objModule.CultureCode = PortalSettings.Current.CultureCode;
}
}
else
{
objModule.CultureCode = Null.NullString;
}
objModule.AllTabs = false;
objModule.Alignment = align;
ModuleController.Instance.AddModule(objModule);
}
}
示例7: AddNewModule
protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align)
{
TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions;
PermissionController objPermissionController = new PermissionController();
ModuleController objModules = new ModuleController();
ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();
Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
int intIndex;
try
{
DesktopModuleController objDesktopModules = new DesktopModuleController();
ArrayList arrDM = objDesktopModules.GetDesktopModulesByPortal(PortalSettings.PortalId);
bool isSelectable = false;
for (int intloop = 0; intloop < arrDM.Count; intloop++)
{
if (((DesktopModuleInfo)(arrDM[intloop])).DesktopModuleID == desktopModuleId)
{
isSelectable = true;
break;
}
}
if (isSelectable == false)
{
throw new Exception();
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
int UserId = -1;
if (Request.IsAuthenticated)
{
UserInfo objUserInfo = UserController.GetCurrentUserInfo();
UserId = objUserInfo.UserID;
}
ArrayList arrModuleDefinitions = objModuleDefinitions.GetModuleDefinitions(desktopModuleId);
for (intIndex = 0; intIndex < arrModuleDefinitions.Count; intIndex++)
{
ModuleDefinitionInfo objModuleDefinition = (ModuleDefinitionInfo)(arrModuleDefinitions[intIndex]);
ModuleInfo objModule = new ModuleInfo();
objModule.Initialize(PortalSettings.PortalId);
objModule.PortalID = PortalSettings.PortalId;
objModule.TabID = PortalSettings.ActiveTab.TabID;
objModule.ModuleOrder = position;
if (String.IsNullOrEmpty(title))
{
objModule.ModuleTitle = objModuleDefinition.FriendlyName;
}
else
{
objModule.ModuleTitle = title;
}
objModule.ModuleTitle = title;
objModule.PaneName = paneName;
objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
objModule.CacheTime = objModuleDefinition.DefaultCacheTime;
// initialize module permissions
ModulePermissionCollection objModulePermissions = new ModulePermissionCollection();
objModule.ModulePermissions = objModulePermissions;
objModule.InheritViewPermissions = false;
// get the default module view permissions
ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");
// get the permissions from the page
foreach (TabPermissionInfo objTabPermission in objTabPermissions)
{
// get the system module permissions for the permissionkey
ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
// loop through the system module permissions
int j;
for (j = 0; j < arrSystemModulePermissions.Count; j++)
{
// create the module permission
PermissionInfo objSystemModulePermission = (PermissionInfo)(arrSystemModulePermissions[j]);
ModulePermissionInfo objModulePermission = AddModulePermission(objModule.ModuleID, objSystemModulePermission, objTabPermission.RoleID);
// add the permission to the collection
if (!(objModulePermissions.Contains(objModulePermission)) & objModulePermission.AllowAccess)
{
objModulePermissions.Add(objModulePermission);
}
// ensure that every EDIT permission which allows access also provides VIEW permission
if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess)
{
ModulePermissionInfo objModuleViewperm = new ModulePermissionInfo();
objModuleViewperm.ModuleID = objModulePermission.ModuleID;
objModuleViewperm.PermissionID = ((PermissionInfo)(arrSystemModuleViewPermissions[0])).PermissionID;
//.........这里部分代码省略.........