Added tester and DbComparer

This commit is contained in:
2025-08-29 20:15:19 -05:00
parent 5876ac0e8a
commit 8cc304c3d2
24 changed files with 1514 additions and 24 deletions

194
DbMigrateTester/Forms/MainForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,194 @@
namespace DbMigrateTester.Forms {
partial class MainForm {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.bar1 = new DevExpress.XtraBars.Bar();
this.bar2 = new DevExpress.XtraBars.Bar();
this.bar3 = new DevExpress.XtraBars.Bar();
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
this.barDockControlRight = new DevExpress.XtraBars.BarDockControl();
this.dbCurrent = new DbMigrateTester.Forms.UserControls.DatabasePanel();
this.splitterControl1 = new DevExpress.XtraEditors.SplitterControl();
this.dbLatest = new DbMigrateTester.Forms.UserControls.DatabasePanel();
this.bbiGenerateDelta = new DevExpress.XtraBars.BarButtonItem();
((System.ComponentModel.ISupportInitialize)(this.barManager1)).BeginInit();
this.SuspendLayout();
//
// barManager1
//
this.barManager1.Bars.AddRange(new DevExpress.XtraBars.Bar[] {
this.bar1,
this.bar2,
this.bar3});
this.barManager1.DockControls.Add(this.barDockControlTop);
this.barManager1.DockControls.Add(this.barDockControlBottom);
this.barManager1.DockControls.Add(this.barDockControlLeft);
this.barManager1.DockControls.Add(this.barDockControlRight);
this.barManager1.Form = this;
this.barManager1.Items.AddRange(new DevExpress.XtraBars.BarItem[] {
this.bbiGenerateDelta});
this.barManager1.MainMenu = this.bar2;
this.barManager1.MaxItemId = 27;
this.barManager1.StatusBar = this.bar3;
//
// bar1
//
this.bar1.BarName = "Tools";
this.bar1.DockCol = 0;
this.bar1.DockRow = 1;
this.bar1.DockStyle = DevExpress.XtraBars.BarDockStyle.Top;
this.bar1.LinksPersistInfo.AddRange(new DevExpress.XtraBars.LinkPersistInfo[] {
new DevExpress.XtraBars.LinkPersistInfo(this.bbiGenerateDelta)});
this.bar1.Text = "Tools";
//
// bar2
//
this.bar2.BarName = "Main menu";
this.bar2.DockCol = 0;
this.bar2.DockRow = 0;
this.bar2.DockStyle = DevExpress.XtraBars.BarDockStyle.Top;
this.bar2.OptionsBar.MultiLine = true;
this.bar2.OptionsBar.UseWholeRow = true;
this.bar2.Text = "Main menu";
//
// bar3
//
this.bar3.BarName = "Status bar";
this.bar3.CanDockStyle = DevExpress.XtraBars.BarCanDockStyle.Bottom;
this.bar3.DockCol = 0;
this.bar3.DockRow = 0;
this.bar3.DockStyle = DevExpress.XtraBars.BarDockStyle.Bottom;
this.bar3.OptionsBar.AllowQuickCustomization = false;
this.bar3.OptionsBar.DrawDragBorder = false;
this.bar3.OptionsBar.UseWholeRow = true;
this.bar3.Text = "Status bar";
//
// barDockControlTop
//
this.barDockControlTop.CausesValidation = false;
this.barDockControlTop.Dock = System.Windows.Forms.DockStyle.Top;
this.barDockControlTop.Location = new System.Drawing.Point(0, 0);
this.barDockControlTop.Manager = this.barManager1;
this.barDockControlTop.Size = new System.Drawing.Size(1173, 46);
//
// barDockControlBottom
//
this.barDockControlBottom.CausesValidation = false;
this.barDockControlBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
this.barDockControlBottom.Location = new System.Drawing.Point(0, 537);
this.barDockControlBottom.Manager = this.barManager1;
this.barDockControlBottom.Size = new System.Drawing.Size(1173, 19);
//
// barDockControlLeft
//
this.barDockControlLeft.CausesValidation = false;
this.barDockControlLeft.Dock = System.Windows.Forms.DockStyle.Left;
this.barDockControlLeft.Location = new System.Drawing.Point(0, 46);
this.barDockControlLeft.Manager = this.barManager1;
this.barDockControlLeft.Size = new System.Drawing.Size(0, 491);
//
// barDockControlRight
//
this.barDockControlRight.CausesValidation = false;
this.barDockControlRight.Dock = System.Windows.Forms.DockStyle.Right;
this.barDockControlRight.Location = new System.Drawing.Point(1173, 46);
this.barDockControlRight.Manager = this.barManager1;
this.barDockControlRight.Size = new System.Drawing.Size(0, 491);
//
// dbCurrent
//
this.dbCurrent.DbFilename = "";
this.dbCurrent.Dock = System.Windows.Forms.DockStyle.Left;
this.dbCurrent.FileLabel = "Current Database:";
this.dbCurrent.Location = new System.Drawing.Point(0, 46);
this.dbCurrent.Name = "dbCurrent";
this.dbCurrent.Size = new System.Drawing.Size(560, 491);
this.dbCurrent.TabIndex = 9;
//
// splitterControl1
//
this.splitterControl1.Location = new System.Drawing.Point(560, 46);
this.splitterControl1.Name = "splitterControl1";
this.splitterControl1.Size = new System.Drawing.Size(10, 491);
this.splitterControl1.TabIndex = 10;
this.splitterControl1.TabStop = false;
//
// dbLatest
//
this.dbLatest.DbFilename = "";
this.dbLatest.Dock = System.Windows.Forms.DockStyle.Fill;
this.dbLatest.FileLabel = "Latest Database:";
this.dbLatest.Location = new System.Drawing.Point(570, 46);
this.dbLatest.Name = "dbLatest";
this.dbLatest.Size = new System.Drawing.Size(603, 491);
this.dbLatest.TabIndex = 11;
//
// bbiGenerateDelta
//
this.bbiGenerateDelta.Caption = "Generate Delta SQL Script";
this.bbiGenerateDelta.Id = 26;
this.bbiGenerateDelta.Name = "bbiGenerateDelta";
this.bbiGenerateDelta.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.ToolbarItemClicked);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1173, 556);
this.Controls.Add(this.dbLatest);
this.Controls.Add(this.splitterControl1);
this.Controls.Add(this.dbCurrent);
this.Controls.Add(this.barDockControlLeft);
this.Controls.Add(this.barDockControlRight);
this.Controls.Add(this.barDockControlBottom);
this.Controls.Add(this.barDockControlTop);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Database Upgrade Tester";
((System.ComponentModel.ISupportInitialize)(this.barManager1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private DevExpress.XtraBars.BarManager barManager1;
private DevExpress.XtraBars.Bar bar1;
private DevExpress.XtraBars.Bar bar2;
private DevExpress.XtraBars.Bar bar3;
private DevExpress.XtraBars.BarDockControl barDockControlTop;
private DevExpress.XtraBars.BarDockControl barDockControlBottom;
private DevExpress.XtraBars.BarDockControl barDockControlLeft;
private DevExpress.XtraBars.BarDockControl barDockControlRight;
private UserControls.DatabasePanel dbLatest;
private DevExpress.XtraEditors.SplitterControl splitterControl1;
private UserControls.DatabasePanel dbCurrent;
private DevExpress.XtraBars.BarButtonItem bbiGenerateDelta;
}
}

View File

@@ -0,0 +1,19 @@
using DevExpress.XtraEditors;
using System.Windows.Forms;
namespace DbMigrateTester.Forms {
public partial class MainForm : DevExpress.XtraEditors.XtraForm {
public MainForm() {
InitializeComponent();
}
private void ToolbarItemClicked(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
if (e.Item.Equals(bbiGenerateDelta)) {
var comparer = new DbMigrate.DbComparer(dbCurrent.SqlDb, dbLatest.SqlDb);
comparer.Compare();
XtraMessageBox.Show(comparer.UpdateSqlScript, "Delta SQL Script", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="barManager1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -0,0 +1,232 @@
namespace DbMigrateTester.Forms.UserControls {
partial class DatabasePanel {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
DevExpress.XtraEditors.Controls.EditorButtonImageOptions editorButtonImageOptions2 = new DevExpress.XtraEditors.Controls.EditorButtonImageOptions();
DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject5 = new DevExpress.Utils.SerializableAppearanceObject();
DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject6 = new DevExpress.Utils.SerializableAppearanceObject();
DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject7 = new DevExpress.Utils.SerializableAppearanceObject();
DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject8 = new DevExpress.Utils.SerializableAppearanceObject();
this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
this.Root = new DevExpress.XtraLayout.LayoutControlGroup();
this.xtraTabControl1 = new DevExpress.XtraTab.XtraTabControl();
this.xtraTabPage1 = new DevExpress.XtraTab.XtraTabPage();
this.xtraTabPage2 = new DevExpress.XtraTab.XtraTabPage();
this.txtDbFilename = new DevExpress.XtraEditors.ButtonEdit();
this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
this.rtfSql = new System.Windows.Forms.RichTextBox();
this.treeList1 = new DevExpress.XtraTreeList.TreeList();
this.splitterControl1 = new DevExpress.XtraEditors.SplitterControl();
this.gridControl1 = new DevExpress.XtraGrid.GridControl();
this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
this.layoutControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.xtraTabControl1)).BeginInit();
this.xtraTabControl1.SuspendLayout();
this.xtraTabPage1.SuspendLayout();
this.xtraTabPage2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.txtDbFilename.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.treeList1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit();
this.SuspendLayout();
//
// layoutControl1
//
this.layoutControl1.Controls.Add(this.txtDbFilename);
this.layoutControl1.Dock = System.Windows.Forms.DockStyle.Top;
this.layoutControl1.Location = new System.Drawing.Point(0, 0);
this.layoutControl1.Name = "layoutControl1";
this.layoutControl1.Root = this.Root;
this.layoutControl1.Size = new System.Drawing.Size(643, 141);
this.layoutControl1.TabIndex = 0;
this.layoutControl1.Text = "layoutControl1";
//
// Root
//
this.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
this.Root.GroupBordersVisible = false;
this.Root.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
this.layoutControlItem1,
this.emptySpaceItem1});
this.Root.Name = "Root";
this.Root.Size = new System.Drawing.Size(643, 141);
this.Root.TextVisible = false;
//
// xtraTabControl1
//
this.xtraTabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.xtraTabControl1.Location = new System.Drawing.Point(0, 141);
this.xtraTabControl1.Name = "xtraTabControl1";
this.xtraTabControl1.SelectedTabPage = this.xtraTabPage1;
this.xtraTabControl1.Size = new System.Drawing.Size(643, 468);
this.xtraTabControl1.TabIndex = 1;
this.xtraTabControl1.TabPages.AddRange(new DevExpress.XtraTab.XtraTabPage[] {
this.xtraTabPage1,
this.xtraTabPage2});
//
// xtraTabPage1
//
this.xtraTabPage1.Controls.Add(this.gridControl1);
this.xtraTabPage1.Controls.Add(this.splitterControl1);
this.xtraTabPage1.Controls.Add(this.treeList1);
this.xtraTabPage1.Name = "xtraTabPage1";
this.xtraTabPage1.Size = new System.Drawing.Size(641, 442);
this.xtraTabPage1.Text = "Structure";
//
// xtraTabPage2
//
this.xtraTabPage2.Controls.Add(this.rtfSql);
this.xtraTabPage2.Name = "xtraTabPage2";
this.xtraTabPage2.Size = new System.Drawing.Size(641, 442);
this.xtraTabPage2.Text = "SQL Text";
//
// txtDbFilename
//
this.txtDbFilename.Location = new System.Drawing.Point(82, 12);
this.txtDbFilename.Name = "txtDbFilename";
this.txtDbFilename.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(),
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Clear, "", -1, true, false, false, editorButtonImageOptions2, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), serializableAppearanceObject5, serializableAppearanceObject6, serializableAppearanceObject7, serializableAppearanceObject8, "", null, null, DevExpress.Utils.ToolTipAnchor.Default)});
this.txtDbFilename.Size = new System.Drawing.Size(549, 22);
this.txtDbFilename.StyleController = this.layoutControl1;
this.txtDbFilename.TabIndex = 4;
this.txtDbFilename.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(this.DbFilename_ButtonClick);
//
// layoutControlItem1
//
this.layoutControlItem1.Control = this.txtDbFilename;
this.layoutControlItem1.Location = new System.Drawing.Point(0, 0);
this.layoutControlItem1.Name = "layoutControlItem1";
this.layoutControlItem1.Size = new System.Drawing.Size(623, 26);
this.layoutControlItem1.Text = "Database:";
this.layoutControlItem1.TextSize = new System.Drawing.Size(58, 16);
//
// emptySpaceItem1
//
this.emptySpaceItem1.AllowHotTrack = false;
this.emptySpaceItem1.Location = new System.Drawing.Point(0, 26);
this.emptySpaceItem1.Name = "emptySpaceItem1";
this.emptySpaceItem1.Size = new System.Drawing.Size(623, 95);
this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
//
// rtfSql
//
this.rtfSql.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtfSql.Font = new System.Drawing.Font("Lucida Console", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.rtfSql.Location = new System.Drawing.Point(0, 0);
this.rtfSql.Name = "rtfSql";
this.rtfSql.ReadOnly = true;
this.rtfSql.Size = new System.Drawing.Size(641, 442);
this.rtfSql.TabIndex = 0;
this.rtfSql.Text = "";
//
// treeList1
//
this.treeList1.Dock = System.Windows.Forms.DockStyle.Left;
this.treeList1.Location = new System.Drawing.Point(0, 0);
this.treeList1.Name = "treeList1";
this.treeList1.OptionsBehavior.Editable = false;
this.treeList1.OptionsBehavior.ReadOnly = true;
this.treeList1.OptionsView.ShowColumns = false;
this.treeList1.OptionsView.ShowHorzLines = false;
this.treeList1.OptionsView.ShowIndicator = false;
this.treeList1.OptionsView.ShowVertLines = false;
this.treeList1.Size = new System.Drawing.Size(164, 442);
this.treeList1.TabIndex = 0;
//
// splitterControl1
//
this.splitterControl1.Location = new System.Drawing.Point(164, 0);
this.splitterControl1.Name = "splitterControl1";
this.splitterControl1.Size = new System.Drawing.Size(10, 442);
this.splitterControl1.TabIndex = 1;
this.splitterControl1.TabStop = false;
//
// gridControl1
//
this.gridControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridControl1.Location = new System.Drawing.Point(174, 0);
this.gridControl1.MainView = this.gridView1;
this.gridControl1.Name = "gridControl1";
this.gridControl1.Size = new System.Drawing.Size(467, 442);
this.gridControl1.TabIndex = 2;
this.gridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
this.gridView1});
//
// gridView1
//
this.gridView1.GridControl = this.gridControl1;
this.gridView1.Name = "gridView1";
this.gridView1.OptionsView.ShowGroupPanel = false;
this.gridView1.OptionsView.ShowHorizontalLines = DevExpress.Utils.DefaultBoolean.False;
this.gridView1.OptionsView.ShowIndicator = false;
this.gridView1.OptionsView.ShowVerticalLines = DevExpress.Utils.DefaultBoolean.False;
//
// DatabasePanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.xtraTabControl1);
this.Controls.Add(this.layoutControl1);
this.Name = "DatabasePanel";
this.Size = new System.Drawing.Size(643, 609);
((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).EndInit();
this.layoutControl1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.Root)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.xtraTabControl1)).EndInit();
this.xtraTabControl1.ResumeLayout(false);
this.xtraTabPage1.ResumeLayout(false);
this.xtraTabPage2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.txtDbFilename.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.treeList1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DevExpress.XtraLayout.LayoutControl layoutControl1;
private DevExpress.XtraLayout.LayoutControlGroup Root;
private DevExpress.XtraEditors.ButtonEdit txtDbFilename;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1;
private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1;
private DevExpress.XtraTab.XtraTabControl xtraTabControl1;
private DevExpress.XtraTab.XtraTabPage xtraTabPage1;
private DevExpress.XtraTab.XtraTabPage xtraTabPage2;
private System.Windows.Forms.RichTextBox rtfSql;
private DevExpress.XtraGrid.GridControl gridControl1;
private DevExpress.XtraGrid.Views.Grid.GridView gridView1;
private DevExpress.XtraEditors.SplitterControl splitterControl1;
private DevExpress.XtraTreeList.TreeList treeList1;
}
}

View File

@@ -0,0 +1,99 @@
using DbMigrate;
using System;
using System.ComponentModel;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DbMigrateTester.Forms.UserControls {
public partial class DatabasePanel : DevExpress.XtraEditors.XtraUserControl {
public string DbFilename {
get { return txtDbFilename.Text; }
set {
txtDbFilename.Text = value;
if (string.IsNullOrEmpty(value)) {
enableDbFilename();
} else {
disableDbFilename();
}
}
}
public string Sql => rtfSql.Text;
public SqlDatabase SqlDb { get; private set; }
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string FileLabel {
get { return layoutControlItem1.Text; }
set { layoutControlItem1.Text = value; }
}
public DatabasePanel() {
InitializeComponent();
}
private async void DbFilename_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) {
try {
if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis) {
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 = "Select Database File"
};
if (dlg.ShowDialog() == DialogResult.OK) {
await LoadDatabase(dlg.FileName);
}
} else if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Clear) {
txtDbFilename.Text = "";
rtfSql.Text = "";
treeList1.DataSource = null;
enableDbFilename();
}
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
}
private void enableDbFilename(bool enabled = true) {
txtDbFilename.ReadOnly = !enabled;
txtDbFilename.Properties.Buttons[0].Visible = enabled;
txtDbFilename.Properties.Buttons[1].Visible = !enabled;
}
private void disableDbFilename() {
enableDbFilename(false);
}
public async Task LoadDatabase(string filename) {
DbFilename = filename;
disableDbFilename();
SqlDatabase db = new SqlDatabase();
if (Path.GetExtension(filename).ToLower() == ".sql" || Path.GetExtension(filename).ToLower() == ".txt") {
// Load data from SQL file
string sql = File.ReadAllText(filename);
MatchCollection mc = Regex.Matches(sql, "^(CREATE TABLE( IF NOT EXISTS)? (\\w*).*\\);)", RegexOptions.Multiline | RegexOptions.Singleline);
db.LoadSql(sql);
rtfSql.Text = db.SqlScript;
} else if (Path.GetExtension(filename).ToLower() == ".sqlite" || Path.GetExtension(filename).ToLower() == ".db") {
// Load data from SQLite database file
string sql = await db.BuildSql("Data Source=" + filename + "; Version=3;");
rtfSql.Text = sql;
} else {
MessageBox.Show("Unsupported database file type: " + Path.GetExtension(filename), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (db.Tables != null && db.Tables.Count > 0) {
treeList1.Columns.Clear();
treeList1.Columns.Add(new DevExpress.XtraTreeList.Columns.TreeListColumn() { Caption = "Table Name", Visible = true, FieldName = "TableName" });
treeList1.DataSource = db.Tables;
}
SqlDb = db;
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>