diff --git a/ConvertExecuteSQL/App.config b/ConvertExecuteSQL/App.config index 731f6de..d1428ad 100644 --- a/ConvertExecuteSQL/App.config +++ b/ConvertExecuteSQL/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/ConvertExecuteSQL/ConvertExecuteSQL.csproj b/ConvertExecuteSQL/ConvertExecuteSQL.csproj index 127c3ea..8e5df3d 100644 --- a/ConvertExecuteSQL/ConvertExecuteSQL.csproj +++ b/ConvertExecuteSQL/ConvertExecuteSQL.csproj @@ -9,7 +9,7 @@ Properties ConvertExecuteSQL ConvertExecuteSQL - v4.6.1 + v4.5 512 true 發行\ @@ -27,6 +27,7 @@ false false true + AnyCPU @@ -80,6 +81,7 @@ True Resources.resx + True SettingsSingleFileGenerator diff --git a/ConvertExecuteSQL/Form1.cs b/ConvertExecuteSQL/Form1.cs index 2032ace..941f95d 100644 --- a/ConvertExecuteSQL/Form1.cs +++ b/ConvertExecuteSQL/Form1.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; @@ -76,6 +77,9 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } + + Regex regex = new Regex("exec (sp_executesql|sys.sp_executesql)", RegexOptions.IgnoreCase); + void DisplayClipboardData() { try @@ -86,8 +90,36 @@ void DisplayClipboardData() if (iData.GetDataPresent(DataFormats.Text)) { var strSQL = (string)iData.GetData(DataFormats.Text); - if (!strSQL.Contains("exec sp_executesql") || strSQL.Trim() == "exec sp_executesql") return; - var newSql = ConvertSql(strSQL); + + if (!regex.IsMatch(strSQL)) + { + return; + } + + //if (!strSQL.Contains("exec sp_executesql") || strSQL.Trim() == "exec sp_executesql") return; + + string newSql = string.Empty; + + //string[] batch = strSQL.Split(new[] { "Go", "go", "GO" }, StringSplitOptions.None); + + //使用 正则表达式 拆分 批量操作 + //Regex regexs = new Regex(@"Go$"); + + var options = System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline | System.Text.RegularExpressions.RegexOptions.Singleline | System.Text.RegularExpressions.RegexOptions.CultureInvariant; + + + + Regex regexs = new Regex(@"\bgo\b", options); + + string[] batch = regexs.Split(strSQL); + + + foreach (var item in batch) + { + newSql += ConvertSql(item) + "\n GO \n"; + } + + Clipboard.SetText(newSql); } } @@ -98,6 +130,8 @@ void DisplayClipboardData() private static string ConvertSql(string origSql) { + if (origSql.Trim() == string.Empty) { return string.Empty; } + var tableParameterSql = string.Empty; var indexOf = origSql.IndexOf("exec sp_executesql"); // origSql.Substring(0, origSql.IndexOf("exec sp_executesql") - 1); if (indexOf > 0) diff --git a/ConvertExecuteSQL/Properties/Resources.Designer.cs b/ConvertExecuteSQL/Properties/Resources.Designer.cs index ab0bc99..2f73b2f 100644 --- a/ConvertExecuteSQL/Properties/Resources.Designer.cs +++ b/ConvertExecuteSQL/Properties/Resources.Designer.cs @@ -1,69 +1,61 @@ //------------------------------------------------------------------------------ // -// 這段程式碼是由工具產生的。 -// 執行階段版本:4.0.30319.42000 +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 // -// 變更這個檔案可能會導致不正確的行為,而且如果已重新產生 -// 程式碼,則會遺失變更。 +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ -namespace ConvertExecuteSQL.Properties -{ - - +namespace ConvertExecuteSQL.Properties { + using System; + + /// - /// 用於查詢當地語系化字串等的強類型資源類別 + /// 一个强类型的资源类,用于查找本地化的字符串等。 /// - // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder - // 類別透過 ResGen 或 Visual Studio 這類工具產生。 - // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen - // (利用 /str 選項),或重建您的 VS 專案。 + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// - /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 + /// 返回此类使用的缓存的 ResourceManager 实例。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ConvertExecuteSQL.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// - /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 - /// 使用這個強類型資源類別的資源查閱。 + /// 使用此强类型资源类,为所有资源查找 + /// 重写当前线程的 CurrentUICulture 属性。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/ConvertExecuteSQL/Properties/Settings.Designer.cs b/ConvertExecuteSQL/Properties/Settings.Designer.cs index 0a99027..12bbeec 100644 --- a/ConvertExecuteSQL/Properties/Settings.Designer.cs +++ b/ConvertExecuteSQL/Properties/Settings.Designer.cs @@ -1,28 +1,24 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ -namespace ConvertExecuteSQL.Properties -{ - - +namespace ConvertExecuteSQL.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.exe b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.exe new file mode 100644 index 0000000..6feb20d Binary files /dev/null and b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.exe differ diff --git a/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.exe.config b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.exe.config new file mode 100644 index 0000000..d1428ad --- /dev/null +++ b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.exe.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.pdb b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.pdb new file mode 100644 index 0000000..f75e195 Binary files /dev/null and b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.pdb differ diff --git a/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.vshost.exe b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.vshost.exe new file mode 100644 index 0000000..666c0af Binary files /dev/null and b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.vshost.exe differ diff --git a/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.vshost.exe.config b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.vshost.exe.config new file mode 100644 index 0000000..d1428ad --- /dev/null +++ b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.vshost.exe.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.vshost.exe.manifest b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/ConvertExecuteSQL/bin/Debug/ConvertExecuteSQL.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.Form1.resources b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.Form1.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.Form1.resources differ diff --git a/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.Properties.Resources.resources b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.Properties.Resources.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.Properties.Resources.resources differ diff --git a/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.csproj.FileListAbsolute.txt b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..4acb527 --- /dev/null +++ b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.csproj.FileListAbsolute.txt @@ -0,0 +1,9 @@ +D:\360极速浏览器下载\参数化提取SQL\分析\ConvertExecuteSQL\ConvertExecuteSQL\bin\Debug\ConvertExecuteSQL.exe.config +D:\360极速浏览器下载\参数化提取SQL\分析\ConvertExecuteSQL\ConvertExecuteSQL\bin\Debug\ConvertExecuteSQL.exe +D:\360极速浏览器下载\参数化提取SQL\分析\ConvertExecuteSQL\ConvertExecuteSQL\bin\Debug\ConvertExecuteSQL.pdb +D:\360极速浏览器下载\参数化提取SQL\分析\ConvertExecuteSQL\ConvertExecuteSQL\obj\Debug\ConvertExecuteSQL.csprojResolveAssemblyReference.cache +D:\360极速浏览器下载\参数化提取SQL\分析\ConvertExecuteSQL\ConvertExecuteSQL\obj\Debug\ConvertExecuteSQL.Form1.resources +D:\360极速浏览器下载\参数化提取SQL\分析\ConvertExecuteSQL\ConvertExecuteSQL\obj\Debug\ConvertExecuteSQL.Properties.Resources.resources +D:\360极速浏览器下载\参数化提取SQL\分析\ConvertExecuteSQL\ConvertExecuteSQL\obj\Debug\ConvertExecuteSQL.csproj.GenerateResource.Cache +D:\360极速浏览器下载\参数化提取SQL\分析\ConvertExecuteSQL\ConvertExecuteSQL\obj\Debug\ConvertExecuteSQL.exe +D:\360极速浏览器下载\参数化提取SQL\分析\ConvertExecuteSQL\ConvertExecuteSQL\obj\Debug\ConvertExecuteSQL.pdb diff --git a/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.csproj.GenerateResource.Cache b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.csproj.GenerateResource.Cache new file mode 100644 index 0000000..a86e8af Binary files /dev/null and b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.csproj.GenerateResource.Cache differ diff --git a/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.csprojResolveAssemblyReference.cache b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..b77f94f Binary files /dev/null and b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.csprojResolveAssemblyReference.cache differ diff --git a/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.exe b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.exe new file mode 100644 index 0000000..6feb20d Binary files /dev/null and b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.exe differ diff --git a/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.pdb b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.pdb new file mode 100644 index 0000000..f75e195 Binary files /dev/null and b/ConvertExecuteSQL/obj/Debug/ConvertExecuteSQL.pdb differ diff --git a/ConvertExecuteSQL/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/ConvertExecuteSQL/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..ed6d58a Binary files /dev/null and b/ConvertExecuteSQL/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/ConvertExecuteSQL/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/ConvertExecuteSQL/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..e4d0993 Binary files /dev/null and b/ConvertExecuteSQL/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/ConvertExecuteSQL/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll b/ConvertExecuteSQL/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll new file mode 100644 index 0000000..2717bdf Binary files /dev/null and b/ConvertExecuteSQL/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll differ diff --git a/ConvertExecuteSQL/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/ConvertExecuteSQL/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/ConvertExecuteSQL/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/ConvertExecuteSQL/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/ConvertExecuteSQL/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/ConvertExecuteSQL/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29