Example #1
0
        /*
         * METODOQ QUE GENERA UN IDENTIFICADOR CON LAS COLUMNAS DE LA CONSULTA
         * @param {tabla} tabla que se obtiene del select
         */
        private void generarIdentificador(TablaSelect tabla)
        {
            string identi = "";

            foreach (Columna c in tabla.columnas)
            {
                if (c.tipo.Contains("map"))
                {
                    identi += "_map";
                }
                else if (c.tipo.Contains("list"))
                {
                    identi += "_list";
                }
                else if (c.tipo.Contains("set"))
                {
                    identi += "_set";
                }
                else if (c.tipo.Equals("counter"))
                {
                    identi += "_int";
                }
                else
                {
                    identi += "_" + c.tipo;
                }
            }
            identificador = identi;
        }
        public string consulta(TablaSelect tabla)
        {
            string resultado = "[+DATA]\n";

            resultado += "\n\t<table class=\"table\">\n";
            resultado += "\n\t<thead class=\"thead-dark\">\n";
            resultado += "\t<tr>\n";
            foreach (Columna columa in tabla.columnas)
            {
                resultado += "\t\t<th scope = \"col\">" + columa.name + "</th>\n";
            }
            resultado += "\t</tr>\n";
            resultado += "\t</thead>\n";
            resultado += "\t<tbody>\n";
            foreach (Data data in tabla.datos)
            {
                resultado += "\t<tr>\n";
                foreach (Atributo atributo in data.valores)
                {
                    if (atributo.valor != null)
                    {
                        if (atributo.valor.GetType() == typeof(Map))
                        {
                            string temp = "[";
                            foreach (KeyValue key in ((Map)atributo.valor).datos)
                            {
                                if (key.value != null)
                                {
                                    if (key.value.GetType() == typeof(InstanciaUserType))
                                    {
                                        InstanciaUserType tempInstancia = (InstanciaUserType)key.value;
                                        temp += key.key + ": [" + getStringUser(tempInstancia.lista) + "] ,";
                                    }
                                    else
                                    {
                                        temp += key.key + ":" + key.value + ",";
                                    }
                                }
                                else
                                {
                                    temp += key.key + ":" + key.value + ",";
                                }
                            }
                            temp       = temp.TrimStart(',');
                            temp      += "]";
                            resultado += "\t\t<td>" + temp + "</td>\n";
                        }
                        else if (atributo.valor.GetType() == typeof(Set))
                        {
                            string temp = "[";
                            foreach (object p in ((Set)atributo.valor).datos)
                            {
                                if (p != null)
                                {
                                    if (p.GetType() == typeof(InstanciaUserType))
                                    {
                                        InstanciaUserType tempInstancia = (InstanciaUserType)p;
                                        temp += " [" + getStringUser(tempInstancia.lista) + "] ,";
                                    }
                                    else
                                    {
                                        temp += p + ",";
                                    }
                                }
                                else
                                {
                                    temp += p + ",";
                                }
                            }
                            temp       = temp.TrimStart(',');
                            temp      += "]";
                            resultado += "\t\t<td>" + temp + "</td>\n";
                        }
                        else if (atributo.valor.GetType() == typeof(List))
                        {
                            string temp = "[";
                            foreach (object p in ((List)atributo.valor).lista)
                            {
                                if (p != null)
                                {
                                    if (p.GetType() == typeof(InstanciaUserType))
                                    {
                                        InstanciaUserType tempInstancia = (InstanciaUserType)p;
                                        temp += " [" + getStringUser(tempInstancia.lista) + "] ,";
                                    }
                                    else
                                    {
                                        temp += p + ",";
                                    }
                                }
                                else
                                {
                                    temp += p + ",";
                                }
                            }
                            temp       = temp.TrimStart(',');
                            temp      += "]";
                            resultado += "\t\t<td>" + temp + "</td>\n";
                        }
                        else if (atributo.valor.GetType() == typeof(InstanciaUserType))
                        {
                            string temp = "[";
                            foreach (Atributo a in ((InstanciaUserType)atributo.valor).lista)
                            {
                                temp += a.nombre + ":" + a.valor + ",";
                            }
                            temp       = temp.TrimStart(',');
                            temp      += "]";
                            resultado += "\t\t<td>" + temp + "</td>\n";
                        }
                        else
                        {
                            resultado += "\t\t<td>" + atributo.valor.ToString() + "</td>";
                        }
                    }
                }
                resultado += "\t</tr>\n";
            }
            resultado += "\t</tbody>\n";
            resultado += "\t</table>\n";
            resultado += "[-DATA]";
            return(resultado);
        }
 /*
  * CONSTRUCTOR DE LA CLASE
  * @param {tabla} lo que devuelve la consulta
  * @param {consulta} es la instruccion que se ejecutara con cada OPEN O CLOSE
  */
 public TypeCursor(TablaSelect tabla, Select consulta)
 {
     this.tabla    = tabla;
     this.consulta = consulta;
 }