public JsonResult ConstructJsTree(string folderPath, string libName, string name)
        {
            try
            {
                var menu = new Menu() { LibraryName = libName, FolderPath = folderPath, Name = name };
                var jsTree = MenuService.GetJsTree(menu);

                var jsTreeModel = ConvertToModel(jsTree);
                var javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                var jsonString = javaScriptSerializer.Serialize(jsTreeModel);

                return Json(jsonString, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex) { throw ex; }
        }
        //Recursive Function
        public void CreateTreeMenu(Menu menuObj, MenuModel toMenuModel)
        {
            foreach (var item in menuObj.Children)
            {
                var subMenuObj = new MenuModel
                                 {
                                     Name = item.Name,
                                     ActionName = item.ActionName,
                                     ControllerName = item.ControllerName,
                                     FolderPath = item.FolderPath,
                                     LibraryName = item.LibraryName,
                                     Class = item.Class,
                                     Type = item.Type,
                                     Id = item.Id,
                                     ParentFolderPath = item.ParentFolderPath
                                 };

                if (item.Children.Count > 0)
                   CreateTreeMenu(item, subMenuObj);

               toMenuModel.Children.Add(subMenuObj);
            }
        }
Esempio n. 3
0
 public JsTree GetJsTree(Menu menu) {
     return MenuDao.GetJsTree(menu);
 }