Added test app
This commit is contained in:
61
DbToolsTester/Forms/MainForm.cs
Normal file
61
DbToolsTester/Forms/MainForm.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using DbTools;
|
||||
using System.Data.SQLite;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DbToolsTester.Forms {
|
||||
public partial class MainForm : DevExpress.XtraEditors.XtraForm {
|
||||
public string DatabaseName { get; set; }
|
||||
public string Database1File { get; set; }
|
||||
public string Database2File { get; set; }
|
||||
|
||||
public MainForm() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void XtraTabControl1_CustomHeaderButtonClick(object sender, DevExpress.XtraTab.ViewInfo.CustomHeaderButtonEventArgs e) {
|
||||
string tag = e.Button.Tag?.ToString();
|
||||
if (tag == "open") {
|
||||
Database1File = getDatabaseFile("Select Original / Production Database...");
|
||||
Database2File = getDatabaseFile("Select Template / New Schema Database...");
|
||||
|
||||
DatabaseName = Path.GetFileNameWithoutExtension(Database1File);
|
||||
Text += " [ Production DB = " + Path.GetFileName(Database1File) + "; Schema DB = " + Path.GetFileName(Database2File) + " ]";
|
||||
} else if (tag == "clear") {
|
||||
Database1File = null;
|
||||
Database2File = null;
|
||||
|
||||
db1Sql.Clear();
|
||||
db2Sql.Clear();
|
||||
deltaSql.Clear();
|
||||
|
||||
Text = "DbSync Tester";
|
||||
}
|
||||
}
|
||||
|
||||
private string getDatabaseFile(string title = "Select Database File...") {
|
||||
OpenFileDialog dlg = new OpenFileDialog() {
|
||||
Filter = "Database Files (*.sql;*.sqlite;*.db)|*.sql;*.sqlite;*.db|SQL Files (*.sql)|*.sql|Sqlite Files (*.sqlite;*.db)|*.sqlite;*.db|Text Files (*.txt)|*.txt|All Files (*.*)|*.*",
|
||||
CheckFileExists = true,
|
||||
Multiselect = false,
|
||||
Title = title
|
||||
};
|
||||
if (dlg.ShowDialog() == DialogResult.OK) {
|
||||
return dlg.FileName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ToolbarItemClicked(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
|
||||
if (e.Item.Equals(bbiDelta)) {
|
||||
SQLiteConnection db1 = new SQLiteConnection("Data Source=" + Database1File + ";Version=3;");
|
||||
SQLiteConnection db2 = new SQLiteConnection("Data Source=" + Database2File + ";Version=3;");
|
||||
|
||||
Delta delta = new Delta();
|
||||
deltaSql.Text = delta.BuildDelta(db1, db2, true, true);
|
||||
db1Sql.Text = delta.Db1Sql;
|
||||
db2Sql.Text = delta.Db2Sql;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user