public static bool StylesheetChanges(XmlDocument xDoc) { XElement node = XElement.Load(new XmlNodeReader(xDoc)); string filehash = XmlDoc.GetPreCalculatedHash(node); if (string.IsNullOrEmpty(filehash)) { return(true); } XElement name = node.Element("Name"); if (name == null) { return(true); } var item = StyleSheet.GetByName(name.Value); if (item == null) { return(true); } XmlDocument xmlDoc = helpers.XmlDoc.CreateDoc(); xmlDoc.AppendChild(item.ToXml(xmlDoc)); string dbMD5 = XmlDoc.CalculateMD5Hash(xmlDoc); return(!filehash.Equals(dbMD5)); }
/// <summary> /// Reads the configuration of the package from the configuration xmldocument /// </summary> /// <param name="tempDir">The folder to which the contents of the package is extracted</param> public void LoadConfig(string tempDir) { Config = new XmlDocument(); Config.Load(tempDir + Path.DirectorySeparatorChar + "package.xml"); Name = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/name").FirstChild.Value; Version = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/version").FirstChild.Value; Url = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/url").FirstChild.Value; License = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/license").FirstChild.Value; LicenseUrl = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/license").Attributes.GetNamedItem("url").Value; RequirementsMajor = int.Parse(Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/requirements/major").FirstChild.Value); RequirementsMinor = int.Parse(Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/requirements/minor").FirstChild.Value); RequirementsPatch = int.Parse(Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/requirements/patch").FirstChild.Value); var reqNode = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/requirements"); RequirementsType = reqNode != null && reqNode.Attributes != null && reqNode.Attributes["type"] != null ? Enum <RequirementsType> .Parse(reqNode.Attributes["type"].Value, true) : RequirementsType.Legacy; var iconNode = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/iconUrl"); if (iconNode != null && iconNode.FirstChild != null) { IconUrl = iconNode.FirstChild.Value; } Author = Config.DocumentElement.SelectSingleNode("/umbPackage/info/author/name").FirstChild.Value; AuthorUrl = Config.DocumentElement.SelectSingleNode("/umbPackage/info/author/website").FirstChild.Value; var basePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath; var dllBinFiles = new List <string>(); foreach (XmlNode n in Config.DocumentElement.SelectNodes("//file")) { var badFile = false; var destPath = GetFileName(basePath, XmlHelper.GetNodeValue(n.SelectSingleNode("orgPath"))); var orgName = XmlHelper.GetNodeValue(n.SelectSingleNode("orgName")); var destFile = GetFileName(destPath, orgName); if (destPath.ToLower().Contains(IOHelper.DirSepChar + "app_code")) { badFile = true; } if (destPath.ToLower().Contains(IOHelper.DirSepChar + "bin")) { badFile = true; } if (destFile.ToLower().EndsWith(".dll")) { badFile = true; dllBinFiles.Add(Path.Combine(tempDir, orgName)); } if (badFile) { ContainsUnsecureFiles = true; _unsecureFiles.Add(XmlHelper.GetNodeValue(n.SelectSingleNode("orgName"))); } } if (ContainsUnsecureFiles) { //Now we want to see if the DLLs contain any legacy data types since we want to warn people about that string[] assemblyErrors; var assembliesWithReferences = PackageBinaryInspector.ScanAssembliesForTypeReference <IDataType>(tempDir, out assemblyErrors).ToArray(); if (assemblyErrors.Any()) { ContainsBinaryFileErrors = true; BinaryFileErrors.AddRange(assemblyErrors); } if (assembliesWithReferences.Any()) { ContainsLegacyPropertyEditors = true; } } //this will check for existing macros with the same alias //since we will not overwrite on import it's a good idea to inform the user what will be overwritten foreach (XmlNode n in Config.DocumentElement.SelectNodes("//macro")) { var alias = n.SelectSingleNode("alias").InnerText; if (!string.IsNullOrEmpty(alias)) { var m = ApplicationContext.Current.Services.MacroService.GetByAlias(alias); if (m != null) { ContainsMacroConflict = true; if (_conflictingMacroAliases.ContainsKey(m.Name) == false) { _conflictingMacroAliases.Add(m.Name, alias); } } } } foreach (XmlNode n in Config.DocumentElement.SelectNodes("Templates/Template")) { var alias = n.SelectSingleNode("Alias").InnerText; if (!string.IsNullOrEmpty(alias)) { var t = Template.GetByAlias(alias); if (t != null) { ContainsTemplateConflicts = true; if (_conflictingTemplateAliases.ContainsKey(t.Text) == false) { _conflictingTemplateAliases.Add(t.Text, alias); } } } } foreach (XmlNode n in Config.DocumentElement.SelectNodes("Stylesheets/Stylesheet")) { var alias = n.SelectSingleNode("Name").InnerText; if (!string.IsNullOrEmpty(alias)) { var s = StyleSheet.GetByName(alias); if (s != null) { ContainsStyleSheeConflicts = true; if (_conflictingStyleSheetNames.ContainsKey(s.Text) == false) { _conflictingStyleSheetNames.Add(s.Text, alias); } } } } var readmeNode = Config.DocumentElement.SelectSingleNode("/umbPackage/info/readme"); if (readmeNode != null) { ReadMe = XmlHelper.GetNodeValue(readmeNode); } var controlNode = Config.DocumentElement.SelectSingleNode("/umbPackage/control"); if (controlNode != null) { Control = XmlHelper.GetNodeValue(controlNode); } }