Ejemplo n.º 1
0
        private Broker createBroker(XmlNode node, PublicationManager publicationManager)
        {
            Broker tmp = new Broker();


            //create broker in DB
            string brokerName = XmlUtility.GetXmlNodeByName(node, "name").InnerText;

            if (publicationManager.BrokerRepo.Query().Any(b => b.Name.Equals(brokerName)))
            {
                tmp = publicationManager.BrokerRepo.Query().Where(b => b.Name.Equals(brokerName)).FirstOrDefault();
            }
            else
            {
                tmp.Name              = XmlUtility.GetXmlNodeByName(node, "name").InnerText;
                tmp.MetadataFormat    = XmlUtility.GetXmlNodeByName(node, "metadatastandard").InnerText;
                tmp.PrimaryDataFormat = XmlUtility.GetXmlNodeByName(node, "primarydataformat").InnerText;
                tmp.Server            = XmlUtility.GetXmlNodeByName(node, "server").InnerText;
                tmp.UserName          = XmlUtility.GetXmlNodeByName(node, "user").InnerText;
                tmp.Password          = XmlUtility.GetXmlNodeByName(node, "password").InnerText;
                tmp.Link              = XmlUtility.GetXmlNodeByName(node, "link").InnerText;
                tmp = publicationManager.CreateBroker(tmp);
            }



            XmlNode dataRepos = XmlUtility.GetXmlNodeByName(node, "dataRepos");

            foreach (XmlNode dataRepo in dataRepos.ChildNodes)
            {
                Repository repo     = null;
                string     repoName = XmlUtility.GetXmlNodeByName(dataRepo, "name").InnerText;

                if (publicationManager.RepositoryRepo.Query().Any(b => b.Name.Equals(repoName)))
                {
                    repo = publicationManager.RepositoryRepo.Get().Where(b => b.Name.Equals(repoName)).FirstOrDefault();
                }
                else
                {
                    repo = createRepository(dataRepo as XmlNode);
                }

                if (repo != null)
                {
                    publicationManager.CreateRepository(repo.Name, repo.Url, tmp);
                }
            }


            return(tmp);
        }