Exemple #1
0
        public override string ToString()
        {
            if (Titulo == null || Titulo == "")
            {
                int    cortar           = 0;
                int    maxCar           = 30;
                string contenidoCortado = "";
                if (Contenido.Length > maxCar)
                {
                    cortar           = Contenido.Length - maxCar;
                    contenidoCortado = Contenido.Remove(maxCar, cortar);
                    return($"{contenidoCortado + "..."} \n {FechaNota}");
                }

                else
                {
                    return($"{Contenido} \n {FechaNota}");
                }
            }
            else

            {
                return($"{Titulo}  \t\t\t\t\t\t   {FechaNota}");
            }
        }
        //--------------------------LECTURA VERIFICACIÓN GENERAL DEL ARCHIVO----------------------------------------

        /// <summary>
        /// Método general de verificación del archivo
        /// </summary>
        /// <param name="rutaArchivo"></param>
        /// <param name="advertencia">Cadena que contiene el mensaje que se le mostrará al usuario final del estado del archivo</param>
        public bool Verificar(string rutaArchivo, ref string advertencia)
        {
            using (var file = new FileStream(rutaArchivo, FileMode.Open))
            {
                using (var reader = new StreamReader(file, Encoding.UTF8))
                {
                    Contenido = reader.ReadToEnd();

                    if (Contenido == string.Empty)
                    {
                        advertencia = Advertencia.AdvertenciasGenerales[1];
                        return(false);
                    }
                }
            }

            if (Contenido.ToUpper().Contains("SETS"))
            {
                if (Contenido.ToUpper().Contains("TOKENS"))
                {
                    if (Contenido.ToUpper().Contains("ACTIONS"))
                    {
                        if (Contenido.ToUpper().Contains("ERROR"))
                        {
                            if (AnalizarSets(Contenido.Substring(Contenido.ToUpper().IndexOf("SETS"), (Contenido.ToUpper().IndexOf("TOKENS") - Contenido.ToUpper().IndexOf("SETS"))), ref advertencia))
                            {
                                //Aquí se le quita la parte de SETS a todo el texto
                                Contenido = Contenido.Remove(Contenido.ToUpper().IndexOf("SETS"), (Contenido.ToUpper().IndexOf("TOKENS") - Contenido.ToUpper().IndexOf("SETS")));

                                //Aquí empieza el análisis de los TOKENS
                                if (AnalizarTokens(Contenido.Substring(Contenido.ToUpper().IndexOf("TOKENS"), (Contenido.ToUpper().IndexOf("ACTIONS") - Contenido.ToUpper().IndexOf("TOKENS"))), ref advertencia))
                                {
                                    //Se quita la parte de TOKENS y se procede a analizar los ACTIONS
                                    Contenido = Contenido.Remove(Contenido.ToUpper().IndexOf("TOKENS"), (Contenido.ToUpper().IndexOf("ACTIONS") - Contenido.ToUpper().IndexOf("TOKENS")));

                                    if (AnalizarActions(Contenido.Substring(Contenido.ToUpper().IndexOf("ACTIONS"), (Contenido.ToUpper().IndexOf("ERROR") - Contenido.ToUpper().IndexOf("ACTIONS"))), ref advertencia))
                                    {
                                        Contenido = Contenido.Remove(Contenido.ToUpper().IndexOf("ACTIONS"), (Contenido.ToUpper().IndexOf("ERROR") - Contenido.ToUpper().IndexOf("ACTIONS")));

                                        if (AnalizadorApartadoError(Contenido))
                                        {
                                            advertencia = Advertencia.AdvertenciasGenerales[0];
                                            return(true);
                                        }
                                    }
                                    else
                                    {
                                        return(false);
                                    }
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            advertencia = Advertencia.AdvertenciasGenerales[2] + "la sección \"ERROR\"";
                            return(false);
                        }
                    }
                    else
                    {
                        advertencia = Advertencia.AdvertenciasGenerales[2] + "ACTIONS";
                        return(false);
                    }
                }
                else
                {
                    advertencia = Advertencia.AdvertenciasGenerales[2] + "TOKENS";
                    return(false);
                }
            }
            else
            {
                advertencia = Advertencia.AdvertenciasGenerales[2] + "SETS";
                return(false);
            }

            advertencia = Advertencia.AdvertenciasGenerales[0];
            return(true);
        }