本文整理汇总了C#中DotNetNuke.Entities.Tabs.TabInfo.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# TabInfo.Clone方法的具体用法?C# TabInfo.Clone怎么用?C# TabInfo.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Tabs.TabInfo
的用法示例。
在下文中一共展示了TabInfo.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateLocalizedCopy
/// <summary>
/// Creates the localized copy.
/// </summary>
/// <param name="originalTab">The original tab.</param>
/// <param name="locale">The locale.</param>
/// <param name="clearCache">Clear the cache?</param>
public void CreateLocalizedCopy(TabInfo originalTab, Locale locale, bool clearCache)
{
try
{
Logger.TraceFormat("Localizing TabId: {0}, TabPath: {1}, Locale: {2}",originalTab.TabID,originalTab.TabPath,locale.Code);
var defaultLocale = LocaleController.Instance.GetDefaultLocale(originalTab.PortalID);
//First Clone the Tab
TabInfo localizedCopy = originalTab.Clone();
localizedCopy.TabID = Null.NullInteger;
//Set Guids and Culture Code
localizedCopy.UniqueId = Guid.NewGuid();
localizedCopy.VersionGuid = Guid.NewGuid();
localizedCopy.LocalizedVersionGuid = Guid.NewGuid();
localizedCopy.CultureCode = locale.Code;
localizedCopy.TabName = localizedCopy.TabName + " (" + locale.Code + ")";
if (locale == defaultLocale)
{
originalTab.DefaultLanguageGuid = localizedCopy.UniqueId;
UpdateTab(originalTab);
}
else
{
localizedCopy.DefaultLanguageGuid = originalTab.UniqueId;
}
//Copy Permissions from original Tab for Admins only
var portalCtrl = new PortalController();
PortalInfo portal = portalCtrl.GetPortal(originalTab.PortalID);
localizedCopy.TabPermissions.AddRange(
originalTab.TabPermissions.Where(p => p.RoleID == portal.AdministratorRoleId));
//Get the original Tabs Parent
//check the original whether have parent.
if (!Null.IsNull(originalTab.ParentId))
{
TabInfo originalParent = GetTab(originalTab.ParentId, originalTab.PortalID, false);
if (originalParent != null)
{
//Get the localized parent
TabInfo localizedParent = GetTabByCulture(originalParent.TabID, originalParent.PortalID, locale);
localizedCopy.ParentId = localizedParent.TabID;
}
}
//Save Tab
AddTabInternal(localizedCopy, -1, -1, true);
//Make shallow copies of all modules
var moduleCtrl = new ModuleController();
moduleCtrl.CopyModules(originalTab, localizedCopy, true);
//Convert these shallow copies to deep copies
foreach (KeyValuePair<int, ModuleInfo> kvp in moduleCtrl.GetTabModules(localizedCopy.TabID))
{
moduleCtrl.LocalizeModule(kvp.Value, locale);
}
//Add Translator Role
GiveTranslatorRoleEditRights(localizedCopy, null);
}
catch (Exception ex)
{
Exceptions.LogException(ex);
throw;
}
//Clear the Cache
if (clearCache)
ClearCache(originalTab.PortalID);
}