本文整理汇总了C#中DotNetNuke.Security.Permissions.PermissionController.UpdatePermission方法的典型用法代码示例。如果您正苦于以下问题:C# PermissionController.UpdatePermission方法的具体用法?C# PermissionController.UpdatePermission怎么用?C# PermissionController.UpdatePermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Security.Permissions.PermissionController
的用法示例。
在下文中一共展示了PermissionController.UpdatePermission方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveModuleDefinition
/// -----------------------------------------------------------------------------
/// <summary>
/// SaveModuleDefinition saves the Module Definition to the database
/// </summary>
/// <param name="moduleDefinition">The Module Definition to save</param>
/// <param name="saveChildren">A flag that determines whether the child objects are also saved</param>
/// <param name="clearCache">A flag that determines whether to clear the host cache</param>
/// <history>
/// [cnurse] 01/14/2008 Created
/// </history>
/// -----------------------------------------------------------------------------
public static int SaveModuleDefinition(ModuleDefinitionInfo moduleDefinition, bool saveChildren, bool clearCache)
{
int moduleDefinitionID = moduleDefinition.ModuleDefID;
if (moduleDefinitionID == Null.NullInteger)
{
//Add new Module Definition
moduleDefinitionID = dataProvider.AddModuleDefinition(moduleDefinition.DesktopModuleID,
moduleDefinition.FriendlyName,
moduleDefinition.DefinitionName,
moduleDefinition.DefaultCacheTime,
UserController.Instance.GetCurrentUserInfo().UserID);
}
else
{
//Upgrade Module Definition
dataProvider.UpdateModuleDefinition(moduleDefinition.ModuleDefID, moduleDefinition.FriendlyName, moduleDefinition.DefinitionName, moduleDefinition.DefaultCacheTime, UserController.Instance.GetCurrentUserInfo().UserID);
}
if (saveChildren)
{
foreach (KeyValuePair<string, PermissionInfo> kvp in moduleDefinition.Permissions)
{
kvp.Value.ModuleDefID = moduleDefinitionID;
//check if permission exists
var permissionController = new PermissionController();
ArrayList permissions = permissionController.GetPermissionByCodeAndKey(kvp.Value.PermissionCode, kvp.Value.PermissionKey);
if (permissions != null && permissions.Count == 1)
{
var permission = (PermissionInfo) permissions[0];
kvp.Value.PermissionID = permission.PermissionID;
permissionController.UpdatePermission(kvp.Value);
}
else
{
permissionController.AddPermission(kvp.Value);
}
}
foreach (KeyValuePair<string, ModuleControlInfo> kvp in moduleDefinition.ModuleControls)
{
kvp.Value.ModuleDefID = moduleDefinitionID;
//check if definition exists
ModuleControlInfo moduleControl = ModuleControlController.GetModuleControlByControlKey(kvp.Value.ControlKey, kvp.Value.ModuleDefID);
if (moduleControl != null)
{
kvp.Value.ModuleControlID = moduleControl.ModuleControlID;
}
ModuleControlController.SaveModuleControl(kvp.Value, clearCache);
}
}
if (clearCache)
{
DataCache.ClearHostCache(true);
}
return moduleDefinitionID;
}