/// <summary> /// Loads the detailed statistics of a user. /// </summary> private void LoadValues() { try { //Connect to the database SqlConnection dbcon = null; try { dbcon = new SqlConnection(globals.ProvideConnectionString()); dbcon.Open(); } catch (Exception e) { if (dbcon != null) { dbcon.Dispose(); dbcon = null; } throw e; } //Load the values from the database SqlCommand cmd = new SqlCommand("cw_select_user_statistic", dbcon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@user_id", SqlDbType.Int); cmd.Parameters[0].Value = userID; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); da.Dispose(); cmd.Dispose(); dbcon.Close(); //Add the entries in the list lstUserClients.Items.Clear(); int itemCount = 0; foreach (DataRow dr in ds.Tables[0].Rows) { lstUserClients.Items.Add(((Guid)dr[3]).ToString()); lstUserClients.Items[itemCount].SubItems.Add(((long)dr[4]).ToString()); lstUserClients.Items[itemCount].SubItems.Add(((long)dr[5]).ToString()); lstUserClients.Items[itemCount].SubItems.Add(((DateTime)dr[6]).ToString()); if (dr[7] != DBNull.Value) { lstUserClients.Items[itemCount].SubItems.Add(((string)dr[7]).Trim()); } else { lstUserClients.Items[itemCount].SubItems.Add(String.Empty); } if (dr[8] != DBNull.Value) { lstUserClients.Items[itemCount].SubItems.Add(((short)dr[8]).ToString()); } else { lstUserClients.Items[itemCount].SubItems.Add(String.Empty); } if (dr[9] != DBNull.Value) { CWConnectionSpeed speed = (CWConnectionSpeed)((byte)dr[9]); lstUserClients.Items[itemCount].SubItems.Add(speed.ToString()); } else { lstUserClients.Items[itemCount].SubItems.Add("Unknown"); } itemCount++; } if (itemCount > 0) { DataRow dr = ds.Tables[0].Rows[0]; lblUsernameVal.Text = ((string)dr[0]).Trim(); lblEmailVal.Text = ((string)dr[1]).Trim(); lblRegistrationVal.Text = ((DateTime)dr[2]).ToString(); } ds.Dispose(); } catch (Exception e) { globals.Log.LogError("CrawlWave.ServerManager failed to load the list of Banned Hosts : " + e.ToString()); MessageBox.Show(this.Text + " failed to load the list of Banned Hosts:\n" + e.Message); GC.Collect(); } }