public static void GetLogins()
{
currentLoader.status.Text = "Querying logins...";
Application.DoEvents();
DateTime checkFrom = DateTime.UtcNow.Subtract(TimeSpan.FromDays(30));
try
{
using (MySqlDataReader reader = MySqlHelper.ExecuteReader(ConnectionString, String.Format("SELECT * FROM alandsyu_live.logs WHERE Date > '{0}/{1}/{2}' AND Event = \"Login\"", checkFrom.Year, checkFrom.Month, checkFrom.Day)))
{
currentLoader.status.Text = "Loading logins...";
Application.DoEvents();
uint id;
ushort serverId;
uint characterId;
string eventName;
string eventDescription;
DateTime time;
uint dmId;
while (reader.Read())
{
try
{
id = (uint)reader.GetValue(0);
serverId = (ushort)reader.GetValue(1);
characterId = (uint)reader.GetValue(2);
eventName = (string)reader.GetValue(3);
eventDescription = (string)reader.GetValue(4);
time = (DateTime)reader.GetValue(5);
if (!reader.IsDBNull(6))
{
dmId = (uint)reader.GetValue(6);
}
else
{
dmId = 0;
}
}
catch
{
continue;
}
Log newLog = new Log()
{
Id = id,
ServerId = serverId,
CharacterId = characterId,
DMId = dmId,
Event = eventName,
EventDescription = eventDescription,
Time = time
};
Logs.RecentLogins.Add(newLog.Id, newLog);
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
Application.Exit();
}
}