public static void GetAlerts()
{
currentLoader.status.Text = "Querying alerts...";
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 = \"Death\" OR Event = \"Kill\" OR Event = \"Resurrection\" OR Event = \"Tech Resurrection\" OR Event = \"LOGOUT DURING COMBAT\" OR Event = \"SELF-LOOTING ATTEMPT\" OR Event = \"LOGOUT WHILE BLEEDING\" OR Event = \"Level Up\" OR Event = \"Drop, Illegal\" OR Event = \"Acquire, Illegal\" OR Event = \"XP Change\" OR (Event = \"Over-CR combat kill\" AND CharacterID != 0) OR Event = \"Death Floor\")", checkFrom.Year, checkFrom.Month, checkFrom.Day)))
{
currentLoader.status.Text = "Loading alerts...";
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
};
switch (eventName)
{
case "Death":
Logs.DeathAlerts.Add(newLog.Id, newLog);
break;
case "Kill":
Logs.DeathAlerts.Add(newLog.Id, newLog);
break;
case "Resurrection":
Logs.DeathAlerts.Add(newLog.Id, newLog);
break;
case "Tech Resurrection":
Logs.DeathAlerts.Add(newLog.Id, newLog);
break;
case "Death Floor":
Logs.DeathAlerts.Add(newLog.Id, newLog);
break;
case "LOGOUT DURING COMBAT":
Logs.EnforcementAlerts.Add(newLog.Id, newLog);
break;
case "SELF-LOOTING ATTEMPT":
Logs.EnforcementAlerts.Add(newLog.Id, newLog);
break;
case "LOGOUT WHILE BLEEDING":
Logs.EnforcementAlerts.Add(newLog.Id, newLog);
break;
case "Drop, Illegal":
Logs.EnforcementAlerts.Add(newLog.Id, newLog);
break;
case "Acquire, Illegal":
Logs.EnforcementAlerts.Add(newLog.Id, newLog);
break;
case "Level Up":
Logs.AdvancementAlerts.Add(newLog.Id, newLog);
break;
case "XP Change":
Logs.AdvancementAlerts.Add(newLog.Id, newLog);
break;
case "Over-CR combat kill":
Logs.AdvancementAlerts.Add(newLog.Id, newLog);
break;
default:
Logs.EnforcementAlerts.Add(newLog.Id, newLog);
break;
}
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
Application.Exit();
}
}