Exemple #1
0
        public JsonResult GetTreeByEasyUi(string id)
        {
            ////CultureInfo info = Thread.CurrentThread.CurrentCulture;
            ////string infoName = info.Name;
            //if (Session["Account"] != null)
            //{
            //    var account = (ManagerAccount)Session["Account"];

            //    List<ChannelMoudle> menus = ChannelMenuBll.GetMenuByParentId(id);
            //    //List<ChannelMoudle> menus = ChannelMenuBll.GetMenuByPersonId(account.ManagerId, id);

            //    var jsonData = from r in menus
            //        select new MoudleNavigationInfo()
            //        {
            //            id = r.MoudleId,
            //            //text = infoName.IndexOf("zh", System.StringComparison.Ordinal) > -1 || infoName == "" ? r.Name : r.EnglishName,
            //            text = r.Name,
            //            //attributes = (infoName.IndexOf("zh", System.StringComparison.Ordinal) > -1 || infoName == "" ? "zh-CN" : "en-US") + "/" + r.Url,
            //            attributes = r.Url,
            //            iconCls = r.Iconic,
            //            state = (ChannelMoudleBll.GetMoudleByParent(r.MoudleId).Count > 0) ? "closed" : "open"
            //        };

            //    return Json(jsonData);
            //}

            if (Request.Cookies["memberNo"] != null)
            {
                var memberNoCookie = Request.Cookies["memberNo"].Value;
                var memberNo       = Int64.Parse(memberNoCookie);
                var manager        = ManagerAccountBll.GetManagerById(memberNo);

                List <ChannelMoudle> menus = null;
                var administratorArr       = ConfigurationManager.AppSettings["Administrator"].Split(new char[] { '|' });
                if (administratorArr.Contains(memberNo.ToString(CultureInfo.InvariantCulture)))
                {
                    menus = ChannelMenuBll.GetMenuByParentId(id);
                }
                else
                {
                    menus = ChannelMenuBll.GetTempMenuByParentId(id);
                }

                //List<ChannelMoudle> menus = ChannelMenuBll.GetMenuByPersonId(manager.ManagerId, id);

                var jsonData = from r in menus
                               select new MoudleNavigationInfo()
                {
                    id         = r.MoudleId,
                    text       = r.Name,
                    attributes = r.Url,
                    iconCls    = r.Iconic,
                    state      = (ChannelMoudleBll.GetMoudleByParent(r.MoudleId).Count > 0) ? "closed" : "open"
                };

                return(Json(jsonData));
            }

            return(Json("0", JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public JsonResult GetTree(string id)
        {
            //if (Session["Account"] != null)
            //{
            //    var account = (ManagerAccount)Session["Account"];

            //    List<ChannelMoudle> menus = ChannelMenuBll.GetMenuByParentId(id);
            //    //List<ChannelMoudle> menus = ChannelMenuBll.GetMenuByPersonName(account.ManagerName, id);
            //    //List<ChannelMoudle> menus = ChannelMenuBll.GetMenuByPersonId(account.ManagerId, id);

            //    var jsonData = menus.Select(m => new
            //    {
            //        id = m.MoudleId,
            //        text = m.Name,
            //        value = m.Url,
            //        showcheck = false,
            //        complete = false,
            //        isexpand = false,
            //        checkstate = 0,
            //        hasChildren = !Convert.ToBoolean(m.IsLast),
            //        icon = m.Iconic
            //    }).ToArray();

            //    return Json(jsonData, JsonRequestBehavior.AllowGet);
            //}

            if (Request.Cookies["memberNo"] != null)
            {
                var memberNoCookie = Request.Cookies["memberNo"].Value;
                var memberNo       = Int64.Parse(memberNoCookie);
                var manager        = ManagerAccountBll.GetManagerById(memberNo);

                List <ChannelMoudle> menus = ChannelMenuBll.GetMenuByParentId(id);
                //List<ChannelMoudle> menus = ChannelMenuBll.GetMenuByPersonId(manager.ManagerId, id);

                var jsonData = menus.Select(m => new
                {
                    id          = m.MoudleId,
                    text        = m.Name,
                    value       = m.Url,
                    showcheck   = false,
                    complete    = false,
                    isexpand    = false,
                    checkstate  = 0,
                    hasChildren = !Convert.ToBoolean(m.IsLast),
                    icon        = m.Iconic
                }).ToArray();

                return(Json(jsonData, JsonRequestBehavior.AllowGet));
            }

            return(Json("0", JsonRequestBehavior.AllowGet));
        }