/// <summary>
        /// Loads the settings from the XML node.
        /// </summary>
        public void LoadFromXml(XmlNode xmlNode)
        {
            if (xmlNode == null)
            {
                throw new ArgumentNullException(nameof(xmlNode));
            }

            InstanceID   = xmlNode.GetChildAsInt("InstanceID");
            Name         = xmlNode.GetChildAsString("Name");
            Extension    = xmlNode.GetChildAsString("Extension");
            WebUrl       = xmlNode.GetChildAsString("WebUrl");
            AgentEnabled = xmlNode.GetChildAsBool("AgentEnabled");
            DbEnabled    = xmlNode.GetChildAsBool("DbEnabled");

            if (xmlNode.SelectSingleNode("AgentConnectionOptions") is XmlNode agentConnectionOptionsNode)
            {
                AgentConnectionOptions.LoadFromXml(agentConnectionOptionsNode);
            }

            if (xmlNode.SelectSingleNode("DbConnectionOptions") is XmlNode dbConnectionOptionsNode)
            {
                DbConnectionOptions.LoadFromXml(dbConnectionOptionsNode);
            }

            if (xmlNode.SelectSingleNode("DownloadOptions") is XmlNode downloadOptionsNode)
            {
                DownloadOptions.LoadFromXml(downloadOptionsNode);
            }

            if (xmlNode.SelectSingleNode("UploadOptions") is XmlNode uploadOptionsNode)
            {
                UploadOptions.LoadFromXml(uploadOptionsNode);
            }
        }
        /// <summary>
        /// Loads the configuration from the XML node.
        /// </summary>
        public override void LoadConfig(XmlElement xmlElement)
        {
            base.LoadConfig(xmlElement);
            waitTimeout = TimeSpan.FromSeconds(xmlElement.GetChildAsInt("WaitTimeout"));

            if (xmlElement.SelectSingleNode("Connection") is XmlNode connectionNode)
            {
                connOptions = new DbConnectionOptions();
                connOptions.LoadFromXml(connectionNode);
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets the connection options from the instance configuration.
        /// </summary>
        public static DbConnectionOptions GetConnectionOptions(InstanceConfig instanceConfig)
        {
            if (instanceConfig.Storages.TryGetValue(StorageCode, out XmlElement storageElem) &&
                storageElem.SelectSingleNode("Connection") is XmlNode connectionNode)
            {
                DbConnectionOptions connOptions = new DbConnectionOptions();
                connOptions.LoadFromXml(connectionNode);
                return(connOptions);
            }

            throw new ScadaException(CommonPhrases.ConnOptionsNotFound);
        }
Exemple #4
0
        /// <summary>
        /// Loads the configuration from the specified reader.
        /// </summary>
        protected override void Load(TextReader reader)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(reader);

            if (xmlDoc.DocumentElement.SelectSingleNode("Connections") is XmlNode connectionsNode)
            {
                foreach (XmlNode connectionNode in connectionsNode.SelectNodes("Connection"))
                {
                    DbConnectionOptions connectionOptions = new DbConnectionOptions();
                    connectionOptions.LoadFromXml(connectionNode);
                    Connections[connectionOptions.Name] = connectionOptions;
                }
            }
        }