public static List<Repository> getAll()
        {

            var repositories = new List<Repository>();

            foreach (var r in UmbracoConfig.For.UmbracoSettings().PackageRepositories.Repositories)
            {
                var repository = new Repository
                {
                    Guid = r.Id.ToString(),
                    Name = r.Name
                };

                repository.RepositoryUrl = r.RepositoryUrl;
                repository.WebserviceUrl = repository.RepositoryUrl.Trim('/') + "/" + r.WebServiceUrl.Trim('/');
                if (r.HasCustomWebServiceUrl)
                {
                    string wsUrl = r.WebServiceUrl;

                    if (wsUrl.Contains("://"))
                    {
                        repository.WebserviceUrl = r.WebServiceUrl;
                    }
                    else
                    {
                        repository.WebserviceUrl = repository.RepositoryUrl.Trim('/') + "/" + wsUrl.Trim('/');
                    }
                }

                repositories.Add(repository);
            }

            return repositories;
        }
        public override void Render(ref XmlTree tree)
        {
            m_packageType = HttpContext.Current.Request.QueryString["packageType"];

            switch (m_packageType)
            {
            case "installed":
                foreach (cms.businesslogic.packager.InstalledPackage p in cms.businesslogic.packager.InstalledPackage.GetAllInstalledPackages())
                {
                    XmlTreeNode xNode = XmlTreeNode.Create(this);
                    xNode.NodeID   = PACKAGE_TREE_PREFIX + p.Data.Id.ToString();
                    xNode.Text     = p.Data.Name;
                    xNode.Action   = "javascript:openInstalledPackage('" + p.Data.Id.ToString() + "');";
                    xNode.Icon     = "package.gif";
                    xNode.OpenIcon = "package.gif";
                    xNode.NodeType = "createdPackageInstance";
                    xNode.Menu     = null;
                    tree.Add(xNode);
                }
                break;

            case "created":
                foreach (cms.businesslogic.packager.CreatedPackage p in cms.businesslogic.packager.CreatedPackage.GetAllCreatedPackages())
                {
                    XmlTreeNode xNode = XmlTreeNode.Create(this);
                    xNode.NodeID   = PACKAGE_TREE_PREFIX + p.Data.Id.ToString();
                    xNode.Text     = p.Data.Name;
                    xNode.Action   = "javascript:openCreatedPackage('" + p.Data.Id.ToString() + "');";
                    xNode.Icon     = "package.gif";
                    xNode.OpenIcon = "package.gif";
                    xNode.NodeType = "createdPackageInstance";
//                        xNode.Menu.Add( umbraco.BusinessLogic.Actions.ActionDelete.Instance );

                    tree.Add(xNode);
                }
                break;

            case "repositories":
                List <cms.businesslogic.packager.repositories.Repository> repos = cms.businesslogic.packager.repositories.Repository.getAll();

                foreach (cms.businesslogic.packager.repositories.Repository repo in repos)
                {
                    XmlTreeNode xNode = XmlTreeNode.Create(this);
                    xNode.Text     = repo.Name;
                    xNode.Action   = "javascript:openPackageCategory('BrowseRepository.aspx?repoGuid=" + repo.Guid + "');";
                    xNode.Icon     = "repository.gif";
                    xNode.OpenIcon = "repository.gif";
                    xNode.NodeType = "packagesRepo" + repo.Guid;
                    xNode.Menu.Add(umbraco.BusinessLogic.Actions.ActionRefresh.Instance);
                    xNode.Source = "tree.aspx?app=" + this.m_app + "&id=" + this.m_id + "&treeType=packagerPackages&packageType=repository&repoGuid=" + repo.Guid + "&rnd=" + Guid.NewGuid();
                    tree.Add(xNode);

                    /*
                     * XmlElement catElement = Tree.CreateElement("tree");
                     * catElement.SetAttribute("text", repo.Name);
                     * catElement.SetAttribute("menu", "L");
                     *
                     * catElement.SetAttribute("icon", "repository.gif");
                     * catElement.SetAttribute("openIcon", "repository.gif");
                     *
                     * catElement.SetAttribute("nodeType", "packagesRepo" + repo.Guid);
                     * catElement.SetAttribute("src", "tree.aspx?app=" + this.m_app + "&id=" + this.m_id + "&treeType=packagerPackages&packageType=repository&repoGuid=" + repo.Guid + "&rnd=" + Guid.NewGuid());
                     * catElement.SetAttribute("action", "javascript:openPackageCategory('BrowseRepository.aspx?repoGuid=" + repo.Guid + "');");
                     * root.AppendChild(catElement);
                     * */
                }

                break;

            case "repository":

                m_repoGuid = HttpContext.Current.Request.QueryString["repoGuid"];
                cms.businesslogic.packager.repositories.Repository currentRepo = cms.businesslogic.packager.repositories.Repository.getByGuid(m_repoGuid);
                if (currentRepo != null)
                {
                    foreach (cms.businesslogic.packager.repositories.Category cat in currentRepo.Webservice.Categories(currentRepo.Guid))
                    {
                        XmlTreeNode xNode = XmlTreeNode.Create(this);
                        xNode.Text     = cat.Text;
                        xNode.Action   = "javascript:openPackageCategory('BrowseRepository.aspx?category=" + cat.Id + "&repoGuid=" + currentRepo.Guid + "');";
                        xNode.Icon     = "folder.gif";
                        xNode.OpenIcon = "folder.gif";
                        xNode.NodeType = "packagesCategory" + cat.Id;
                        tree.Add(xNode);

                        /*
                         * XmlElement catElement = Tree.CreateElement("tree");
                         * catElement.SetAttribute("text", cat.Text);
                         * //catElement.SetAttribute("menu", "");
                         * catElement.SetAttribute("icon", "folder.gif");
                         * catElement.SetAttribute("openIcon", "folder_o.gif");
                         * catElement.SetAttribute("nodeType", "packagesCategory" + cat.Id);
                         * catElement.SetAttribute("action", "javascript:openPackageCategory('BrowseRepository.aspx?category=" + cat.Id + "&repoGuid=" + currentRepo.Guid + "');");
                         * root.AppendChild(catElement);*/
                    }
                }
                break;
            }
        }
        void ITree.Render(ref XmlDocument Tree)
        {
            m_packageType = HttpContext.Current.Request.QueryString["packageType"];
            XmlNode root = Tree.DocumentElement;

            switch (m_packageType)
            {
            case "installed":
                foreach (cms.businesslogic.packager.InstalledPackage p in cms.businesslogic.packager.InstalledPackage.GetAllInstalledPackages())
                {
                    XmlElement treeElement = Tree.CreateElement("tree");
                    treeElement.SetAttribute("nodeID", "package_" + p.Data.Id.ToString());
                    treeElement.SetAttribute("text", p.Data.Name);
                    treeElement.SetAttribute("action", "javascript:openInstalledPackage('" + p.Data.Id.ToString() + "');");
                    treeElement.SetAttribute("menu", "");
                    //treeElement.SetAttribute("src", "");
                    treeElement.SetAttribute("icon", "package.gif");
                    treeElement.SetAttribute("openIcon", "package.gif");
                    treeElement.SetAttribute("nodeType", "createdPackageInstance");
                    root.AppendChild(treeElement);
                }
                break;

            case "created":
                foreach (cms.businesslogic.packager.CreatedPackage p in cms.businesslogic.packager.CreatedPackage.GetAllCreatedPackages())
                {
                    XmlElement treeElement = Tree.CreateElement("tree");
                    treeElement.SetAttribute("nodeID", "package_" + p.Data.Id.ToString());
                    treeElement.SetAttribute("text", p.Data.Name);
                    treeElement.SetAttribute("action", "javascript:openCreatedPackage('" + p.Data.Id.ToString() + "');");
                    treeElement.SetAttribute("menu", "D");
                    treeElement.SetAttribute("src", "");
                    treeElement.SetAttribute("icon", "package.gif");
                    treeElement.SetAttribute("openIcon", "package.gif");
                    treeElement.SetAttribute("nodeType", "createdPackageInstance");
                    root.AppendChild(treeElement);
                }
                break;

            case "repositories":
                List <cms.businesslogic.packager.repositories.Repository> repos = cms.businesslogic.packager.repositories.Repository.getAll();

                foreach (cms.businesslogic.packager.repositories.Repository repo in repos)
                {
                    XmlElement catElement = Tree.CreateElement("tree");
                    catElement.SetAttribute("text", repo.Name);
                    catElement.SetAttribute("menu", "L");

                    catElement.SetAttribute("icon", "repository.gif");
                    catElement.SetAttribute("openIcon", "repository.gif");

                    catElement.SetAttribute("nodeType", "packagesRepo" + repo.Guid);
                    catElement.SetAttribute("src", "tree.aspx?app=" + this.m_app + "&id=" + this.m_id + "&treeType=packagerPackages&packageType=repository&repoGuid=" + repo.Guid + "&rnd=" + Guid.NewGuid());
                    catElement.SetAttribute("action", "javascript:openPackageCategory('BrowseRepository.aspx?repoGuid=" + repo.Guid + "');");
                    root.AppendChild(catElement);
                }

                break;

            case "repository":

                m_repoGuid = HttpContext.Current.Request.QueryString["repoGuid"];
                cms.businesslogic.packager.repositories.Repository currentRepo = cms.businesslogic.packager.repositories.Repository.getByGuid(m_repoGuid);
                if (currentRepo != null)
                {
                    foreach (cms.businesslogic.packager.repositories.Category cat in currentRepo.Webservice.Categories(currentRepo.Guid))
                    {
                        XmlElement catElement = Tree.CreateElement("tree");
                        catElement.SetAttribute("text", cat.Text);
                        //catElement.SetAttribute("menu", "");
                        catElement.SetAttribute("icon", "folder.gif");
                        catElement.SetAttribute("openIcon", "folder_o.gif");
                        catElement.SetAttribute("nodeType", "packagesCategory" + cat.Id);
                        catElement.SetAttribute("action", "javascript:openPackageCategory('BrowseRepository.aspx?category=" + cat.Id + "&repoGuid=" + currentRepo.Guid + "');");
                        root.AppendChild(catElement);
                    }
                }
                break;
            }

            //SD: Commented this out... not sure why it was here??
            //throw new Exception("The method or operation is not implemented.");
        }
Exemple #4
0
        public static List<Repository> getAll() {

            List<Repository> repositories = new List<Repository>();

            XmlNodeList repositoriesXml = m_repositories.SelectNodes("./repository");

            foreach (XmlNode repositoryXml in repositoriesXml) {
                Repository repository = new Repository();
                repository.m_guid = repositoryXml.Attributes["guid"].Value;
                repository.m_name = repositoryXml.Attributes["name"].Value;

                if (repositoryXml.Attributes["repositoryurl"] != null) {
                    repository.m_repositoryUrl = repositoryXml.Attributes["repositoryurl"].Value;
                    repository.m_webserviceUrl = repository.m_repositoryUrl.Trim('/') + "/" + repository.m_webserviceUrl.Trim('/');
                }

                if (repositoryXml.Attributes["webserviceurl"] != null) {
                    string wsUrl = repositoryXml.Attributes["webserviceurl"].Value;

                    if (wsUrl.Contains("://")) {
                        repository.m_webserviceUrl = repositoryXml.Attributes["webserviceurl"].Value;
                    } else {
                        repository.m_webserviceUrl = repository.m_repositoryUrl.Trim('/') + "/" + wsUrl.Trim('/');
                    }
                }

                repositories.Add(repository);
            }

            return repositories;
        }
Exemple #5
0
        public static Repository getByGuid(string repositoryGuid) {
            Repository repository = new Repository();

            XmlNode repositoryXml = m_repositories.SelectSingleNode("./repository [@guid = '" + repositoryGuid + "']");
            if (repositoryXml != null) {
                repository.m_guid = repositoryXml.Attributes["guid"].Value;
                repository.m_name = repositoryXml.Attributes["name"].Value;

                if (repositoryXml.Attributes["repositoryurl"] != null) {
                    repository.m_repositoryUrl = repositoryXml.Attributes["repositoryurl"].Value;
                    repository.m_webserviceUrl = repository.m_repositoryUrl.Trim('/') + "/" + repository.m_webserviceUrl.Trim('/');
                }

                if (repositoryXml.Attributes["webserviceurl"] != null) {
                    string wsUrl = repositoryXml.Attributes["webserviceurl"].Value;

                    if (wsUrl.Contains("://")) {
                        repository.m_webserviceUrl = repositoryXml.Attributes["webserviceurl"].Value;
                    } else {
                        repository.m_webserviceUrl = repository.m_repositoryUrl.Trim('/') + "/" + wsUrl.Trim('/');
                    }
                }
            }

            return repository;
        }
        public static Repository getByGuid(string repositoryGuid)
        {
            Guid id;
            if (System.Guid.TryParse(repositoryGuid, out id) == false)
            {
                throw new FormatException("The repositoryGuid is not a valid GUID");
            }

            var found = UmbracoConfig.For.UmbracoSettings().PackageRepositories.Repositories.FirstOrDefault(x => x.Id == id);
            if (found == null)
            {
                return null;
            }
            
            var repository = new Repository
            {
                Guid = found.Id.ToString(),
                Name = found.Name
            };

            repository.RepositoryUrl = found.RepositoryUrl;
            repository.WebserviceUrl = repository.RepositoryUrl.Trim('/') + "/" + found.WebServiceUrl.Trim('/');

            if (found.HasCustomWebServiceUrl)
            {
                string wsUrl = found.WebServiceUrl;

                if (wsUrl.Contains("://"))
                {
                    repository.WebserviceUrl = found.WebServiceUrl;
                }
                else
                {
                    repository.WebserviceUrl = repository.RepositoryUrl.Trim('/') + "/" + wsUrl.Trim('/');
                }
            }

            return repository;
        }