private List <ContentDataItem> GetChildrenData(string parentItemId, string childrenTemplateId, string parentItemPath)
        {
            List <ContentDataItem> itemList  = new List <ContentDataItem>();
            List <FieldDataItem>   fieldList = null;

            var items = ItemHelper.GetChildrenContentItems(parentItemId, parentItemPath, childrenTemplateId);

            foreach (var item in items)
            {
                var dataItem = new ContentDataItem()
                {
                    ItemId       = item.ID.ToGuid().ToString(),
                    ItemName     = item.Name,
                    TemplateId   = item.TemplateID.ToGuid().ToString(),
                    TemplateName = item.TemplateName,
                    Version      = item.Version.ToString(),
                    Path         = item.Paths.FullPath
                };

                fieldList       = GetData(dataItem.ItemId, null, null, null, null);
                dataItem.Fields = fieldList.ToArray();
                itemList.Add(dataItem);
            }
            return(itemList);
        }
 private ContentDataItem GetChildren(Item item)
 {
     if (!item.HasChildren)
     {
         return(BuildTreeNode(item, false));
     }
     else
     {
         ContentDataItem root = BuildTreeNode(item, true);
         foreach (Item child in item.Children)
         {
             root.Children.Add(GetChildren(child));
         }
         return(root);
     }
 }
        private ContentDataItem[] GetItemSubTreeSelectedNodeFromDB(string itemId, string dbName)
        {
            ContentDataItem tree = null;

            if (string.IsNullOrWhiteSpace(itemId))
            {
                return(null);
            }

            if (!string.IsNullOrWhiteSpace(dbName))
            {
                using (new Sitecore.SecurityModel.SecurityDisabler())
                {
                    Sitecore.Data.Database database = Sitecore.Data.Database.GetDatabase(dbName);

                    var rootItem = database.GetItem(new Sitecore.Data.ID(itemId));
                    tree = GetChildren(rootItem);
                }
            }

            return(new ContentDataItem[] { tree });
        }
        private ContentDataItem BuildTreeNode(Item item, bool initializeChildrenCollection)
        {
            var dataItem = new ContentDataItem()
            {
                ItemId       = item.ID.ToGuid().ToString(),
                ItemName     = item.Name,
                TemplateId   = item.TemplateID.ToGuid().ToString(),
                TemplateName = item.TemplateName,
                Version      = item.Version.ToString(),
                Path         = item.Paths.FullPath
            };

            List <FieldDataItem> fieldList = GetData(dataItem.ItemId, null, null, null, null, item.Database.Name);

            dataItem.Fields = fieldList.ToArray();

            if (initializeChildrenCollection)
            {
                dataItem.Children = new List <ContentDataItem>();
            }

            return(dataItem);
        }