internal static bool IsValidDirectoryEntry(cSector Sector, int SubIndex, ushort SectorIndex, cFAT FAT)
        {
            if (SubIndex > Sector.Memory.Length)
                return false;
            for (int i = 0; i < 6; i++)
            {
                if (Sector.Memory[SubIndex] == 0x0000)      //Name
                    return false;
            }
            uint TempSize = (uint)(Sector.Memory[SubIndex + 0xC] + (Sector.Memory[SubIndex + 0xD] << 16));
            if ((TempSize == 0) && ((Sector.Memory[SubIndex + 0x5] & 0x0010) == 0))
                return false;
            if (FAT.NextSector(SectorIndex) == 0x0000)
                return false;

            return true;
        }
Esempio n. 2
0
 private void GetSectores()
 {
     try
     {
         cSector objSector = new cSector();
         ListItems = new ObservableCollection <SECTOR>(objSector.ObtenerTodos(Busqueda, SelectedMunicipio.ID_MUNICIPIO, SelectedCentro.ID_CENTRO, SelectedEdificio.ID_EDIFICIO));
         if (ListItems.Count > 0)
         {
             EmptyVisible = false;
         }
         else
         {
             EmptyVisible = true;
         }
     }
     catch (Exception ex)
     {
         StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al obtener datos.", ex);
     }
 }
 public static bool VerifyFHAT16BootSector(cSector Bootloader, ushort KernelSectorSize, ushort FloppyLength, bool IsBootable)
 {
     if (IsBootable && Bootloader.Memory[0] != 0xC382)      //is the Bootable Flag correct?
     {
         MessageBox.Show("Incorrect Bootflag");
         return false;
     }
     else if (!IsBootable && Bootloader.Memory[0] != 0x0000)
     {
         MessageBox.Show("Incorrect Bootflag");
         return false;
     }
     //now some checks for consistency to the HA FAT
     if (Bootloader.Memory[8] != KernelSectorSize)
     {
         if (MessageBox.Show("Wrong amount of reserved sectors detected.\r\nCorrect them?", "FAT Inconsistency", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             Bootloader.Memory[8] = KernelSectorSize;
         }
         else
         {
             return false;
         }
     }
     if (FloppyLength != Bootloader.Memory[0xb])
     {
         if (MessageBox.Show("Wron amount of sectors specified fot the loaded Device.\r\nCorrect them?", "Device size inconsitency", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             Bootloader.Memory[0xb] = FloppyLength;
         }
         else
         {
             return false;
         }
     }
     //and whatever more can go wrong...
     return true;
 }
        private void ObtenerCamas()
        {
            LstCeldaX = new ObservableCollection <CeldaX>();

            try
            {
                if (SelectedSector != null)
                {
                    SelectedSector = new cSector().Obtener(SelectedSector.ID_SECTOR, SelectedSector.ID_EDIFICIO, SelectedSector.ID_CENTRO);
                    foreach (var celda in SelectedSector.CELDA.OrderBy(w => w.ID_CELDA)) //celdas por sector
                    {
                        foreach (var cama in celda.CAMA.OrderBy(x => x.ID_CAMA))         //camas por celda
                        {
                            if (SelectedObservacion == null)
                            {
                                if (cama.SECTOR_OBSERVACION_CELDA != null)//ya fue registrada antes
                                {
                                    continue;
                                }

                                else
                                {//Aun no ha sido registrada en observaciones celda. se crea para que se seleccione desde la vista
                                    LstCeldaX.Add(
                                        new CeldaX
                                    {
                                        Cama         = cama,
                                        Seleccionado = false
                                    });
                                };
                            }

                            else
                            {
                                if (SelectedObservacion.SECTOR_OBSERVACION_CELDA.AsQueryable().Any() && SelectedObservacion.SECTOR_OBSERVACION_CELDA.AsQueryable().Any(d => d.ID_CAMA == cama.ID_CAMA))
                                {
                                    LstCeldaX.Add(//Se acaba de dar de alta
                                        new CeldaX
                                    {
                                        Cama         = cama,
                                        Seleccionado = true
                                    });

                                    continue;
                                }

                                if (cama.SECTOR_OBSERVACION_CELDA != null)
                                {
                                    if (SelectedObservacion.SECTOR_OBSERVACION_CELDA.AsQueryable().Where(x => x.ID_SECTOR_OBS == SelectedObservacion.ID_SECTOR_OBS && x.ID_CAMA == cama.ID_CAMA).Count() > 0)
                                    {
                                        LstCeldaX.Add(//Ya fue registrada , se regresa marcada para que se vuelva a crear y se borre solo si el usuario la desmarca
                                            new CeldaX
                                        {
                                            Cama         = cama,
                                            Seleccionado = true
                                        });
                                    }
                                }

                                else
                                {//Aun no ha sido registrada en observaciones celda. se crea para que se seleccione desde la vista
                                    LstCeldaX.Add(
                                        new CeldaX
                                    {
                                        Cama         = cama,
                                        Seleccionado = false
                                    });
                                };
                            };
                        }
                        ;
                    }
                    ;
                }
                ;
            }

            catch (Exception ex)
            {
                StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al obtener las camas", ex);
            }
        }