コード例 #1
0
        private void LeeConfiguracionConexion(dtoConexion dto)
        {
            StringReader  _Reader    = new StringReader(Properties.Resources.Configuraciones);
            XmlTextReader _xmlReader = new XmlTextReader(_Reader);

            XmlDocument xDoc = new XmlDocument();

            //La ruta del documento XML permite rutas relativas
            //respecto del ejecutable!
            xDoc.Load(_xmlReader);

            XmlNodeList configuraciones = xDoc.GetElementsByTagName("Configuraciones");
            XmlNodeList lista           = ((XmlElement)configuraciones[0]).GetElementsByTagName("Configuracion");

            foreach (XmlElement nodo in lista)
            {
                dto.Estado = Convert.ToBoolean(nodo.GetAttribute("Estado"));

                if (dto.Estado)
                {
                    dto.Nombre    = nodo.GetAttribute("Nombre");
                    dto.IpLocal   = nodo.GetAttribute("IpLocal");
                    dto.IpPublico = nodo.GetAttribute("IpPublico");
                    dto.NomBD     = nodo.GetAttribute("NomBD");
                    dto.UserBD    = nodo.GetAttribute("UserBD");
                    dto.PassBD    = nodo.GetAttribute("PassBD");
                    break;
                }
            }
        }
コード例 #2
0
        private void CrearConexion()
        {
            dtoConexion dto = new dtoConexion();

            LeeConfiguracionConexion(dto);

            IpServer        = dto.IpLocal;
            EsConexionLocal = true;

            if (ValidaIP(dto.IpLocal))
            {
                IpServer        = dto.IpLocal;
                EsConexionLocal = true;
            }
            else
            {
                IpServer        = dto.IpPublico;
                EsConexionLocal = false;
            }
            UserBD = dto.UserBD;
            NomBD  = dto.NomBD;
            PassBD = dto.PassBD;
        }