// GET: Menu
        public ActionResult Index()
        {
            if (string.IsNullOrWhiteSpace(action))
            {
                string        path      = Server.MapPath("~/images/menu");
                DirectoryInfo directory = new DirectoryInfo(path);
                FileInfo[]    files     = directory.GetFiles("*.png");
                List <string> list      = new List <string>();
                foreach (FileInfo info in files)
                {
                    list.Add("~/images/menu/" + info.Name);
                }
                ViewBag.MenuIcos = list;
                return(View());
            }
            JsonResult     result      = new JsonResult();
            string         menuId      = GetParams("menuId");
            SysMenuService menuService = GetService <SysMenuService>();
            XT_MENU        menu        = null;

            switch (action)
            {
            case "GetMenus":
                List <XT_MENU> menus = menuService.SelectAll(new List <string>()
                {
                    "PARENT_ID", "SORT"
                });
                List <ZTreeItemData> treeDatas = new List <ZTreeItemData>();
                ZTreeItemData        itemData  = new ZTreeItemData()
                {
                    name = "菜单根节点",
                    Id   = "0",
                };
                treeDatas.Add(itemData);
                foreach (XT_MENU item in menus)
                {
                    ZTreeItemData data = new ZTreeItemData {
                        Id   = item.ID,
                        name = item.MENU_NAME,
                        PId  = item.PARENT_ID,
                    };
                    data.AddAttribute("MENU_URL", item.MENU_URL);
                    data.AddAttribute("ICON", item.ICON);
                    data.AddAttribute("SORT", item.SORT);
                    treeDatas.Add(data);
                }
                result.Data = treeDatas;
                break;

            case "DeleteMenu":
                if (string.IsNullOrWhiteSpace(menuId))
                {
                    result.Data = false;
                    break;
                }
                menuService.DeleteMenuAndChilderById(menuId);
                result.Data = true;
                break;

            case "menuMove":
                List <string[]> menuList = GetParams <List <string[]> >("treeMenus");
                try
                {
                    foreach (string[] item in menuList)
                    {
                        menuService.UpdataMenuSotrAndGroup(item[0], item[1], int.Parse(item[2]));
                    }
                    result.Data = new object[2] {
                        true, menuList
                    };
                }
                catch (Exception e) {
                    result.Data = new object[2] {
                        false, menuList
                    };
                }

                break;

            case "AddMenu":
                menu = GetParams <XT_MENU>("xt_menu");
                if (menu == null)
                {
                    result.Data = false;
                }
                menu.CREATE_BY = UserInfo.ID;
                menu.MODIFY_BY = UserInfo.ID;
                if (string.IsNullOrWhiteSpace(menu.MENU_URL))
                {
                    menu.MENU_URL = "";
                }
                menu = (XT_MENU)menuService.Insert(menu, true);
                ZTreeItemData newMenu = new ZTreeItemData
                {
                    Id   = menu.ID,
                    name = menu.MENU_NAME,
                    PId  = menu.PARENT_ID,
                };
                newMenu.AddAttribute("MENU_URL", menu.MENU_URL);
                newMenu.AddAttribute("ICON", menu.ICON);
                newMenu.AddAttribute("SORT", menu.SORT);
                result.Data = new object[2] {
                    true, newMenu
                };
                break;

            case "modityMenn":
                menu = GetParams <XT_MENU>("xt_menu");
                menuService.InsertOrUpdate(menu);
                break;
            }
            return(result);
        }
        /// <summary>
        /// 角色管理
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            if (string.IsNullOrWhiteSpace(action))
            {
                return(View());
            }
            JsonResult     result      = new JsonResult();
            SysRoleService roleService = GetService <SysRoleService>();
            XT_ROLE        role        = null;
            string         roleId      = GetParams("roleId");

            switch (action)
            {
            case "GetRoles":
                List <XT_ROLE> roles = roleService.SelectAll(new List <string>()
                {
                    "PARENT_ID", "SORT"
                });
                List <ZTreeItemData> treeDatas = new List <ZTreeItemData>();
                ZTreeItemData        itemData  = new ZTreeItemData()
                {
                    name = "根节点",
                    Id   = "0",
                };
                treeDatas.Add(itemData);
                foreach (XT_ROLE item in roles)
                {
                    ZTreeItemData data = new ZTreeItemData
                    {
                        Id   = item.ID,
                        name = item.ROLE_NAME,
                        PId  = item.PARENT_ID,
                    };
                    data.AddAttribute("SORT", item.SORT);
                    treeDatas.Add(data);
                }
                result.Data = treeDatas;
                break;

            case "Deleterole":
                if (string.IsNullOrWhiteSpace(roleId))
                {
                    result.Data = false;
                    break;
                }
                roleService.DeleteAndChilderById(roleId);
                result.Data = true;
                break;

            case "roleMove":
                List <string[]> roleList = GetParams <List <string[]> >("treeroles");
                try
                {
                    foreach (string[] item in roleList)
                    {
                        roleService.UpdataSotrAndGroup(item[0], item[1], int.Parse(item[2]));
                    }
                    result.Data = new object[2] {
                        true, roleList
                    };
                }
                catch (Exception e)
                {
                    result.Data = new object[2] {
                        false, roleList
                    };
                }

                break;

            case "AddRole":
                role = GetParams <XT_ROLE>("xt_role");
                if (role == null)
                {
                    result.Data = false;
                }
                role.CREATE_BY = UserInfo.ID;
                role.MODIFY_BY = UserInfo.ID;

                role = (XT_ROLE)roleService.Insert(role, true);
                ZTreeItemData newrole = new ZTreeItemData
                {
                    Id   = role.ID,
                    name = role.ROLE_NAME,
                    PId  = role.PARENT_ID,
                };

                newrole.AddAttribute("SORT", role.SORT);
                result.Data = new object[2] {
                    true, newrole
                };
                break;

            case "modityMenn":
                role = GetParams <XT_ROLE>("xt_role");
                roleService.InsertOrUpdate(role);
                break;
            }
            return(result);
        }