public static XPathNodeIterator FindPackageForUmbracoVersion(int nodeid, string umbracoVersion) { XmlDocument xd = new XmlDocument(); WikiFile wf = WikiFile.FindPackageForUmbracoVersion(nodeid, umbracoVersion); if (wf != null) { xd.AppendChild(wf.ToXml(xd)); } return(xd.CreateNavigator().Select(".")); }
public byte[] fetchPackageByVersion(string packageGuid, string repoVersion) { //first, translate repo version enum to our.umb version strings //version3 = v31 //version4 = v4 //version41 = v45 //if v45, check if default package is v47 as well, as 4.7 install use v45 when calling the repo (thank god we are moving to nuget) //everything else = v4 string version = "v4"; switch (repoVersion.ToLower()) { case "version3": version = "v31"; break; case "version4": version = "v4"; break; case "version41": version = "v45"; break; case "version41legacy": version = "v45l"; break; default: version = "v4"; break; } WikiFile wf = OurUmbraco.Repository.Packages.PackageFileByGuid(new Guid(packageGuid)); if (wf != null) { //if the package doesn't care about the umbraco version needed... if (wf.Version.Version == "nan") { return(wf.ToByteArray()); } //if v45 if (version == "v45") { int v = 0; if (int.TryParse(wf.Version.Version.Replace("v", ""), out v)) { if (v >= 45) { return(wf.ToByteArray()); } } if (wf.Version.Version == "v47" || wf.Version.Version == "v45") { return(wf.ToByteArray()); } else if (wf.Version.Version != version && wf.Version.Version != "nan") { wf = WikiFile.FindPackageForUmbracoVersion(wf.NodeId, version); return(wf.ToByteArray()); } } } return(new byte[0]); /* * if (wf.Version.Version != version && wf.Version.Version != "nan") * wf = uWiki.Businesslogic.WikiFile.FindPackageForUmbracoVersion(wf.NodeId, version); * * * if(wf != null) * return wf.ToByteArray(); * else * return new byte[0];*/ }
public byte[] fetchPackageByVersion(string packageGuid, string repoVersion) { //first, translate repo version enum to our.umb version strings //version3 = v31 //version4 = v4 //version41 = v45 //if v45, check if default package is v47 as well, as 4.7 install use v45 when calling the repo (thank god we are moving to nuget) //everything else = v4 string version = "v4"; switch (repoVersion.ToLower()) { case "version3": version = "v31"; break; case "version4": version = "v4"; break; case "version41": version = "v45"; break; case "version41legacy": version = "v45l"; break; default: version = "v4"; break; } var umbHelper = new UmbracoHelper(UmbracoContext.Current); var pckRepoService = new PackageRepositoryService(umbHelper, umbHelper.MembershipHelper, ApplicationContext.Current.DatabaseContext); //This doesn't matter what we set it to so long as it's below 7.5 since that is the version we introduce strict dependencies //Side note: Umbraco 7.5.0 uses this endpoint but since 7.5.0 is already out there's nothing we can do about this, if we pass in 7.5.x then // the logic will use strict file versions which we cannot do because this endpoint is also used for < 7.5! // The worst that can happen in this case is that a strict package dependency has been made on 7.5 and then an umbraco 7.5 package // requests the file, well it won't get it because this will only return non strict packages. var currUmbracoVersion = new System.Version(4, 0, 0); var guid = new Guid(packageGuid); var details = pckRepoService.GetDetails(guid, currUmbracoVersion, true); if (details == null) { return(new byte[0]); } if (details.ZipUrl.IsNullOrWhiteSpace()) { throw new InvalidOperationException("This package is not compatible with the Umbraco version " + currUmbracoVersion); } var wf = new WikiFile(details.ZipFileId); //WikiFile wf = OurUmbraco.Repository.Packages.PackageFileByGuid(new Guid(packageGuid)); //if the package doesn't care about the umbraco version needed... if (wf.Version.Version == "nan") { return(wf.ToByteArray()); } //if v45 if (version == "v45") { int v = 0; if (int.TryParse(wf.Version.Version.Replace("v", ""), out v)) { if (v >= 45) { return(wf.ToByteArray()); } } if (wf.Version.Version == "v47" || wf.Version.Version == "v45") { return(wf.ToByteArray()); } if (wf.Version.Version != version && wf.Version.Version != "nan") { wf = WikiFile.FindPackageForUmbracoVersion(wf.NodeId, version); return(wf.ToByteArray()); } } return(new byte[0]); }