Esempio n. 1
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(UploadRestor.FileName))
            {
                Response.Write("<script language='JavaScript'> alert('Chưa chọn file.'); </script>");
                return;
            }
            UploadFile();

            dtSetting dt   = new dtSetting();
            DataTable db   = dt.LayTenDatabase();
            DataRow   dr   = db.Rows[0];
            string    Name = dr["DatabaseName"].ToString();
            string    File = Server.MapPath("~/Uploads/") + strFileExcel;

            try
            {
                data = new dtDuLieu();
                ProgressBarPhucHoi.Position = 100;
                data.PhucHoiCSDL(File, Name);
                lblThongBaoPhucHoi.Text = "Phục hồi cơ sở dữ liệu thành công!";
            }
            catch (Exception ex)
            {
                ProgressBarPhucHoi.Position = 99;
                lblThongBaoPhucHoi.Text     = "Lỗi xảy ra Trong quá trình phục hồi dữ liệu !" + ex.ToString();
            }
        }
Esempio n. 2
0
        protected void btnSaoLuuDuLieu_Click(object sender, EventArgs e)
        {
            dtSetting dt      = new dtSetting();
            DataTable db      = dt.LayTenDatabase();
            DataRow   dr      = db.Rows[0];
            string    Name    = dr["DatabaseName"].ToString();
            string    CD      = Server.MapPath("~/Uploads/");
            string    TenFile = DateTime.Now.ToString("ddMMyyyy") + "_" + Name + ".Bak";

            data = new dtDuLieu();
            //FileInfo newFile = new FileInfo(Server.MapPath("~/Uploads/" + TenFile));
            //newFile.Delete();
            string[] Files = Directory.GetFiles(Server.MapPath("~/Uploads/"));

            foreach (string file in Files)
            {
                File.Delete(file);
            }
            data.SaoLuuCSDL(CD, Name);

            System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
            response.ClearContent();
            response.Clear();
            response.ContentType = "text/plain";
            response.AddHeader("Content-Disposition", "attachment; filename=" + TenFile + ";");
            response.TransmitFile(Server.MapPath("~/Uploads/" + TenFile));
            response.Flush();
            response.End();
        }