예제 #1
0
        public ActionResult RoleAccess()
        {
            UserResBody currResBody = new UserResBody();

            foreach (UserResBody item in base._userResBody)
            {
                if (item.res_path.Equals("0,1,107,240,241,"))
                {
                    currResBody = item;
                    break;
                }
            }

            HasPermission(currResBody.res_id);

            ViewData["currResBody"] = currResBody;//当前菜单
            string position = "";

            ViewData["pageTitle"] = base.FormatPageTile(currResBody, ref position);
            ViewData["position"]  = position;//页面位置

            List <AccessInfo> list = new List <AccessInfo>();
            var res = QueryAccessList.Do();

            if (res != null && res.Body != null && res.Body.access_list != null)
            {
                list = res.Body.access_list;
            }
            ViewData["infolist"] = list;

            return(View());
        }
예제 #2
0
        //[HttpPost]
        public ActionResult GetAccess()
        {
            int parentId = DoRequest.RequestInt("parentId");
            int nodeId   = DoRequest.RequestInt("nodeId");

            List <AccessInfo> accesslist = new List <AccessInfo>();
            var reslist = QueryAccessList.Do();

            if (reslist != null && reslist.Body != null && reslist.Body.access_list != null)
            {
                accesslist = reslist.Body.access_list;
            }

            AccessInfo pInfo = accesslist.FindLast(delegate(AccessInfo item) { return(item.access_id == parentId); });
            AccessInfo tInfo = accesslist.FindLast(delegate(AccessInfo item) { return(item.access_id == nodeId); });

            if (pInfo == null)
            {
                pInfo = new AccessInfo();
            }
            if (tInfo == null)
            {
                tInfo = new AccessInfo();
            }
            if (tInfo.access_id < 1)
            {
                List <AccessInfo> temList = accesslist.FindAll(delegate(AccessInfo item) { return(item.parent_id == parentId); });
                tInfo.sort_no = 1;
                foreach (AccessInfo node in temList)
                {
                    if (tInfo.sort_no <= node.sort_no)
                    {
                        tInfo.sort_no += 1;
                    }
                }
            }

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            string[] arr = null;
            sb.Append("根");
            try
            {
                arr = pInfo.access_path.Split(',');
                foreach (string s in arr)
                {
                    if (string.IsNullOrEmpty(s))
                    {
                        continue;
                    }
                    int val = Utils.StrToInt(s.Trim());
                    if (val == 0)
                    {
                        continue;
                    }
                    List <AccessInfo> list = accesslist.FindAll(
                        delegate(AccessInfo item)
                    {
                        return(item.access_id == val);
                    });
                    if (list.Count > 0)
                    {
                        sb.Append(" >> " + list[0].access_name);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(Json(new { parent = pInfo, type = tInfo, parentName = sb.ToString() }, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult PostAccessData()
        {
            int    parentId = DoRequest.GetFormInt("parentId");
            int    nodeId   = DoRequest.GetFormInt("nodeId");
            string name     = DoRequest.GetFormString("name").Trim();
            int    sort     = DoRequest.GetFormInt("sort");
            string desc     = DoRequest.GetFormString("desc");

            #region 验证
            if (string.IsNullOrEmpty(name))
            {
                return(Json(new { error = true, message = "名称不能为空" }));
            }

            #endregion

            List <AccessInfo> accesslist = new List <AccessInfo>();
            var reslist = QueryAccessList.Do();
            if (reslist != null && reslist.Body != null && reslist.Body.access_list != null)
            {
                accesslist = reslist.Body.access_list;
            }

            AccessInfo pNode = accesslist.FindLast(delegate(AccessInfo item) { return(item.access_id == parentId); });
            AccessInfo cNode = accesslist.FindLast(delegate(AccessInfo item) { return(item.access_id == nodeId); });
            if (pNode == null)
            {
                pNode = new AccessInfo();
            }
            if (cNode == null)
            {
                cNode = new AccessInfo();
            }

            #region 初始化参数
            if (pNode.access_id == 0 && cNode.access_id == 0)
            {
                cNode.parent_id = 0;
            }
            else
            {
                cNode.parent_id = pNode.access_id;
            }
            cNode.access_name = name;
            cNode.sort_no     = sort;
            cNode.access_desc = desc;
            #endregion

            int  returnValue = -1;
            bool isAdd       = false;
            if (cNode.access_id == 0)
            {
                //新增
                cNode.access_id = 0;
                isAdd           = true;
                var resResp = OpAccess.Do(cNode);
                if (resResp != null && resResp.Header != null && resResp.Header.Result != null && resResp.Header.Result.Code != null)
                {
                    returnValue = Utils.StrToInt(resResp.Header.Result.Code, -1);
                }
            }
            else
            {
                //更新
                var resResp = OpAccess.Do(cNode);
                if (resResp != null && resResp.Header != null && resResp.Header.Result != null && resResp.Header.Result.Code != null)
                {
                    returnValue = Utils.StrToInt(resResp.Header.Result.Code, -1);
                }
            }
            bool   isError = true;
            string message = "操作失败";


            if (returnValue == 0)
            {
                isError = false;
                message = "操作成功";
            }

            return(Json(new { error = isError, message = message, isadd = isAdd }));
        }