示例#1
0
        public List <WordStat> GetWords(string userName)
        {
            List <WordStat> words = new List <WordStat>();

            using (SqlConnection connection = new SqlConnection(sqlConnectionString))
            {
                connection.Open();

                SqlCommand command = new SqlCommand("GetWords", connection);
                command.Parameters.Add("@userName", System.Data.SqlDbType.NVarChar);
                command.Parameters["@userName"].Value = userName;
                command.CommandType = System.Data.CommandType.StoredProcedure;

                SqlDataReader rdr = command.ExecuteReader();
                while (rdr.Read())
                {
                    WordStat word = new WordStat();
                    word.WordText  = Convert.ToString(rdr["WordText"]);
                    word.ImageUrl  = Convert.ToString(rdr["ImageUrl"]);
                    word.RewardUrl = Convert.ToString(rdr["RewardUrl"]);
                    words.Add(word);
                }
            }
            return(words);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="targetWord"></param>
        public List <WordStat> GetStats(string userName, string targetWord)
        {
            /*if (_statsTable == null)
             * {
             *  CloudTableClient tableClient = _storageAccount.CreateCloudTableClient();
             *
             *  _statsTable = tableClient.GetTableReference("userstats");
             *  _statsTable.CreateIfNotExists();
             * }
             *
             * //todo: missed rates
             * TableQuery<UserStatEntry> query =
             *  new TableQuery<UserStatEntry>().Where(
             *      TableQuery.GenerateFilterCondition("TargetWord",
             *      QueryComparisons.Equal, targetWord));
             */

            List <WordStat> stats = new List <WordStat>();

            using (SqlConnection connection = new SqlConnection(sqlConnectionString))
            {
                connection.Open();

                SqlCommand command = new SqlCommand("GetWordStats", connection);
                command.Parameters.Add("@userName", System.Data.SqlDbType.NVarChar);
                command.Parameters["@userName"].Value = userName;
                command.Parameters.Add("@word", System.Data.SqlDbType.NVarChar);
                command.Parameters["@word"].Value = targetWord;
                command.CommandType = System.Data.CommandType.StoredProcedure;

                SqlDataReader rdr = command.ExecuteReader();
                while (rdr.Read())
                {
                    //todo: JSON!
                    WordStat stat = new WordStat();
                    stat.Bored     = Convert.ToBoolean(rdr["Bored"]);
                    stat.Panic     = Convert.ToBoolean(rdr["Panic"]);
                    stat.Duration  = Convert.ToInt32(rdr["Duration"]);
                    stat.WordText  = Convert.ToString(rdr["WordText"]);
                    stat.ImageUrl  = Convert.ToString(rdr["ImageUrl"]);
                    stat.RewardUrl = Convert.ToString(rdr["RewardUrl"]);
                    stats.Add(stat);
                }
            }
            return(stats);
        }