/**Inserta un atribuoto, el entidad especificada*/
        public void insAtributo(CNodoAtributo nuevo, CNodoEntidad ent)
        {
            CNodoAtributo aux, ant = null;

            aux = ent.getCabListAtri();

            while (aux != null)
            {
                ant = aux;
                aux = aux.getSigAtri();
            }

            if (aux == ent.getCabListAtri())
                ent.setCabListAtri(nuevo);
            else
                ant.setSigAtri(nuevo);

            nuevo.setSigAtri(aux);
       }
Beispiel #2
0
        /**Inicializa los controles necesaria para iniciar la interfaz de la organización*/
        public void iniControles()
        {
            CNodoEntidad ent = archivo.getListaEntidad().getCabListEnt();
        
            while (ent != null)
            {
                listaEnt.Items.Add(ent.getNombre());
                ent = ent.getSigEnt();
            }

            tablaDatos = new DataGridView();
            tablaDatos.BackgroundColor = Color.White;
            tablaDatos.AllowUserToAddRows = false;
            Size tamaño = new Size(475, 331);
            tablaDatos.Location = new Point(299, 29);
            tablaDatos.Size = tamaño;
            tablaDatos.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            Controls.Add(getTablaDatos()); 
        }
        /** Inserta una objeto entidad en la lista de etnidades*/
        public void insEntidad(CNodoEntidad nueva)
        { 
            CNodoEntidad aux, ant = null;

            aux = getCabListEnt();

            while (aux != null)
            {
                ant = aux;
                aux = aux.getSigEnt();
            }

            if (aux == cabListEnt)
                cabListEnt = nueva;
            else
                ant.setSigEnt(nueva);

            nueva.setSigEnt(aux);

        }
        private void dameBloquesDatos(ref List<CBloque> lB, CNodoEntidad nE, CBloque bS, CNodoEntidad e)
        {
            CBloque bloqueAux;
            CTablaHashExt tH;
            List<CCubeta> listaCub;
            CCubeta cubetaAux;
            long ptrAux, ptrAux2;
            int despCE, tipoD, tamCE, tamBloq, despCB, tipoCB, tamCB; ;

            despCE = tipoD = tamCE = tamBloq = despCB = tipoCB = tamCB = 0;

            lB = new List<CBloque>();
            listaCub = new List<CCubeta>();

            ptrAux = nE.getApCabDatos();

            if (ptrAux != -1)
            {
                DameCE(nE, ref despCE, ref tipoD, ref tamCE, ref tamBloq, ref despCB, ref tipoCB, ref tamCB, e);
                tH = getArchivo().LeerTablaHashExt(ptrAux);

                foreach (CEntrada entrada in tH.getListEntradas())
                {
                    cubetaAux = entrada.getCubeta();
                    if (listaCub.Contains(cubetaAux)==false)
                    {
                        listaCub.Add(cubetaAux);

                        for (int j = 0; j < cubetaAux.getTamaño(); j++)
                            if (cubetaAux.getAtDirBloque(j) != -1)
                            {
                                bloqueAux = getArchivo().leerBloque(cubetaAux.getAtDirBloque(j), tamBloq);
                                bloqueAux.setDespCE(despCE);
                                bloqueAux.setTipoCE(tipoD);
                                bloqueAux.setTamCE(tamCE);
                                bloqueAux.setDesp(despCB);
                                bloqueAux.setTamAtri(tamCB);
                                bloqueAux.setTipoCA(tipoCB);
                                bloqueAux.setTamBlo(tamBloq);

                                if (bloqueAux.CompareClaveExt(bS) == 0)
                                    lB.Add(bloqueAux);
                            }
                    }
                }
            }
        }
        /**´Méetodo principal para llevar a cabo la inserción de algun bloque*/
        public bool Alta_HashDinamica(CNodoEntidad e, CBloque b)
        {
            /**
             * \param e Entidad a la que pertrnece el bloque
             * \param b Bloque Nuevo bloque a insertar
             * \return Retorna Falso(Si tuvo exito), True(Si ya existe el bloque alguna cubeta)
             * */
            CCubeta cubetaAux;
            CEntrada entradaAux;
            bool res = false;

            if (e.getApCabDatos() == -1)
            {
                tHashExt = new CTablaHashExt(); 
                cubetaAux = new CCubeta(-1, TAM_CUBETA); 
                entradaAux = new CEntrada(cubetaAux, -1);
                
                tHashExt.insEntrada(entradaAux);

                cubetaAux.setDir(getArchivo().ENDF());
                getArchivo().EscribeCubeta(cubetaAux);

                entradaAux.setDirCubeta(cubetaAux.getDir());
                entradaAux.setDir(getArchivo().ENDF());
                getArchivo().EscribeEntrada(entradaAux);

                tHashExt.setCabEntradas(entradaAux.getDir());
                tHashExt.setDir(getArchivo().ENDF());
                getArchivo().EscribeTablaHashExt(tHashExt);

                e.setApCabDatos(tHashExt.getDir());
                getArchivo().escribeEntidad(e, e.getDir());
            }
            else
                tHashExt = getArchivo().LeerTablaHashExt(e.getApCabDatos());

            b.setDir(getArchivo().ENDF());
         
            if ((res = InsBloque(b)) == false)
            {
                tHashExt.incNumReg();
                getArchivo().EscribeTablaHashExt(tHashExt);
            }

            return (res);
        }
Beispiel #6
0
        /**Actualiza una entidad*/
        public void ModificaEntidad(string nameEnt, CNodoEntidad nueva)
        {
            CNodoEntidad aux, nodoVerAux = null;
            CNodoAtributo auxAtri;

            buscaEntidad(ref nodoVerAux, nameEnt);

            nueva.setCabListAtri(nodoVerAux.getCabListAtri());
            nueva.setApCabListAtri(nodoVerAux.getApCabListAtri());

            AbrirArchivo();
            nueva.setDir(fs.Length);

            aux = listaEntidades.getCabListEnt();

            while (aux != null)
            {
                if (aux != nodoVerAux)
                {
                    auxAtri = aux.getCabListAtri();
                    while (auxAtri != null)
                    {
                        if (auxAtri.getEntRel() == nodoVerAux)
                        {
                            auxAtri.setEntRel(nueva);
                            auxAtri.setApEntRel(nueva.getDir());
                            escribeAtributo(auxAtri, auxAtri.getDir());
                        }

                        auxAtri = auxAtri.getSigAtri();
                    }
                }

                aux = aux.getSigEnt();
            }
            CerrarArchivo();
            BajaEntidad(nameEnt);
            AltaEntidad(nueva);
        }
Beispiel #7
0
 /** Se ecribe una nueva entidad en el diccionario*/
 public void escribeEntidad(CNodoEntidad nueva, long pos)
 {
     bw.BaseStream.Seek(pos, SeekOrigin.Begin);
     bw.Write(nueva.getApSigEnt());
     bw.Write(nueva.getNombre());
     bw.Write(nueva.getApCabListAtri());
     bw.Write(nueva.getDir());
     bw.Write(nueva.getApCabDatos());
 }
        private void dameBloquesDatos(ref List<CBloque> lB, CNodoEntidad nE, CBloque bS, CNodoEntidad e)
        {
            CBloque bloqueAux;
            CHash tablaAux;
            Cubeta cubetaAux;
            long ptrAux, ptrAux2;
            int despCE, tipoD, tamCE, tamBloq, despCB, tipoCB, tamCB; ;
            
            despCE = tipoD = tamCE = tamBloq = despCB = tipoCB = tamCB = 0;

            lB = new List<CBloque>();
            ptrAux = nE.getApCabDatos();

            if (ptrAux != -1)
            {
                DameCE(nE, ref despCE, ref tipoD, ref tamCE, ref tamBloq, ref despCB, ref tipoCB, ref tamCB, e);
                tablaAux = getArchivo().LeerTablaHash(ptrAux);

                for(int i = 0; i < tablaAux.getTamaño(); i++)
                    if( (ptrAux2 = tablaAux.getAtDirCubeta(i)) != -1)
                        while(ptrAux2 != -1 )
                        {
                            cubetaAux = getArchivo().LeerCubetaHashEstatica(ptrAux2);
                            for(int j = 0; j < cubetaAux.getTamaño(); j++)
                                   if(cubetaAux.getAtDirBloque(j) != -1 )
                                   {
                                       bloqueAux = getArchivo().leerBloque(cubetaAux.getAtDirBloque(j),tamBloq);
                                       bloqueAux.setDespCE(despCE);
                                       bloqueAux.setTipoCE(tipoD);
                                       bloqueAux.setTamCE(tamCE);
                                       bloqueAux.setDesp(despCB);
                                       bloqueAux.setTamAtri(tamCB);
                                       bloqueAux.setTipoCA(tipoCB);
                                       bloqueAux.setTamBlo(tamBloq);
                                      
                                       if (bloqueAux.CompareClaveExt(bS) == 0)
                                           lB.Add(bloqueAux);
                                   }
                                
                             ptrAux2 = cubetaAux.getSigCubeta();
                        }
            }
        }
        /**Método principal para llevar a cabo el alta de algun bloque*/
        public int Alta_HashEstatica(CNodoEntidad e, CBloque b)
        {
            int fH, fC;
            int res;
            CHash tHash;

            fH = fC = 0;

            if (e.getApCabDatos() == -1)
            {
                tHash = new CHash(getArchivo().ENDF(), TAM_HASH);
                getArchivo().EscribeTablaHash(tHash);
                e.setApCabDatos(tHash.getDir());
                getArchivo().escribeEntidad(e, e.getDir());
            }else
                tHash = getArchivo().LeerTablaHash(e.getApCabDatos());//Se lee la tabla Hash 

            FuncionHash(b, ref fH, ref fC);
            cubetaSel = fH;
            res = InsDirBloque(tHash, fH, b, fC);

            return (res);
        }
        /* Inserta un indice primario en la lista de indices*/
        private void insIndicePri(CNodoEntidad e, ref CIndice nuevo, long posInd)
        {
            CIndice indAux, indAnt = null;
            long ptrAux, ptrAnt = -1;

            ptrAux = e.getApCabDatos();
            
            while (ptrAux != -1)
            {
                indAux = getArchivo().LeerIndicePrimario(ptrAux);

                if (indAux.comparateTo(nuevo) < 0)
                {
                    ptrAnt = ptrAux;
                    indAnt = indAux;
                    ptrAux = indAux.getSigInd();
                }
                else
                    break;
            }

            if (ptrAux == e.getApCabDatos())
            {
                e.setApCabDatos(posInd);
                getArchivo().escribeEntidad(e, e.getDir());
            }
            else
            {
                indAnt.setSigInd(posInd);
                getArchivo().EscribeIndicePrimario(indAnt);
            }

            nuevo.setDirInd(posInd);
            nuevo.setSigInd(ptrAux);
            getArchivo().EscribeIndicePrimario(nuevo);
        }
        /**\brief Inserta un bloque de datos a la organización*/
        public int AltaOSI(CNodoEntidad e, CBloque nuevo, long posB)
        {
            CIndice indPri, indAux = null;
            int res;
            long ptrAux, posInd;

            
            indPri = generaIndPri(nuevo);
            getArchivo().AbrirArchivo();
            
            ptrAux = e.getApCabDatos();
            
            while (ptrAux != -1)
            {
                indPrim = getArchivo().LeerIndicePrimario(ptrAux);
                if (indPrim.comparateTo(indPri) != 0)
                    ptrAux = indPrim.getSigInd();
                else
                    break;
            }

            if (ptrAux == -1)
            {
                posInd = getArchivo().getFS().Length;
                insIndicePri(e, ref indPri,posInd);
                posB = getArchivo().getFS().Length;
                indPrim = indPri;
                res = insBloque(indPri, nuevo, posB);
            }
            else
                res = insBloque(indPrim, nuevo, posB);
           
            getArchivo().CerrarArchivo();
            return (res);
        }
Beispiel #12
0
        /**Función de Mantenimiento para la Hash Dinamica*/
        private void MantenimientoHashDinamica(CArchivo fileOri, CArchivo fileNew, CNodoEntidad ent, CNodoEntidad entC, int tamBloque)
        {
            CTablaHashExt tH, nuevaTH;
            List<CCubeta> listCub;
            List<int> lE;
            CCubeta nuevaCub;
            long cabDatos;

            cabDatos = ent.getApCabDatos();

            if (cabDatos != -1)
            {
                tH = fileOri.LeerTablaHashExt(cabDatos);
                nuevaTH = creaTabla(tH);

                listCub = dameCubetas(tH);
                foreach (CCubeta c in listCub)
                {
                    lE = buscaEntradas(tH, c);
                    nuevaCub = creaCubeta(c, fileNew, fileOri);

                    foreach (int i in lE)
                        nuevaTH.getAtEntrada(i).setCubeta(nuevaCub);
                }

                foreach (CEntrada e in nuevaTH.getListEntradas())
                {
                    e.setDir(fileNew.ENDF());
                    fileNew.EscribeEntrada(e);
                }

                for (int i = 0; i < nuevaTH.getListEntradas().Count - 1; i++)
                {
                    nuevaTH.getAtEntrada(i).setSigEntrada(nuevaTH.getAtEntrada(i + 1).getDir());
                    fileNew.EscribeEntrada(nuevaTH.getAtEntrada(i));
                }

                nuevaTH.setCabEntradas(nuevaTH.getAtEntrada(0).getDir());
                nuevaTH.setDir(fileNew.ENDF());
                fileNew.EscribeTablaHashExt(nuevaTH);
                entC.setApCabDatos(nuevaTH.getDir());
                fileNew.escribeEntidad(entC,entC.getDir());
            }
        }
Beispiel #13
0
        /**Función de Mantenimiento para la Hash Estatica*/
        private void MantenimientoHashEstatica(CArchivo fileOri, CArchivo fileNew, CNodoEntidad ent, CNodoEntidad entC, int tamBloque)
        {
            CHash tablaHash, nuevaTablaHash;
            long cabTabla;

            cabTabla = ent.getApCabDatos();

            if (cabTabla != -1)
            {
                tablaHash = fileOri.LeerTablaHash(cabTabla);
                nuevaTablaHash = new CHash(fileNew.ENDF(), tablaHash.getTamaño());
                nuevaTablaHash.setNumCubetas(tablaHash.getNumCubetas());

                fileNew.EscribeTablaHash(nuevaTablaHash);

                for (int i = 0; i < tablaHash.getTamaño(); i++)
                    nuevaTablaHash.setAtDirCubeta(i, CopiarListaCubetasRec(tablaHash.getAtDirCubeta(i), fileOri, fileNew, tamBloque));

                fileNew.EscribeTablaHash(nuevaTablaHash);

                entC.setApCabDatos(nuevaTablaHash.getDir());
                fileNew.escribeEntidad(entC, entC.getDir());
            }
        }
Beispiel #14
0
 /**Función de Mantenimiento para Arboles B+*/
 public void MantenimientoArbolBplus(CArchivo fileOri, CArchivo fileNew, CNodoEntidad ent, CNodoEntidad entC, int tamBloque)
 {
     if (ent.getApCabDatos() != -1)
     {
         entC.setApCabDatos(generaArbolRec(fileOri, fileNew, tamBloque, ent.getApCabDatos()));
         fileNew.escribeEntidad(entC, entC.getDir());
     }
 }
Beispiel #15
0
        /**Función de Mantenimiento para la Organizacion Secuencial indexada*/
        public void MantenimientoSecInd(CArchivo fileOri, CArchivo fileNew, CNodoEntidad ent, CNodoEntidad entC, int tamBloque)
        {
            List<CBloque> listBloque;
            List<CIndice> listaInd;
            CIndice indPri,nuevoInd;
            long aux;
            
            listaInd = new List<CIndice>();
            
            aux = ent.getApCabDatos();
            
            while (aux != -1)
            {
                indPri = fileOri.LeerIndicePrimario(aux);
                nuevoInd = new CIndice();

                nuevoInd.setIndPrim(indPri.getIndPrim());
                nuevoInd.setTamIndPri(indPri.getTamIndPri());
                nuevoInd.setTipoInd(indPri.getTipoInd());

                listBloque = new List<CBloque>();
                
                CopiarSec(fileOri, fileNew, indPri.getCabBloques(), tamBloque, ref listBloque);
                
                nuevoInd.setDirInd(fileNew.ENDF());
                nuevoInd.setCabBloques(listBloque[0].getDir());
                fileNew.EscribeIndicePrimario(nuevoInd);
                
                listaInd.Add(nuevoInd);
                
                aux = indPri.getSigInd();
            }

            for (int i = 0; i < listaInd.Count - 1; i++)
            {
                listaInd[i].setSigInd(listaInd[i + 1].getDirInd());
                fileNew.EscribeIndicePrimario((listaInd[i]));
            }
            
            entC.setApCabDatos(listaInd[0].getDirInd());
            fileNew.escribeEntidad(entC, ent.getDir());
        }
Beispiel #16
0
        private void dameBloques(ref List<CBloque> lB, CNodoEntidad nE, CBloque bS, CNodoEntidad e)
        {
            int despCE, tipoD, tamCE, tamBloq, despCB, tipoCB, tamCB;
            despCE = tipoD = tamCE = tamBloq = despCB = tipoCB = tamCB = 0;

            if (nE.getApCabDatos() != -1)
            {
                DameCE(nE, ref despCE, ref tipoD, ref tamCE, ref tamBloq, ref despCB, ref tipoCB, ref tamCB, e);
              
                creaListaBloques(nE.getApCabDatos(), ref lB, despCE, tipoD, tamCE, tamBloq, despCB, tipoCB, tamCB, bS);
            }
        }
Beispiel #17
0
        /**Médoto principal para eliminar un  registro*/
        public void eliminaABplus(CNodoEntidad e, CBloque b)
        {
            long dirCabNueva = -1;

            if (eliminaClaveRec(e.getApCabDatos(), b.dameClavePrim(), ref dirCabNueva))
            {
                e.setApCabDatos(dirCabNueva);
                getArchivo().escribeEntidad(e, e.getDir());
            }
        }
        /**Busca si no existe un bloque en el archivo comparandolo con el nuevo*/
        public bool buscaBloqueRep(CNodoEntidad e, CBloque bO, CBloque bN)
        {
            CBloque bAux;
            CIndice indAux;
            long ptrAux, ptrAux2;
            bool band = false;
            
            getArchivo().AbrirArchivo();

            ptrAux = e.getApCabDatos();
            while (ptrAux != -1 && band != true)
            {
                indAux = getArchivo().LeerIndicePrimario(ptrAux);
                ptrAux2 = indAux.getCabBloques();
                while (ptrAux2 != -1)
                {
                    bAux = getArchivo().leerBloque(ptrAux2, tamBloque);

                    if (indPrim.comparateTo(indAux) == 0)
                    {
                        if (bO.ComparateTo(bAux) != 0 && bN.ComparateTo(bAux) == 0)
                        {
                            band = true;
                            break;
                        }
                    }else
                        if (bN.ComparateTo(bAux) == 0)
                        {
                            band = true;
                            break;
                        }


                    ptrAux2 = bAux.getSigBlo();
                }

                ptrAux = indAux.getSigInd();
           }

            getArchivo().CerrarArchivo();

            return (band);
        }
        /**Método principal para la eliminación de un registro*/
        public  void EliminaHashEstatica(CNodoEntidad e, CBloque b)
        {
            CHash tablaHash;

            tablaHash = getArchivo().LeerTablaHash(e.getApCabDatos());
            EliminaBloque(tablaHash, b);

            if (tablaHash.getNumCubetas() == 0)
            {
                e.setApCabDatos(-1);
                getArchivo().escribeEntidad(e, e.getDir());
            }
        }
        /** Se elimina un indice primiraio*/
        public void eliminaIndicePrimario(CNodoEntidad e, CIndice ind)
        {
            CIndice bloAux, bloAnt;
            long ptrAux, ptrAnt;

            bloAux = bloAnt = null;
            ptrAux = ptrAnt = -1;

            ptrAux = e.getApCabDatos();

            while (ptrAux != -1)
            {
                bloAux = getArchivo().LeerIndicePrimario(ptrAux);

                if (ind.comparateTo(bloAux) != 0 )
                {
                    ptrAnt = ptrAux;
                    bloAnt = bloAux;
                    ptrAux = bloAux.getSigInd();
                }
                else
                    break;
            }

            if (ptrAux == e.getApCabDatos())
            {
                e.setApCabDatos(bloAux.getSigInd());
                getArchivo().escribeEntidad(e, e.getDir());
            }
            else
            {
                bloAnt.setSigInd(bloAux.getSigInd());
                getArchivo().EscribeIndicePrimario(bloAnt);
            }
        }
Beispiel #21
0
        /**\brief Se inserta una entidad en el Diccionario de datos*/
        public void AltaEntidad(CNodoEntidad nueva)
        {
            /**
             * \details
             * \param nueva Recibe un objeto de tipo entidad, que sera agregada a la lista de entidades
             *  y posteriormente escrita en el diccionario
             **/ 
            CNodoEntidad aux, ant = null;
            long ptrAnt, ptrAux, posCab;
            bool band = false;
            ptrAux = ptrAnt = -1;

            AbrirArchivo();//Se abren el archivo que contiene el diccionario de datos

            aux = listaEntidades.getCabListEnt();
            ptrAux = leerCabecera();

            while (aux != null)
                if ((aux.getNombre()).CompareTo(nueva.getNombre()) < 0)
                {
                    ant = aux;
                    ptrAnt = ptrAux;
                    ptrAux = aux.getApSigEnt();
                    aux = aux.getSigEnt();
                }
                else
                    if ((aux.getNombre()).CompareTo(nueva.getNombre()) == 0)
                    {
                        band = true;
                        break;
                    }
                    else
                        break;

            if (aux == listaEntidades.getCabListEnt())
            {
                if (band == false)
                {
                    posCab = leerCabecera();
                    nueva.setApSigEnt(posCab);
                    actCab(fs.Length);
                    listaEntidades.setCabListEnt(nueva);
                }
            }
            else
                if (band == false)
                {
                    nueva.setApSigEnt(ptrAux);
                    ant.setApSigEnt(fs.Length);
                    escribeEntidad(ant, ptrAnt);
                    ant.setSigEnt(nueva);
                }

            if (band == false)
            {
                nueva.setDir(fs.Length);
                escribeEntidad(nueva, fs.Length);
                nueva.setSigEnt(aux);
            }
            numEntidades++;
            CerrarArchivo();
        }
        /**Método principal para llevar a cabo la elimianción de un registro*/
        public void eliminaOSI(CNodoEntidad e, CBloque b)
        {
            CIndice index, index2 = null;
            long ptrAux;

            index = generaIndPri(b);
            ptrAux = e.getApCabDatos();

            while (ptrAux != -1)
            {
                index2 = getArchivo().LeerIndicePrimario(ptrAux);

                if (index2.comparateTo(index) < 0)
                    ptrAux = index2.getSigInd();
                else
                    break;
            }

            eliminaBloque(ref index2, b);

            if (index2.getCabBloques() == -1)
                eliminaIndicePrimario(e, index2);
        }
Beispiel #23
0
        /** Busca una entidad en el diccionario*/
        public void buscaEntidad(ref CNodoEntidad auxEnt, string nameEnt)
        {
            auxEnt = listaEntidades.getCabListEnt();

            while (auxEnt != null && auxEnt.getNombre().CompareTo(nameEnt) != 0)
                auxEnt = auxEnt.getSigEnt();
        }
        /**Elimina en forma recursiva los registros, siempre y cuando haya claves externas entre
         * las entidades*/
        public void BajaOSIRec(CNodoEntidad e, CBloque bS)
        {
            List<CNodoEntidad> lR = new List<CNodoEntidad>();
            List<CBloque> lB;

            lR = buscaRelacionesEnt(e);//Busqueda de las entidades que tengan alguna relación con la entidad actual*/
           
            if (lR.Count > 0)
            {
                foreach (CNodoEntidad nE in lR)
                {
                    lB = new List<CBloque>();
                    dameBloquesDatos(ref lB, nE, bS, e);

                    if(lB.Count > 0 )
                        foreach (CBloque nB in lB)
                        {
                            BajaOSIRec(nE, nB);
                            eliminaOSI(nE, nB);
                        }
                }
            }
        }
        private void btEditarEntidad_Click(object sender, EventArgs e)
        {
            CapturaEntidad dlgEnt = new CapturaEntidad();
        
            if (nameEntidad != null)
            {

               dlgEnt.nameEntidad.Text = nameEntidad;

                if (dlgEnt.ShowDialog() == DialogResult.OK)
                {
                    CNodoEntidad nuevo = new CNodoEntidad(dlgEnt.nameEntidad.Text);
                    archivo.ModificaEntidad(nameEntidad, nuevo);
                    imprimeEntidades();
                    imprimeAtributos();
                }
            }
            else
               MessageBox.Show("Seleccione el nombre de la entidad", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

        }
        private void dameBloquesDatos(ref List<CBloque> lB, CNodoEntidad nE, CBloque bS, CNodoEntidad e)
        {
            CBloque aux;
            CIndice indAux;
            long ptrAux, ptrAux2;
            int despCE, tipoD, tamCE, tamBloq, despCB, tipoCB, tamCB; ;
            despCE = tipoD = tamCE = tamBloq = despCB = tipoCB = tamCB = 0;

            lB = new List<CBloque>();
            ptrAux = nE.getApCabDatos();

            if (ptrAux != -1)
            {
                DameCE(nE, ref despCE, ref tipoD, ref tamCE, ref tamBloq, ref despCB, ref tipoCB, ref tamCB, e);

                while (ptrAux != -1)
                {
                    indAux = getArchivo().LeerIndicePrimario(ptrAux);
                    ptrAux2 = indAux.getCabBloques();
                    while (ptrAux2 != -1)
                    {
                        aux = getArchivo().leerBloque(ptrAux2, tamBloq);
                        aux.setDespCE(despCE);
                        aux.setTipoCE(tipoD);
                        aux.setTamCE(tamCE);
                        aux.setDesp(despCB);
                        aux.setTamAtri(tamCB);
                        aux.setTipoCA(tipoCB);
                        aux.setTamBlo(tamBloq);
                        aux.setDir(ptrAux2);

                        if (aux.CompareClaveExt(bS) == 0)
                            lB.Add(aux); 
                        
                        ptrAux2 = aux.getSigBlo();
                    }

                    ptrAux = indAux.getSigInd();
                }
            }
        }
        /**Elimina en forma recursiva todos los registros afectados por la eliminación de algun 
       * registro externo*/
        private void Baja_HashDinamicaRec(CNodoEntidad e, CBloque bS)
        { 
            List<CNodoEntidad> lR = new List<CNodoEntidad>();
            List<CBloque> lB;

            lR = buscaRelacionesEnt(e);

            if (lR.Count > 0)//Caso Base
            {
                foreach (CNodoEntidad nE in lR)
                {
                    lB = new List<CBloque>();
                    dameBloquesDatos(ref lB, nE, bS, e);//Se buscan los bloques que seran afectados
                
                    if (lB.Count > 0)
                        foreach (CBloque nB in lB)
                        {
                            Baja_HashDinamicaRec(nE, nB);
                            Elimina_BloqueHashDinamica(nE, nB);//Llamada recursiva
                        }
                }
            }
        }
Beispiel #28
0
        /**Metodo principal para la inserción de la clave junto con su bloque de datos*/
        public bool AltaArbolBplus(CNodoEntidad e, CBloque b, long posB)
        {
            CNodo nuevo = null;
            Object clave;
            bool res = true;
            long dirClave = -1;

            clave = b.dameClavePrim();

            if (e.getApCabDatos() == -1)//Si no hay algun arbol se crea la primera pagina
            {
                nuevo = new CNodo(RAIZHOJA, GRADO);
                nuevo.setDir(getArchivo().ENDF());
                nuevo.setTipoClave(b.getTipoCA());
                getArchivo().escribeNodo(nuevo);
                e.setApCabDatos(nuevo.getDir());
                getArchivo().escribeEntidad(e, e.getDir());
            }
            else
            {
                bool bandera = false;

                res = EmpujaDato(e.getApCabDatos(), ref clave, ref dirClave, b, posB, ref nuevo, ref bandera);

                if (bandera == true)//La raiz se partido
                {
                    CNodo nuevaRaiz;
                    nuevaRaiz = new CNodo(RAIZ, GRADO);

                    nuevaRaiz.setAtClave(0, clave);
                    nuevaRaiz.setAtDirClaves(0, dirClave);
                    nuevaRaiz.setAtDirNodo(0, ent.getApCabDatos());
                    nuevaRaiz.setAtDirNodo(1, nuevo.getDir());
                    nuevaRaiz.setDir(getArchivo().ENDF());
                    nuevaRaiz.setNumElemnt(1);
                    nuevaRaiz.setTipoClave(b.getTipoCA());
                    getArchivo().escribeNodo(nuevaRaiz);
                    e.setApCabDatos(nuevaRaiz.getDir());
                    getArchivo().escribeEntidad(e, e.getDir());
                }
            }

            return (res);
        }
        /**Método principal para llevar a cabo la eliminación de algun bloque*/
        public void Elimina_BloqueHashDinamica(CNodoEntidad e, CBloque b)
        {
            CTablaHashExt tH;
            /**
             * \param e Entidad a la que pertenece el nuevo bloque
             * \param b Objeto del nuevo bloque
             * */

            tH = getArchivo().LeerTablaHashExt(e.getApCabDatos());
            if (EliminaBloque(b, tH))
            {
                e.setApCabDatos(-1);
                getArchivo().escribeEntidad(e, e.getDir());
            }
        }
Beispiel #30
0
        /**Se Lleva a cabo la elimación de los registros en forma rucursiva, en el caso
         * de que algun registro se vea afectado por la eliminación de uno seleccionado en el dataGrid*/
        public void BajaABplusRec(CNodoEntidad e, CBloque bS)
        {
            List<CNodoEntidad> lR = new List<CNodoEntidad>();
            List<CBloque> lB;

            lR = buscaRelacionesEnt(e);

            if (lR.Count > 0)
            {
                foreach (CNodoEntidad nE in lR)
                {
                    lB = new List<CBloque>();

                    dameBloques(ref lB, nE, bS, e);
                    
                    if (lB.Count > 0)
                        foreach (CBloque nB in lB)
                        {
                            BajaABplusRec(nE, nB);
                            eliminaABplus(nE, nB);//Elimacion de un elemento de un arbol
                        }
                }
            }
        }