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; } }
private void backup_Click(object sender, EventArgs e) { SaveFileDialog fichero = new SaveFileDialog(); fichero.Filter = "SQL (*.sql)|*.sql"; fichero.FileName = "Backup"; if (fichero.ShowDialog() == DialogResult.OK) { List <string> credentials = UtilVarios.GetCredentialsDB(); string server = credentials[0]; string user = credentials[1]; string database = credentials[2]; string pass = credentials[3]; UtilDB.DumpDB(server, 3306, user, pass, database, fichero.FileName); } }
public frmPrincipal() { InitializeComponent(); foreach (Control control in this.Controls) { MdiClient client = control as MdiClient; if (!(client == null)) { client.BackColor = this.BackColor; break; } } List <String> credentials = UtilVarios.GetCredentialsFTP(); string server = credentials[0]; string user = credentials[1]; string pass = credentials[2]; }
private void btnCrearUsuarioMysql_Click(object sender, EventArgs e) { List <string> credentials = UtilVarios.GetCredentialsDB(); string server = credentials[0]; string user = credentials[1]; string database = credentials[2]; string pass = credentials[3]; Process process = new Process(); process.StartInfo.FileName = Application.StartupPath + @"\Mysql\mysql.exe"; string usuario = string.Format("-u root -e \"GRANT ALL ON *.* TO '{0}'@'%' IDENTIFIED BY '{1}' WITH GRANT OPTION;\"", user, pass); // string usuario = string.Format("-u root -e \"GRANT ALL ON *.* TO 'dale_che'@'%' IDENTIFIED BY '8953#AFjn' WITH GRANT OPTION;\""); process.StartInfo.Arguments = usuario; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start(); process.WaitForExit(); }
public static void RestoreDB() { List <string> credentials = UtilVarios.GetCredentialsDB(); string server = credentials[0]; string user = credentials[1]; string database = credentials[2]; string pass = credentials[3]; string path = Application.StartupPath + @"\Mysql\mysql.exe"; string filename = Application.StartupPath + @"\Mysql\ncsoftwa_re.sql"; Process process = new Process(); process.StartInfo.FileName = path; string args = "-C -B --host=" + server + " -P 3306 --user="******" --password="******" -e \"\\. " + filename + "\""; process.StartInfo.Arguments = args; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start(); process.WaitForExit(); }
private void restaurarBaseDeDatosToolStripMenuItem_Click(object sender, EventArgs e) { string fileName; OpenFileDialog opFilDlg = new OpenFileDialog(); opFilDlg.Filter = "SQL (*.sql)|*.sql"; if (opFilDlg.ShowDialog() == DialogResult.OK) { fileName = opFilDlg.FileName; } else { return; } Cursor.Current = Cursors.WaitCursor; List <string> credentials = UtilVarios.GetCredentialsDB(); string server = credentials[0]; string user = credentials[1]; string database = credentials[2]; string pass = credentials[3]; BL.UtilDB.RestoreDB(server, 3306, user, pass, database, fileName); Application.Restart(); }
private void bckIniciarComponetes_DoWork(object sender, DoWorkEventArgs e) { if (!UtilVarios.ExisteServicio("MySQL")) { this.pictureBox2.Location = new System.Drawing.Point(29, 55); label2.Text = "Iniciando el sistema por primera vez." + '\r' + "Este proceso puede tomar unos minutos."; // label1.Text = "Instalando servidor de base de datos . . ."; // UtilDB.InstalarMySQL(); label1.Text = "Configurando servidor de base de datos . . ."; UtilDB.ConfigurarMySQL(); } label1.Text = "Obteniendo datos del servidor . . ."; reiniciar: try { ds = BL.GetDataBLL.GetData(); string idRazonSocial = BL.GetDataBLL.RazonSocial().Rows[0][0].ToString(); BL.MantenimientoBLL.Mantenimiento(); BL.VentasBLL.VentasHistoricasMantener(); label1.Text = "Importando datos . . ."; // BL.DatosBLL.GetDataPOS(false); // false no importa los datos de hoy label1.Text = "Exportando datos . . ."; // BL.DatosBLL.ExportarDatos(); } catch (ServidorMysqlInaccesibleException ex) { this.Invoke((Action)delegate { this.Visible = false; MessageBox.Show(ex.Message, "Trend Gestión", MessageBoxButtons.OK, MessageBoxIcon.Error); }); System.Environment.Exit(1); } catch (System.TimeoutException) { this.Invoke((Action)delegate { this.Visible = false; MessageBox.Show("El tiempo de conexión con el servidor ha expirado. Intente nuevamente.", "Trend Gestión", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(1); }); } catch (IndexOutOfRangeException) // se produce la excepción si no existe el registro en la tabla. Lo agrego { try { DataTable tblRazon = BL.GetDataBLL.RazonSocial(); DataRow row = tblRazon.NewRow(); Random rand = new Random(); int clave = rand.Next(147483647, 2147483647); row["IdRazonSocialRAZ"] = clave; row["RazonSocialRAZ"] = ""; row["NombreFantasiaRAZ"] = ""; row["DomicilioRAZ"] = ""; row["LocalidadRAZ"] = ""; row["ProvinciaRAZ"] = ""; row["IdCondicionIvaRAZ"] = DBNull.Value; row["CuitRAZ"] = ""; row["IngresosBrutosRAZ"] = ""; row["InicioActividadRAZ"] = DBNull.Value; tblRazon.Rows.Add(row); BL.RazonSocialBLL.GrabarDB(tblRazon); } catch (ServidorMysqlInaccesibleException ex) { this.Invoke((Action)delegate { this.Visible = false; MessageBox.Show(ex.Message, "Trend Gestión", MessageBoxButtons.OK, MessageBoxIcon.Error); }); System.Environment.Exit(1); } goto reiniciar; } catch (WebException) { this.Invoke((Action)delegate { this.Visible = false; MessageBox.Show("No se pudo establecer conexión con el servidor remoto. No se actualizaron los datos.", "Trend Gestión", MessageBoxButtons.OK, MessageBoxIcon.Error); }); } catch (Exception ex) { this.Invoke((Action)delegate { this.Visible = false; string error = ex.Message; MessageBox.Show(error, "Trend Gestión", MessageBoxButtons.OK, MessageBoxIcon.Error); }); } }