Ejemplo n.º 1
0
        private IEnumerable <object> RecursivelyExportTreeData(IEnumerable <ContentNode> treeNodes, string parentNodeId)
        {
            var exportBranch = new List <object>();
            var treeBranch   = treeNodes
                               .Where(x => x.ParentId == parentNodeId)
                               .OrderBy(x => x.Zone)
                               .ThenBy(x => x.Index);

            foreach (var node in treeBranch)
            {
                try
                {
                    var style = node.GetStyle();

                    var exportNode = new
                    {
                        Zone  = node.Zone,
                        Type  = node.WidgetType,
                        View  = node.ViewId,
                        Style = new
                        {
                            Background    = style.BackgroundClass,
                            Classes       = style.NodeClasses,
                            PaddingTop    = style.PaddingTop,
                            PaddingBottom = style.PaddingBottom
                        },
                        Model    = _widgetProvider.ExportSettings(node.WidgetType, node.WidgetId),
                        Children = RecursivelyExportTreeData(treeNodes, node.Id)
                    };

                    exportBranch.Add(exportNode);
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex);
                }
            }

            return(exportBranch.Count > 0 ? exportBranch : null);
        }