COmpletato metodi con

- password zip
- gestione temp folder
- ripristino altri DB
This commit is contained in:
Samuele Locatelli
2023-07-27 12:23:53 +02:00
parent 8980da46be
commit dfb3e1f74a
7 changed files with 141 additions and 37 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
</configSections> </configSections>
<entityFramework> <entityFramework>
<!--<defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.EntityFramework" />--> <!--<defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.EntityFramework" />-->
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers> <providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.21.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.21.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
</provider> </provider>
+86 -21
View File
@@ -1,7 +1,10 @@
using System; using Ionic.Zip;
using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Xml.Linq;
namespace EgtBEAMWALL.DataLayer namespace EgtBEAMWALL.DataLayer
{ {
@@ -18,6 +21,7 @@ namespace EgtBEAMWALL.DataLayer
public static string DATABASE_SERV = "127.0.0.1"; public static string DATABASE_SERV = "127.0.0.1";
public static string DATABASE_USER = "EgtUser"; public static string DATABASE_USER = "EgtUser";
public static string ZIP_PWD = "viacremasca-viacremasca-viacremasca-viacremasca";
#endregion Public Fields #endregion Public Fields
@@ -74,13 +78,14 @@ namespace EgtBEAMWALL.DataLayer
} }
/// <summary> /// <summary>
/// Effettua DUMP del DB dato utente admin + percorso salvataggio /// Effettua DUMP del DB dato utente admin + percorso salvataggio (zip cifrato)
/// </summary> /// </summary>
/// <param name="outFilePath">Percorso di salvataggio del dump (*.sql)</param> /// <param name="zipFilePath">Percorso di salvataggio del dump (*.zip)</param>
/// <param name="dbName">Nome del DB da processare (se vuoto quello di default calcolato)</param>
/// <param name="mysqlDumpPath">Nome o Percorso Eseguibile mysqldump (opzionale)</param> /// <param name="mysqlDumpPath">Nome o Percorso Eseguibile mysqldump (opzionale)</param>
/// <param name="exportOpt">Opzioni in fase di export (default: --skip-extended-insert)</param> /// <param name="exportOpt">Opzioni in fase di export (default: --skip-extended-insert)</param>
/// <returns></returns> /// <returns></returns>
public static bool DataBaseDumpToFile(string outFilePath, string mysqlDumpPath = "mysqldump", string exportOpt = "--skip-extended-insert") public static bool DataBaseDumpToFile(string zipFilePath, string dbName = "", string mysqlDumpPath = "mysqldump", string exportOpt = "--skip-extended-insert")
{ {
bool fatto = false; bool fatto = false;
// fix path eseguibile // fix path eseguibile
@@ -88,36 +93,63 @@ namespace EgtBEAMWALL.DataLayer
{ {
mysqlDumpPath = "mysqldump"; mysqlDumpPath = "mysqldump";
} }
// aggiungo sql finale if (string.IsNullOrEmpty(dbName))
if (!outFilePath.EndsWith(".sql"))
{ {
outFilePath = $"{outFilePath}.sql"; dbName = DATABASE_NAME;
} }
// verifica zip finale
if (!zipFilePath.EndsWith(".zip"))
{
zipFilePath = $"{zipFilePath}.zip";
}
// creo nome file per export sql (temporaneo)
string tempSqlPath = zipFilePath.Replace(".zip", ".sql");
// esecuzione script x dump del DB // esecuzione script x dump del DB
string dirPath = Path.GetDirectoryName(outFilePath); string dirPath = Path.GetDirectoryName(zipFilePath);
if (!Directory.Exists(dirPath)) if (!Directory.Exists(dirPath))
{ {
Directory.CreateDirectory(dirPath); Directory.CreateDirectory(dirPath);
} }
// se ci fosse già file elimino... // se ci fosse già file elimino (sql/zip)
if (File.Exists(outFilePath)) if (File.Exists(tempSqlPath))
{ {
File.Delete(outFilePath); File.Delete(tempSqlPath);
} }
// chiamo script esterno... importante parametro "--skip-extended-insert" altrimenti problemi con restore (anche se + verboso e lento in backup...) if (File.Exists(zipFilePath))
string callScript = $"\"{mysqlDumpPath}\" -u{DATABASE_USER} -p{DATABASE_PWD} {DATABASE_NAME} {exportOpt} > {outFilePath}"; {
File.Delete(zipFilePath);
}
// creazione SQL, tramite 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} {dbName} {exportOpt} > {tempSqlPath}";
ExecuteCommand(callScript); ExecuteCommand(callScript);
// compressione con pwd!
using (ZipFile zip = new ZipFile())
{
// aggiungo pwd
zip.Password = ZIP_PWD;
// inserisco file
zip.AddFile(tempSqlPath, "");
zip.Save(zipFilePath);
fatto = true;
}
// elimino file sql temporaneo...
if (File.Exists(tempSqlPath))
{
File.Delete(tempSqlPath);
}
return fatto; return fatto;
} }
/// <summary> /// <summary>
/// Effettua restore come overwrite del DB di DEFAULT... irreversibile /// Effettua restore come overwrite del DB di DEFAULT... irreversibile
/// </summary> /// </summary>
/// <param name="inFilePath">Percorso di lettura del dump (*.sql)</param> /// <param name="zipFilePath">Percorso di lettura del dump cifrato (*.zip)</param>
/// <param name="dbName">Nome del DB da processare (se vuoto quello di default calcolato)</param>
/// <param name="tempFolder">Percorso cartella temp x esecuzione</param>
/// <param name="mysqlPath">Nome o Percorso Eseguibile mysql (opzionale)</param> /// <param name="mysqlPath">Nome o Percorso Eseguibile mysql (opzionale)</param>
/// <param name="importOpt">Opzioni in fase di import (default: --force)</param> /// <param name="importOpt">Opzioni in fase di import (default: --force)</param>
/// <returns></returns> /// <returns></returns>
public static bool DataBaseRestoreFromFile(string inFilePath, string mysqlPath = "mysql", string importOpt = "--force") public static bool DataBaseRestoreFromFile(string zipFilePath, string dbName = "", string tempFolder="", string mysqlPath = "mysql", string importOpt = "--force")
{ {
bool fatto = false; bool fatto = false;
// fix path eseguibile // fix path eseguibile
@@ -125,14 +157,46 @@ namespace EgtBEAMWALL.DataLayer
{ {
mysqlPath = "mysql"; mysqlPath = "mysql";
} }
// aggiungo sql finale if (string.IsNullOrEmpty(dbName))
if (!inFilePath.EndsWith(".sql"))
{ {
inFilePath = $"{inFilePath}.sql"; dbName = DATABASE_NAME;
}
if (string.IsNullOrEmpty(tempFolder))
{
tempFolder = "C:\\Temp";
}
// verifica zip finale
if (!zipFilePath.EndsWith(".zip"))
{
zipFilePath = $"{zipFilePath}.zip";
}
// elimino eventuale temp folder precedente...
if (Directory.Exists(tempFolder))
{
Directory.Delete(tempFolder, true);
}
Directory.CreateDirectory(tempFolder);
// scompatto file zip --> sql
using (ZipFile zip = ZipFile.Read(zipFilePath))
{
zip.Password = ZIP_PWD;
zip.ExtractAll(tempFolder, ExtractExistingFileAction.OverwriteSilently);
}
// verifico che ci sia 1 file sql...
var sqlFiles = Directory.GetFiles(tempFolder, "*.sql");
if (sqlFiles != null && sqlFiles.Length == 1)
{
// verifico nome file per export sql (temporaneo)
string tempSqlPath = sqlFiles.FirstOrDefault();
// chiamo script esterno...
string callScript = $"\"{mysqlPath}\" -u{DATABASE_USER} -p{DATABASE_PWD} {importOpt} {dbName} < {tempSqlPath}";
ExecuteCommand(callScript);
// elimino il file sql importato...
File.Delete(tempSqlPath);
// elimino temp folder...
Directory.Delete(tempFolder, true);
fatto = true;
} }
// chiamo script esterno...
string callScript = $"\"{mysqlPath}\" -u{DATABASE_USER} -p{DATABASE_PWD} {importOpt} {DATABASE_NAME} < {inFilePath}";
ExecuteCommand(callScript);
return fatto; return fatto;
} }
@@ -184,6 +248,7 @@ namespace EgtBEAMWALL.DataLayer
DATABASE_NAME = $"EgtBwDb_{masterKey}"; DATABASE_NAME = $"EgtBwDb_{masterKey}";
DATABASE_USER = $"user_{nKey}"; DATABASE_USER = $"user_{nKey}";
DATABASE_PWD = $"pwd_{sKey}"; DATABASE_PWD = $"pwd_{sKey}";
ZIP_PWD = $"{DATABASE_USER}:{DATABASE_PWD}:{DATABASE_USER}:{DATABASE_PWD}";
CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database={DATABASE_NAME};uid={DATABASE_USER};pwd={DATABASE_PWD};SslMode=None"; CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database={DATABASE_NAME};uid={DATABASE_USER};pwd={DATABASE_PWD};SslMode=None";
// stringa admin con utente root egalware... // stringa admin con utente root egalware...
ADMIN_CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database=mysql;uid=root;pwd=Egalware_24068!;SslMode=none;CHARSET=utf8"; ADMIN_CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database=mysql;uid=root;pwd=Egalware_24068!;SslMode=none;CHARSET=utf8";
@@ -40,6 +40,9 @@
<Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL"> <Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll</HintPath> <HintPath>..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll</HintPath>
</Reference> </Reference>
<Reference Include="DotNetZip, Version=1.16.0.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.16.0\lib\net40\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="EgtWPFLib5"> <Reference Include="EgtWPFLib5">
<HintPath>..\ExtLibs\EgtWPFLib5.dll</HintPath> <HintPath>..\ExtLibs\EgtWPFLib5.dll</HintPath>
</Reference> </Reference>
+1
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="BouncyCastle" version="1.8.5" targetFramework="net472" /> <package id="BouncyCastle" version="1.8.5" targetFramework="net472" />
<package id="DotNetZip" version="1.16.0" targetFramework="net472" />
<package id="EntityFramework" version="6.4.4" targetFramework="net452" /> <package id="EntityFramework" version="6.4.4" targetFramework="net452" />
<package id="Google.Protobuf" version="3.21.9" targetFramework="net472" /> <package id="Google.Protobuf" version="3.21.9" targetFramework="net472" />
<package id="K4os.Compression.LZ4" version="1.3.5" targetFramework="net472" /> <package id="K4os.Compression.LZ4" version="1.3.5" targetFramework="net472" />
+29 -9
View File
@@ -1,31 +1,51 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<configSections> <configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections> </configSections>
<entityFramework> <entityFramework>
<defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6"/> <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
<providers> <providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers> </providers>
</entityFramework> </entityFramework>
<connectionStrings> <connectionStrings>
<add name="DefaultConnection" connectionString="server=localhost;port=3306;User Id=EgtUser;password=viacremasca;Persist Security Info=True;database=EgtBwDb;SslMode=none" providerName="MySql.Data.MySqlClient"/> <add name="DefaultConnection" connectionString="server=localhost;port=3306;User Id=EgtUser;password=viacremasca;Persist Security Info=True;database=EgtBwDb;SslMode=none" providerName="MySql.Data.MySqlClient" />
</connectionStrings> </connectionStrings>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral"/> <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.10.9.0" newVersion="6.10.9.0"/> <bindingRedirect oldVersion="0.0.0.0-6.10.9.0" newVersion="6.10.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.21.9.0" newVersion="3.21.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="K4os.Compression.LZ4.Streams" publicKeyToken="2186fa9121ef231d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.5.0" newVersion="1.3.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.9.0.0" newVersion="1.9.0.0" />
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
<system.data> <system.data>
<DbProviderFactories> <DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient"/> <remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories> </DbProviderFactories>
</system.data> </system.data>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup></configuration>
+15 -4
View File
@@ -38,6 +38,7 @@ namespace EgtBEAMWALL.StressTest
this.btnDbDump = new System.Windows.Forms.Button(); this.btnDbDump = new System.Windows.Forms.Button();
this.btnDbRestore = new System.Windows.Forms.Button(); this.btnDbRestore = new System.Windows.Forms.Button();
this.txtDumpFile = new System.Windows.Forms.TextBox(); this.txtDumpFile = new System.Windows.Forms.TextBox();
this.txtDbName = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@@ -105,7 +106,7 @@ namespace EgtBEAMWALL.StressTest
// //
this.btnDbDump.Location = new System.Drawing.Point(18, 136); this.btnDbDump.Location = new System.Drawing.Point(18, 136);
this.btnDbDump.Name = "btnDbDump"; this.btnDbDump.Name = "btnDbDump";
this.btnDbDump.Size = new System.Drawing.Size(75, 23); this.btnDbDump.Size = new System.Drawing.Size(75, 45);
this.btnDbDump.TabIndex = 5; this.btnDbDump.TabIndex = 5;
this.btnDbDump.Text = "DB Dump"; this.btnDbDump.Text = "DB Dump";
this.btnDbDump.UseVisualStyleBackColor = true; this.btnDbDump.UseVisualStyleBackColor = true;
@@ -115,7 +116,7 @@ namespace EgtBEAMWALL.StressTest
// //
this.btnDbRestore.Location = new System.Drawing.Point(338, 136); this.btnDbRestore.Location = new System.Drawing.Point(338, 136);
this.btnDbRestore.Name = "btnDbRestore"; this.btnDbRestore.Name = "btnDbRestore";
this.btnDbRestore.Size = new System.Drawing.Size(75, 23); this.btnDbRestore.Size = new System.Drawing.Size(75, 45);
this.btnDbRestore.TabIndex = 6; this.btnDbRestore.TabIndex = 6;
this.btnDbRestore.Text = "DB Restore"; this.btnDbRestore.Text = "DB Restore";
this.btnDbRestore.UseVisualStyleBackColor = true; this.btnDbRestore.UseVisualStyleBackColor = true;
@@ -123,17 +124,26 @@ namespace EgtBEAMWALL.StressTest
// //
// txtDumpFile // txtDumpFile
// //
this.txtDumpFile.Location = new System.Drawing.Point(118, 136); this.txtDumpFile.Location = new System.Drawing.Point(118, 161);
this.txtDumpFile.Name = "txtDumpFile"; this.txtDumpFile.Name = "txtDumpFile";
this.txtDumpFile.Size = new System.Drawing.Size(186, 20); this.txtDumpFile.Size = new System.Drawing.Size(186, 20);
this.txtDumpFile.TabIndex = 3; this.txtDumpFile.TabIndex = 3;
this.txtDumpFile.Text = "C:\\Temp\\MyDbDump.sql"; this.txtDumpFile.Text = "C:\\Temp\\MyDbDump.zip";
//
// txtDbName
//
this.txtDbName.Location = new System.Drawing.Point(118, 136);
this.txtDbName.Name = "txtDbName";
this.txtDbName.Size = new System.Drawing.Size(186, 20);
this.txtDbName.TabIndex = 7;
this.txtDbName.Text = "egtbwdb_000142";
// //
// StressTest // StressTest
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.txtDbName);
this.Controls.Add(this.txtDumpFile); this.Controls.Add(this.txtDumpFile);
this.Controls.Add(this.btnDbRestore); this.Controls.Add(this.btnDbRestore);
this.Controls.Add(this.btnDbDump); this.Controls.Add(this.btnDbDump);
@@ -159,6 +169,7 @@ namespace EgtBEAMWALL.StressTest
private System.Windows.Forms.Button btnDbDump; private System.Windows.Forms.Button btnDbDump;
private System.Windows.Forms.Button btnDbRestore; private System.Windows.Forms.Button btnDbRestore;
private System.Windows.Forms.TextBox txtDumpFile; private System.Windows.Forms.TextBox txtDumpFile;
private System.Windows.Forms.TextBox txtDbName;
} }
} }
+6 -2
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
namespace EgtBEAMWALL.StressTest namespace EgtBEAMWALL.StressTest
@@ -60,12 +61,13 @@ namespace EgtBEAMWALL.StressTest
//string binPath = "C:\\Program Files\\MariaDB 10.5\\bin"; //string binPath = "C:\\Program Files\\MariaDB 10.5\\bin";
//string myDumpPath = Path.Combine(binPath, "mysqldump.exe"); //string myDumpPath = Path.Combine(binPath, "mysqldump.exe");
string outPath = txtDumpFile.Text.Trim(); string outPath = txtDumpFile.Text.Trim();
string dbName = txtDbName.Text.Trim();
if (!string.IsNullOrEmpty(outPath)) if (!string.IsNullOrEmpty(outPath))
{ {
// effettua dump // effettua dump
//DataLayer.DbConfig.DataBaseDumpToFile(outPath, "mysqldump"); //DataLayer.DbConfig.DataBaseDumpToFile(outPath, "mysqldump");
//DataLayer.DbConfig.DataBaseDumpToFile(outPath, "mysqldump", "--skip-extended-insert"); //DataLayer.DbConfig.DataBaseDumpToFile(outPath, "mysqldump", "--skip-extended-insert");
DataLayer.DbConfig.DataBaseDumpToFile(outPath); DataLayer.DbConfig.DataBaseDumpToFile(outPath, dbName);
sw.Stop(); sw.Stop();
var elapsed = sw.Elapsed; var elapsed = sw.Elapsed;
labelResult.Text = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} | Dump Done in {elapsed.TotalSeconds:N3} sec!"; labelResult.Text = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} | Dump Done in {elapsed.TotalSeconds:N3} sec!";
@@ -81,10 +83,12 @@ namespace EgtBEAMWALL.StressTest
{ {
labelResult.Text = "..."; labelResult.Text = "...";
string inPath = txtDumpFile.Text.Trim(); string inPath = txtDumpFile.Text.Trim();
string dbName = txtDbName.Text.Trim();
string tempFolder = Path.Combine(Path.GetDirectoryName(inPath), "DbRestore");
Stopwatch sw = new Stopwatch(); Stopwatch sw = new Stopwatch();
sw.Start(); sw.Start();
// effettua restore // effettua restore
DataLayer.DbConfig.DataBaseRestoreFromFile(inPath); sw.Stop(); DataLayer.DbConfig.DataBaseRestoreFromFile(inPath, dbName, tempFolder); sw.Stop();
//string binPath = "C:\\Program Files\\MariaDB 10.5\\bin"; //string binPath = "C:\\Program Files\\MariaDB 10.5\\bin";
//string mysqlPath = Path.Combine(binPath, "mysql.exe"); //string mysqlPath = Path.Combine(binPath, "mysql.exe");
//DataLayer.DbConfig.DataBaseRestoreFromFile(inPath, "mysql"); //DataLayer.DbConfig.DataBaseRestoreFromFile(inPath, "mysql");