public LoginController(IUserBLL userBll, IPageBLL pageBll, IPOABLL poabll, IUserAuthorizationBLL userAuthorizationBll)
     : base(pageBll, Enums.MenuList.LOGIN)
 {
     _userBll = userBll;
     _poabll  = poabll;
     _userAuthorizationBll = userAuthorizationBll;
 }
示例#2
0
        public static SelectList GetBroleList()
        {
            IUserAuthorizationBLL userAuthorizationBll = MvcApplication.GetInstance <UserAuthorizationBLL>();
            var data             = userAuthorizationBll.GetAllBRole();
            var selectItemSource = Mapper.Map <List <SelectItemModel> >(data);

            return(new SelectList(selectItemSource, "ValueField", "TextField"));
        }
 public UserAuthorizationController(IPageBLL pageBll, IUserAuthorizationBLL userAuthorization, IChangesHistoryBLL changesHistoryBll)
     : base(pageBll, Enums.MenuList.UserAuthorization)
 {
     _userAuthorizationBll = userAuthorization;
     _mainMenu             = Enums.MenuList.Settings;
     _pageBll           = pageBll;
     _changesHistoryBll = changesHistoryBll;
 }
        public void SetLoginSession()
        {
            if (Session[Core.Constans.SessionKey.CurrentUser] == null)
            {
                var      userId  = User.Identity.Name.Split('\\')[User.Identity.Name.Split('\\').Length - 1]; //User.Identity.Name.Remove(0, 4);
                IUserBLL userBll = MvcApplication.GetInstance <UserBLL>();
                IPOABLL  poabll  = MvcApplication.GetInstance <POABLL>();
                IUserAuthorizationBLL userAuthorizationBll = MvcApplication.GetInstance <UserAuthorizationBLL>();
                var loginResult = userBll.GetLogin(userId);

                if (loginResult != null)
                {
                    //CurrentUser = loginResult;
                    loginResult.UserRole       = poabll.GetUserRole(loginResult.USER_ID);
                    loginResult.AuthorizePages = userAuthorizationBll.GetAuthPages(loginResult.USER_ID);
                    loginResult.NppbckPlants   = userAuthorizationBll.GetNppbckPlants(loginResult.USER_ID);
                    loginResult.ListUserPlants = new List <string>();
                    loginResult.ListUserNppbkc = new List <string>();
                    switch (loginResult.UserRole)
                    {
                    case Enums.UserRole.User:
                    case Enums.UserRole.Viewer:
                    case Enums.UserRole.Controller:
                        loginResult.ListUserPlants =
                            userAuthorizationBll.GetListPlantByUserId(loginResult.USER_ID);
                        loginResult.ListUserNppbkc =
                            userAuthorizationBll.GetListNppbkcByUserId(loginResult.USER_ID);
                        break;

                    case Enums.UserRole.POA:
                        loginResult.ListUserPlants = new List <string>();
                        foreach (var nppbkcPlantDto in loginResult.NppbckPlants)
                        {
                            foreach (var plantDto in nppbkcPlantDto.Plants)
                            {
                                loginResult.ListUserPlants.Add(plantDto.WERKS);
                            }
                        }
                        loginResult.ListUserNppbkc = loginResult.NppbckPlants.Select(c => c.NppbckId).ToList();
                        break;
                    }
                }
                Session[Core.Constans.SessionKey.CurrentUser] = loginResult;
            }
        }