internal static BreedsList GetBreeds(MySqlConnection sql) { BreedsList result = new BreedsList(); MySqlCommand cmd = new MySqlCommand("SELECT b_id,b_name,b_short_name FROM breeds;", sql); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { result.Add(new Breed(rd.GetInt32("b_id"), rd.GetString("b_name"), rd.GetString("b_short_name"))); } rd.Close(); return(result); }
public string Import(string data, out List <OneRabbit> exportRab, out List <OneRabbit> ascendants, out BreedsList breeds, out RabNamesList names) { XmlDocument doc = new XmlDocument(); doc.LoadXml(data); exportRab = new List <OneRabbit>(); ascendants = new List <OneRabbit>(); breeds = new BreedsList(); names = new RabNamesList(); int fromClientId; XmlNode rootNode = doc.FirstChild.NextSibling; int.TryParse(rootNode.Attributes["clientId"].Value, out fromClientId); if (fromClientId == _client.ID && rootNode.Attributes["dbGuid"].Value == _myDbGuid) { throw new RabNetException("Файл был экспортирован с этой же фермы"); } XmlNode tmpNode = rootNode.SelectSingleNode("exports"); foreach (XmlNode child in tmpNode.ChildNodes) { exportRab.Add(fillOneRabbit(child, fromClientId)); } tmpNode = rootNode.SelectSingleNode("ascendants"); foreach (XmlNode child in tmpNode.ChildNodes) { ascendants.Add(fillOneRabbit(child, fromClientId)); } tmpNode = rootNode.SelectSingleNode("breeds"); foreach (XmlNode child in tmpNode.ChildNodes) { breeds.Add(fillBreed(child)); } tmpNode = rootNode.SelectSingleNode("names"); foreach (XmlNode child in tmpNode.ChildNodes) { names.Add(fillName(child)); } return(rootNode.Attributes["fileGuid"].Value); }