예제 #1
0
        private void SilenceBackup(object source, ElapsedEventArgs e)
        {
            List <string> credentials    = UtilVarios.GetCredentialsDB();
            string        server         = credentials[0];
            string        user           = credentials[1];
            string        database       = credentials[2];
            string        pass           = credentials[3];
            DataTable     tbl            = BL.GetDataBLL.RazonSocial();
            string        fileSilenceBck = @"c:\windows\temp\" + tbl.Rows[0][0].ToString() + "_bck.sql";
            string        remoteFile     = tbl.Rows[0][0].ToString() + "_bck.sql.xz";

            UtilDB.DumpDB(server, 3306, user, pass, database, fileSilenceBck);
            if (File.Exists(fileSilenceBck + ".xz"))
            {
                File.Delete(fileSilenceBck + ".xz");
            }
            UtilDB.ZipDB(fileSilenceBck);
            MemoryStream ms = new MemoryStream();

            using (FileStream fs = File.OpenRead(fileSilenceBck + ".xz"))
            {
                fs.CopyTo(ms);
            }
            try
            {
                BL.UtilFTP.UploadFromMemoryStream(ms, remoteFile, "trendsistemas");
            }
            catch (WebException)
            {
                return;
            }
        }