Пример #1
0
        public IActionResult GetUserRoleMebmer(int userid)
        {
            TRIGHT_USER_ROLE_Da userroleManage = new TRIGHT_USER_ROLE_Da();
            var list = userroleManage.Db.Queryable <TRIGHT_USER_ROLE>().Where(s => s.USERID == userid).ToList();

            return(SuccessResultList(list));
        }
Пример #2
0
        public IActionResult AddPrincipalCheck(AddPrincipalCheckModel model)
        {
            TRIGHT_USER_ROLE_Da     userroleDa = new TRIGHT_USER_ROLE_Da();
            List <TRIGHT_USER_ROLE> rolelist   = userroleDa.ListVmByUserid(User_Id);

            if (rolelist.Where(s => s.ROLEID == 2).Count() <= 0)
            {
                return(FailMessage("您不是超级管理员,没有工单处理权限"));
            }


            TASM_SUPPORT_PERSONAL_Da personalDa    = new TASM_SUPPORT_PERSONAL_Da();
            TASM_SUPPORT_PERSONAL    personalModel = personalDa.SelectByWhere(model.SID, (int)SupportendPoint.现场整改_现场负责人审核);

            model.PERSONALID = personalModel.ID;


            Facade.PrincipalFacade facade = new PrincipalFacade();

            if (!facade.Create(model))
            {
                return(FailMessage(facade.Msg));
            }
            return(SuccessMessage("处理成功!"));
        }
Пример #3
0
        public IActionResult AddSiteCheck(AddSiteCheckModel model)
        {
            TRIGHT_USER_ROLE_Da     userroleDa = new TRIGHT_USER_ROLE_Da();
            List <TRIGHT_USER_ROLE> rolelist   = userroleDa.ListVmByUserid(User_Id);

            if (rolelist.Where(s => s.ROLEID == 2).Count() <= 0)
            {
                return(FailMessage("您不是超级管理员,没有工单处理权限"));
            }



            TASM_SUPPORT_PERSONAL_Da personalDa    = new TASM_SUPPORT_PERSONAL_Da();
            TASM_SUPPORT_PERSONAL    personalModel = personalDa.SelectByWhere(model.SID, (int)SupportendPoint.分析完成_现场整改);


            if (personalModel != null)
            {
                model.PERSONALID = personalModel.ID;    //找上一步有可能是分析完成, 也有可能是内勤维护完成(PMC)
            }
            else
            {
                personalModel    = personalDa.SelectByWhere(model.SID, (int)SupportendPoint.售后内勤维护完成_现场整改);
                model.PERSONALID = personalModel.ID;
            }


            Facade.SiteCheckFacade facade = new SiteCheckFacade();
            if (!facade.Create(model))
            {
                return(FailMessage(facade.Msg));
            }
            return(SuccessMessage("处理成功!"));
        }
Пример #4
0
        public IActionResult AddDisposer(AddDisposerModel model)
        {
            //1,不是管理员不能处理。 2,查询出 根据Sid,处理人id,流程节点,处理状态,查出 Presonal 表的id,


            TRIGHT_USER_ROLE_Da     userroleDa = new TRIGHT_USER_ROLE_Da();
            List <TRIGHT_USER_ROLE> rolelist   = userroleDa.ListVmByUserid(User_Id);

            if (rolelist.Where(s => s.ROLEID == 2).Count() <= 0)
            {
                return(FailMessage("您不是超级管理员,没有工单处理权限"));
            }


            TASM_SUPPORT_PERSONAL_Da personalDa    = new TASM_SUPPORT_PERSONAL_Da();
            TASM_SUPPORT_PERSONAL    personalModel = personalDa.SelectByWhere(model.SID, (int)SupportendPoint.创建管理表_责任人处理);


            model.PERSONALID = personalModel.ID;

            DisposerFacade facade = new DisposerFacade();

            if (!facade.Create(model))
            {
                return(FailMessage(facade.Msg));
            }
            return(SuccessMessage("处理成功!"));
        }
Пример #5
0
        public IActionResult DeleteUserRoleMebmer(int id)
        {
            TRIGHT_USER_ROLE_Da userroleManage = new TRIGHT_USER_ROLE_Da();
            var model = userroleManage.CurrentDb.GetById(id);

            if (model == null)
            {
                return(SuccessMessage("请不要反复取消!"));;
            }

            userroleManage.CurrentDb.Delete(model);

            return(SuccessMessage("已取消!"));
        }
Пример #6
0
        public IActionResult AddUserRoleMebmer(int userid, int roleid)
        {
            TRIGHT_USER_ROLE_Da userroleManage = new TRIGHT_USER_ROLE_Da();

            if (userroleManage.CurrentDb.AsQueryable().Where(s => s.ROLEID == roleid && s.USERID == userid).Count() > 0)
            {
                return(SuccessMessage("请不要反复添加!"));
            }



            TRIGHT_USER_ROLE model = new TRIGHT_USER_ROLE
            {
                ROLEID = roleid,
                USERID = userid
            };

            userroleManage.CurrentDb.Insert(model);

            return(SuccessMessage("已添加!"));
        }
Пример #7
0
        public override void OnActionExecuting(ActionExecutingContext Context)
        {
            base.OnActionExecuting(Context);


            //先取出登录用户id;

            int userid = int.Parse(Context.HttpContext.User.FindFirst("USER_ID").Value);


            //如果是初次登录,再系统中没有任何角色 则给用户 分配 一个默认角色,数据库id为1,1为普通会员
            TRIGHT_USER_ROLE_Da userrole = new TRIGHT_USER_ROLE_Da();

            if (userrole.CurrentDb.AsQueryable().Where(s => s.USERID == userid).Count() <= 0)
            {
                TRIGHT_USER_ROLE userolemodel = new TRIGHT_USER_ROLE()
                {
                    ROLEID = 1,   //默认1为普通会员
                    USERID = userid
                };
                userrole.CurrentDb.Insert(userolemodel);
            }



            //如果Ignore 为true 则表示不检查权限,这里只给他初次登录分配 普通会员角色
            if (Ignore)
            {
                return;
            }



            //获取当前页面 或 功能 的路由地址

            var areaName       = string.Empty;
            var controllerName = string.Empty;
            var actionName     = string.Empty;

            if (Context.ActionDescriptor.RouteValues.ContainsKey("area"))
            {
                areaName = Context.ActionDescriptor.RouteValues["area"].ToString();
            }
            if (Context.ActionDescriptor.RouteValues.ContainsKey("controller"))
            {
                controllerName = Context.ActionDescriptor.RouteValues["controller"].ToString();
            }
            if (Context.ActionDescriptor.RouteValues.ContainsKey("action"))
            {
                actionName = Context.ActionDescriptor.RouteValues["action"].ToString();
            }



            var page = "/" + controllerName + "/" + actionName;

            if (!string.IsNullOrEmpty(areaName))
            {
                page = "/" + areaName + page;
            }



            //判断请求的 为访问页面 还是 请求功能操作 Ajax请求为功能, 非ajax请求为访问页面
            var isAjax = Context.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest";



            //判断该页面或操作,是否有再数据库配置过
            TRIGHT_POWER_Da pwmanager = new TRIGHT_POWER_Da();

            var HasPage = pwmanager.Db.Queryable <TRIGHT_POWER>().Where(s => s.PAGEURL.ToLower() == page.ToLower()).Count() <= 0;

            //该页面再数据库未配置
            if (HasPage)
            {
                TRIGHT_POWER powermodel = new TRIGHT_POWER
                {
                    CONTROLLER = controllerName,
                    ACTION     = actionName,
                    AREA       = areaName,
                    POWERNAME  = PowerName,
                    PAGEURL    = page.ToLower()
                };

                if (isAjax)
                {
                    // 添加一个功能功能操作的权限
                    var m = pwmanager.Db.Queryable <TRIGHT_POWER>().Where(s => s.CONTROLLER == controllerName && s.POWERTYPE == (int)PowerType.页面访问).First();

                    powermodel.PARENTID  = m.ID;
                    powermodel.POWERTYPE = (int)PowerType.功能操作;
                }
                else
                {
                    //添加一个 页面访问 权限
                    powermodel.PARENTID  = 0;
                    powermodel.POWERTYPE = (int)PowerType.页面访问;
                }

                pwmanager.CurrentDb.Insert(powermodel);
            }



            //如果全局配置忽略权限,则忽略检测
            if (Entites.AppConfig.IgnoreAuthRight)
            {
                return;
            }


            //该用户存在该页面权限
            if (userrole.ListByVm(userid, page).Count() > 0)
            {
                return;
            }


            //是否ajax请求,是ajax 则判定为 请求操作, 非ajax则判定为 访问页面
            if (isAjax)
            {
                Context.Result = new JsonResult(new { Success = false, Code = 405, Message = "您没有该功能操作权限!" });
                return;
            }

            //跳转配置的页面
            Context.Result = new RedirectToRouteResult(new RouteValueDictionary(new
            {
                controller = "UserRight",
                action     = "NoPermission"
            }));

            return;
        }