Esempio n. 1
0
        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);
        }