miniSql

创建
zgc123@gmail.com authored at 11/19/2023 1:40:15 AM
6136600
Tree
0 Parent(s)
Summary: 4 changed files with 123 additions and 0 deletions.
Added +18 -0
Added +18 -0
Added +73 -0
Added +14 -0
Added +18 -0
diff --git a/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/RunExportSqlCe40Command.cs b/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/RunExportSqlCe40Command.cs
new file mode 100644
index 0000000..2450129
--- /dev/null
+++ b/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/RunExportSqlCe40Command.cs
@@ -0,0 +1,18 @@
+using MiniSqlQuery.ExternalTools.Plugin.Properties;
+
+namespace MiniSqlQuery.ExternalTools.Plugin.Commands
+{
+    public class RunExportSqlCe40Command : RunExportSqlCeCommandBase
+    {
+        public RunExportSqlCe40Command()
+            : base("Run 'Export SQL CE 4.0' Tool")
+        {
+            SmallImage = Resources.data_out.ToBitmap();
+        }
+
+        public override void Execute()
+        {
+            RunExportSqlCe("ExportSqlCE40.exe");
+        }
+    }
+}
\ No newline at end of file
Added +18 -0
diff --git a/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/RunExportSqlCeCommand.cs b/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/RunExportSqlCeCommand.cs
new file mode 100644
index 0000000..a79bdf3
--- /dev/null
+++ b/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/RunExportSqlCeCommand.cs
@@ -0,0 +1,18 @@
+using MiniSqlQuery.ExternalTools.Plugin.Properties;
+
+namespace MiniSqlQuery.ExternalTools.Plugin.Commands
+{
+    public class RunExportSqlCeCommand : RunExportSqlCeCommandBase
+    {
+        public RunExportSqlCeCommand()
+            : base("Run 'Export SQL CE 3.5' Tool")
+        {
+            SmallImage = Resources.data_out.ToBitmap();
+        }
+
+        public override void Execute()
+        {
+            RunExportSqlCe("ExportSqlCE.exe");
+        }
+    }
+}
\ No newline at end of file
Added +73 -0
diff --git a/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/RunExportSqlCeCommandBase.cs b/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/RunExportSqlCeCommandBase.cs
new file mode 100644
index 0000000..ccc4daa
--- /dev/null
+++ b/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/RunExportSqlCeCommandBase.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using MiniSqlQuery.Core;
+using MiniSqlQuery.Core.Commands;
+using WeifenLuo.WinFormsUI.Docking;
+
+namespace MiniSqlQuery.ExternalTools.Plugin.Commands
+{
+    public class RunExportSqlCeCommandBase : CommandBase
+    {
+        public RunExportSqlCeCommandBase(string name)
+            : base(name)
+        {
+        }
+
+        protected void RunExportSqlCe(string fileName)
+        {
+            string file = Path.GetTempFileName() + ".sql";
+            string conn = Settings.ConnectionDefinition.ConnectionString.Replace(@"""", @"\""");
+            string arguments = string.Format("\"{0}\" \"{1}\"", conn, file);
+
+            var tool = new Process();
+            tool.StartInfo.FileName = fileName;
+            tool.StartInfo.Arguments = arguments;
+            tool.StartInfo.UseShellExecute = false;
+            tool.StartInfo.RedirectStandardOutput = true;
+            tool.StartInfo.RedirectStandardError = true;
+
+            if (tool.Start())
+            {
+                string output = tool.StandardOutput.ReadToEnd();
+                string err = tool.StandardError.ReadToEnd();
+
+                if (!string.IsNullOrEmpty(err))
+                {
+                    output = "ERROR:" + Environment.NewLine + err + Environment.NewLine + output;
+                }
+
+                if (File.Exists(file))
+                {
+                    IEditor editor = Services.Resolve<IFileEditorResolver>().ResolveEditorInstance(file);
+                    editor.FileName = file;
+                    editor.LoadFile();
+                    HostWindow.DisplayDockedForm(editor as DockContent);
+                }
+                else
+                {
+                    var sb = new StringBuilder();
+                    sb.AppendLine("Error generating the output file.");
+                    sb.AppendLine("Process Info:");
+                    sb.AppendFormat("  File Name: {0}", tool.StartInfo.FileName);
+                    sb.AppendLine();
+                    sb.AppendFormat("  Arguments: {0}", tool.StartInfo.Arguments);
+                    sb.AppendLine();
+                    sb.AppendLine(output);
+                    output = sb.ToString();
+                }
+
+                if (!string.IsNullOrEmpty(output))
+                {
+                    HostWindow.DisplaySimpleMessageBox(null, output, fileName + " Output");
+                }
+            }
+        }
+
+        public override void Execute()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}
\ No newline at end of file
Added +14 -0
diff --git a/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/ShowSiteForExportSqlCeCommand.cs b/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/ShowSiteForExportSqlCeCommand.cs
new file mode 100644
index 0000000..f5cf053
--- /dev/null
+++ b/minisqlquery-master/src/Contrib/MiniSqlQuery.ExternalTools.Plugin/Commands/ShowSiteForExportSqlCeCommand.cs
@@ -0,0 +1,14 @@
+using MiniSqlQuery.Core.Commands;
+using MiniSqlQuery.ExternalTools.Plugin.Properties;
+
+namespace MiniSqlQuery.ExternalTools.Plugin.Commands
+{
+    public class ShowSiteForExportSqlCeCommand
+        : ShowUrlCommand
+    {
+        public ShowSiteForExportSqlCeCommand()
+            : base("&Export SQL CE site (https://github.com/ErikEJ/SqlCeToolbox/)", "https://github.com/ErikEJ/SqlCeToolbox/", Resources.data_out.ToBitmap())
+        {
+        }
+    }
+}
\ No newline at end of file