Exemplo n.º 1
0
        public void Leer(string archivo, out Queue <Patente> datos)
        {
            datos = new Queue <Patente>();
            //string a;
            StreamReader reader = null;

            try
            {
                reader = new StreamReader(string.Format("{0}\\{1}", Environment.GetFolderPath(Environment.SpecialFolder.Desktop), archivo));
                while (!reader.EndOfStream)
                {
                    Patente p = PatenteStringExtension.ValidarPatente(reader.ReadLine());
                    datos.Enqueue(p);
                }
            }
            catch (PatenteInvalidaException)
            {
                //throw PatenteInvalidaException(e);
            }
            finally
            {
                if (!(reader is null))
                {
                    reader.Close();
                }
            }
        }
Exemplo n.º 2
0
        public void Leer(string archivo, out Queue <Patente> datos)
        {
            StreamReader    texto = null;
            Queue <Patente> cola  = null;

            try
            {
                texto = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + archivo + ".txt");

                while (!texto.EndOfStream)
                {
                    Patente p = PatenteStringExtension.ValidarPatente(texto.ReadLine());
                    cola.Enqueue(p);
                }

                datos = cola;
            }
            catch (Exception e)
            {
                datos = null;
                throw e;
            }
            finally
            {
                texto.Close();
            }
        }
Exemplo n.º 3
0
        public void Leer(string archivo, out Queue <Patente> datos)
        {
            try
            {
                StreamReader    file       = new StreamReader(archivo);
                Queue <Patente> aux        = new Queue <Patente>();
                string          auxPatente = file.ReadLine();

                while (auxPatente != null)
                {
                    aux.Enqueue(PatenteStringExtension.ValidarPatente(auxPatente));
                    auxPatente = file.ReadLine();
                }

                datos = aux;
                file.Close();
            }
            catch (PatenteInvalidaException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 4
0
        public void Leer(string tabla, out Queue <Patente> datos)
        {
            datos = new Queue <Patente>();
            Patente p = null;

            try
            {
                comando.CommandText = String.Format("SELECT * FROM {0}", tabla);
                conexion.Open();
                reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    p = PatenteStringExtension.ValidarPatente(reader.GetString(1));
                    datos.Enqueue(p);
                }
            }
            catch (PatenteInvalidaException pE)
            {
                throw pE;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                reader.Close();
                conexion.Close();
            }
        }
Exemplo n.º 5
0
 public void Leer(string archivo, out Queue<Patente> datos)
 {
     datos = new Queue<Patente>();
     using (StreamReader sr = new StreamReader(@"C:\Users\alumno\Desktop\" + archivo))
     {
         while (!sr.EndOfStream)
         {
             datos.Enqueue(PatenteStringExtension.ValidarPatente(sr.ReadLine()));//UNA VEZ QUE TENGAMOS LOS METODOS DE EXTENSION SE ENCARGARAN DE DEVOLVER EL TIPO
         }
     }
 }
Exemplo n.º 6
0
        public void Leer(string archivo, out Queue <Patente> datos)
        {
            StreamReader sr = new StreamReader(archivo);

            datos = new Queue <Patente>();

            while (!sr.EndOfStream)
            {
                Patente patente = new Patente();
                PatenteStringExtension.ValidarPatente(sr.ReadLine());
                datos.Enqueue(patente);
            }

            sr.Close();
        }
Exemplo n.º 7
0
        public void Leer(string archivo, out Queue <Patente> datos)
        {
            Queue <Patente> patentesAux = new Queue <Patente>();

            try {
                using (StreamReader sr = new StreamReader("D:\\" + archivo + ".txt"))
                {
                    while (!sr.EndOfStream)
                    {
                        patentesAux.Enqueue(PatenteStringExtension.ValidarPatente(sr.ReadLine()));
                    }
                }
            }
            catch (Exception e) {
                throw new Exception("Error al leer archivo de texto", e);
            }


            datos = patentesAux;
        }
Exemplo n.º 8
0
        /// <summary>
        /// lee de archivo y deja en la cola datos lo leido
        /// </summary>
        /// <param name="archivo"></param>
        /// <param name="datos"></param>
        public void Leer(string archivo, out Queue <Patente> datos)
        {
            StreamReader    sr  = new StreamReader(archivo);
            string          str = sr.ReadToEnd();
            Patente         p;
            Queue <Patente> auxQueue = new Queue <Patente>();

            foreach (string s in str.Split('\n'))
            {
                string aux = s.Replace('\r', ' ');
                aux = s.Trim();
                p   = PatenteStringExtension.ValidarPatente(aux);
                if (p != null)
                {
                    auxQueue.Enqueue(p);
                }
            }
            datos = auxQueue;
            sr.Close();
        }
Exemplo n.º 9
0
        public void Leer(string archivos, out Queue <Patente> datos)
        {
            try
            {
                StreamReader    rdr      = new StreamReader(archivos);
                Queue <Patente> patentes = new Queue <Patente>();
                //datos = rdr.ReadToEnd();
                while (!rdr.EndOfStream)
                {
                    string patente = rdr.ReadLine();
                    patentes.Enqueue(PatenteStringExtension.ValidarPatente(patente));
                }
                datos = patentes;

                rdr.Close();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 10
0
 public void Leer(string archivo, out Queue <Patente> datos)
 {
     try
     {
         string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
         path  += @"\" + archivo;
         reader = new StreamReader(path);
         Patente p = null;
         datos = new Queue <Patente>();
         while (!reader.EndOfStream)
         {
             p = PatenteStringExtension.ValidarPatente(reader.ReadLine());
             datos.Enqueue(p);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         reader.Close();
     }
 }
Exemplo n.º 11
0
        public void Leer(string tabla, out Queue <Patente> datos)
        {
            conexion = new SqlConnection(tabla);
            //using (conexion = new SqlConnection(tabla))
            //{
            datos = new Queue <Patente>();
            string coman = "SELECT * FROM Patentes";

            comando = new SqlCommand(coman, conexion);
            conexion.Open();
            SqlDataReader dataReader = comando.ExecuteReader();

            while (dataReader.Read())
            {
                string patente = dataReader.GetString(0);
                string tipo    = dataReader.GetString(1);

                Patente pat = PatenteStringExtension.ValidarPatente(patente);

                datos.Enqueue(pat);
            }
            conexion.Close();
            //}
        }