/// <summary>
/// Import Stats Button Click Event
/// </summary>
private void ImportBtn_Click(object sender, EventArgs e)
{
// Make sure PID text box is a valid PID
if (!Validator.IsValidPID(PidTextBox.Text))
{
MessageBox.Show("The player ID entered is NOT a valid PID. Please try again.",
"Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Establist Database connection
try
{
using (StatsDatabase Database = new StatsDatabase())
{
// Make sure the PID doesnt exist already
int Pid = Int32.Parse(PidTextBox.Text);
if (Database.PlayerExists(Pid))
{
MessageBox.Show("The player ID entered already exists.",
"Import Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// Show Task Form
TaskForm.Show(this, "Import ASP Stats", "Importing ASP Stats...", false, ProgressBarStyle.Blocks, 13);
// Setup the worker
bWorker = new BackgroundWorker();
bWorker.WorkerSupportsCancellation = false;
bWorker.WorkerReportsProgress = true;
// Run Worker
bWorker.DoWork += bWorker_ImportEaStats;
bWorker.ProgressChanged += (s, ea) =>
{
TaskForm.Progress.Report(new TaskProgressUpdate(ea.UserState.ToString(), ea.ProgressPercentage));
};
bWorker.RunWorkerCompleted += bWorker_RunWorkerCompleted;
bWorker.RunWorkerAsync(PidTextBox.Text);
}
}
catch (DbConnectException Ex)
{
ExceptionForm.ShowDbConnectError(Ex);
HttpServer.Stop();
this.Close();
return;
}
}