Esempio n. 1
0
        public JsonResult GeneraDiagramaBD(int appid, string nomapp)
        {
            int        maxe = 100;
            Aplicacion appobj = new Aplicacion();
            string     diagramahtml = string.Empty;
            int        xini = 0, xfin = 0, yini = 0, yfin = 0, xinc = 0, yinc = 0;
            string     dim = string.Empty;

            DiagramaDimension(maxe, ref xini, ref xfin, ref yini, ref yfin, ref xinc, ref yinc, ref dim);
            ldbd.Clear();
            int existe = 0;

            int ide_padre = 49;

            if (dim.Equals("2"))
            {
                ide_padre = 21;
            }
            if (appobj.ObtenRelTablas(int.Parse(Session["usuid"].ToString()), appid))
            {
                int contador = 0;
                for (int x = xini; x < xfin; x += xinc)
                {
                    for (int y = yini; y < yfin; y += yinc)
                    {
                        de.Add(new Utilerias.diagramElem(contador, x, y, string.Empty, 0, 0, 0, ""));
                        contador++;
                    }
                }
                XmlNode select = appobj.AplicaionXML.DocumentElement.SelectSingleNode("ObjetosDB");

                de[ide_padre].name = nomapp; de[ide_padre].ocp = 1; de[ide_padre].idepadre = -1; de[ide_padre].ispadre = 1;
                ldbd.Add(new Utilerias.LineDiagramaDB(-1, ide_padre, "", "", ""));
                ide_padre++;
                de[ide_padre].name = "DiagramaBD"; de[ide_padre].ocp = 1; de[ide_padre].idepadre = (ide_padre - 1); de[ide_padre].ispadre = 1;
                ldbd.Add(new Utilerias.LineDiagramaDB((ide_padre - 1), ide_padre, "", "", ""));
                int ide_hijo = 0;
                foreach (XmlNode padre in select.SelectNodes("padre"))
                {
                    ide_hijo          = EncuentraHijoAmigo(ide_padre, de, xini);
                    de[ide_hijo].name = padre.Attributes["TblPadre"].Value.ToString(); de[ide_hijo].ocp = 1; de[ide_hijo].idepadre = ide_padre;
                    ldbd.Add(new Utilerias.LineDiagramaDB(ide_hijo, ide_padre, padre.Attributes["PK_Nombre"].Value.ToString(), padre.Attributes["ColumnaPadre"].Value.ToString(), ""));
                    foreach (XmlNode hijo in padre.SelectNodes("hijo"))
                    {
                        existe = existeTabla(de, hijo.Attributes["TblHijo"].Value.ToString());
                        if (existe == 0)
                        {
                            existe          = EncuentraHijoAmigo(ide_hijo, de, xini);
                            de[existe].name = hijo.Attributes["TblHijo"].Value.ToString(); de[existe].ocp = 1; de[existe].idepadre = ide_hijo;
                        }
                        ldbd.Add(new Utilerias.LineDiagramaDB(ide_hijo, existe, hijo.Attributes["FK_Nombre"].Value.ToString(), hijo.Attributes["ColumnaHijo"].Value.ToString(), padre.Attributes["ColumnaPadre"].Value.ToString()));
                    }
                }
                diagramahtml = ArmandoDIagramaBD(de, ldbd);
            }
            TempData["nomapp"]     = nomapp;
            TempData["appid"]      = appid;
            TempData["ControlDiv"] = de;
            TempData["DiagBD"]     = 1;
            TempData["xmlActual"]  = appobj.AplicaionXML;
            TempData["LineasDB"]   = ldbd;

            return(Json(diagramahtml, JsonRequestBehavior.AllowGet));
        }