Пример #1
0
        //private int BuscarFinalPatron(FuenteInformacionDetalleEtiqueta patron, string texto)
        //{
        //    string strPatron = patron.Etiqueta.Descripcion.Replace('_', ' ');
        //    int inicio = texto.IndexOf(strPatron);
        //    int fin = texto.IndexOf(patron.Finaliza.Replace('_', ' '), (inicio + strPatron.Length)) - (inicio + strPatron.Length);
        //    return fin;
        //}

        private int BuscarFinalPatron(FuenteInformacionDetalleEtiqueta patron, string texto)
        {
            string strPatron = patron.Etiqueta.Descripcion.Replace('_', ' ');
            int    inicio    = texto.IndexOf(strPatron);

            int c   = texto.IndexOf(patron.Finaliza.Replace('_', ' '), (inicio + (patron.Etiqueta.ConcatenaEtiqueta ? 0 : strPatron.Length)), System.StringComparison.Ordinal);
            int z   = (inicio + (patron.Etiqueta.ConcatenaEtiqueta ? 0 : strPatron.Length));
            int fin = c - z;

            return(fin);
        }
Пример #2
0
        //private string BuscarValor(FuenteInformacionDetalleEtiqueta patron, string texto)
        //{
        //    string valor = string.Empty; ;
        //    string strPatron = patron.Etiqueta.Descripcion.Replace('_', ' ');

        //    if (texto.Contains(strPatron))
        //    {
        //        int inicio = texto.IndexOf(strPatron);

        //        if (patron.LongitudFija > 0)
        //        {
        //            valor = texto.Substring((inicio + strPatron.Length), patron.LongitudFija);
        //        }
        //        else
        //        {
        //            valor = texto.Substring((inicio + strPatron.Length), BuscarFinalPatron(patron, texto));
        //        }
        //    }
        //    return valor;
        //}

        //private string BuscarValor(FuenteInformacionDetalleEtiqueta patron, string texto)
        //{

        //    string valor = string.Empty; ;
        //    string strPatron = patron.Etiqueta.Descripcion.Replace('_', ' ');

        //    if (texto.Contains(strPatron))
        //    {

        //        int inicio = texto.IndexOf(strPatron);
        //        if (patron.LongitudFija > 0)
        //        {
        //            valor = texto.Substring((inicio + strPatron.Length), patron.LongitudFija);
        //        }
        //        else
        //        {
        //            int final = BuscarFinalPatron(patron, texto);
        //            if (final > 0)
        //            {

        //                valor = texto.Substring(inicio + strPatron.Length, final);

        //            }

        //        }

        //    }

        //    return valor;

        //}
        private string BuscarValor(FuenteInformacionDetalleEtiqueta patron, string texto)
        {
            string valor = string.Empty;

            string strPatron = patron.Etiqueta.Descripcion.Replace('_', ' ');
            int    i         = texto.IndexOf(strPatron);

            if (i != 0)
            {
                strPatron = " " + strPatron;
            }
            //if (texto.Contains(" " + strPatron))
            if (texto.Contains(strPatron))
            {
                int inicio = texto.IndexOf(strPatron);

                if (patron.LongitudFija > 0)
                {
                    int LongitudValor = (texto.Length - (inicio + (patron.Etiqueta.ConcatenaEtiqueta ? 0 : strPatron.Length)));
                    if (LongitudValor >= patron.LongitudFija)
                    {
                        valor = patron.Etiqueta.ConcatenaEtiqueta
                            ? texto.Substring((inicio), patron.LongitudFija)
                            : texto.Substring((inicio + strPatron.Length), patron.LongitudFija);
                    }
                }
                else
                {
                    int final = BuscarFinalPatron(patron, texto);
                    if (final > 0)
                    {
                        valor = patron.Etiqueta.ConcatenaEtiqueta
                            ? texto.Substring(inicio, final)
                            : texto.Substring(inicio + strPatron.Length, final);
                    }
                }
            }

            return(valor.Trim());
        }