Ejemplo n.º 1
0
        private async Task GetVersion(SqlConnection connection1, RoleUserQuery role)
        {
            SqlCommand command1 = new SqlCommand("SELECT version FROM Versionapp", connection1);

            SqlDataReader reader = await command1.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                role.version = reader.GetString(0);
            }
            reader.Close();
        }
Ejemplo n.º 2
0
        private async Task GetAdminVersion(SqlConnection connection1, List <RoleUserQuery> roles)
        {
            SqlCommand command1 = new SqlCommand("SELECT version FROM Versionadminapp", connection1);

            SqlDataReader reader = await command1.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                RoleUserQuery role = new RoleUserQuery();
                role.role = reader.GetString(0);
                roles.Add(role);
            }
            reader.Close();
        }
Ejemplo n.º 3
0
        ///// <summary>
        ///// 根据资源ID,从临时列表获取资源
        ///// </summary>
        ///// <param name="resourceID"></param>
        ///// <param name="list"></param>
        ///// <returns></returns>
        //private ResourceNode GetResourceByID(int resourceID, List<ResourceNode> list)
        //{
        //    var node = (from a in list
        //                where a.ID == resourceID
        //                select a).FirstOrDefault<ResourceNode>();
        //    return node;
        //}

        /// <summary>
        /// 获取用户资源权限列表(用于用户分配资源权限)
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public List <RoleResourcePermissionView> GetResourcePermission(RoleUserQuery query)
        {
            try
            {
                var param = new DynamicParameters();
                param.Add("@userID", query.UserID);
                param.Add("@roleID", query.RoleID);

                var list = QuickRepository.ExecProcQuery <RoleResourcePermissionView>("pr_sys_ResourcePermissionGetListByUserRole",
                                                                                      param).ToList <RoleResourcePermissionView>();

                return(list);
            }
            catch (System.Exception ex)
            {
                //NLogWriter.Error("获取用户资源权限列表(用于用户分配资源权限)失败!", ex);
                throw;
            }
        }
Ejemplo n.º 4
0
        private async Task GetFirstTime(SqlConnection connection1, String email, RoleUserQuery role)
        {
            SqlCommand command1 = new SqlCommand("SELECT firsttime FROM users where UPPER(email) = @email", connection1);

            SqlParameter parameter = new SqlParameter("@email", SqlDbType.VarChar);

            parameter.Value = email.ToUpper();
            command1.Parameters.Add(parameter);

            SqlDataReader reader = await command1.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                if (!reader.IsDBNull(0))
                {
                    role.firstTime = reader.GetBoolean(0);
                }
            }
            reader.Close();
        }
Ejemplo n.º 5
0
        private async Task GetRoles(SqlConnection connection1, String email, RoleUserQuery role)
        {
            SqlCommand command1 = new SqlCommand("SELECT r.name, u.id " +
                                                 "FROM AspNetUsers u " +
                                                 "left join AspNetUserRoles ur on u.id = ur.UserId " +
                                                 "left join AspNetRoles r on ur.RoleId = r.id " +
                                                 "where UPPER(u.email) = @email", connection1);

            SqlParameter parameter = new SqlParameter("@email", SqlDbType.VarChar);

            parameter.Value = email.ToUpper();
            command1.Parameters.Add(parameter);

            SqlDataReader reader = await command1.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                role.role = reader.GetString(0);
                userId    = reader.GetString(1);
            }
            reader.Close();
        }
Ejemplo n.º 6
0
        public async Task <HttpResponseMessage> QueryUserRoles(SearchModel varSearchModel)
        {
            Thread.CurrentThread.CurrentCulture = culture;

            String email = varSearchModel.parameters[0].Trim();

            RoleUserQuery role = new RoleUserQuery();

            try
            {
                using (SqlConnection connection1 = new SqlConnection(connetionString))
                {
                    await connection1.OpenAsync();

                    await GetVersion(connection1, role);
                    await GetRoles(connection1, email, role);
                    await GetFirstTime(connection1, email, role);

                    role.locations = await queryGetLocations(connection1, userId);
                }
            }
            catch (ApplicationException ex)
            {
                ErrorModel _errors = new ErrorModel();
                _errors.message = ex.Message;
                return(Request.CreateResponse(System.Net.HttpStatusCode.InternalServerError, _errors));
            }
            catch (Exception ex)
            {
                ErrorModel _errors = new ErrorModel();
                _errors.message = ex.Message;
                return(Request.CreateResponse(System.Net.HttpStatusCode.InternalServerError, _errors));
            }

            return(Request.CreateResponse(System.Net.HttpStatusCode.OK, role));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 显示 岗位下 显示用户
        /// </summary>
        /// <param name="RoleId"></param>
        /// <returns></returns>
        public RoleUserQuery GetRoleUserQueryList(int RoleId)
        {
            RoleUserQuery role = db.RoleUserQuery.FromSql("SELECT * from role a INNER JOIN userrole b on a.Role_Id=b.Role_Id INNER JOIN `user` c on b.User_Id=c.User_Id WHERE a.Role_Identify=3").FirstOrDefault();

            return(role);
        }