本文整理汇总了C#中umbraco.cms.businesslogic.web.DocumentType类的典型用法代码示例。如果您正苦于以下问题:C# DocumentType类的具体用法?C# DocumentType怎么用?C# DocumentType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentType类属于umbraco.cms.businesslogic.web命名空间,在下文中一共展示了DocumentType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Document_Delete_Heirarchy_Permanently
public void Document_Delete_Heirarchy_Permanently()
{
var docList = new List<Document>();
var total = 20;
var dt = new DocumentType(GetExistingDocTypeId());
//allow the doc type to be created underneath itself
dt.AllowedChildContentTypeIDs = new int[] { dt.Id };
dt.Save();
//create 20 content nodes underneath each other, this will test deleting with heirarchy as well
var lastParentId = -1;
for (var i = 0; i < total; i++)
{
var newDoc = Document.MakeNew(i.ToString() + Guid.NewGuid().ToString("N"), dt, m_User, lastParentId);
docList.Add(newDoc);
Assert.IsTrue(docList[docList.Count - 1].Id > 0);
lastParentId = newDoc.Id;
}
//now delete all of them permanently, since they are nested, we only need to delete one
docList.First().delete(true);
//make sure they are all gone
foreach (var d in docList)
{
Assert.IsFalse(Document.IsNode(d.Id));
}
}
示例2: UpdateAllowedTemplates
private DocumentType UpdateAllowedTemplates(DocumentType documentType)
{
var tmp = new ArrayList();
foreach (ListItem li in templateList.Items)
{
if (li.Selected)
tmp.Add(new cms.businesslogic.template.Template(int.Parse(li.Value)));
}
var tt = new cms.businesslogic.template.Template[tmp.Count];
for (int i = 0; i < tt.Length; i++)
{
tt[i] = (cms.businesslogic.template.Template)tmp[i];
}
documentType.allowedTemplates = tt;
if (documentType.allowedTemplates.Length > 0 && ddlTemplates.SelectedIndex >= 0)
{
documentType.DefaultTemplate = int.Parse(ddlTemplates.SelectedValue);
}
else
{
documentType.RemoveDefaultTemplate();
}
_dt = documentType;
return documentType;
}
示例3: GetRelations
public DataTable GetRelations(object id)
{
var currentDocType = new DocumentType(int.Parse(id.ToString()));
var templates = currentDocType.allowedTemplates;
return UmbracoObject.Template.ToDataTable(templates);
}
示例4: LoadAllowedContentTypeChildrenIds
private static void LoadAllowedContentTypeChildrenIds(DocumentType nativeDocumentType, UmbracoDocumentType documentType)
{
documentType.AllowedContentTypeChildrenIds = new int[nativeDocumentType.AllowedChildContentTypeIDs.Count()];
for (var idx = 0; idx < nativeDocumentType.AllowedChildContentTypeIDs.Count(); idx++)
{
documentType.AllowedContentTypeChildrenIds[idx] = nativeDocumentType.AllowedChildContentTypeIDs[idx];
}
}
示例5: GetPath
public static string GetPath(DocumentType dt)
{
if (dt.MasterContentType != 0)
{
var parent = new DocumentType(dt.MasterContentType);
return GetPath(parent) + "/" + dt.Alias;
}
return dt.Alias;
}
示例6: SynchronizeTemplateFieldsTask
public SynchronizeTemplateFieldsTask(UmbracoDataContext context, XmlElement[] input, DocumentType container)
{
_context = context;
_input = input;
_container = container;
_datatypes = DataTypeDefinition.GetAll().ToDictionary(dt => dt.Text);
_tabIds = _context.cmsTabs.ToDictionary(t => DataHelper.GetPath(_context, t), t => t.id);
}
示例7: CreateOrGetDocument
/// <summary>Create or get document if exist.</summary>
public static Document CreateOrGetDocument(string newName, DocumentType newType, Document parent)
{
// Get document and validate existence.
var cmsDocument = GetDocumentsByParentAndName(parent, newName, true).FirstOrDefault();
if(cmsDocument != null) {
return cmsDocument;
} else {
// Create document.
return Document.MakeNew(newName, newType, parent.User, parent.Id);
}
}
示例8: GetById
/// <summary>
/// Gets a document type, based on its id.
/// </summary>
/// <param name="id">The id.</param>
/// <returns></returns>
/// <remarks></remarks>
public virtual UmbracoDocumentType GetById(int id)
{
var nativeDocumentType = new DocumentType(id);
var documentType = new UmbracoDocumentType { Name = nativeDocumentType.Alias };
LoadParentId(nativeDocumentType, documentType);
LoadChildrenIds(nativeDocumentType, documentType);
LoadAllowedContentTypeChildrenIds(nativeDocumentType, documentType);
LoadPropertyTypes(nativeDocumentType, documentType);
return documentType;
}
示例9: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
_dt = new DocumentType(int.Parse(Request.QueryString["id"]));
if (!Page.IsPostBack)
{
BindTemplates();
ClientTools
.SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<loadNodeTypes>().Tree.Alias)
.SyncTree("-1,init," + _dt.Path.Replace("-1,", ""), false);
}
}
示例10: BuildDocumentTypeItem
private DocumentTypeItem BuildDocumentTypeItem(DocumentType documentType)
{
var documentTypeItem = new DocumentTypeItem();
documentTypeItem.Alias = documentType.Alias;
documentTypeItem.Id = documentType.Id;
documentTypeItem.ParentId = documentType.MasterContentType;
documentTypeItem.Text = documentType.Text;
documentTypeItem.Description = documentType.Description;
foreach (var property in documentType.PropertyTypes)
documentTypeItem.Properties.Add(this.BuildPropertyTypeItem(property));
return documentTypeItem;
}
示例11: OnInit
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (!(Page.Request.CurrentExecutionFilePath ?? string.Empty).Contains("editContent.aspx"))
return;
_dlTemplates = new DropDownList();
var useDefaultText = library.GetDictionaryItem("UseDefault");
if (string.IsNullOrEmpty(useDefaultText))
{
useDefaultText = "Use Default";
}
int currentId;
int.TryParse(Page.Request.QueryString["id"], out currentId);
if (currentId != 0)
{
var document = new Document(currentId);
documentType = DocumentType.GetByAlias(document.ContentType.Alias);
}
_dlTemplates.Items.Add(new ListItem(useDefaultText, "0"));
if (documentType != null)
{
foreach (var template in documentType.allowedTemplates)
{
_dlTemplates.Items.Add(new ListItem(template.Text, template.Id.ToString(CultureInfo.InvariantCulture)));
}
}
else
{
foreach (var template in umbraco.cms.businesslogic.template.Template.GetAllAsList())
{
_dlTemplates.Items.Add(new ListItem(template.Text, template.Id.ToString(CultureInfo.InvariantCulture)));
}
}
if (_data != null) _dlTemplates.SelectedValue = _data.Value.ToString();
if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_dlTemplates);
}
示例12: CreateNode
public override Node CreateNode(string name, string parentId, string templateId)
{
var parent = new Document(Convert.ToInt32(parentId));
var template = new DocumentType(Convert.ToInt32(templateId));
var author = umbraco.BusinessLogic.User.GetUser(0);
var document = Document.MakeNew(name, template, author, parent.Id);
umbraco.library.UpdateDocumentCache(document.Id);
using (CmsContext.Editing)
{
var entity = CmsService.Instance.GetItem<Entity>(new Id(document.Id));
var result = GetTreeNode(entity);
return result;
}
}
示例13: CheckTranslationInfrastructure
/// <summary>
/// Checks if the appropriate document types exist and if they are properly structured so that
/// translations for a given node can be created.
/// </summary>
/// <param name="nodeID">The id of the node for which the translations are going to be created</param>
/// <returns>"ok" if everything is in order; otherwise a description of the problem which has been discovered </returns>
public static string CheckTranslationInfrastructure(int nodeID)
{
var status = "ok";
var nodeDoc = new Document(nodeID);
try
{
var translationFolderContentType = GetTranslationFolderContentType(nodeID);
if (translationFolderContentType != null)
{
if (!translationFolderContentType.AllowedChildContentTypeIDs.Any())
throw new Exception(
"Translation document type does not exist, or it is not an allowed child nodetype of the translation folder document type.");
if (translationFolderContentType.AllowedChildContentTypeIDs.Count() > 1)
throw new Exception(
"Translation folder document type has more than one allowed child nodetypes. It should only have one.");
var translationContentType =
new DocumentType(translationFolderContentType.AllowedChildContentTypeIDs[0]);
if (!(from prop in translationContentType.PropertyTypes
where prop.Alias == LanguagePropertyAlias
select prop).Any())
throw new Exception("Translation document type does not contain the '" + LanguagePropertyAlias +
"' (alias) property");
if ((from p in ContentType.GetPropertyList(translationContentType.Id)
where
!(from pr in ContentType.GetPropertyList(nodeDoc.ContentType.Id) select pr.Alias).Contains(
p.Alias)
&& p.Alias != GetHideFromNavigationPropertyAlias() && p.Alias != LanguagePropertyAlias
select p).Any())
throw new Exception(
"Translation document type contains properties that do not exist in the document type (apart from language and navigation hiding)");
}
else
throw new Exception("TranslationFolder document type " + new Document(nodeID).ContentType.Alias +
TranslationFolderAliasSuffix +
" does not exist, or it does not have the right alias or is not an allowed child nodetype");
}
catch (Exception ex)
{
status = ex.Message;
}
return status;
}
示例14: SaveToDisk
/// <summary>
/// save a document type to the disk, the document type will be
/// saved as an xml file, in a folder structure that mimics
/// that of the document type structure in umbraco.
///
/// this makes it easier to read them back in
/// </summary>
/// <param name="item">DocumentType to save</param>
public static void SaveToDisk(DocumentType item)
{
if (item != null)
{
try
{
XmlDocument xmlDoc = helpers.XmlDoc.CreateDoc();
xmlDoc.AppendChild(item.ToXml(xmlDoc));
helpers.XmlDoc.SaveXmlDoc(item.GetType().ToString(), GetDocPath(item), "def", xmlDoc);
}
catch (Exception e)
{
Log.Add(LogTypes.Error, 0, String.Format("uSync: Error Saving DocumentType {0} - {1}", item.Alias, e.ToString()));
}
}
}
示例15: Save
public bool Save()
{
var dt = new cms.businesslogic.web.DocumentType(TypeID);
var d = cms.businesslogic.web.Document.MakeNew(Alias, dt, User.GetUser(_userId), ParentID);
if (d == null)
{
//TODO: Slace - Fix this to use the language files
BasePage.Current.ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.error, "Document Creation", "Document creation was canceled");
return false;
}
else
{
_returnUrl = "editContent.aspx?id=" + d.Id.ToString() + "&isNew=true";
return true;
}
}