private User RetrieveUser(System.Data.IDbConnection conn, string username)
        {
            using (System.Data.IDbCommand cmd = conn.CreateCommand())
            {
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = this.SelectUserSQL(username);
                using (System.Data.IDataReader dr = cmd.ExecuteReader())
                {
                    if (!dr.Read()) return null;

                    string uname = RetrieveFieldString(dr, "user_name");
                    string kpirole = RetrieveFieldString(dr, "kpi_role_name");
                    string locations_packed = RetrieveFieldString(dr, "kpi_plants");

                    User user = new User
                    {
                        Username = uname.Trim(),
                        Role = kpirole.Trim(),
                        Locations = new string[] { }
                    };

                    if (!string.IsNullOrEmpty(locations_packed))
                    {
                        // gotta whack the empy last entry (padded with 20 spaces)
                        // there must be a more elegant way to do this!
                        string[] locations = locations_packed.Split(cDelimitter);
                        user.Locations = new string[locations.Length - 1];
                        for (int i = 0; i<locations.Length -1; i++)
                            user.Locations[i] = locations[i].Trim();
                    }
                    return user;
                }
            }
        }
        public User GetUser(string username)
        {
            User user = new User {
                Username = username,
                Role = string.Empty,
                Locations = new string[] {}
            };
            if (_numlocations > 0)
            {
                string[] roles = new string[] {"Shipper", "Operator", "Manager"};
                user.Role = roles[_r.Next(0, roles.Length)];

                int count = _r.Next(1, _numlocations);
                IList<string> locations = new List<string>();
                for (int i = 0; i < 50; i++)
                    locations.Add((i + 1).ToString());
                SortedList<int, string> randomlocations = new SortedList<int, string>();

                for (int i = 0; i < count; i++)
                {
                    string loc = locations[_r.Next(0, locations.Count)];
                    randomlocations.Add(Convert.ToInt32(loc), loc);
                    locations.Remove(loc);
                }

                user.Locations = new string[randomlocations.Count];
                int j = 0;
                foreach (KeyValuePair<int, string> kvp in randomlocations)
                {
                    user.Locations[j++] = kvp.Value;
                }
            }
            else
            {
                user.Role = "Shipper";
                user.Locations = new string[] { "1", "3", "4", "6" };
            }

            return user;
        }