Exemple #1
0
        /// <summary>
        /// Removes the specified user names from the specified roles for the configured applicationName
        /// </summary>
        /// <param name="usernames"> A string array of user names to be removed from the specified roles.</param>
        /// <param name="roleNames">A string array of role names to remove the specified user names from.</param>
        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            if (_App == null)
            {
                return;
            }
            IuserService UserSrv  = new userService(SessionFactoryConfigPath);
            IroleService RoleSrv  = new roleService(SessionFactoryConfigPath);
            string       hql      = "from user u where u.username in (:usernames)";
            IList <user> UserList = UserSrv.GetbyHQuery(hql, new SQLParam("usernames", usernames.ToString()));
            string       hql2     = "from role r where r.name in (:roleNames) AND r.AppID = :AppID";
            IList <role> RoleList = RoleSrv.GetbyHQuery(hql2, new SQLParam("roleNames", roleNames.ToString()), new SQLParam("AppID", _App.AppID));

            foreach (user u in UserList)
            {
                foreach (role r in RoleList)
                {
                    if (u.Roles.Contains(r))
                    {
                        u.Roles.Remove(r);
                    }
                }
            }
            UserSrv.CommitChanges();
        }
Exemple #2
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="pageIndex">required implementation</param>
        /// <param name="pageSize">required implementation</param>
        /// <param name="totalRecords">required implementation</param>
        /// <returns>required implementation</returns>
        public IList <user> GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            log.Info("GetAllUsers Application " + _App.AppName);
            IuserService UserSrv = new userService(SessionFactoryConfigPath);

            try
            {
                string       HQL = "select u from user u join u.ApplicationList app where app.AppID = :appid order by u.CreateDate ";
                IList <user> lst = UserSrv.GetbyHQuery(HQL, pageIndex, pageSize, out totalRecords, new SQLParam("appid", _App.AppID));
                return(lst);
            }
            catch (Exception ex)
            {
                log.Error("GetAllUsers Error Application " + _App.AppName, ex);
                totalRecords = 0;
                return(null);
            }
        }
Exemple #3
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="usernameToMatch">required implementation</param>
        /// <param name="pageIndex">required implementation</param>
        /// <param name="pageSize">required implementation</param>
        /// <param name="totalRecords">required implementation</param>
        /// <returns>required implementation</returns>
        public IList <user> FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            log.Info("FinUserByName Application " + _App.AppName);
            IuserService UserSrv = new userService(SessionFactoryConfigPath);
            string       hql     = "select u from user u join u.ApplicationList app where u.username like %:username% AND app.AppID = :AppID  ";

            try
            {
                IList <user> lst = UserSrv.GetbyHQuery(hql, pageIndex, pageSize, out totalRecords, new SQLParam("username", usernameToMatch), new SQLParam("AppID", _App.AppID));
                return(lst);
            }
            catch (Exception ex)
            {
                log.Error("FindUsersByName Error Application " + _App.AppName, ex);
                totalRecords = 0;
                return(null);
            }
        }