Beispiel #1
0
        //***MAPEOS***//
        private BE.Backup MapDataReaderBackup(SqlDataReader dataReader)
        {
            BE.Backup backup = new BE.Backup();
            backup.id_Backup       = dataReader.GetInt32(0);
            backup.descripcion     = dataReader.GetString(1);
            backup.ruta            = dataReader.GetString(2);
            backup.nro_particiones = dataReader.GetInt32(3);

            return(backup);
        }
Beispiel #2
0
        public int RestaurarBackupSeleccionado(BE.Backup backup)
        {
            try
            {
                //Modifico la base a Single User
                string query_singleUser = "******";
                helper.ExecuteNonQuery(query_singleUser);
            }
            catch (Exception)
            {
            }

            try
            {
                //Obtengo las particiones
                string mainPath      = backup.ruta + "\\" + backup.descripcion;
                string particionPath = "";

                for (int i = 1; i <= backup.nro_particiones; i++)
                {
                    particionPath += " DISK = '" + mainPath + "." + i + ".bak'";
                    if (i < backup.nro_particiones)
                    {
                        particionPath += ",";
                    }
                }

                //Realizo la restauracion de la BD
                string query_restore = @"USE MASTER RESTORE DATABASE HotelYavin FROM " + particionPath + " WITH REPLACE";
                //string query = @"RESTORE DATABASE HotelYavin FROM " + particionPath;
                helper.ExecuteNonQuery(query_restore);
            }
            catch (Exception)
            {
                throw;
            }

            try
            {
                //Modifico la base a Multi User
                string query_multiUser = "******";
                return(helper.ExecuteNonQuery(query_multiUser));
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #3
0
        public List <BE.Backup> SelectAll()
        {
            string query = "SELECT * FROM [Backup]";

            using (SqlDataReader dataReader = helper.ExecuteReader(query))
            {
                List <BE.Backup> backupList = new List <BE.Backup>();
                while (dataReader.Read())
                {
                    BE.Backup backup = MapDataReaderBackup(dataReader);
                    backupList.Add(backup);
                }

                return(backupList);
            }
        }
        private void btn_restaurar_Click(object sender, EventArgs e)
        {
            BE.Backup       backupSeleccionado = new BE.Backup();
            DataGridViewRow filaSelected       = this.dgv_listadoBackups.SelectedRows[0];

            backupSeleccionado.id_Backup       = (int)filaSelected.Cells[0].Value;
            backupSeleccionado.descripcion     = (string)filaSelected.Cells[1].Value;
            backupSeleccionado.ruta            = (string)filaSelected.Cells[2].Value;
            backupSeleccionado.nro_particiones = (int)filaSelected.Cells[3].Value;

            if (restaurarBackup_BLL.RestaurarBackupSeleccionado(backupSeleccionado) == -1)
            {
                MessageBox.Show("Se realizó la restauración correctamente");
                bitacora_ALTA.RegistrarEnBitacora(this.usuario_logueado, DateTime.Now, "Se generó una Restauración de una Copia de Seguridad");
                this.Close();
            }
            else
            {
                MessageBox.Show("Fallo la restauración de la copia de seguridad. Verifique por favor la existencia de la ruta y/o archivo");
            }
        }
Beispiel #5
0
        private void btn_generar_Click(object sender, EventArgs e)
        {
            BLL.Backup backup_BLL = new BLL.Backup();
            string     fecha      = DateTime.Now.ToShortDateString().Replace('/', '-');

            if (this.txt_ubicacion.Text != "" && this.txt_nombreBackup.Text != "")
            {
                string fileNamefinal        = this.txt_nombreBackup.Text + "-" + fecha;
                string pathFinal            = this.txt_ubicacion.Text + "\\" + fileNamefinal;
                int    cantidad_particiones = (int)this.nud_particiones.Value;
                if (backup_BLL.GenerarBackup(pathFinal, cantidad_particiones) == -1)
                {
                    BE.Backup backupGenerado = new BE.Backup();
                    backupGenerado.descripcion     = fileNamefinal;
                    backupGenerado.ruta            = this.txt_ubicacion.Text;
                    backupGenerado.nro_particiones = (int)this.nud_particiones.Value;

                    if (backup_BLL.AddBackup(backupGenerado) != -1)
                    {
                        MessageBox.Show("Se realizó el backup correctamente");
                        bitacora_BAJA.RegistrarEnBitacora(this.usuario_logueado, DateTime.Now, "Se creó una Copia de Seguridad");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Error al generar registro de backup en DB");
                    }
                }
                else
                {
                    MessageBox.Show("Error al generar backup. Vuelva a intentar más tarde");
                }
            }
            else
            {
                MessageBox.Show("Debe completar todos los campos para continuar");
            }
        }
Beispiel #6
0
        public int AddBackup(BE.Backup backup)
        {
            string query = "INSERT INTO [Backup] values ('" + backup.descripcion + "','" + backup.ruta + "'," + backup.nro_particiones + ")";

            return(helper.ExecuteNonQuery(query));
        }
Beispiel #7
0
 public int AddBackup(BE.Backup backup)
 {
     return(GetInstance().AddBackup(backup));
 }
Beispiel #8
0
 public int RestaurarBackupSeleccionado(BE.Backup backup)
 {
     DAL.RestaurarBackup restaurarBackup_DAL = new DAL.RestaurarBackup();
     return(restaurarBackup_DAL.RestaurarBackupSeleccionado(backup));
 }