diff --git a/EgtBEAMWALL.DataLayer/DbConfig.cs b/EgtBEAMWALL.DataLayer/DbConfig.cs
index 979c14fe..dcba6782 100644
--- a/EgtBEAMWALL.DataLayer/DbConfig.cs
+++ b/EgtBEAMWALL.DataLayer/DbConfig.cs
@@ -76,10 +76,10 @@ namespace EgtBEAMWALL.DataLayer
///
/// Effettua DUMP del DB dato utente admin + percorso salvataggio
///
- /// Percorso eseguibile mysqldump
/// Percorso di salvataggio del dump (*.sql)
+ /// Nome o Percorso Eseguibile mysqldump (opzionale)
///
- public static bool DataBaseDumpToFile(string mysqlDumpPath, string outFilePath)
+ public static bool DataBaseDumpToFile(string outFilePath, string mysqlDumpPath = "mysqldump")
{
bool fatto = false;
// aggiungo sql finale
@@ -98,7 +98,7 @@ namespace EgtBEAMWALL.DataLayer
{
File.Delete(outFilePath);
}
- // chiamo script esterno...
+ // chiamo script esterno... importante parametro "--skip-extended-insert" altrimenti problemi con restore (anche se + verboso e lento in backup...)
string callScript = $"\"{mysqlDumpPath}\" -u{DATABASE_USER} -p{DATABASE_PWD} {DATABASE_NAME} --skip-extended-insert > {outFilePath}";
ExecuteCommand(callScript);
return fatto;
@@ -107,10 +107,10 @@ namespace EgtBEAMWALL.DataLayer
///
/// Effettua restore come overwrite del DB di DEFAULT... irreversibile
///
- /// Percorso eseguibile mysql
/// Percorso di lettura del dump (*.sql)
+ /// Nome o Percorso Eseguibile mysql (opzionale)
///
- public static bool DataBaseRestoreFromFile(string mysqlPath, string inFilePath)
+ public static bool DataBaseRestoreFromFile(string inFilePath, string mysqlPath="mysql")
{
bool fatto = false;
// aggiungo sql finale
diff --git a/EgtBEAMWALL.StressTest/StressTest.cs b/EgtBEAMWALL.StressTest/StressTest.cs
index 8271ac72..992f7e3a 100644
--- a/EgtBEAMWALL.StressTest/StressTest.cs
+++ b/EgtBEAMWALL.StressTest/StressTest.cs
@@ -1,28 +1,11 @@
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
using System.Diagnostics;
-using System.Drawing;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Text;
using System.Windows.Forms;
namespace EgtBEAMWALL.StressTest
{
public partial class StressTest : Form
{
- #region Protected Fields
-
- ///
- /// Controller dati simulati x provare procedure
- ///
- protected Simulator CurrSim = new Simulator();
-
- #endregion Protected Fields
-
#region Public Constructors
public StressTest()
@@ -36,6 +19,15 @@ namespace EgtBEAMWALL.StressTest
#endregion Public Constructors
+ #region Protected Fields
+
+ ///
+ /// Controller dati simulati x provare procedure
+ ///
+ protected Simulator CurrSim = new Simulator();
+
+ #endregion Protected Fields
+
#region Protected Properties
protected int numProj
@@ -56,6 +48,50 @@ namespace EgtBEAMWALL.StressTest
#region Private Methods
+ private void btnDbDump_Click(object sender, EventArgs e)
+ {
+ var result = MessageBox.Show("Sicuro di voler generare il dump del DB corrente?", "DB Dump", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
+
+ if (result == DialogResult.Yes)
+ {
+ labelResult.Text = "...";
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+ //string binPath = "C:\\Program Files\\MariaDB 10.5\\bin";
+ //string myDumpPath = Path.Combine(binPath, "mysqldump.exe");
+ string outPath = txtDumpFile.Text.Trim();
+ if (!string.IsNullOrEmpty(outPath))
+ {
+ // effettua dump
+ //DataLayer.DbConfig.DataBaseDumpToFile(outPath, "mysqldump");
+ DataLayer.DbConfig.DataBaseDumpToFile(outPath);
+ sw.Stop();
+ var elapsed = sw.Elapsed;
+ labelResult.Text = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} | Dump Done in {elapsed.TotalSeconds:N3} sec!";
+ }
+ }
+ }
+
+ private void btnDbRestore_Click(object sender, EventArgs e)
+ {
+ var result = MessageBox.Show("Sicuro di voler ripristinare il file dump sul DB corrente?", "DB Restore", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
+
+ if (result == DialogResult.Yes)
+ {
+ labelResult.Text = "...";
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+ //string binPath = "C:\\Program Files\\MariaDB 10.5\\bin";
+ //string mysqlPath = Path.Combine(binPath, "mysql.exe");
+ string inPath = txtDumpFile.Text.Trim();
+ // effettua restore
+ //DataLayer.DbConfig.DataBaseRestoreFromFile(inPath, "mysql");
+ DataLayer.DbConfig.DataBaseRestoreFromFile(inPath); sw.Stop();
+ var elapsed = sw.Elapsed;
+ labelResult.Text = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} | Restore Done in {elapsed.TotalSeconds:N3} sec!";
+ }
+ }
+
private void buttonDataSeed_Click(object sender, EventArgs e)
{
// genero dati col SIM
@@ -73,40 +109,5 @@ namespace EgtBEAMWALL.StressTest
}
#endregion Private Methods
-
- private void btnDbDump_Click(object sender, EventArgs e)
- {
- var result = MessageBox.Show("Sicuro di voler generare il dump del DB corrente?", "DB Dump", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
- if (result == DialogResult.Yes)
- {
- labelResult.Text = "...";
- //string binPath = "C:\\Program Files\\MariaDB 10.5\\bin";
- //string myDumpPath = Path.Combine(binPath, "mysqldump.exe");
- string myDumpPath = "mysqldump";
- string outPath = txtDumpFile.Text.Trim();
- if (!string.IsNullOrEmpty(outPath))
- {
- // effettua dump
- DataLayer.DbConfig.DataBaseDumpToFile(myDumpPath, outPath);
- labelResult.Text = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} | Dump Done!";
- }
- }
- }
-
- private void btnDbRestore_Click(object sender, EventArgs e)
- {
- var result = MessageBox.Show("Sicuro di voler ripristinare il file dump sul DB corrente?", "DB Restore", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
- if (result == DialogResult.Yes)
- {
- labelResult.Text = "...";
- //string binPath = "C:\\Program Files\\MariaDB 10.5\\bin";
- //string mysqlPath = Path.Combine(binPath, "mysql.exe");
- string mysqlPath = "mysql";
- string inPath = txtDumpFile.Text.Trim();
- // effettua restore
- DataLayer.DbConfig.DataBaseRestoreFromFile(mysqlPath, inPath);
- labelResult.Text = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} | Restore Done!";
- }
- }
}
}
\ No newline at end of file