• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# web.DocumentType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中umbraco.cms.businesslogic.web.DocumentType的典型用法代码示例。如果您正苦于以下问题:C# DocumentType类的具体用法?C# DocumentType怎么用?C# DocumentType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DocumentType类属于umbraco.cms.businesslogic.web命名空间,在下文中一共展示了DocumentType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
            }
            
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:29,代码来源:DocumentTest.cs


示例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;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:31,代码来源:EditNodeTypeNew.aspx.cs


示例3: GetRelations

        public DataTable GetRelations(object id)
        {
            var currentDocType = new DocumentType(int.Parse(id.ToString()));

            var templates = currentDocType.allowedTemplates;

            return UmbracoObject.Template.ToDataTable(templates);
        }
开发者ID:PeteDuncanson,项目名称:census,代码行数:8,代码来源:DocumentTypeToTemplate.cs


示例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];
            }
        }
开发者ID:coding3d,项目名称:InstantRDF,代码行数:9,代码来源:UmbracoDocumentTypeRepository.cs


示例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;
 }
开发者ID:cdrewery,项目名称:Umbraco-Public,代码行数:9,代码来源:DataHelper.cs


示例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);
        }
开发者ID:jeppe-andreasen,项目名称:Umbraco-Public,代码行数:9,代码来源:SynchronizeTemplateFieldsTask.cs


示例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);
     }
 }
开发者ID:williamchang,项目名称:umbraco-labs,代码行数:12,代码来源:CmsDocumentHelper.cs


示例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;
        }
开发者ID:coding3d,项目名称:InstantRDF,代码行数:18,代码来源:UmbracoDocumentTypeRepository.cs


示例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);
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:12,代码来源:EditNodeTypeNew.aspx.cs


示例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;
        }
开发者ID:pgregorynz,项目名称:UmbCodeGen,代码行数:14,代码来源:DocumentTypeLibrary.cs


示例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);
		}
开发者ID:Chuhukon,项目名称:uWebshop-Releases,代码行数:50,代码来源:StoreTemplatePickerDataEditor.cs


示例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;
     }
 }
开发者ID:Psolow,项目名称:Umbraco-Public,代码行数:14,代码来源:GridLibraryFolderProvider.cs


示例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;
        }
开发者ID:purna,项目名称:Polyglot,代码行数:54,代码来源:DocumentTranslation.cs


示例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()));
         }
     }
 }
开发者ID:jonnyirwin,项目名称:jumps.umbraco.usync,代码行数:24,代码来源:SyncDocType.cs


示例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;
     }
 }
开发者ID:saciervo,项目名称:Umbraco-CMS,代码行数:16,代码来源:contentTasks.cs


示例16: GetForNativeDocumentTypePropertyAlias

        /// <summary>
        /// Gets for native node and property alias.
        /// </summary>
        /// <param name="id">The node id.</param>
        /// <param name="propertyTypeAlias">The property alias.</param>
        /// <returns></returns>
        public virtual UmbracoPropertyType GetForNativeDocumentTypePropertyAlias(int id, string propertyTypeAlias)
        {
            var documentType = new DocumentType(id);
            var nativePropertyType = documentType.getPropertyType(propertyTypeAlias);

            var umbracoPropertyType = new UmbracoPropertyType
                                          {
                                              Name = propertyTypeAlias,
                                              DataTypeName = nativePropertyType.DataTypeDefinition.DataType.DataTypeName,
                                              DatabaseType =
                                                  GetDatabaseType(
                                                      nativePropertyType.DataTypeDefinition.DataType.
                                                          DataTypeDefinitionId)
                                          };

            return umbracoPropertyType;
        }
开发者ID:coding3d,项目名称:InstantRDF,代码行数:23,代码来源:UmbracoPropertyTypeRepository.cs


示例17: CreateItem

        public override GridItem CreateItem(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);

            Document modulesFolder;

            modulesFolder = GetModulesFolder(parent, author);
            var document = Document.MakeNew(name, template, author, modulesFolder.Id);
            umbraco.library.UpdateDocumentCache(document.Id);
            using (CmsContext.Editing)
            {
                var entity = CmsService.Instance.GetItem<Entity>(new Id(document.Id));
                var result = GetGridItem(entity);
                result.IsLocal = true;
                return result;
            }
        }
开发者ID:Psolow,项目名称:Umbraco-Public,代码行数:19,代码来源:UmbracoGridModuleProvider.cs


示例18: GetDocPath

        /// <summary>
        /// works out what the folder stucture for a doctype should be.
        /// 
        /// recurses up the parent path of the doctype, adding a folder
        /// for each one, this then gives us a structure we can create
        /// on the disk, that mimics that of the umbraco internal one
        /// </summary>
        /// <param name="item">DocType path to find</param>
        /// <returns>folderstucture (relative to uSync folder)</returns>
        private static string GetDocPath(DocumentType item)
        {
            string path = "";

            if (item != null)
            {
                // does this documentType have a parent 
                if (item.MasterContentType != 0)
                {
                    // recurse in to the parent to build the path
                    path = GetDocPath(new DocumentType(item.MasterContentType));
                }

                // buld the final path (as path is "" to start with we always get
                // a preceeding '/' on the path, which is nice
                path = string.Format(@"{0}\{1}", path, helpers.XmlDoc.ScrubFile(item.Alias));
            }
         
            return path; 
        }
开发者ID:jonnyirwin,项目名称:jumps.umbraco.usync,代码行数:29,代码来源:SyncDocType.cs


示例19: LoadChildrenIds

        private static void LoadChildrenIds(DocumentType nativeDocumentType, UmbracoDocumentType documentType)
        {
            documentType.InherritanceParentId = -1;

            var h = UmbracoSQLHelper.Get();
            using (
                var reader = UmbracoConfiguration.IsVersion6() ?
                    h.ExecuteReader("SELECT childContentTypeId from [cmsContentType2ContentType] WHERE parentContentTypeId = @parentContentTypeId",
                    h.CreateParameter("parentContentTypeId", nativeDocumentType.Id)) :
                    h.ExecuteReader("SELECT nodeId FROM [cmsContentType] WHERE masterContentType = @nodeId",
                                    h.CreateParameter("nodeId", nativeDocumentType.Id))
                    )
            {
                while (reader.Read())
                {
                    var result = reader.GetInt(UmbracoConfiguration.IsVersion6() ? "childContentTypeId" : "nodeId");
                    if (result > 0)
                        documentType.InherritanceChildrenIds.Add(result);
                }

            }
        }
开发者ID:coding3d,项目名称:InstantRDF,代码行数:22,代码来源:UmbracoDocumentTypeRepository.cs


示例20: create

        public int create(documentCarrier carrier, string username, string password)
        {
            Authenticate(username, password);

            // Some validation
            if (carrier == null) throw new Exception("No carrier specified");
            if (carrier.ParentID == 0) throw new Exception("Document needs a parent");
            if (carrier.DocumentTypeID == 0) throw new Exception("Documenttype must be specified");
            if (carrier.Id != 0) throw new Exception("ID cannot be specifed when creating. Must be 0");
            if (carrier.Name == null || carrier.Name.Length == 0) carrier.Name = "unnamed";

            umbraco.BusinessLogic.User user = GetUser(username, password);

            // We get the documenttype
            umbraco.cms.businesslogic.web.DocumentType docType = new umbraco.cms.businesslogic.web.DocumentType(carrier.DocumentTypeID);
            if (docType == null) throw new Exception("DocumenttypeID " + carrier.DocumentTypeID + " not found");

            // We create the document
            Document newDoc = Document.MakeNew(carrier.Name, docType, user, carrier.ParentID);
            newDoc.ReleaseDate = carrier.ReleaseDate;
            newDoc.ExpireDate = carrier.ExpireDate;

            // We iterate the properties in the carrier
            if (carrier.DocumentProperties != null)
            {
                foreach (documentProperty updatedproperty in carrier.DocumentProperties)
                {
                    umbraco.cms.businesslogic.property.Property property = newDoc.getProperty(updatedproperty.Key);
                    if (property == null) throw new Exception("property " + updatedproperty.Key + " was not found");
                    property.Value = updatedproperty.PropertyValue;
                }
            }

            // We check the publishaction and do the appropiate
            handlePublishing(newDoc, carrier, user);

            // We return the ID of the document..65
            return newDoc.Id;
        }
开发者ID:rehan-sarwar-confiz,项目名称:Umbraco-CMS,代码行数:39,代码来源:documentService.cs



注:本文中的umbraco.cms.businesslogic.web.DocumentType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Trees.XmlTree类代码示例发布时间:2022-05-26
下一篇:
C# web.Document类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap