public bool SetProductSettingsXml(ProductSettings productSettings, string xpath, string value) { if (_xmlDoc == null || string.IsNullOrWhiteSpace(value)) { return(false); } XmlNode onlineProductSettings = GetOnlineProductSettings(productSettings); if (onlineProductSettings == null) { return(false); } try { XmlParser.SetStringValue(_xmlDoc, onlineProductSettings, xpath, value); _isProductSettingsParsed = false; } catch (Exception) { return(false); } return(true); }
public Dictionary <string, string> GetEventParameters(ProductSettings productSettings, int eventIndex) { Dictionary <string, string> res = new Dictionary <string, string>(); XmlNode onlineProductSettings = GetOnlineProductSettings(productSettings); if (onlineProductSettings == null) { return(res); } int currentIndex = 0; foreach (XmlNode productLogicNode in onlineProductSettings.SelectNodes("StaticData/Logic")) { foreach (XmlNode eventNode in productLogicNode.SelectNodes("Events/Event")) { if (currentIndex == eventIndex) { return(XmlParser.GetChildNodesValues(eventNode)); } currentIndex++; } } return(res); }
private XmlNode GetOnlineProductSettings(ProductSettings productSettings) { XmlNode onlineProductSettings = null; foreach (XmlNode productSettingsNode in _xmlDoc.SelectNodes("//Products/Product")) { if (XmlParser.GetStringValue(productSettingsNode, "Guid") == productSettings.Guid) { onlineProductSettings = productSettingsNode; break; } } return(onlineProductSettings); }
internal virtual void AddAdditionalSettings(ref ProductSettings productSettings, XmlNode productStaticData, XmlNode productDynamicData) { }
private ProductSettings ExtractProductSettings(XmlNode productSettingsNode) { #if DEBUG Logger.GetLogger().Info("Read config file - Product Settings:", Logger.Level.MEDIUM_DEBUG_LEVEL); #endif ProductSettings productSettings = new ProductSettings { IsOptional = XmlParser.GetBoolAttribute(productSettingsNode, "optional"), IsExtractable = XmlParser.GetBoolAttribute(productSettingsNode, "extractable", true), Exclusive = XmlParser.GetBoolAttribute(productSettingsNode, "exclusive", false) }; string guid = XmlParser.GetStringValue(productSettingsNode, "Guid"); if (string.IsNullOrEmpty(guid)) { guid = Guid.NewGuid().ToString(); XmlParser.SetStringValue(_xmlDoc, productSettingsNode, "Guid", guid); } productSettings.Guid = guid; XmlNode productStaticData = productSettingsNode.SelectSingleNode("StaticData"); XmlNode productDynamicData = productSettingsNode.SelectSingleNode("DynamicData"); productSettings.Name = XmlParser.GetStringValue(productStaticData, "Title"); if (productSettings.IsOptional) { productSettings.Name = XmlParser.GetStringValue(productDynamicData, "InternalName"); } productSettings.Class = XmlParser.GetStringValue(productDynamicData, "Class"); EvalCustomVariables(productStaticData.SelectSingleNode("CustomData/CustomVars")); productSettings.Filename = XmlParser.GetStringValue(productStaticData, "Filename"); productSettings.ExtractPath = XmlParser.GetStringValue(productStaticData, "ExtractPath"); productSettings.RunPath = XmlParser.GetStringValue(productStaticData, "RunPath"); productSettings.DownloadURLs = new List <ProductSettings.DownloadURL>(); foreach (XmlNode DownloadURLNode in productStaticData.SelectNodes("DownloadURLs/DownloadURL")) { ProductSettings.DownloadURL downloadURL = new ProductSettings.DownloadURL { Arch = XmlParser.GetStringAttribute(DownloadURLNode, "arch").Trim(), URL = XmlParser.GetStringValue(DownloadURLNode).Trim() }; productSettings.DownloadURLs.Add(downloadURL); } bool runWithBitsDefault = XmlParser.GetBoolValue(_xmlDoc.SelectSingleNode("//Config"), ConfigConsts.RUN_WITH_BITS, true); productSettings.ProductEvents = new List <ProductSettings.ProductEvent>(); foreach (XmlNode productLogicNode in productStaticData.SelectNodes("Logic")) { productSettings.Behavior = XmlParser.GetStringValue(productLogicNode, "Behavior"); productSettings.RunWithBits = XmlParser.GetBoolValue(productLogicNode, "RunWithBits", runWithBitsDefault); productSettings.RunAndWait = XmlParser.GetBoolValue(productLogicNode, "RunAndWait"); productSettings.DownloadMethod = XmlParser.GetStringValue(productLogicNode, "DownloadMethod"); if (string.IsNullOrEmpty(productSettings.DownloadMethod)) { productSettings.DownloadMethod = GetConfigValue(ConfigConsts.DOWNLOAD_METHOD); } productSettings.SecondaryDownloadMethod = XmlParser.GetStringValue(productLogicNode, "SecondaryDownloadMethod"); if (string.IsNullOrEmpty(productSettings.SecondaryDownloadMethod)) { productSettings.SecondaryDownloadMethod = GetConfigValue(ConfigConsts.SECONDARY_DOWNLOAD_METHOD); } productSettings.MsiTimeoutMS = XmlParser.GetIntValue(productLogicNode, "MsiTimeoutMs"); foreach (XmlNode eventNode in productLogicNode.SelectNodes("Events/Event")) { if (eventNode.Attributes.Count > 0) { ProductSettings.ProductEvent productEvent = new ProductSettings.ProductEvent { Name = eventNode.Attributes.Item(0).Name, Trigger = XmlParser.GetStringAttribute(eventNode, eventNode.Attributes.Item(0).Name) }; productSettings.ProductEvents.Add(productEvent); } } } productSettings.RunParams = ""; foreach (XmlNode runParamsNode in productStaticData.SelectNodes("RunParams/RunParam")) { string RunParam = XmlParser.GetStringValue(runParamsNode).Trim(); productSettings.RunParams += string.IsNullOrEmpty(productSettings.RunParams) ? RunParam : " " + RunParam; } productSettings.PreInstall = ExtractProductRequirementsRoot(productStaticData.SelectNodes("PreInstall/Requirements")); productSettings.PostInstall = ExtractProductRequirementsRoot(productStaticData.SelectNodes("PostInstall/Requirements")); productSettings.LayoutName = XmlParser.GetStringValue(productStaticData, "Layout"); ControlsLayout defLocaleControlsLayout = null; productSettings.ControlsLayouts = null; XmlNodeList Locales = productSettingsNode.SelectNodes("Locales/Locale"); if (Locales.Count > 0) { foreach (XmlNode localeNode in Locales) { if (XmlParser.GetBoolAttribute(localeNode, "default")) { defLocaleControlsLayout = new ControlsLayout(new XmlNodeList[] { localeNode.SelectNodes("Texts/Text"), localeNode.SelectNodes("Images/Image"), localeNode.SelectNodes("UILayouts") }, _formDesign.DefaultControlDesign); } string localeLanguage = XmlParser.GetStringAttribute(localeNode, "name"); if (localeLanguage == LocaleCode) { productSettings.ControlsLayouts = new ControlsLayout(new XmlNodeList[] { localeNode.SelectNodes("Texts/Text"), localeNode.SelectNodes("Images/Image"), localeNode.SelectNodes("UILayouts") }, _formDesign.DefaultControlDesign); } } if (productSettings.ControlsLayouts == null) { productSettings.ControlsLayouts = defLocaleControlsLayout; } #if DEBUG if (productSettings.ControlsLayouts == null) { Logger.GetLogger().Error("Missing locale for product: " + productSettings.Name + " language code: " + LocaleCode); } #endif } AddAdditionalSettings(ref productSettings, productStaticData, productDynamicData); return(productSettings); }