public JsonResult GetTreeModule(string result, int pageId)
        {
            List <PageItem> pages = new PagesDB().GetPagesFlat(this.PortalSettings.PortalID);
            var             page  = pages.First(p => p.ID == pageId);

            JsTreeModel[]      child  = getChildrenTree(page);
            List <JsTreeModel> child2 = new List <JsTreeModel>();
            var panelist   = result.Split('+').ToList();
            var panetopage = ModelServices.GetPageModules(pageId);
            var lowerpane  = panelist.ConvertAll(d => d.ToLower());
            var i          = 0;

            foreach (var pane in panelist)
            {
                JsTreeModel[] childm = getModuleToPane(pane, pageId);
                JsTreeModel   nodem  = new JsTreeModel
                {
                    text = pane,
                    id   = i.ToString(),
                    data = pane,
                    attr = new JsTreeAttribute {
                        id = "pjson_pane_" + i, rel = "folder"
                    },
                    //children2 = childm
                };
                child2.Add(nodem);
                i++;
            }
            // add other pane.
            foreach (var pane in panetopage)
            {
                if (!lowerpane.Contains(pane.Key))
                {
                    JsTreeModel[] childm = getModuleToPane(pane.Key, pageId);
                    JsTreeModel   nodem  = new JsTreeModel
                    {
                        text = pane.Key,
                        id   = i.ToString(),
                        data = pane.Key + "  [Not present in current layout]",
                        attr = new JsTreeAttribute {
                            id = "pjson_pane_" + i, rel = "folder2"
                        },
                        //children2 = childm
                    };
                    child2.Add(nodem);
                    i++;
                }
                panelist.Add(pane.Key);
            }
            var childlist = child.ToList();

            foreach (var childmod in child2)
            {
                childlist.Add(childmod);
            }
            child = childlist.ToArray <JsTreeModel>();
            return(Json(child));
        }
        private int getPageOrder(int idToSearch)
        {
            List <PageItem> pages = new PagesDB().GetPagesFlat(this.PortalSettings.PortalID);

            while (pages.Count > 0)
            {
                PageItem page = pages.First <PageItem>();
                pages.Remove(page);
                if (page.ID == idToSearch)
                {
                    return(page.Order);
                }
            }
            return(-1);
        }