Example #1
0
        public async Task <List <StatisticsEntry> > GetStatisticEntriesAsync(int limit)
        {
            Connection.Open();

            List <StatisticsEntry> ret     = new List <StatisticsEntry>();
            SQLiteCommand          command = new SQLiteCommand("SELECT ID, Timestamp, Runtime, CurrentPlayers, TotalPlayers, CurrentMemory, MaximumMemory, Restarts FROM statistics ORDER BY Timestamp DESC Limit $limit", Connection);

            command.Parameters.AddWithValue("$limit", limit);
            DbDataReader reader = await command.ExecuteReaderAsync();

            while (reader.Read())
            {
                int      ID             = Convert.ToInt32(reader["ID"]);
                DateTime Timestamp      = (DateTime)reader["Timestamp"];
                TimeSpan Runtime        = TimeSpan.Parse(reader.GetString(2));
                int      CurrentPlayers = Convert.ToInt32(reader["CurrentPlayers"]);
                int      TotalPlayers   = Convert.ToInt32(reader["TotalPlayers"]);
                long     CurrentMemory  = Convert.ToInt64(reader["CurrentMemory"]);
                long     MaxMemory      = Convert.ToInt64(reader["MaximumMemory"]);
                int      Restarts       = Convert.ToInt32(reader["Restarts"]);

                StatisticsEntry tmp = new StatisticsEntry(ID, Timestamp, Runtime, CurrentPlayers, TotalPlayers, CurrentMemory, MaxMemory, Restarts);
                ret.Add(tmp);
            }

            reader.Close();

            Connection.Close();
            return(ret);
        }
Example #2
0
        public async Task<List<StatisticsEntry>> GetStatisticEntriesAsync(int limit)
        {
            Connection.Open();

            List<StatisticsEntry> ret = new List<StatisticsEntry>();
            SQLiteCommand command = new SQLiteCommand("SELECT ID, Timestamp, Runtime, CurrentPlayers, TotalPlayers, CurrentMemory, MaximumMemory, Restarts FROM statistics ORDER BY Timestamp DESC Limit $limit", Connection);
            command.Parameters.AddWithValue("$limit", limit);
            DbDataReader reader = await command.ExecuteReaderAsync();

            while (reader.Read())
            {
                int ID = Convert.ToInt32(reader["ID"]);
                DateTime Timestamp = (DateTime)reader["Timestamp"];
                TimeSpan Runtime = TimeSpan.Parse(reader.GetString(2));
                int CurrentPlayers = Convert.ToInt32(reader["CurrentPlayers"]);
                int TotalPlayers = Convert.ToInt32(reader["TotalPlayers"]);
                long CurrentMemory = Convert.ToInt64(reader["CurrentMemory"]);
                long MaxMemory = Convert.ToInt64(reader["MaximumMemory"]);
                int Restarts = Convert.ToInt32(reader["Restarts"]);

                StatisticsEntry tmp = new StatisticsEntry(ID, Timestamp, Runtime, CurrentPlayers, TotalPlayers, CurrentMemory, MaxMemory, Restarts);
                ret.Add(tmp);
            }

            reader.Close();

            Connection.Close();
            return ret;
        }