Пример #1
0
        public static List <XHERO> GetAllHeroesFromID(int id_idx)
        {
            List <XHERO> Heroes = new List <XHERO>();

            //Console.WriteLine("Gettind characters!");
            if (conn.State == ConnectionState.Open)
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = "select hero_order, serial, class, name, hero_type, baselevel, avatar_head, status, status_time from u_hero WHERE id_idx = @id ORDER BY hero_order asc;";
                cmd.Parameters.AddWithValue("@id", id_idx);


                MySqlDataReader reader = cmd.ExecuteReader();
                //Console.WriteLine("Columns:" + reader.FieldCount);
                while (reader.Read())
                {
                    XHERO temp = new XHERO();
                    temp.id_idx      = id_idx;
                    temp.hero_order  = reader.GetInt32(0);
                    temp.serial      = reader.GetInt64(1);
                    temp.hero_class  = reader.GetInt32(2);
                    temp.name        = reader.GetString(3);
                    temp.hero_type   = reader.GetInt32(4);
                    temp.baselevel   = reader.GetInt32(5);
                    temp.avatar_head = reader.GetInt32(6);
                    temp.status      = reader.GetInt32(7);

                    DateTime status_time = reader.GetDateTime(reader.GetOrdinal("status_time"));
                    temp.status_time = (int)ClientFunctions.GetTotalSecondsFromDateTime(status_time);
                    // Console.WriteLine("Status_time: " + ClientFunctions.GetTotalSecondsFromDateTime(status_time));
                    //Console.WriteLine("Status_time: " + status_time.ToString("yyyy - MM - dd HH: mm:ss"));

                    Heroes.Add(temp);
                }

                reader.Close();
            }



            return(Heroes);
        }