public void addRecord(string w, float error)
    {
        print("save score:" + Word.getScore(error));
        database.addRecord(new writeRecord(w, Word.getScore(error), database.getTime()));

        if (_wordRecord != null)
        {
            foreach (wordRecord word in _wordRecord)
            {
                if (word.word == w)
                {
                    word.addRecord(Word.getScore(error), database.getTime());
                    print(word.records.Count);
                    return;
                }
            }
            wordRecord wr = new wordRecord(w);
            wr.addRecord(Word.getScore(error), database.getTime());

            wordRecord[] nRecords = new wordRecord[_wordRecord.Length + 1];
            _wordRecord.CopyTo(nRecords, 0);
            nRecords[_wordRecord.Length] = wr;
            _wordRecord = nRecords;
        }
    }
Exemple #2
0
    public wordRecord getOrderedRecords(string r, int limit)
    {
        if (r == null)
        {
            return(null);
        }

        string query = "SELECT * FROM history WHERE word='" + r + "' ORDER BY time DESC";

        if (limit != 0)
        {
            query += " LIMIT " + limit;
        }

        try {
            dbcmd             = dbcon.CreateCommand();
            dbcmd.CommandText = query;
            reader            = dbcmd.ExecuteReader();
        } catch (Exception e) {
            Debug.Log(e);
            errMsg = e.ToString();
            return(null);
        }

        wordRecord record = new wordRecord(r);

        while (reader.Read())
        {
            float           score = reader.GetFloat(1);
            System.DateTime time  = (System.DateTime)reader.GetValue(2);
            record.addRecord(score, time);
        }
        return(record);
    }