protected override IList <IParameter> ExtractParameters() { var parameters = new List <IParameter>(); var configurationNode = FileXmlDocument.SelectSingleNode( $"/Project/Configurations/Configuration[Name=\"{_configurationName}\"]", NamespaceManager); if (configurationNode == null) { throw new InvalidConfigurationNameException(_configurationName); } var parameterNodes = configurationNode.SelectNodes( $"./Options/ParameterConfigurationValues/ConfigurationSetting", NamespaceManager); if (parameterNodes == null || parameterNodes.Count == 0) { return(parameters); } foreach (XmlNode parameterNode in parameterNodes) { var parameter = new ConfigurationParameter(parameterNode, false); if (parameter.Name != null) { parameters.Add(parameter); } } return(parameters); }
private void ResolveProtectionLevel() { _protectionLevelAttribute = FileXmlDocument.SelectSingleNode("/DTS:Executable", NamespaceManager)?.Attributes?["DTS:ProtectionLevel"]; // At least in Visual Studio 2017 (14.0.0800.98), the DTS:ProtectionLevel elemented is ommited in case it is set to DontSaveSensitive. if (_protectionLevelAttribute == null) { var attr = FileXmlDocument.CreateAttribute("DTS:ProtectionLevel"); attr.Value = "DontSaveSensitive"; _protectionLevelAttribute = attr; } var protectionLevelValue = _protectionLevelAttribute?.Value; ProtectionLevel protectionLevel; if (!Enum.TryParse(protectionLevelValue, true, out protectionLevel)) { throw new InvalidXmlException($"Invalid DTS:ProtectionLevel value {protectionLevelValue}.", FileXmlDocument); } if (!Enum.IsDefined(typeof(ProtectionLevel), protectionLevel)) { throw new InvalidXmlException($"Invalid DTS:ProtectionLevel value {protectionLevelValue}.", FileXmlDocument); } }
private void ResolveProtectionLevel() { _protectionLevelAttribute = FileXmlDocument.SelectSingleNode("/DTS:Executable", NamespaceManager)?.Attributes?["DTS:ProtectionLevel"]; var protectionLevelValue = _protectionLevelAttribute?.Value; if (protectionLevelValue == null) { throw new InvalidXmlException("Failed to determine protection level. DTS:ProtectionLevel attribute was not found.", FileXmlDocument); } ProtectionLevel protectionLevel; if (!Enum.TryParse(protectionLevelValue, true, out protectionLevel)) { throw new InvalidXmlException($"Invalid DTS:ProtectionLevel value {protectionLevelValue}.", FileXmlDocument); } if (!Enum.IsDefined(typeof(ProtectionLevel), protectionLevel)) { throw new InvalidXmlException($"Invalid DTS:ProtectionLevel value {protectionLevelValue}.", FileXmlDocument); } }
private void ResolveProtectionLevel() { _protectionLevelAttribute = FileXmlDocument.SelectSingleNode("/DTS:Executable", NamespaceManager)?.Attributes?["DTS:ProtectionLevel"]; if (_protectionLevelAttribute == null) { _protectionLevelAttribute = FileXmlDocument.SelectSingleNode("/DTS:Executable", NamespaceManager).Attributes.Append(FileXmlDocument.CreateAttribute("DTS:ProtectionLevel")); ProtectionLevel = ProtectionLevel.DontSaveSensitive; } var protectionLevelValue = _protectionLevelAttribute.Value; ProtectionLevel protectionLevel; if (!Enum.TryParse(protectionLevelValue, true, out protectionLevel)) { throw new InvalidXmlException($"Invalid DTS:ProtectionLevel value {protectionLevelValue}. For Project {FilePath}", FileXmlDocument); } if (!Enum.IsDefined(typeof(ProtectionLevel), protectionLevel)) { throw new InvalidXmlException($"Invalid DTS:ProtectionLevel value {protectionLevelValue}. . For Project {FilePath}", FileXmlDocument); } }
protected override void PostInitialize() { var manifestXml = FileXmlDocument.DocumentElement; var projectProtectionLevelAttribute = manifestXml?.Attributes["SSIS:ProtectionLevel"]; var protectionLevelString = projectProtectionLevelAttribute?.Value; if (string.IsNullOrWhiteSpace(protectionLevelString)) { throw new InvalidXmlException("Invalid project file. SSIS:Project node must contain a SSIS:ProtectionLevel attribute.", manifestXml); } ProtectionLevel protectionLevel; if (!Enum.TryParse(protectionLevelString, out protectionLevel)) { throw new InvalidXmlException($"Invalid Protection Level {protectionLevelString}.", manifestXml); } if (protectionLevel == ProtectionLevel.EncryptAllWithUserKey || protectionLevel == ProtectionLevel.EncryptSensitiveWithUserKey) { throw new InvalidProtectionLevelException(protectionLevel); } _protectionLevelNodes.Add(projectProtectionLevelAttribute); PackageNames = ExtractPackageNames(); ConnectionManagerNames = ExtractConnectionManagerNames(); foreach (XmlElement packageProtectionLevelNode in FileXmlDocument.SelectNodes("//SSIS:Property[@SSIS:Name = \"ProtectionLevel\"]", NamespaceManager)) { packageProtectionLevelNode.InnerText = protectionLevel.ToString("D"); _protectionLevelNodes.Add(packageProtectionLevelNode); } var versionMajorNode = FileXmlDocument.SelectSingleNode("/SSIS:Project/SSIS:Properties/SSIS:Property[@SSIS:Name = \"VersionMajor\"]", NamespaceManager); if (versionMajorNode == null) { throw new InvalidXmlException("Version Major Xml Node was not found", FileXmlDocument); } var versionMajorString = versionMajorNode.InnerText; int test; if (!int.TryParse(versionMajorString, out test)) { throw new InvalidXmlException($"Invalid value of Version Major Xml Node: {versionMajorString}.", FileXmlDocument); } var versionMajorNodes = FileXmlDocument.SelectNodes("//*[@SSIS:Name = \"VersionMajor\"]", NamespaceManager); if (versionMajorNodes != null) { foreach (XmlElement element in versionMajorNodes) { if (element != null) { element.InnerText = versionMajorString; _versionMajorNodes.Add(element); } } } var versionMinorNode = FileXmlDocument.SelectSingleNode("/SSIS:Project/SSIS:Properties/SSIS:Property[@SSIS:Name = \"VersionMinor\"]", NamespaceManager); if (versionMinorNode == null) { throw new InvalidXmlException("Version Minor Xml Node was not found", FileXmlDocument); } var versionMinorString = versionMinorNode.InnerText; if (!int.TryParse(versionMinorString, out test)) { throw new InvalidXmlException($"Invalid value of Version Minor Xml Node: {versionMinorString}.", FileXmlDocument); } var versionMinorNodes = FileXmlDocument.SelectNodes("//*[@SSIS:Name = \"VersionMinor\"]", NamespaceManager); if (versionMinorNodes != null) { foreach (XmlElement element in versionMinorNodes) { if (element != null) { element.InnerText = versionMinorString; _versionMinorNodes.Add(element); } } } var versionBuildNode = FileXmlDocument.SelectSingleNode("/SSIS:Project/SSIS:Properties/SSIS:Property[@SSIS:Name = \"VersionBuild\"]", NamespaceManager); if (versionBuildNode == null) { throw new InvalidXmlException("Version Build Xml Node was not found", FileXmlDocument); } var versionBuildString = versionBuildNode.InnerText; if (!int.TryParse(versionBuildString, out test)) { throw new InvalidXmlException($"Invalid value of Version Build Xml Node: {versionBuildString}.", FileXmlDocument); } var versionBuildNodes = FileXmlDocument.SelectNodes("//*[@SSIS:Name = \"VersionBuild\"]", NamespaceManager); if (versionBuildNodes != null) { foreach (XmlElement element in versionBuildNodes) { if (element != null) { element.InnerText = versionBuildString; _versionBuildNodes.Add(element); } } } var versionCommentsNode = FileXmlDocument.SelectSingleNode("/SSIS:Project/SSIS:Properties/SSIS:Property[@SSIS:Name = \"VersionComments\"]", NamespaceManager); if (versionCommentsNode == null) { throw new InvalidXmlException("Version Comments Xml Node was not found", FileXmlDocument); } var versionCommentsString = versionCommentsNode.InnerText; var versionCommentsNodes = FileXmlDocument.SelectNodes("//*[@SSIS:Name = \"VersionComments\"]", NamespaceManager); if (versionCommentsNodes != null) { foreach (XmlElement element in versionCommentsNodes) { if (element != null) { element.InnerText = versionCommentsString; _versionCommentsNodes.Add(element); } } } _descriptionNode = FileXmlDocument.SelectSingleNode("/SSIS:Project/SSIS:Properties/SSIS:Property[@SSIS:Name = \"Description\"]", NamespaceManager) as XmlElement; if (_descriptionNode == null) { throw new InvalidXmlException("Description Xml Node was not found", FileXmlDocument); } }