示例#1
0
        private void PowerLogic(ActionExecutedContext filterContext)
        {
            string ControllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            string ActionName     = filterContext.ActionDescriptor.ActionName;
            string Area           = filterContext.RouteData.DataTokens["area"].ToStr();

            //判断是否执行权限逻辑
            if (this.IsExecutePowerLogic)
            {
                var _func_list  = db.Query <Sys_Function>().OrderBy(item => new { item.Function_Num }).ToList();
                var _power_list = new Dictionary <string, object>();
                //这里得判断一下是否是查找带回调用页面
                string findback = filterContext.HttpContext.Request.QueryString["findback"].ToStr();

                if (string.IsNullOrEmpty(findback))
                {
                    //dynamic model = new ExpandoObject();
                    if (string.IsNullOrEmpty(MenuID))
                    {
                        throw new MessageBox("区域(" + Area + "),控制器(" + ControllerName + "):的程序中缺少菜单ID");
                    }

                    var _Menu = db.Find <Sys_Menu>(w => w.Menu_Num == MenuID);
                    if (!_Menu.Menu_Url.ToStr().StartsWith("/" + Area + "/" + ControllerName + "/"))
                    {
                        throw new MessageBox("区域(" + Area + "),控制器(" + ControllerName + "):的程序中缺少菜单ID与该页面不匹配");
                    }

                    var _role_menu_func_list = db.Query <Sys_RoleMenuFunction>().ToList();
                    var _menu_func_list      = db.Query <Sys_MenuFunction>().ToList();

                    if (!_Account.IsSuperManage)
                    {
                        _power_list = new Dictionary <string, object>();
                        _func_list.ForEach(item =>
                        {
                            var ispower = _role_menu_func_list.FindAll(x =>
                                                                       x.RoleMenuFunction_RoleID == _Account.RoleID &&
                                                                       x.RoleMenuFunction_MenuID == _Menu.Menu_ID &&
                                                                       x.RoleMenuFunction_FunctionID == item.Function_ID);

                            _power_list.Add(item.Function_ByName, (ispower.Count > 0));
                        });
                    }
                    else
                    {
                        _func_list.ForEach(item =>
                        {
                            _power_list.Add(item.Function_ByName, true);
                            //var ispower = _menu_func_list.FindAll(x => x.uMenuFunction_MenuID == Tools.ToGuid(MenuID) && x.uMenuFunction_FunctionID == item.uFunction_ID);
                            //if (ispower.Count > 0)
                            //    _power_list.Add(item.cFunction_ByName, true);
                            //else
                            //    _power_list.Add(item.cFunction_ByName, false);
                        });
                    }
                }
                else
                {
                    _power_list = new Dictionary <string, object>();
                    _func_list.ForEach(item =>
                    {
                        _power_list.Add(item.Function_ByName, false);
                    });
                    _power_list["Have"]   = true;
                    _power_list["Search"] = true;
                }
                filterContext.Controller.ViewData["PowerModel"] = _power_list.SerializeObject();
            }

            this.ViewData["thisWindowName"] = $"adminIframe-{Request.Path}{Request.QueryString}";
            this.ViewData["formWindowName"] = $"Form_{Request.Path.ToStr().Replace("/", "")}";
        }
示例#2
0
 public T Get(Expression <Func <T, bool> > _Where)
 {
     return(db.Find(_Where));
 }