public static void GetDMTime()
{
currentLoader.status.Text = "Querying DM Time...";
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 = \"XP Gain, DM RP\" OR Event = \"XP Gain, DM Quest\")", checkFrom.Year, checkFrom.Month, checkFrom.Day)))
{
currentLoader.status.Text = "Parsing DM Time...";
Application.DoEvents();
while (reader.Read())
{
try
{
uint id = (uint)reader.GetValue(0);
ushort serverId = (ushort)reader.GetValue(1);
uint characterId = (uint)reader.GetValue(2);
string eventName = (string)reader.GetValue(3);
string eventDescription = (string)reader.GetValue(4);
string timeDMed;
if (eventName == "XP Gain, DM RP")
{
timeDMed = eventDescription.Split(' ')[7];
}
else
{
timeDMed = eventDescription.Split(' ')[11];
}
float addingTime = 0.0f;
float.TryParse(timeDMed, out addingTime);
Character charDMed = Characters.List[characterId];
charDMed.DMTime += addingTime;
Player playerDMed = Players.ListByPlayerId[charDMed.PlayerId];
playerDMed.DMTime += addingTime;
}
catch(Exception e)
{
MessageBox.Show(e.Message);
continue;
}
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
Application.Exit();
}
}