Пример #1
0
        public void RestoreDatabase(Backups backup)
        {
            //Genero la bitacora
            UsuariosComponent usuarios       = new UsuariosComponent();
            EventoBitacora    eventoBitacora = new EventoBitacora();
            Usuarios          unUsuario      = new Usuarios();

            unUsuario.Id      = 2;
            eventoBitacora.Id = 10;

            BitacoraComponent bitacoraComponent = new BitacoraComponent();
            Bitacora          bitacora          = new Bitacora(backup.usuarios, eventoBitacora);

            bitacora.fecha = DateTime.Now.ToString("dd-MM-yyyy");
            bitacora.hora  = DateTime.Now.ToString("hh mm ss");
            bitacoraComponent.Create(bitacora);
            Backups   backupRestore = new Backups(backup.usuarios);
            BackupDAC backupDAC     = new BackupDAC();

            backupRestore      = backupDAC.ReadBy(backup.Id);
            backupRestore.Path = @"C:\\Backup\" + backupRestore.Nombre + ".bak";
            backupDAC.Restore(backupRestore);
            //restauro DVV y Base AUX

            UsuariosComponent usuariosComponent = new UsuariosComponent();
            //usuariosComponent.RestoreBDAUX();

            DVVComponent dVVComponent = new DVVComponent();

            dVVComponent.CrearDVV(usuariosComponent.ListaDVH(), "Usuario");

            var bkSerie = new Backups(usuariosComponent.ReadBy(unUsuario.Id))

            {
                Fecha             = bitacora.fecha,
                Path              = backupRestore.Path,
                Nombre            = backupRestore.Nombre,
                Id                = backupRestore.Id,
                FechaRestauracion = DateTime.Now
            };

            string output = JsonConvert.SerializeObject(bkSerie);

            DateTime date = new DateTime();

            date = DateTime.Parse(bkSerie.Fecha);
            string filename = @"C:\Imagenes\json\" + date.ToString("dd-MM-yyyy") + date.ToString("ss") + ".json";

            if (!File.Exists(filename))
            {
                // Create a file to write to.
                System.IO.File.WriteAllText(filename, output);
            }
            else
            {
                string filename2 = @"C:\Imagenes\json\" + date.ToString("dd-MM-yyyy ss") + ".json";
                System.IO.File.WriteAllText(filename2, output);
            }
        }
        public void RestoreDatabase(Backups backup)
        {
            Entities.Backups backupRestore = new Entities.Backups();
            BackupDAC        backupDAC     = new BackupDAC();

            backupRestore      = backupDAC.ReadBy(backup.Id);
            backupRestore.Path = HostingEnvironment.MapPath("~/Backup/" + backupRestore.Nombre + ".bak");
            backupDAC.Restore(backupRestore);
            Bitacora bitacora = new Bitacora();

            bitacora.eventoBitacora.Id = 11;

            UsuariosComponent usuarios = new UsuariosComponent();

            bitacora.usuarios.Email = "*****@*****.**";
            BitacoraComponent bitacoraComponent = new BitacoraComponent();

            bitacoraComponent.Create(bitacora);
        }