コード例 #1
0
ファイル: XML.cs プロジェクト: Tincho04/Parciales_LabII
        /// <summary>
        /// Método de lectura del archivo xml de los turnos
        /// </summary>
        /// <param name="archivo"></param>
        /// <param name="datos"></param>
        public void Leer(string archivo, out TurnoXML datos)
        {
            XmlTextReader reader      = new XmlTextReader(archivo);
            string        fechaAux    = string.Empty;
            string        apellidoAux = string.Empty;
            string        nombreAux   = string.Empty;

            datos = new TurnoXML();

            bool flag = true;

            try
            {
                while (reader.Read())
                {
                    PacDerivados derivado = new PacDerivados();
                    #region ValidacionTipoDeDato
                    #region ValidaFecha
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "Fecha")
                    {
                        fechaAux = reader.ReadElementString();

                        #endregion
                        #region ValidaApellido
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "Apellido")
                        {
                            apellidoAux = reader.ReadElementString();
                        }
                        #endregion
                        #region ValidaNombre
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "Nombre")
                        {
                            nombreAux = reader.ReadElementString();
                        }
                        #endregion
                        #endregion
                        if (flag == true)
                        {
                            datos = new TurnoXML(fechaAux, apellidoAux, nombreAux);
                        }
                    }
                }
            }
            catch (ArchivosException a)
            {
                Texto  texto = new Texto();
                string route = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + ".\\SegundoParcialUtn\\LogDeErrores.txt";
                texto.Guardar(route, a.Message);
            }
            catch (XmlException e)
            {
                Texto  texto = new Texto();
                string route = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + ".\\SegundoParcialUtn\\LogDeErrores.txt";
                texto.Guardar(route, e.Message);
            }
        }
コード例 #2
0
ファイル: TurnoXML.cs プロジェクト: Tincho04/Parciales_LabII
        /// <summary>
        /// método que nos permitirá disparar el proceso de guardado para archivo binario
        /// </summary>
        /// <param name="turno"></param>
        /// <returns></returns>
        public static bool GuardarBinario(TurnoXML turno)
        {
            bool           retorno = false;
            XML <TurnoXML> xml     = new XML <TurnoXML>();
            string         route   = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + ".\\SegundoParcialUtn\\TurnosClinica\\Turnos.dat";

            if (xml.Guardar(route, turno))
            {
                retorno = true;
            }
            return(retorno);
        }