diff --git a/Libraries.sln b/Libraries.sln index e90be5b..ff00f3f 100644 --- a/Libraries.sln +++ b/Libraries.sln @@ -5,6 +5,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utility", "Utility\Utility. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestLibrary", "TestLibrary\TestLibrary.csproj", "{4C10C60B-BD24-4940-9FAE-D0891FD8A241}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApp", "WebApp\WebApp.csproj", "{53842398-D053-4B2E-94C0-152FC7DA2DA7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -19,6 +21,10 @@ Global {4C10C60B-BD24-4940-9FAE-D0891FD8A241}.Debug|Any CPU.Build.0 = Debug|Any CPU {4C10C60B-BD24-4940-9FAE-D0891FD8A241}.Release|Any CPU.ActiveCfg = Release|Any CPU {4C10C60B-BD24-4940-9FAE-D0891FD8A241}.Release|Any CPU.Build.0 = Release|Any CPU + {53842398-D053-4B2E-94C0-152FC7DA2DA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {53842398-D053-4B2E-94C0-152FC7DA2DA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {53842398-D053-4B2E-94C0-152FC7DA2DA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {53842398-D053-4B2E-94C0-152FC7DA2DA7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Libraries.v11.suo b/Libraries.v11.suo index c2808a2..62d2015 100644 Binary files a/Libraries.v11.suo and b/Libraries.v11.suo differ diff --git a/TestLibrary/UnitTest.cs b/TestLibrary/UnitTest.cs index 443ca22..31a7c5c 100644 --- a/TestLibrary/UnitTest.cs +++ b/TestLibrary/UnitTest.cs @@ -4,6 +4,7 @@ using System.Data.SqlClient; using Microsoft.VisualStudio.TestTools.UnitTesting; using Utility.Data; +using Utility.WebForm; namespace TestLibrary { @@ -49,6 +50,17 @@ public void NonQuery() string delete_sql = args.BuildDeleteSql(TableName); conn.ExecuteNonQuery(delete_sql, args); } + + [TestMethod] + public void ConvertToParameter() + { + IDataParameter param = ControlTool.ConvertToParameter("Name$lr", "J"); + param.ParameterName = @"@Name"; + SqlConnection conn = new SqlConnection(ConnStr); + var args = new IDataParameter[] { param }; + string insert_sql = args.BuildInsertSql(TableName); + conn.ExecuteNonQuery(insert_sql, args); + } } } diff --git a/TestLibrary/bin/Debug/TestLibrary.exe b/TestLibrary/bin/Debug/TestLibrary.exe index 3d8bfbb..9683ecb 100644 Binary files a/TestLibrary/bin/Debug/TestLibrary.exe and b/TestLibrary/bin/Debug/TestLibrary.exe differ diff --git a/TestLibrary/bin/Debug/TestLibrary.pdb b/TestLibrary/bin/Debug/TestLibrary.pdb index cc7b1c3..fffae7b 100644 Binary files a/TestLibrary/bin/Debug/TestLibrary.pdb and b/TestLibrary/bin/Debug/TestLibrary.pdb differ diff --git a/TestLibrary/bin/Debug/Utility.dll b/TestLibrary/bin/Debug/Utility.dll index 4e3f279..2b47528 100644 Binary files a/TestLibrary/bin/Debug/Utility.dll and b/TestLibrary/bin/Debug/Utility.dll differ diff --git a/TestLibrary/bin/Debug/Utility.pdb b/TestLibrary/bin/Debug/Utility.pdb index 63b6035..3006b0a 100644 Binary files a/TestLibrary/bin/Debug/Utility.pdb and b/TestLibrary/bin/Debug/Utility.pdb differ diff --git a/TestLibrary/bin/Debug/Utility.xml b/TestLibrary/bin/Debug/Utility.xml index 60fb26e..e072b35 100644 --- a/TestLibrary/bin/Debug/Utility.xml +++ b/TestLibrary/bin/Debug/Utility.xml @@ -743,6 +743,11 @@ 返回已经添加到集合里 + + + ParameterName的前缀 + + SQL语句 @@ -881,5 +886,14 @@ 控件工具 + + + + + + + + + diff --git a/TestLibrary/obj/Debug/TestLibrary.csprojResolveAssemblyReference.cache b/TestLibrary/obj/Debug/TestLibrary.csprojResolveAssemblyReference.cache index 8f54893..dc3b85a 100644 Binary files a/TestLibrary/obj/Debug/TestLibrary.csprojResolveAssemblyReference.cache and b/TestLibrary/obj/Debug/TestLibrary.csprojResolveAssemblyReference.cache differ diff --git a/TestLibrary/obj/Debug/TestLibrary.exe b/TestLibrary/obj/Debug/TestLibrary.exe index 3d8bfbb..9683ecb 100644 Binary files a/TestLibrary/obj/Debug/TestLibrary.exe and b/TestLibrary/obj/Debug/TestLibrary.exe differ diff --git a/TestLibrary/obj/Debug/TestLibrary.pdb b/TestLibrary/obj/Debug/TestLibrary.pdb index cc7b1c3..fffae7b 100644 Binary files a/TestLibrary/obj/Debug/TestLibrary.pdb and b/TestLibrary/obj/Debug/TestLibrary.pdb differ diff --git a/Utility/Readme.txt b/Utility/Readme.txt index 8ca18d0..da313d2 100644 --- a/Utility/Readme.txt +++ b/Utility/Readme.txt @@ -8,4 +8,5 @@ if (String.IsNullOrWhiteSpace(IDataParameter.ParameterName)) else { SourceColumn = "FieldName Comparer"; // 空格是必须的 -} \ No newline at end of file +} + diff --git a/Utility/Utility.csproj b/Utility/Utility.csproj index a29ecd4..b863ce8 100644 --- a/Utility/Utility.csproj +++ b/Utility/Utility.csproj @@ -35,6 +35,7 @@ + diff --git a/Utility/WebForm/ControlTool.cs b/Utility/WebForm/ControlTool.cs index f5a231c..54bc7dc 100644 --- a/Utility/WebForm/ControlTool.cs +++ b/Utility/WebForm/ControlTool.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -11,8 +12,97 @@ namespace Utility.WebForm /// public static class ControlTool { + /// + /// + /// + /// + /// + /// + /// + public static T ConvertToParameter(string name, object value) where T : IDataParameter, new() + { + T t = new T(); + var array = name.Split('$'); + t.SourceColumn = array[0]; + t.Value = value; + if (array.Length >= 2) + Mapping(t, array[1]); + else + Mapping(t, String.Empty); + return t; + } + private static void Mapping(IDataParameter Param, string name) + { + name = name ?? String.Empty; + name = name.ToLower().Trim(); + if (name.Length == 1) + MappingLength1(Param, name); + else if(name.Length == 2) + MappingLength2(Param, name); + else if (name.Length == 3) + MappingLength3(Param, name); + else + MappingLength0(Param); + } + private static void MappingLength0(IDataParameter Param) + { + Param.SourceColumn += " LIKE"; + } + + private static void MappingLength3(IDataParameter Param, string name) + { + switch (name) + { + case "lte": + Param.SourceColumn += " <="; + break; + case "neq": + Param.SourceColumn += " <>"; + break; + case "gte": + Param.SourceColumn += " >="; + break; + } + } + + private static void MappingLength2(IDataParameter Param, string name) + { + switch (name) + { + case "lt": + Param.SourceColumn += " <"; + break; + case "eq": + Param.SourceColumn += " ="; + break; + case "gt": + Param.SourceColumn += " ="; + break; + case "lr": + Param.SourceColumn += " LIKE"; + string value = Param.Value == null ? String.Empty : Param.Value.ToString(); + Param.Value = String.Format("%{0}%", value); + break; + } + } + + private static void MappingLength1(IDataParameter Param, string name) + { + string value = Param.Value == null ? String.Empty : Param.Value.ToString(); + Param.SourceColumn += " LIKE"; + switch (name) + { + case "l": + value = String.Format("%{0}", value); + break; + case "r": + value = String.Format("{0}%", value); + break; + } + Param.Value = value; + } } } diff --git a/Utility/bin/Debug/Utility.XML b/Utility/bin/Debug/Utility.XML index 60fb26e..e072b35 100644 --- a/Utility/bin/Debug/Utility.XML +++ b/Utility/bin/Debug/Utility.XML @@ -743,6 +743,11 @@ 返回已经添加到集合里 + + + ParameterName的前缀 + + SQL语句 @@ -881,5 +886,14 @@ 控件工具 + + + + + + + + + diff --git a/Utility/bin/Debug/Utility.dll b/Utility/bin/Debug/Utility.dll index 4e3f279..2b47528 100644 Binary files a/Utility/bin/Debug/Utility.dll and b/Utility/bin/Debug/Utility.dll differ diff --git a/Utility/bin/Debug/Utility.pdb b/Utility/bin/Debug/Utility.pdb index 63b6035..3006b0a 100644 Binary files a/Utility/bin/Debug/Utility.pdb and b/Utility/bin/Debug/Utility.pdb differ diff --git a/Utility/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Utility/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index b6ad11e..c2e95a9 100644 Binary files a/Utility/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/Utility/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Utility/obj/Debug/Utility.csproj.FileListAbsolute.txt b/Utility/obj/Debug/Utility.csproj.FileListAbsolute.txt index db90ba8..0dcbe0e 100644 --- a/Utility/obj/Debug/Utility.csproj.FileListAbsolute.txt +++ b/Utility/obj/Debug/Utility.csproj.FileListAbsolute.txt @@ -25,3 +25,4 @@ I:\CSharpLibrary\Utility\bin\Debug\Utility.pdb I:\CSharpLibrary\Utility\obj\Debug\Utility.csprojResolveAssemblyReference.cache I:\CSharpLibrary\Utility\obj\Debug\Utility.dll I:\CSharpLibrary\Utility\obj\Debug\Utility.pdb +F:\WorkSpace\Github\CSharpLibrary\Utility\obj\Debug\Utility.csprojResolveAssemblyReference.cache diff --git a/Utility/obj/Debug/Utility.csprojResolveAssemblyReference.cache b/Utility/obj/Debug/Utility.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..363c3e4 Binary files /dev/null and b/Utility/obj/Debug/Utility.csprojResolveAssemblyReference.cache differ diff --git a/Utility/obj/Debug/Utility.dll b/Utility/obj/Debug/Utility.dll index 4e3f279..2b47528 100644 Binary files a/Utility/obj/Debug/Utility.dll and b/Utility/obj/Debug/Utility.dll differ diff --git a/Utility/obj/Debug/Utility.pdb b/Utility/obj/Debug/Utility.pdb index 63b6035..3006b0a 100644 Binary files a/Utility/obj/Debug/Utility.pdb and b/Utility/obj/Debug/Utility.pdb differ diff --git a/WebApp/Default.aspx b/WebApp/Default.aspx new file mode 100644 index 0000000..1c9f684 --- /dev/null +++ b/WebApp/Default.aspx @@ -0,0 +1,18 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApp.Default" %> + + + + + + + + + +
+
+ <%=DateTime.Now.ToString() %> + <%=ParameterDirection.Input %> +
+
+ + diff --git a/WebApp/Default.aspx.cs b/WebApp/Default.aspx.cs new file mode 100644 index 0000000..8332d48 --- /dev/null +++ b/WebApp/Default.aspx.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebApp +{ + public partial class Default : System.Web.UI.Page + { + public const string LANGUAGE = "zh-CN"; + + protected override void InitializeCulture() + { + this.Culture = LANGUAGE; + this.UICulture = LANGUAGE; + CultureInfo ci = System.Globalization.CultureInfo.CreateSpecificCulture(LANGUAGE); + ci.DateTimeFormat.DateSeparator = "|"; + System.Threading.Thread.CurrentThread.CurrentCulture = ci; + System.Threading.Thread.CurrentThread.CurrentUICulture = ci; + } + + protected void Page_Load(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/WebApp/Default.aspx.designer.cs b/WebApp/Default.aspx.designer.cs new file mode 100644 index 0000000..f8a8b00 --- /dev/null +++ b/WebApp/Default.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace WebApp { + + + public partial class Default { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + } +} diff --git a/WebApp/Language.cs b/WebApp/Language.cs new file mode 100644 index 0000000..5afcb32 --- /dev/null +++ b/WebApp/Language.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Web; + +namespace WebApp +{ + public class Language : IHttpModule + { + public const string LANGUAGE = "zh-CN"; + + public void Dispose() + { + //此处放置清除代码。 + } + + public void Init(HttpApplication context) + { + context.PostAuthenticateRequest += context_PostAuthenticateRequest; + } + + void context_PostAuthenticateRequest(object sender, EventArgs e) + { + var context = HttpContext.Current; + CultureInfo ci = System.Globalization.CultureInfo.CreateSpecificCulture(LANGUAGE); + ci.DateTimeFormat.DateSeparator = "|"; + System.Threading.Thread.CurrentThread.CurrentCulture = ci; + System.Threading.Thread.CurrentThread.CurrentUICulture = ci; + } + + } +} diff --git a/WebApp/Properties/AssemblyInfo.cs b/WebApp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d684dc4 --- /dev/null +++ b/WebApp/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过下列特性集 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("WebApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Sky123.Org")] +[assembly: AssemblyProduct("WebApp")] +[assembly: AssemblyCopyright("版权所有(C) Sky123.Org 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的某个类型, +// 请针对该类型将 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("78e6c0f2-767e-4df9-8504-418d79f0e704")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值, +// 方法是按如下所示使用“*”: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WebApp/Web.Debug.config b/WebApp/Web.Debug.config new file mode 100644 index 0000000..a26200b --- /dev/null +++ b/WebApp/Web.Debug.config @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git a/WebApp/Web.Release.config b/WebApp/Web.Release.config new file mode 100644 index 0000000..59941db --- /dev/null +++ b/WebApp/Web.Release.config @@ -0,0 +1,32 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/WebApp/Web.config b/WebApp/Web.config new file mode 100644 index 0000000..bbfbaae --- /dev/null +++ b/WebApp/Web.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/WebApp/WebApp.csproj b/WebApp/WebApp.csproj new file mode 100644 index 0000000..4138e0c --- /dev/null +++ b/WebApp/WebApp.csproj @@ -0,0 +1,114 @@ + + + + + Debug + AnyCPU + + + 2.0 + {53842398-D053-4B2E-94C0-152FC7DA2DA7} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + WebApp + WebApp + v4.5 + true + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + Default.aspx + ASPXCodeBehind + + + Default.aspx + + + + + + + Web.config + + + Web.config + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 0 + / + http://localhost:1086/ + False + False + + + False + + + + + + \ No newline at end of file diff --git a/WebApp/WebApp.csproj.user b/WebApp/WebApp.csproj.user new file mode 100644 index 0000000..dedb3c9 --- /dev/null +++ b/WebApp/WebApp.csproj.user @@ -0,0 +1,28 @@ + + + + + + + + + CurrentPage + True + False + False + False + + + + + + + + + False + True + + + + + \ No newline at end of file diff --git a/WebApp/bin/WebApp.dll b/WebApp/bin/WebApp.dll new file mode 100644 index 0000000..87d3a34 Binary files /dev/null and b/WebApp/bin/WebApp.dll differ diff --git a/WebApp/bin/WebApp.pdb b/WebApp/bin/WebApp.pdb new file mode 100644 index 0000000..84d8c80 Binary files /dev/null and b/WebApp/bin/WebApp.pdb differ diff --git a/WebApp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/WebApp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..dee8458 Binary files /dev/null and b/WebApp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/WebApp/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/WebApp/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/WebApp/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/WebApp/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/WebApp/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/WebApp/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/WebApp/obj/Debug/WebApp.csproj.FileListAbsolute.txt b/WebApp/obj/Debug/WebApp.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..2e16be0 --- /dev/null +++ b/WebApp/obj/Debug/WebApp.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +F:\WorkSpace\Github\CSharpLibrary\WebApp\bin\WebApp.dll +F:\WorkSpace\Github\CSharpLibrary\WebApp\bin\WebApp.pdb +F:\WorkSpace\Github\CSharpLibrary\WebApp\obj\Debug\WebApp.csprojResolveAssemblyReference.cache +F:\WorkSpace\Github\CSharpLibrary\WebApp\obj\Debug\WebApp.dll +F:\WorkSpace\Github\CSharpLibrary\WebApp\obj\Debug\WebApp.pdb diff --git a/WebApp/obj/Debug/WebApp.csprojResolveAssemblyReference.cache b/WebApp/obj/Debug/WebApp.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..c412a37 Binary files /dev/null and b/WebApp/obj/Debug/WebApp.csprojResolveAssemblyReference.cache differ diff --git a/WebApp/obj/Debug/WebApp.dll b/WebApp/obj/Debug/WebApp.dll new file mode 100644 index 0000000..87d3a34 Binary files /dev/null and b/WebApp/obj/Debug/WebApp.dll differ diff --git a/WebApp/obj/Debug/WebApp.pdb b/WebApp/obj/Debug/WebApp.pdb new file mode 100644 index 0000000..84d8c80 Binary files /dev/null and b/WebApp/obj/Debug/WebApp.pdb differ