Exemplo n.º 1
0
        public HQResult <string> Sigin(string UserName, string Password)
        {
            HQResult <string> result = new HQResult <string>(0, "");

            OrderManagementBll.Authority.Account accountBll = new OrderManagementBll.Authority.Account(Configuration);

            var v1 = accountBll.Sigin(UserName, Password);

            if (v1.Status < 1)
            {
                return(result.SetResult(-1, v1.Msg));
            }


            HQAuthorizationUser User = new HQAuthorizationUser()
            {
                UserName = UserName, Account = UserName, UserID = 10
            };

            User.UserHQAuthorizationSign.LoadData(new List <HQAuthorizationSign>()
            {
                new HQAuthorizationSign {
                    Area = "", Controller = "login", Action = "test1", ID = 10
                },
                // new HQAuthorizationSign { Area="", Controller="login", Action="test3" },
            });

            _stateManager.Sigin(User);



            //  return RedirectToAction("test1");

            return(result.SetResult(1, "登入成功", ""));
        }
Exemplo n.º 2
0
        public HQResult <string> Sigout()
        {
            HQResult <string> result = new HQResult <string>(0, "");


            _stateManager.Signout();



            return(result.SetResult(1, "退出成功"));
        }
Exemplo n.º 3
0
        public HQResult <string> AddRole(string RoleName, string Description)
        {
            HQResult <string> result    = new HQResult <string>();
            OrderManagementDB DBcontext = new OrderManagementDB();

            DBcontext.Authority_Role.Add(new  Authority_Role {
                RoleName = RoleName, Description = Description
            });
            DBcontext.SaveChanges();

            return(result.SetResult(1, "ok"));
        }
Exemplo n.º 4
0
        public HQResult <string> AddAccount(string Account, string Name, string Pass)
        {
            HQResult <string> result    = new HQResult <string>();
            OrderManagementDB DBcontext = new OrderManagementDB();

            DBcontext.Authority_Account.Add(new Authority_Account {
                Account = Account, Name = Name, Pass = Pass,
            });
            DBcontext.SaveChanges();

            return(result.SetResult(1, "ok"));
        }
Exemplo n.º 5
0
        public HQResult <string> RelatedPerBase(int RoleId, int BaseId)
        {
            HQResult <string> result    = new HQResult <string>();
            OrderManagementDB DBcontext = new OrderManagementDB();

            DBcontext.Authority_RelatedRoleBasePer.Add(new  OrderManagementModel.DBModel.Authority.Authority_RelatedRoleBasePer()
            {
                BasePerID = BaseId, RoleID = RoleId
            });
            DBcontext.SaveChanges();

            return(result.SetResult(1, "ok"));
        }
Exemplo n.º 6
0
        public HQResult <string> RelatedRole(int AccountId, int RoleId)
        {
            HQResult <string> result    = new HQResult <string>();
            OrderManagementDB DBcontext = new OrderManagementDB();

            DBcontext.Authority_RelatedAccountRole.Add(new OrderManagementModel.DBModel.Authority.Authority_RelatedAccountRole()
            {
                AccountID = AccountId, RoleID = RoleId
            });
            DBcontext.SaveChanges();

            return(result.SetResult(1, "ok"));
        }
Exemplo n.º 7
0
        public HQResult <Authority_Account> Sigin(string Account, string Password)
        {
            HQResult <Authority_Account> result = new HQResult <Authority_Account>();

            OrderManagementDB DBcontext = new OrderManagementDB();

            var user = DBcontext.Authority_Account.Where(w => w.Account == Account && w.Pass == Password)
                       .Include(p => p.RelatedRoles)
                       .ThenInclude(p => p.Role)
                       .ThenInclude(p => p.RelatedRoleBases)
                       .ThenInclude(p => p.BasePer).FirstOrDefault();

            if (user == null)
            {
                return(result.SetResult(-1, null));
            }

            return(result.SetResult(1, "ok", user));
        }
Exemplo n.º 8
0
        public IActionResult Sigin2(string UserName, string Password)
        {
            HQResult <string> result = new HQResult <string>(0, "");

            OrderManagementBll.Authority.Account accountBll = new OrderManagementBll.Authority.Account(Configuration);

            var user = accountBll.Sigin(UserName, Password);

            if (user.Status < 1)
            {
                ViewData["msg"] = "登入失败";
                return(View("index"));
            }


            HQAuthorizationUser User = new HQAuthorizationUser()
            {
                UserName = user.Value.Name, Account = user.Value.Account, UserID = user.Value.ID
            };

            var pers = user.Value.RelatedRoles.SelectMany(s => s.Role.RelatedRoleBases.SelectMany(p => p.Role.RelatedRoleBases.Select(o => o.BasePer)));


            User.UserHQAuthorizationSign.LoadData(
                pers.Select(p => new HQAuthorizationSign {
                Action = p.Action, Area = p.Area, Controller = p.Control, ID = p.ID
            }).ToList()
                );;

            _stateManager.Sigin(User);



            return(RedirectToAction("index", "home", new { area = "main" }));

            // return result.SetResult(1, "登入成功", "");
        }
Exemplo n.º 9
0
        public HQResult <string> NoAuthority(string ReturnUrl)
        {
            HQResult <string> result = new HQResult <string>(0, "没有访问权限", ReturnUrl);

            return(result);
        }
Exemplo n.º 10
0
        public HQResult <string> NotSigin(string ReturnUrl)
        {
            HQResult <string> result = new HQResult <string>(0, "未登入", ReturnUrl);

            return(result);
        }