From 15604d7f0e445389b7ab63ff8cbf44d646d68ff7 Mon Sep 17 00:00:00 2001 From: Elivo Date: Wed, 23 Apr 2025 21:02:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Logger=EF=BC=9A=E4=BF=AE=E6=94=B9=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=AE=9E=E4=BE=8B=E6=96=B9=E6=B3=95=E4=B8=BA=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E6=96=B9=E6=B3=95=EF=BC=8C=E9=81=BF=E5=85=8D=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=20NULL=20=E6=97=B6=E7=9A=84=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apewer/Logger.cs | 17 ----------------- Apewer/_Extensions.cs | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Apewer/Logger.cs b/Apewer/Logger.cs index 1091b5d..fec5614 100644 --- a/Apewer/Logger.cs +++ b/Apewer/Logger.cs @@ -378,24 +378,7 @@ namespace Apewer #region public - /// 记录异常。 - public void Exception(T exception, params object[] content) where T : Exception => Output("Exception", content, exception); - /// 记录错误。多个 Content 参数将以“ | ”分隔。 - public void Error(params object[] content) => Output("Error", content, null); - - /// 记录警告。多个 Content 参数将以“ | ”分隔。 - public void Warning(params object[] content) => Output("Warning", content, null); - - /// 记录警告。多个 Content 参数将以“ | ”分隔。 - public void Info(params object[] content) => Output("Info", content, null); - - /// 记录文本。多个 Content 参数将以“ | ”分隔。 - public void Text(params object[] content) => Output(null, content, null); - - /// 记录调试。多个 Content 参数将以“ | ”分隔。 - [Conditional("DEBUG")] - public void Debug(params object[] content) => Output("Debug", content, null); #endregion diff --git a/Apewer/_Extensions.cs b/Apewer/_Extensions.cs index 81bc6d7..ab12d04 100644 --- a/Apewer/_Extensions.cs +++ b/Apewer/_Extensions.cs @@ -358,8 +358,27 @@ public static class Extensions #region Logger - /// 记录文本。多个 Content 参数将以“ | ”分隔,此方法等同于 - public static void Write(this Logger logger, object sender, params object[] content) => logger?.Text(sender, null, content, null); + /// 记录文本。多个 Content 参数将以“ | ”分隔。 + public static void Write(this Logger logger, params object[] content) => logger?.Output(null, content, null); + + /// 记录异常。 + public static void Exception(this Logger logger, T exception, params object[] content) where T : Exception => logger?.Output("Exception", content, exception); + + /// 记录错误。多个 Content 参数将以“ | ”分隔。 + public static void Error(this Logger logger, params object[] content) => logger?.Output("Error", content, null); + + /// 记录警告。多个 Content 参数将以“ | ”分隔。 + public static void Warning(this Logger logger, params object[] content) => logger?.Output("Warning", content, null); + + /// 记录警告。多个 Content 参数将以“ | ”分隔。 + public static void Info(this Logger logger, params object[] content) => logger?.Output("Info", content, null); + + /// 记录文本。多个 Content 参数将以“ | ”分隔。 + public static void Text(this Logger logger, params object[] content) => logger?.Output(null, content, null); + + /// 记录调试。多个 Content 参数将以“ | ”分隔。 + [Conditional("DEBUG")] + public static void Debug(this Logger logger, params object[] content) => logger?.Output("Debug", content, null); #endregion From c6274747abcbf9bdf67dfc795bc82ea123ca232d Mon Sep 17 00:00:00 2001 From: Elivo Date: Wed, 23 Apr 2025 21:03:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?Source=EF=BC=9A=E5=A2=9E=E5=8A=A0=20DataTab?= =?UTF-8?q?le.ToJson=20=E6=89=A9=E5=B1=95=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apewer/Source/SourceUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apewer/Source/SourceUtility.cs b/Apewer/Source/SourceUtility.cs index f2edb49..d9fdc7e 100644 --- a/Apewer/Source/SourceUtility.cs +++ b/Apewer/Source/SourceUtility.cs @@ -900,7 +900,7 @@ namespace Apewer.Source if (table == null) return null; var columns = ToJson(table.Columns); - var rows = ToJson(table.Rows); + var rows = ToJson(table.Rows, dateTimeFormatter); var jsonObject = Json.NewObject(); jsonObject.SetProperty("columns", columns); From a9b30cc32b2eff5c04baf8f27ddb563998b98de7 Mon Sep 17 00:00:00 2001 From: Elivo Date: Wed, 23 Apr 2025 21:03:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Access=EF=BC=8C=E4=BF=AE=E6=AD=A3=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=A1=A8=E5=90=8D=E7=9A=84=20TableNames=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apewer.Source/Source/Access.cs | 51 ++++++++++++++++++++++++++++---- Apewer.Source/Source/DbClient.cs | 6 +++- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Apewer.Source/Source/Access.cs b/Apewer.Source/Source/Access.cs index 94ebac1..fedbab2 100644 --- a/Apewer.Source/Source/Access.cs +++ b/Apewer.Source/Source/Access.cs @@ -21,6 +21,9 @@ namespace Apewer.Source /// 当操作系统启用随机化内存分配时,此方法可能会产生异常。 public static string[] ParsePassword(string path) => AccessHelper.GetPassword(path); + /// 数据库文件路径。 + public virtual string Path { get; protected set; } + } #if NETFRAMEWORK @@ -79,7 +82,33 @@ namespace Apewer.Source public override string[] StoreNames() => throw new InvalidOperationException(); /// - public override string[] TableNames() => QueryStrings("select name from msysobjects where type=1 and flags = 0"); + public override string[] TableNames() + { + // QueryStrings("select name from msysobjects where type=1 and flags = 0"); + Connect(); + var schema = _conn.GetSchema("Tables"); + using (var query = new Query(schema)) + { + var json = query.ToJson(); + var names = new List(); + for (var i = 0; i < query.Rows; i++) + { + var type = query.Text(i, "TABLE_TYPE"); + var name = query.Text(i, "TABLE_NAME"); + switch (type) + { + case "ACCESS TABLE": + case "SYSTEM TABLE": + break; + case "TABLE": + names.Add(name); + break; + } + } + names.Sort(); + return names.ToArray(); + } + } /// public override string Insert(object record, string table = null, bool adjust = true) @@ -494,12 +523,18 @@ namespace Apewer.Source /// 创建 Access 类的新实例。 /// public AccessJet4(string path, string pass = null, string jo = null, Timeout timeout = null) - : base(GenerateCS(JetOleDB4, path, pass, jo), timeout) { } + : base(GenerateCS(JetOleDB4, path, pass, jo), timeout) + { + Path = path; + } /// 使用连接字符串创建数据库连接实例。 /// /// - public AccessJet4(IDbConnection connection, Timeout timeout = null) : base(connection, timeout) { } + public AccessJet4(IDbConnection connection, Timeout timeout = null) : base(connection, timeout) + { + Path = (connection as Access)?.Path; + } } @@ -512,12 +547,18 @@ namespace Apewer.Source /// 创建 Access 类的新实例。 /// public AccessAce12(string path, string pass = null, string jo = null, Timeout timeout = null) - : base(GenerateCS(AceOleDB12, path, pass, jo), timeout) { } + : base(GenerateCS(AceOleDB12, path, pass, jo), timeout) + { + Path = path; + } /// 使用连接字符串创建数据库连接实例。 /// /// - public AccessAce12(IDbConnection connection, Timeout timeout = null) : base(connection, timeout) { } + public AccessAce12(IDbConnection connection, Timeout timeout = null) : base(connection, timeout) + { + Path = (connection as Access)?.Path; + } } diff --git a/Apewer.Source/Source/DbClient.cs b/Apewer.Source/Source/DbClient.cs index 63674a7..594edbb 100644 --- a/Apewer.Source/Source/DbClient.cs +++ b/Apewer.Source/Source/DbClient.cs @@ -102,7 +102,11 @@ namespace Apewer.Source } var connect = Connect(); - if (connect.NotEmpty()) return connect; + if (connect.NotEmpty()) + { + if (ThrowAdoException) throw new Exception(connect); + return connect; + } try {