コード例 #1
0
        public IEnumerable <object> QueryScore([FromBody] QScoreParModel qspm)
        {
            try
            {
                var account       = HttpContext.Session.GetString("user_Account");
                var localProvince = HttpContext.Session.GetString("user_Province");

                if (account == null || localProvince == null)
                {
                    return(new[]
                    {
                        new { msg = "not login" }
                    });
                }

                if (Server.AccountHandle(account) == 0)
                {
                    return(new[]
                    {
                        new { msg = "times exceeded" }
                    });
                }

                var re = NewHistoryDataQueryServer.QueryScore(qspm, localProvince);

                return(re);
            }
            catch (Exception e)
            {
                return(new[] { e.Message });
            }
        }
コード例 #2
0
        public IEnumerable <object> QueryScore([FromBody] QScoreParModel qspm, string localProvince)
        {
            try
            {
                var addr = Server.GetUserIp(Request.HttpContext);
                if (Server.IPHandle(addr) == 0)
                {
                    return(new[] { "your ip can't using our api , please contact administrator" });
                }

                var re = NewHistoryDataQueryServer.QueryScore(qspm, localProvince);

                return(re);
            }
            catch (Exception e)
            {
                return(new[] { e.Message });
            }
        }
コード例 #3
0
        /// <summary>
        /// 分数查询
        /// </summary>
        /// <param name="qspm">查询参数头</param>
        /// <param name="localProvince">生源地</param>
        /// <returns>查询结果</returns>
        public static IEnumerable <object> QueryScore(QScoreParModel qspm, string localProvince)
        {
            using (var con = new SqlConnection(Server.SqlConString))
            {
                if (qspm.classes == null || qspm.year == 0 || qspm.rScore == 0)
                {
                    return(new List <object>
                    {
                        new
                        {
                            code = "306",
                            msg = "No necessary parameters"
                        }
                    });
                }


                string sqlUniLocal = " ", sqlBatch = " ";

                if (qspm.uniLocal != null)
                {
                    sqlUniLocal = " and University.address = '" + qspm.uniLocal + "' ";
                }
                if (qspm.batch != null)
                {
                    sqlBatch = " and batch = '" + qspm.batch + "' ";
                }

                con.Open();
                var re = new List <object>();

                var sqlStr =
                    "SELECT DISTINCT " + Server.Province[localProvince] +
                    "Admit.uniName  , address , batch ,  uniMin , uniAve , uniMinP , uniNum " +
                    "FROM " + Server.Province[localProvince] + "Admit JOIN University ON " +
                    Server.Province[localProvince] +
                    "Admit.uniName = University.uniName " +
                    "WHERE province = '" + localProvince + "' " + sqlUniLocal + sqlBatch +
                    " AND classes = '" + qspm.classes + "'" +
                    "AND uniMin >= " + qspm.lScore + " AND uniMin <= " + qspm.rScore + " AND year = " + qspm.year +
                    "ORDER BY uniMin";

                var sc = new SqlCommand(sqlStr, con);

                sc.ExecuteNonQuery();

                var reader = sc.ExecuteReader();

                while (reader.Read())
                {
                    re.Add(new
                    {
                        uName    = (string)reader[0],
                        uAddress = (string)reader[1],
                        uBatch   = (string)reader[2],
                        uMin     = (int)reader[3],
                        uAve     = (decimal)reader[4],
                        uMinP    = (int)reader[5],
                        uNum     = (int)reader[6]
                    });
                }

                return(re);
            }
        }