本文整理汇总了C#中TreeNode.SetDefaultPageTemplateID方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.SetDefaultPageTemplateID方法的具体用法?C# TreeNode.SetDefaultPageTemplateID怎么用?C# TreeNode.SetDefaultPageTemplateID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode.SetDefaultPageTemplateID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
int selectedPageTemplateId = ValidationHelper.GetInteger(hdnSelected.Value, 0);
// Inserts new document
if (action == "new")
{
try
{
string name = txtPageName.Text;
node = TreeNode.New("CMS.menuitem");
node.DocumentName = name;
node.SetDefaultPageTemplateID(selectedPageTemplateId);
node.SetValue("MenuItemName", name);
node.DocumentCulture = CultureHelper.GetDefaultCulture(siteName);
DocumentHelper.InsertDocument(node, nodeId, tree);
AddScript("RefreshNode(" + node.NodeParentID + "," + node.NodeID + "); SelectNode(" + node.NodeID + ");");
ShowChangesSaved();
}
catch (Exception ex)
{
AddAlert(GetString("DefineSiteStructure.InsertFailed") + " : " + ex.Message);
}
}
else if (action == "edit")
{
// Updates node
try
{
node = tree.SelectSingleNode(nodeId);
node.SetValue("DocumentName", txtPageName.Text);
node.SetDefaultPageTemplateID(selectedPageTemplateId);
DocumentHelper.UpdateDocument(node, tree);
AddScript("RefreshNode(" + node.NodeParentID + "," + node.NodeID + "); SelectNode(" + node.NodeID + ");");
ShowChangesSaved();
}
catch (Exception ex)
{
AddAlert(GetString("DefineSiteStructure.UpdateFailed") + " : " + ex.Message);
}
}
}
示例2: HandleContentUpload
/// <summary>
/// Provides operations necessary to create and store new cms file.
/// </summary>
/// <param name="args">Upload arguments.</param>
/// <param name="context">HttpContext instance.</param>
private void HandleContentUpload(UploaderHelper args, HttpContext context)
{
bool newDocumentCreated = false;
string name = args.Name;
try
{
if (args.FileArgs.NodeID == 0)
{
throw new Exception(ResHelper.GetString("dialogs.document.parentmissing"));
}
// Check license limitations
if (!LicenseHelper.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Documents, VersionActionEnum.Insert))
{
throw new Exception(ResHelper.GetString("cmsdesk.documentslicenselimits"));
}
// Check user permissions
if (!CMSContext.CurrentUser.IsAuthorizedToCreateNewDocument(args.FileArgs.NodeID, "CMS.File"))
{
throw new Exception(string.Format(ResHelper.GetString("dialogs.newfile.notallowed"), "CMS.File"));
}
// Check if class exists
DataClassInfo ci = DataClassInfoProvider.GetDataClass("CMS.File");
if (ci == null)
{
throw new Exception(string.Format(ResHelper.GetString("dialogs.newfile.classnotfound"), "CMS.File"));
}
#region "Check permissions"
// Get the node
using (TreeNode parentNode = TreeProvider.SelectSingleNode(args.FileArgs.NodeID, args.FileArgs.Culture, true))
{
if (parentNode != null)
{
if (!DataClassInfoProvider.IsChildClassAllowed(ValidationHelper.GetInteger(parentNode.GetValue("NodeClassID"), 0), ci.ClassID))
{
throw new Exception(ResHelper.GetString("Content.ChildClassNotAllowed"));
}
}
// Check user permissions
if (!CMSContext.CurrentUser.IsAuthorizedToCreateNewDocument(parentNode, "CMS.File"))
{
throw new Exception(string.Format(ResHelper.GetString("dialogs.newfile.notallowed"), args.AttachmentArgs.NodeClassName));
}
}
#endregion
args.IsExtensionAllowed();
if (args.FileArgs.IncludeExtension)
{
name += args.Extension;
}
// Make sure the file name with extension respects maximum file name
name = TreePathUtils.EnsureMaxFileNameLength(name, ci.ClassName);
node = TreeNode.New("CMS.File", TreeProvider);
node.DocumentCulture = args.FileArgs.Culture;
node.DocumentName = name;
if (args.FileArgs.NodeGroupID > 0)
{
node.SetValue("NodeGroupID", args.FileArgs.NodeGroupID);
}
// Load default values
FormHelper.LoadDefaultValues(node.NodeClassName, node);
node.SetValue("FileDescription", "");
node.SetValue("FileName", name);
node.SetValue("FileAttachment", Guid.Empty);
node.SetValue("DocumentType", args.Extension);
node.SetDefaultPageTemplateID(ci.ClassDefaultPageTemplateID);
// Insert the document
DocumentHelper.InsertDocument(node, args.FileArgs.NodeID, TreeProvider);
newDocumentCreated = true;
// Add the attachment data
DocumentHelper.AddAttachment(node, "FileAttachment", args.FilePath, TreeProvider, args.ResizeToWidth, args.ResizeToHeight, args.ResizeToMaxSide);
// Create default SKU if configured
if (ModuleEntry.CheckModuleLicense(ModuleEntry.ECOMMERCE, URLHelper.GetCurrentDomain(), FeatureEnum.Ecommerce, VersionActionEnum.Insert))
{
node.CreateDefaultSKU();
}
DocumentHelper.UpdateDocument(node, TreeProvider);
// Get workflow info
//.........这里部分代码省略.........
示例3: HandleContentUpload
/// <summary>
/// Provides operations necessary to create and store new content file.
/// </summary>
private void HandleContentUpload()
{
string message = string.Empty;
bool newDocumentCreated = false;
try
{
if (NodeParentNodeID == 0)
{
throw new Exception(GetString("dialogs.document.parentmissing"));
}
// Check license limitations
if (!LicenseHelper.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Documents, ObjectActionEnum.Insert))
{
throw new Exception(GetString("cmsdesk.documentslicenselimits"));
}
// Check if class exists
DataClassInfo ci = DataClassInfoProvider.GetDataClassInfo(SystemDocumentTypes.File);
if (ci == null)
{
throw new Exception(string.Format(GetString("dialogs.newfile.classnotfound"), SystemDocumentTypes.File));
}
#region "Check permissions"
// Get the node
TreeNode parentNode = TreeProvider.SelectSingleNode(NodeParentNodeID, LocalizationContext.PreferredCultureCode, true);
if (parentNode != null)
{
// Check whether node class is allowed on site and parent node
if (!DocumentHelper.IsDocumentTypeAllowed(parentNode, ci.ClassID) || (ClassSiteInfoProvider.GetClassSiteInfo(ci.ClassID, parentNode.NodeSiteID) == null))
{
throw new Exception(GetString("Content.ChildClassNotAllowed"));
}
}
// Check user permissions
if (!RaiseOnCheckPermissions("Create", this))
{
if (!MembershipContext.AuthenticatedUser.IsAuthorizedToCreateNewDocument(parentNode, SystemDocumentTypes.File))
{
throw new Exception(string.Format(GetString("dialogs.newfile.notallowed"), NodeClassName));
}
}
#endregion
// Check the allowed extensions
CheckAllowedExtensions();
// Create new document
string fileName = Path.GetFileNameWithoutExtension(ucFileUpload.FileName);
string ext = Path.GetExtension(ucFileUpload.FileName);
if (IncludeExtension)
{
fileName += ext;
}
// Make sure the file name with extension respects maximum file name
fileName = TreePathUtils.EnsureMaxFileNameLength(fileName, ci.ClassName);
node = TreeNode.New(SystemDocumentTypes.File, TreeProvider);
node.DocumentCulture = LocalizationContext.PreferredCultureCode;
node.DocumentName = fileName;
if (NodeGroupID > 0)
{
node.SetValue("NodeGroupID", NodeGroupID);
}
// Load default values
FormHelper.LoadDefaultValues(node.NodeClassName, node);
node.SetValue("FileDescription", "");
node.SetValue("FileName", fileName);
node.SetValue("FileAttachment", Guid.Empty);
// Set default template ID
node.SetDefaultPageTemplateID(ci.ClassDefaultPageTemplateID);
// Insert the document
DocumentHelper.InsertDocument(node, parentNode, TreeProvider);
newDocumentCreated = true;
// Add the file
DocumentHelper.AddAttachment(node, "FileAttachment", ucFileUpload.PostedFile, TreeProvider, ResizeToWidth, ResizeToHeight, ResizeToMaxSideSize);
// Create default SKU if configured
if (ModuleManager.CheckModuleLicense(ModuleName.ECOMMERCE, RequestContext.CurrentDomain, FeatureEnum.Ecommerce, ObjectActionEnum.Insert))
{
node.CreateDefaultSKU();
}
// Update the document
DocumentHelper.UpdateDocument(node, TreeProvider);
//.........这里部分代码省略.........